diff mm7_1.cpp @ 232:c879446b4a22

inventory indexing fixed
author zipi
date Sun, 17 Feb 2013 15:04:56 +0100
parents 1bd823f52e3a
children 0d9d30a1efc9 2799737f8a74
line wrap: on
line diff
--- a/mm7_1.cpp	Sun Feb 17 14:47:34 2013 +0100
+++ b/mm7_1.cpp	Sun Feb 17 15:04:56 2013 +0100
@@ -5276,7 +5276,7 @@
         uLastPointedObjectID = pMouse->uPointingObjectID;
         return;
       }
-      pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v14 + 5];
+      pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v14-1];
       //goto LABEL_49;
       v17 = pItemGen->GetDisplayName();
       sub_41C0B8_set_status_string(v17);
@@ -5663,7 +5663,7 @@
   if ( uActiveCharacter
     && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
   {
-    memcpy(&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u);
+    memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u);
   }
   else
   {
@@ -5748,7 +5748,7 @@
     if (auto slot = player->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID))
     {
       __debugbreak(); // invalid inventory indexing
-      memcpy(&player->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * slot + 5], &pParty->pPickedItem, 0x24u);
+      memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u);
       viewparams->bRedrawGameUI = true;
       pMouse->RemoveHoldingItem();
       return;
@@ -5901,7 +5901,7 @@
       *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
       *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
       *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
-      ptr_50C9A4 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5];
+      ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
       unk_50C9A0 = 0;
       if ( pMessageQueue_50CBD0->uNumMessages )
         pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -5920,7 +5920,7 @@
   {
     if ( !v8 )
       return;
-    memcpy(&pParty->pPickedItem, &v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5], sizeof(pParty->pPickedItem));
+    memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
     v0->RemoveItemAtInventoryIndex(a4);
     v9 = pParty->pPickedItem.uItemID;
     goto LABEL_24;
@@ -5928,7 +5928,7 @@
   v13 = v8;
   if ( v8 )
   {
-    a2.y = (LONG)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    a2.y = (LONG)&v0->pInventoryItems[v8-1];
     memcpy(&this_, (const void *)a2.y, sizeof(this_));
     v0->RemoveItemAtInventoryIndex(a4);
     pX = v0->AddItem2(a4, &pParty->pPickedItem);
@@ -5952,7 +5952,7 @@
   pX = v10;
   if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
   {
-    memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], &pParty->pPickedItem, 0x24u);
+    memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
     pMouse->RemoveHoldingItem();
   }
 }