diff Chest.cpp @ 702:efde64b3e147

sub_4BDAAF clean some Chest pointer fixes
author zipi
date Mon, 18 Mar 2013 20:19:20 +0000
parents d5b16a44d9b3
children ef4d646d738d
line wrap: on
line diff
--- a/Chest.cpp	Mon Mar 18 22:53:56 2013 +0400
+++ b/Chest.cpp	Mon Mar 18 20:19:20 2013 +0000
@@ -687,7 +687,7 @@
     {
       *strchr(&Buf, 10) = 0;
       memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17));
-      if ( v17.uPropCount && *v17.pProperties[0] != 47 )
+	  if ( v17.uPropCount && *v17.pProperties[0] != 47 )
         ++Argsa;
     }
     while ( fgets(&Buf, 490, File) );
@@ -708,7 +708,7 @@
   {
     *strchr(&Buf, 10) = 0;
     memcpy(&v17, texture_frame_table_txt_parser(&Buf, &v16), sizeof(v17));
-    if ( v17.uPropCount && *v17.pProperties[0] != 47 )
+	if ( v17.uPropCount && *v17.pProperties[0] != 47 )
     {
       strcpy(v2->pChests[v2->uNumChests].pName, v17.pProperties[0]);
       v10 = atoi(v17.pProperties[1]);
@@ -726,7 +726,7 @@
 
 //----- (00420B13) --------------------------------------------------------
 void __fastcall sub_420B13(int a1, int a2)
-    {
+{
     void *v2; // eax@1
     ItemGen *v3; // ebx@1
     unsigned int v4; // eax@1
@@ -745,16 +745,18 @@
     int v17; // [sp+Ch] [bp-14h]@1
     int v18; // [sp+10h] [bp-10h]@3
     int v19; // [sp+14h] [bp-Ch]@1
-    void *v20; // [sp+18h] [bp-8h]@1
+    int v20; // [sp+18h] [bp-8h]@1
     int v21; // [sp+1Ch] [bp-4h]@5
     int v22; // [sp+1Ch] [bp-4h]@8
 
     v19 = a2;
     v2 = pChestWindow->ptr_1C;
-    v20 = v2;
+    v20 = (int)v2;
     v2 = (void *)(5324 * (int)v2);
-    v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
-    v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
+    //v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
+	v3 = &pChests[v20].igChestItems[a1];
+    //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
+	v17 = pChestWidthsByType[pChests[v20].uChestBitmapID];
     v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
     v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
     v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
@@ -769,37 +771,38 @@
     v10 = ((v8 - 14) >> 5) + 1;
     v21 = v10;
     if ( !areWeLoadingTexture )
-        {
+    {
         v5->Release();
         pIcons_LOD->_40F9C5();
         v10 = v21;
-        }
+    }
     if ( v10 > 0 )
-        {
+    {
         v11 = 0;
         v22 = v10;
         do
-            {
+        {
             if ( v9 > 0 )
-                {
+            {
                 v12 = v9;
-                v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20];
+                //v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20];
+				v13 = &pChests[v20].pInventoryIndices[v19 + v11];
                 v14 = v12 & 1;
                 v12 >>= 1;
                 memset(v13, 0, 4 * v12);
                 v15 = (int)((char *)v13 + 4 * v12);
                 for ( i = v14; i; --i )
-                    {
+                {
                     *(short *)v15 = 0;
                     v15 += 2;
-                    }
+                }
                 v9 = v18;
-                }
+            }
             v11 += v17;
             --v22;
-            }
-            while ( v22 );
         }
-    v3->Reset();
+        while ( v22 );
     }
+    v3->Reset();
+}
 // 506128: using guessed type int areWeLoadingTexture;