diff mm7_1.cpp @ 526:214d9d47cf1f

Chest working, but items are not laid correctly
author Gloval
date Sun, 03 Mar 2013 01:55:57 +0400
parents 5196a51cc9ec
children f146781c5c2d
line wrap: on
line diff
--- a/mm7_1.cpp	Sat Mar 02 15:38:49 2013 +0400
+++ b/mm7_1.cpp	Sun Mar 03 01:55:57 2013 +0400
@@ -3817,7 +3817,7 @@
     if ( v1 )
     {
       auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C
-                                             + 18 * *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
+                                             + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime
                                                + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
       v2 = _w->GetDisplayName();
       sub_41C0B8_set_status_string(v2);
@@ -3825,85 +3825,6 @@
   }
 }
 
-//----- (00420B13) --------------------------------------------------------
-void __fastcall sub_420B13(int a1, int a2)
-{
-  void *v2; // eax@1
-  ItemGen *v3; // ebx@1
-  unsigned int v4; // eax@1
-  Texture *v5; // ecx@1
-  signed int v6; // eax@1
-  signed int v7; // edi@3
-  signed int v8; // eax@3
-  int v9; // edi@3
-  int v10; // eax@5
-  int v11; // esi@8
-  unsigned int v12; // ecx@10
-  void *v13; // edi@10
-  unsigned __int8 v14; // cf@10
-  int v15; // edi@10
-  int i; // ecx@10
-  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 v21; // [sp+1Ch] [bp-4h]@5
-  int v22; // [sp+1Ch] [bp-4h]@8
-
-  v19 = a2;
-  v2 = pChestWindow->ptr_1C;
-  v20 = v2;
-  v2 = (void *)(5324 * (int)v2);
-  v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
-  v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
-  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);
-  if ( v6 < 14 )
-    v6 = 14;
-  v7 = v6 - 14;
-  v8 = v5->uTextureHeight;
-  v9 = (v7 >> 5) + 1;
-  v18 = v9;
-  if ( v8 < 14 )
-    v8 = 14;
-  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];
-        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();
-}
-// 506128: using guessed type int areWeLoadingTexture;
 
 //----- (00420C05) --------------------------------------------------------
 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal)
@@ -4017,23 +3938,23 @@
 //----- (00420E01) --------------------------------------------------------
 void __cdecl sub_420E01()
 {
-  void *v0; // edi@1
+  int chest_id; // edi@1
   POINT *v1; // esi@2
   int v2; // eax@2
   int v3; // ebx@4
   int v4; // esi@6
   int v5; // ecx@6
   //SpriteObject v6; // [sp+Ch] [bp-80h]@1
-  char v7; // [sp+7Ch] [bp-10h]@2
+  POINT v7; // [sp+7Ch] [bp-10h]@2
   POINT a2; // [sp+84h] [bp-8h]@2
   
   SpriteObject v6; // [sp+Ch] [bp-80h]@1
   //SpriteObject::SpriteObject(&v6);
 
-  v0 = pGUIWindow_CurrentMenu->ptr_1C;
+  chest_id = pGUIWindow_CurrentMenu->par1C;
   if ( pParty->pPickedItem.uItemID )
   {
-    if ( Chest::_41FFA2(-1, &pParty->pPickedItem, (unsigned int)pGUIWindow_CurrentMenu->ptr_1C) )
+    if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) )
       pMouse->RemoveHoldingItem();
   }
   else
@@ -4046,16 +3967,15 @@
         v3 = v2 - 1;
       else
         v3 = -1;
-      v4 = pChests[0].pInventoryIndices[v3 + 2662 * (int)v0] - 1;
-      v5 = 5324 * (int)v0 + 36 * v4;
-      if ( pItemsTable->pItems[*(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v5)].uEquipType == 18 )
+      v4 = pChests[chest_id].pInventoryIndices[v3] - 1;
+      if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == 18 )
       {
-        party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uSpecEnchantmentType + v5), 0);
+        party_finds_gold(pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uValue, 0); //recheck
         viewparams->bRedrawGameUI = 1;
       }
       else
       {
-        pParty->SetHoldingItem((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v5));
+        pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]);
       }
       sub_420B13(v4, v3);
     }
@@ -5468,7 +5388,7 @@
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-c", 2);
+        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
@@ -5504,7 +5424,7 @@
         uTextureID_Btn_Rest = pIcons_LOD->LoadTexture("ib-m2d-c", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_QuickReference = pIcons_LOD->LoadTexture("ib-m3d-c", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-c", TEXTURE_16BIT_PALETTE);
-        uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE);
+        uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE);
         dword_50796C = pIcons_LOD->LoadTexture("isg-01-c", TEXTURE_16BIT_PALETTE);
         dword_507968 = pIcons_LOD->LoadTexture("isg-02-c", TEXTURE_16BIT_PALETTE);
         dword_507964 = pIcons_LOD->LoadTexture("isg-03-c", TEXTURE_16BIT_PALETTE);
@@ -5553,7 +5473,7 @@
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-a", 2);
+        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-a", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
@@ -5589,7 +5509,7 @@
         uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-a", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_ZoomIn = pIcons_LOD->LoadTexture("ib-autout-a", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_ZoomOut = pIcons_LOD->LoadTexture("ib-autin-a", TEXTURE_16BIT_PALETTE);
-        uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE);
+        uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE);
         dword_50796C = pIcons_LOD->LoadTexture("isg-01-a", TEXTURE_16BIT_PALETTE);
         dword_507968 = pIcons_LOD->LoadTexture("isg-02-a", TEXTURE_16BIT_PALETTE);
         dword_507964 = pIcons_LOD->LoadTexture("isg-03-a", TEXTURE_16BIT_PALETTE);
@@ -5649,7 +5569,7 @@
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
       pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchB");
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-b", 2);
+      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);