diff Chest.cpp @ 426:94546824edad

Chests party fixed
author Nomad
date Sat, 23 Feb 2013 22:59:01 +0200
parents 80a5aab68b67
children 0dbf780e247f
line wrap: on
line diff
--- a/Chest.cpp	Sat Feb 23 21:14:31 2013 +0200
+++ b/Chest.cpp	Sat Feb 23 22:59:01 2013 +0200
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <assert.h>
 
 #include "Chest.h"
 #include "FrameTableInc.h"
@@ -34,7 +35,7 @@
 //----- (0042041E) --------------------------------------------------------
 bool Chest::Open(unsigned int uChestID)
 {
-  char *v1; // edi@5
+  //char *v1; // edi@5
   unsigned int v2; // eax@8
   GUIWindow *v3; // eax@15
   int v5; // edx@16
@@ -66,7 +67,7 @@
   int v31; // [sp+8Ch] [bp-38h]@16
   int v32; // [sp+90h] [bp-34h]@16
   float v33; // [sp+94h] [bp-30h]@23
-  char *v34; // [sp+98h] [bp-2Ch]@5
+  //char *v34; // [sp+98h] [bp-2Ch]@5
   int v35; // [sp+9Ch] [bp-28h]@16
   Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28
   int a4; // [sp+ACh] [bp-18h]@1
@@ -76,21 +77,25 @@
   float v41; // [sp+BCh] [bp-8h]@23
   int sRotY; // [sp+C0h] [bp-4h]@8
 
-  a4 = uChestID;
-  if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 )
-    return 0;
+  //a4 = uChestID;
+  assert(uChestID < 20);
+  auto chest = pChests + uChestID;
+
   ++pIcons_LOD->uTexturePacksCount;
-  if ( !pIcons_LOD->uNumPrevLoadedFiles )
+  if (!pIcons_LOD->uNumPrevLoadedFiles)
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  v1 = (char *)&pChests[uChestID].uFlags;
-  v34 = v1;
-  if ( !(*v1 & CHEST_ITEMS_PLACED) )
+
+
+  //v1 = (char *)&pChests[uChestID].uFlags;
+  //v34 = v1;
+  if (!chest->Initialized())
     Chest::_420284(uChestID);
+
   if ( !uActiveCharacter )
     return 0;
   *(float *)&sRotY = 0.0;
   v2 = pMapStats->GetMapInfo(pCurrentMapName);
-  if ( !(*v1 & 1) || !v2 )
+  if ( !chest->Trapped() || !v2 )
     goto LABEL_12;
   if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 )
   {
@@ -206,7 +211,7 @@
     a1.Create(0, 0, 0, 0);
     pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
     a1._438E35();
-    *v34 &= 0xFEu;
+    chest->SetInitialized(false);//*v34 &= 0xFEu;
     if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 )
     {
       qword_A750D8 = 256i64;
@@ -217,11 +222,11 @@
     dword_507CD8 = 0;
     return 0;
   }
-  *v1 &= 0xFEu;
+  chest->SetInitialized(false);//*v1 &= 0xFEu;
   sRotY = 1;
 LABEL_12:
   pAudioPlayer->StopChannels(-1, -1);
-  pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0);
+  pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0);
   if ( *(float *)&sRotY != 0.0 )
   {
     if ( !dword_507CD8 )