comparison Chest.cpp @ 1440:a72236d60edc

m
author Ritor1
date Sat, 27 Jul 2013 09:36:29 +0600
parents c0b273d33338
children b67a3e0d6fc3
comparison
equal deleted inserted replaced
1439:468f434a8d8a 1440:a72236d60edc
41 41
42 42
43 //----- (0042041E) -------------------------------------------------------- 43 //----- (0042041E) --------------------------------------------------------
44 bool Chest::Open( signed int uChestID ) 44 bool Chest::Open( signed int uChestID )
45 { 45 {
46 //char *v1; // edi@5
47 unsigned int v2; // eax@8 46 unsigned int v2; // eax@8
48 GUIWindow *v3; // eax@15 47 GUIWindow *v3; // eax@15
49 int v5; // edx@16 48 int v5; // edx@16
50 int v6; // eax@16 49 int v6; // eax@16
51 ODMFace *v7; // eax@19 50 ODMFace *pOdmFace; // eax@19
52 int v8; // edx@19 51 int v8; // edx@19
53 int v9; // edi@19 52 int v9; // edi@19
54 signed int v10; // ebx@19 53 signed int v10; // ebx@19
55 int v11; // ecx@19 54 int v11; // ecx@19
56 int v12; // eax@19 55 int v12; // eax@19
57 BLVFace *v13; // eax@20 56 BLVFace *pBlvFace; // eax@20
58 int v14; // ebx@21 57 int v14; // ebx@21
59 int v15; // edi@21 58 int v15; // edi@21
60 int v16; // ecx@22
61 __int64 v17; // qax@22 59 __int64 v17; // qax@22
62 double v18; // st7@23 60 double v18; // st7@23
63 double v19; // st6@23 61 double v19; // st6@23
64 double v20; // st7@23 62 double v20; // st7@23
65 int v21; // ecx@26 63 int v21; // ecx@26
67 unsigned int *v23; // edi@28 65 unsigned int *v23; // edi@28
68 unsigned __int16 v24; // di@28 66 unsigned __int16 v24; // di@28
69 signed int v25; // ecx@28 67 signed int v25; // ecx@28
70 char *v26; // edx@29 68 char *v26; // edx@29
71 unsigned __int16 v27; // ax@32 69 unsigned __int16 v27; // ax@32
72 //SpriteObject a1; // [sp+14h] [bp-B0h]@28
73 int v29[4]; // [sp+84h] [bp-40h]@16 70 int v29[4]; // [sp+84h] [bp-40h]@16
74 //int v30; // [sp+88h] [bp-3Ch]@16
75 //int v31; // [sp+8Ch] [bp-38h]@16
76 //int v32; // [sp+90h] [bp-34h]@16
77 float v33; // [sp+94h] [bp-30h]@23 71 float v33; // [sp+94h] [bp-30h]@23
78 //char *v34; // [sp+98h] [bp-2Ch]@5
79 int v35; // [sp+9Ch] [bp-28h]@16
80 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 72 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
81 int a4; // [sp+ACh] [bp-18h]@1 73 int a4; // [sp+ACh] [bp-18h]@1
82 int v38; // [sp+B0h] [bp-14h]@21 74 int v38; // [sp+B0h] [bp-14h]@21
83 int sRotX; // [sp+B4h] [bp-10h]@23 75 int sRotX; // [sp+B4h] [bp-10h]@23
84 float v40; // [sp+B8h] [bp-Ch]@23 76 float v40; // [sp+B8h] [bp-Ch]@23
85 float v41; // [sp+BCh] [bp-8h]@23 77 float v41; // [sp+BCh] [bp-8h]@23
86 int sRotY; // [sp+C0h] [bp-4h]@8 78 int sRotY; // [sp+C0h] [bp-4h]@8
87 79 SpriteObject a1; // [sp+14h] [bp-B0h]@28
88 //a4 = uChestID; 80
89 assert(uChestID < 20); 81 assert(uChestID < 20);
90 if ((uChestID <0)&&(uChestID >=20) ) 82 if ((uChestID <0)&&(uChestID >=20) )
91 return false; 83 return false;
92 auto chest = &pChests[uChestID]; 84 auto chest = &pChests[uChestID];
93 85
94 ++pIcons_LOD->uTexturePacksCount; 86 ++pIcons_LOD->uTexturePacksCount;
95 if (!pIcons_LOD->uNumPrevLoadedFiles) 87 if (!pIcons_LOD->uNumPrevLoadedFiles)
96 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; 88 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
97 89
98
99 //v1 = (char *)&pChests[uChestID].uFlags;
100 //v34 = v1;
101 if (!chest->Initialized()) 90 if (!chest->Initialized())
102 Chest::PlaceItems(uChestID); 91 Chest::PlaceItems(uChestID);
103 92
104 if ( !uActiveCharacter ) 93 if ( !uActiveCharacter )
105 return 0; 94 return false;
106 *(float *)&sRotY = 0.0; 95 *(float *)&sRotY = 0.0;
107 v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); 96 v2 = pMapStats->GetMapInfo(pCurrentMapName.data());
108 if ( !chest->Trapped() || !v2 ) 97 if ( !chest->Trapped() || !v2 )
109 goto LABEL_12; 98 goto LABEL_12;
110 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) 99 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 )
113 v29[1] = 812; 102 v29[1] = 812;
114 v29[2] = 813; 103 v29[2] = 813;
115 v29[3] = 814; 104 v29[3] = 814;
116 v5 = rand() % 4; 105 v5 = rand() % 4;
117 v6 = PID_ID(EvtTargetObj); 106 v6 = PID_ID(EvtTargetObj);
118 v35 = v5;
119 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) 107 if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration)
120 { 108 {
121 v16 = v6;
122 v14 = pLevelDecorations[v6].vPosition.x; 109 v14 = pLevelDecorations[v6].vPosition.x;
123 v38 = pLevelDecorations[v6].vPosition.y; 110 v38 = pLevelDecorations[v6].vPosition.y;
124 v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; 111 v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight;
125 v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); 112 v15 = pLevelDecorations[v6].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1);
126 } 113 }
127 else 114 else
128 { 115 {
129 if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) 116 if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel)
130 goto LABEL_12; 117 goto LABEL_12;
131 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) 118 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
132 { 119 {
133 v7 = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; 120 pOdmFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F];
134 v8 = v7->pBoundingBox.y1; 121 v8 = pOdmFace->pBoundingBox.y1;
135 v9 = v7->pBoundingBox.z2; 122 v9 = pOdmFace->pBoundingBox.z2;
136 v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; 123 v10 = pOdmFace->pBoundingBox.x1 + pOdmFace->pBoundingBox.x2;
137 v11 = v7->pBoundingBox.y2; 124 v11 = pOdmFace->pBoundingBox.y2;
138 v12 = v7->pBoundingBox.z1; 125 v12 = pOdmFace->pBoundingBox.z1;
139 } 126 }
140 else 127 else
141 { 128 {
142 v13 = &pIndoor->pFaces[v6]; 129 pBlvFace = &pIndoor->pFaces[v6];
143 v8 = v13->pBounding.y1; 130 v8 = pBlvFace->pBounding.y1;
144 v9 = v13->pBounding.z2; 131 v9 = pBlvFace->pBounding.z2;
145 v10 = v13->pBounding.x1 + v13->pBounding.x2; 132 v10 = pBlvFace->pBounding.x1 + pBlvFace->pBounding.x2;
146 v11 = v13->pBounding.y2; 133 v11 = pBlvFace->pBounding.y2;
147 v12 = v13->pBounding.z1; 134 v12 = pBlvFace->pBounding.z1;
148 } 135 }
149 v14 = v10 >> 1; 136 v14 = v10 >> 1;
150 v38 = (v8 + v11) >> 1; 137 v38 = (v8 + v11) >> 1;
151 v15 = (v12 + v9) >> 1; 138 v15 = (v12 + v9) >> 1;
152 } 139 }
174 if ( v40 < 256.0 ) 161 if ( v40 < 256.0 )
175 v21 = (signed __int64)v40 / 4; 162 v21 = (signed __int64)v40 / 4;
176 *(int *)&v22[8] = v15; 163 *(int *)&v22[8] = v15;
177 *(_QWORD *)v22 = __PAIR__(v38, v14); 164 *(_QWORD *)v22 = __PAIR__(v38, v14);
178 Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); 165 Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y);
179 v23 = (unsigned int *)(&v29 + v35); 166 v23 = (unsigned int *)(&v29 + v5);
180 sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); 167 sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0);
181
182 SpriteObject a1; // [sp+14h] [bp-B0h]@28
183 //SpriteObject::SpriteObject(&a1);
184 168
185 a1.stru_24.Reset(); 169 a1.stru_24.Reset();
186 v24 = *(short *)v23; 170 v24 = *(short *)v23;
187 v25 = 0; 171 v25 = 0;
188 a1.spell_skill = 0; 172 a1.spell_skill = 0;
228 word_A750E0 = 5; 212 word_A750E0 = 5;
229 word_A750E2 = uActiveCharacter; 213 word_A750E2 = uActiveCharacter;
230 } 214 }
231 pIcons_LOD->RemoveTexturesPackFromTextureList(); 215 pIcons_LOD->RemoveTexturesPackFromTextureList();
232 dword_507CD8 = 0; 216 dword_507CD8 = 0;
233 return 0; 217 return false;
234 } 218 }
235 chest->SetInitialized(false);//*v1 &= 0xFEu; 219 chest->SetInitialized(false);//*v1 &= 0xFEu;
236 sRotY = 1; 220 sRotY = 1;
237 LABEL_12: 221 LABEL_12:
238 pAudioPlayer->StopChannels(-1, -1); 222 pAudioPlayer->StopChannels(-1, -1);
241 { 225 {
242 if ( !dword_507CD8 ) 226 if ( !dword_507CD8 )
243 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); 227 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
244 } 228 }
245 dword_507CD8 = 0; 229 dword_507CD8 = 0;
246
247 pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0); 230 pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0);
248
249 pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit 231 pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit
250 pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); 232 pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0);
251
252 pCurrentScreen = SCREEN_CHEST; 233 pCurrentScreen = SCREEN_CHEST;
253 pEventTimer->Pause(); 234 pEventTimer->Pause();
254 return 1; 235 return true;
255 } 236 }
256 237
257 //----- (0042092D) -------------------------------------------------------- 238 //----- (0042092D) --------------------------------------------------------
258 void Chest::DrawChestUI(signed int uChestID) 239 void Chest::DrawChestUI(signed int uChestID)
259 { 240 {