changeset 429:f33af971bae7

Merge
author Gloval
date Sun, 24 Feb 2013 00:49:20 +0400
parents 24936a5ff8ca (current diff) 49d945ce4285 (diff)
children 8c45cac1c5e1
files
diffstat 4 files changed, 27 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.h	Sun Feb 24 00:48:41 2013 +0400
+++ b/AudioPlayer.h	Sun Feb 24 00:49:20 2013 +0400
@@ -98,6 +98,7 @@
   SOUND_Arcomage_TowerUpgrade = 0x81,
   SOUND_Arcomage_WallUpgrade = 0x84,
   SOUND_GoldReceived = 0xC8,
+  SOUND_OpenChest = 208,
   SOUND_PlayerCantCastSpell = 0xD1,
   SOUND_Bell = 0xD9,
   SOUND_20001 = 0x4E21,
--- a/Chest.cpp	Sun Feb 24 00:48:41 2013 +0400
+++ b/Chest.cpp	Sun Feb 24 00:49:20 2013 +0400
@@ -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 )
--- a/Chest.h	Sun Feb 24 00:48:41 2013 +0400
+++ b/Chest.h	Sun Feb 24 00:49:20 2013 +0400
@@ -49,6 +49,10 @@
 #pragma pack(push, 1)
 struct Chest
 {
+  inline bool Initialized() const    {return uFlags & CHEST_ITEMS_PLACED;}
+  inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;}
+  inline bool Trapped() const        {return uFlags & CHEST_TRAPPED;}
+
   static int CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID);
   static int _41FF64(unsigned int uChestID);
   static int _41FFA2(int a1, ItemGen *a2, unsigned int uChestID);
--- a/mm7_data.cpp	Sun Feb 24 00:48:41 2013 +0400
+++ b/mm7_data.cpp	Sun Feb 24 00:49:20 2013 +0400
@@ -685,10 +685,10 @@
 char _4E2B21_buff_spell_tooltip_colors[80];
 char byte_4E2B70[777]; // weak
 char byte_4E2BC8; // weak
-int pChestSmthn1ByType[8];
-int pChestSmthn2ByType[8];
-int pChestWidthsByType[8];
-int pChestHeightsByType[8];
+int pChestSmthn1ByType[8] = {42, 18, 18, 42, 42, 42, 18, 42};
+int pChestSmthn2ByType[8] = {34, 30, 30, 34, 34, 34, 30, 34};
+int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
+int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
 char aSS[777]; // idb
 char ascii_4E2C54[6];
 char ascii_4E2C5C[7];