Mercurial > mm7
comparison Chest.cpp @ 426:94546824edad
Chests party fixed
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 22:59:01 +0200 |
parents | 80a5aab68b67 |
children | 0dbf780e247f |
comparison
equal
deleted
inserted
replaced
422:03ccac4fad25 | 426:94546824edad |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <assert.h> | |
2 | 3 |
3 #include "Chest.h" | 4 #include "Chest.h" |
4 #include "FrameTableInc.h" | 5 #include "FrameTableInc.h" |
5 #include "Allocator.h" | 6 #include "Allocator.h" |
6 #include "LOD.h" | 7 #include "LOD.h" |
32 | 33 |
33 | 34 |
34 //----- (0042041E) -------------------------------------------------------- | 35 //----- (0042041E) -------------------------------------------------------- |
35 bool Chest::Open(unsigned int uChestID) | 36 bool Chest::Open(unsigned int uChestID) |
36 { | 37 { |
37 char *v1; // edi@5 | 38 //char *v1; // edi@5 |
38 unsigned int v2; // eax@8 | 39 unsigned int v2; // eax@8 |
39 GUIWindow *v3; // eax@15 | 40 GUIWindow *v3; // eax@15 |
40 int v5; // edx@16 | 41 int v5; // edx@16 |
41 int v6; // eax@16 | 42 int v6; // eax@16 |
42 ODMFace *v7; // eax@19 | 43 ODMFace *v7; // eax@19 |
64 int v29; // [sp+84h] [bp-40h]@16 | 65 int v29; // [sp+84h] [bp-40h]@16 |
65 int v30; // [sp+88h] [bp-3Ch]@16 | 66 int v30; // [sp+88h] [bp-3Ch]@16 |
66 int v31; // [sp+8Ch] [bp-38h]@16 | 67 int v31; // [sp+8Ch] [bp-38h]@16 |
67 int v32; // [sp+90h] [bp-34h]@16 | 68 int v32; // [sp+90h] [bp-34h]@16 |
68 float v33; // [sp+94h] [bp-30h]@23 | 69 float v33; // [sp+94h] [bp-30h]@23 |
69 char *v34; // [sp+98h] [bp-2Ch]@5 | 70 //char *v34; // [sp+98h] [bp-2Ch]@5 |
70 int v35; // [sp+9Ch] [bp-28h]@16 | 71 int v35; // [sp+9Ch] [bp-28h]@16 |
71 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 | 72 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 |
72 int a4; // [sp+ACh] [bp-18h]@1 | 73 int a4; // [sp+ACh] [bp-18h]@1 |
73 int v38; // [sp+B0h] [bp-14h]@21 | 74 int v38; // [sp+B0h] [bp-14h]@21 |
74 int sRotX; // [sp+B4h] [bp-10h]@23 | 75 int sRotX; // [sp+B4h] [bp-10h]@23 |
75 float v40; // [sp+B8h] [bp-Ch]@23 | 76 float v40; // [sp+B8h] [bp-Ch]@23 |
76 float v41; // [sp+BCh] [bp-8h]@23 | 77 float v41; // [sp+BCh] [bp-8h]@23 |
77 int sRotY; // [sp+C0h] [bp-4h]@8 | 78 int sRotY; // [sp+C0h] [bp-4h]@8 |
78 | 79 |
79 a4 = uChestID; | 80 //a4 = uChestID; |
80 if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 ) | 81 assert(uChestID < 20); |
81 return 0; | 82 auto chest = pChests + uChestID; |
83 | |
82 ++pIcons_LOD->uTexturePacksCount; | 84 ++pIcons_LOD->uTexturePacksCount; |
83 if ( !pIcons_LOD->uNumPrevLoadedFiles ) | 85 if (!pIcons_LOD->uNumPrevLoadedFiles) |
84 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; | 86 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; |
85 v1 = (char *)&pChests[uChestID].uFlags; | 87 |
86 v34 = v1; | 88 |
87 if ( !(*v1 & CHEST_ITEMS_PLACED) ) | 89 //v1 = (char *)&pChests[uChestID].uFlags; |
90 //v34 = v1; | |
91 if (!chest->Initialized()) | |
88 Chest::_420284(uChestID); | 92 Chest::_420284(uChestID); |
93 | |
89 if ( !uActiveCharacter ) | 94 if ( !uActiveCharacter ) |
90 return 0; | 95 return 0; |
91 *(float *)&sRotY = 0.0; | 96 *(float *)&sRotY = 0.0; |
92 v2 = pMapStats->GetMapInfo(pCurrentMapName); | 97 v2 = pMapStats->GetMapInfo(pCurrentMapName); |
93 if ( !(*v1 & 1) || !v2 ) | 98 if ( !chest->Trapped() || !v2 ) |
94 goto LABEL_12; | 99 goto LABEL_12; |
95 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) | 100 if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) |
96 { | 101 { |
97 v29 = 811; | 102 v29 = 811; |
98 v30 = 812; | 103 v30 = 812; |
204 a1.field_5C = 0; | 209 a1.field_5C = 0; |
205 a1.uFacing = 0; | 210 a1.uFacing = 0; |
206 a1.Create(0, 0, 0, 0); | 211 a1.Create(0, 0, 0, 0); |
207 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); | 212 pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); |
208 a1._438E35(); | 213 a1._438E35(); |
209 *v34 &= 0xFEu; | 214 chest->SetInitialized(false);//*v34 &= 0xFEu; |
210 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) | 215 if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) |
211 { | 216 { |
212 qword_A750D8 = 256i64; | 217 qword_A750D8 = 256i64; |
213 word_A750E0 = 5; | 218 word_A750E0 = 5; |
214 word_A750E2 = uActiveCharacter; | 219 word_A750E2 = uActiveCharacter; |
215 } | 220 } |
216 pIcons_LOD->_4114F2(); | 221 pIcons_LOD->_4114F2(); |
217 dword_507CD8 = 0; | 222 dword_507CD8 = 0; |
218 return 0; | 223 return 0; |
219 } | 224 } |
220 *v1 &= 0xFEu; | 225 chest->SetInitialized(false);//*v1 &= 0xFEu; |
221 sRotY = 1; | 226 sRotY = 1; |
222 LABEL_12: | 227 LABEL_12: |
223 pAudioPlayer->StopChannels(-1, -1); | 228 pAudioPlayer->StopChannels(-1, -1); |
224 pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0); | 229 pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); |
225 if ( *(float *)&sRotY != 0.0 ) | 230 if ( *(float *)&sRotY != 0.0 ) |
226 { | 231 { |
227 if ( !dword_507CD8 ) | 232 if ( !dword_507CD8 ) |
228 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); | 233 pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); |
229 } | 234 } |