changeset 232:c879446b4a22

inventory indexing fixed
author zipi
date Sun, 17 Feb 2013 15:04:56 +0100
parents a69fc44061d5
children 47e06334c564 ccf14ac29caf
files Player.cpp Player.h mm7_1.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp
diffstat 7 files changed, 64 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Sun Feb 17 14:47:34 2013 +0100
+++ b/Player.cpp	Sun Feb 17 15:04:56 2013 +0100
@@ -257,7 +257,7 @@
     result = v2->uOffHand;
     if ( v2->uOffHand )
     {
-      result = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
+      result = *(int *)&this->pInventoryItems[result-1];
       if ( result )
       {
         if ( result != 64 && result != 65 )
@@ -1761,8 +1761,7 @@
 
   pIndices = &this->pInventoryIndices[uSlot];
 
-  __debugbreak();  // the following indexing is invalid
-  v3 = (ItemGen *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *pIndices + 5];
+  v3 = &this->pInventoryItems[*pIndices-1];
   v4 = v3->uItemID;
   v3->Reset();
   v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE);
@@ -2391,7 +2390,7 @@
         goto LABEL_15;
       }
     }
-    memcpy(&v9->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], pItem, 0x24u);
+    memcpy(&v9->pInventoryItems[v10-1], pItem, 0x24u);
     pItem->Reset();
     pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
     v19->PlaySound(SPEECH_60, 0);
@@ -2786,7 +2785,7 @@
   }
   if ( HasItemEquipped(EQUIP_TWO_HANDED) )
   {
-    v6 = (ItemGen *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pEquipment.uMainHand + 5];
+    v6 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uMainHand-1];
     v7 = v6->uItemID;
     v8 = v6->uItemID;
     v9 = pItemsTable->pItems[v8].uDamageDice;
@@ -2858,7 +2857,7 @@
   {
     if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) )
     {
-      v15 = (ItemGen *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pEquipment.uOffHand + 5];
+      v15 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uOffHand-1];
       v16 = v15->uItemID;
       v17 = v15->uItemID;
       if ( pItemsTable->pItems[v17].uEquipType != 4 )
@@ -2951,7 +2950,7 @@
   int v7; // edi@4
 
   v1 = this;
-  v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5];
+  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
   if ( v2 < 64 || v2 > 65 )
   {
     v4 = GetActualAccuracy();
@@ -3041,7 +3040,7 @@
   result = HasItemEquipped(EQUIP_BOW);
   if ( !result )
     return result;
-  v4 = (ItemGen *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2->pEquipment.uBow + 5];
+  v4 = (ItemGen *)&v2->pInventoryItems[v2->pEquipment.uBow-1];
   v5 = v4->uItemID;
   v6 = v4->uItemID;
   v15 = pItemsTable->pItems[v6].uDamageRoll;
@@ -3112,7 +3111,7 @@
   static char player__getmeleedamagestring_static_buff[40]; // idb
 
   v1 = this;
-  v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5];
+  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
   if ( v2 < 64 || v2 > 65 )
   {
     v3 = GetMeleeDamageMinimal();
@@ -3138,7 +3137,7 @@
   v8 = v1->pEquipment.uMainHand;
   if ( v8 )
   {
-    v9 = *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v9 = *(int *)&v1->pInventoryItems[v8-1];
     if ( v9 >= 135 )
     {
       if ( v9 <= 159 )
@@ -3164,7 +3163,7 @@
   static char player__getrangeddamagestring_static_buff[40]; // idb
 
   v1 = this;
-  v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5];
+  v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1];
   if ( v2 < 64 || v2 > 65 )
   {
     v3 = GetRangedDamageMin();
@@ -3198,7 +3197,7 @@
   v8 = v1->pEquipment.uMainHand;
   if ( v8 )
   {
-    v9 = *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v9 = *(int *)&v1->pInventoryItems[v8-1];
     if ( v9 >= 135 )
     {
       if ( v9 <= 159 )
@@ -3862,7 +3861,7 @@
       {
         if ( *v20 > 0 )
         {
-          v21 = *(int *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v20 + 5];
+          v21 = *(int *)&v5->pInventoryItems[*v20-1];
           if ( v21 > 0 )
           {
             if ( v21 <= 134 )
@@ -4142,7 +4141,7 @@
   {
     if ( !HasItemEquipped(EQUIP_BOW) )
       goto LABEL_17;
-    v5 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uBow + 5];
+    v5 = (int)&v4->pInventoryItems[v4->pEquipment.uBow-1];
     v46 = v5;
     v3 = (char *)&pItemsTable->pItems[*(int *)v5].pIconName;
     v6 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]];
@@ -4161,7 +4160,7 @@
   }
   if ( HasItemEquipped(EQUIP_TWO_HANDED) )
   {
-    v8 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uMainHand + 5];
+    v8 = (int)&v4->pInventoryItems[v4->pEquipment.uMainHand-1];
     v46 = v8;
     v9 = *(int *)v8;
     v3 = (char *)&pItemsTable->pItems[v9].pIconName;
@@ -4173,7 +4172,7 @@
   }
   if ( HasItemEquipped((ITEM_EQUIP_TYPE)0) )
   {
-    v12 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uOffHand + 5];
+    v12 = (int)&v4->pInventoryItems[v4->pEquipment.uOffHand-1];
     v42 = (unsigned __int16)word_4EDED8[pItemsTable->pItems[*(int *)v12].uSkillType];
     if ( (signed int)v42 > v47 )
     {
@@ -4187,7 +4186,7 @@
 LABEL_17:
   if ( HasItemEquipped(EQUIP_ARMOUR) )
   {
-    v14 = pItemsTable->pItems[*(int *)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uBody + 5]].uSkillType;
+    v14 = pItemsTable->pItems[*(int *)&v4->pInventoryItems[v4->pEquipment.uBody-1]].uSkillType;
     SkillToMastery(v4->pActiveSkills[9]);
     v15 = (unsigned __int16)word_4EDED8[v14];
     v35 = 1.0;
@@ -4870,14 +4869,14 @@
     if ( (signed int)attr <= 30 )
     {
       if ( HasItemEquipped(EQUIP_BOW) )
-        v5 = pItemsTable->pItems[*(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5]].uDamageMod;
+        v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]].uDamageMod;
       return v5 + v62 + v61;
     }
     if ( attr == 31 )
     {
       if ( !HasItemEquipped(EQUIP_BOW) )
         return v5 + v62 + v61;
-      v57 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5];
+      v57 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1];
       v5 = pItemsTable->pItems[v57].uDamageMod;
       v56 = pItemsTable->pItems[v57].uDamageDice;
       goto LABEL_366;
@@ -4886,7 +4885,7 @@
     {
       if ( !HasItemEquipped(EQUIP_BOW) )
         return v5 + v62 + v61;
-      v20 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5];
+      v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1];
       v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll;
 LABEL_365:
       v56 = pItemsTable->pItems[v20].uDamageMod;
@@ -5519,12 +5518,12 @@
       if ( v17 >= 0 )
       {
         if ( v17 <= 2 )
-          v5 = pItemsTable->pItems[*(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uMainHand + 5]].uDamageMod;
+          v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uMainHand-1]].uDamageMod;
       }
     }
     if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v19 = v18->GetEquippedItemEquipType(0), v19 < 0) || v19 > 2 )
       return v5 + v62 + v61;
-    v20 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uOffHand + 5];
+    v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uOffHand-1];
     goto LABEL_365;
   }
   if ( attr == 27 )
--- a/Player.h	Sun Feb 17 14:47:34 2013 +0100
+++ b/Player.h	Sun Feb 17 15:04:56 2013 +0100
@@ -277,10 +277,12 @@
       PlayerSpellbookChapter pBodySpellbook;
       PlayerSpellbookChapter pLightSpellbook;
       PlayerSpellbookChapter pDarkSpellbook;
+      char _pad_0;
     };
     struct
     {
       PlayerSpellbookChapter pChapters[9];
+      char _pad_1;
     };
   };
 };
--- 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();
   }
 }
--- a/mm7_2.cpp	Sun Feb 17 14:47:34 2013 +0100
+++ b/mm7_2.cpp	Sun Feb 17 15:04:56 2013 +0100
@@ -2869,7 +2869,7 @@
     v124 = 0;
     v122 = 3;
     v120 = ptr_507BC0->ptr_1C;
-    v116 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5];
+    v116 = (ItemGen *)&v0->pInventoryItems[v10-1];
     v12 = (int)ptr_507BC0->ptr_1C;
     uPlayerID = uActiveCharacter - 1;
     v13 = v0->_490EEE(v116, 2, v12, 3);
@@ -2893,7 +2893,7 @@
           v2 = v0->GetItemIDAtInventoryIndex((int *)&v149);
           if ( v2 )
           {
-            v3 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            v3 = (ItemGen *)&v0->pInventoryItems[v2-1];
             if ( v3->uAttributes & 1 )
             {
               v118 = ptr_507BC0->ptr_1C;
@@ -4596,7 +4596,7 @@
     {
       v26 = 1;
       v20->uAttributes |= 1u;
-      memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v25 + 5], v20, 0x24u);
+      memcpy(&v0->pInventoryItems[v25-1], v20, 0x24u);
       goto LABEL_42;
     }
     v0->PlaySound(SPEECH_NoRoom, 0);
@@ -4707,7 +4707,7 @@
       || (v15 = v0->GetItemIDAtInventoryIndex((int *)&v79), (v77 = (Player *)v15) == 0) )
       return;
     v16 = ptr_507BC0;
-    if ( sub_4BDAAF((ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5], (int)ptr_507BC0->ptr_1C) )
+    if ( sub_4BDAAF((ItemGen *)&v0->pInventoryItems[v15-1], (int)ptr_507BC0->ptr_1C) )
     {
       dword_F8B1E4 = 1;
       v0->_4BE2DD(v79, (int)((char *)v77 - 1), (int)v16->ptr_1C);
@@ -4742,7 +4742,7 @@
         {
           //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
           v80 = v0->_4B8179(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier);
-          v12 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v11 + 5];
+          v12 = (int)&v0->pInventoryItems[v11-1];
           if ( !(*(char *)(v12 + 20) & 1) )
           {
             _this = (ItemGen *)ptr_507BC0->ptr_1C;
@@ -4784,11 +4784,11 @@
           v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
           if ( v2 )
           {
-            v3 = (int)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            v3 = (int)&v0->pInventoryItems[v2-1];
             //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
             v4 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
 
-            auto _v = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5];
+            auto _v = (ItemGen *)&v0->pInventoryItems[v2-1];
             v5 = _v->GetValue();
 
             v6 = v0->_4B81C3(v5, v4);
@@ -14768,7 +14768,7 @@
   v2 = v0->pEquipment.uOffHand;
   v54 = v0->pEquipment.uOffHand;
   v53 = v1;
-  if ( v1 && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uEquipType == 1 )
+  if ( v1 && pItemsTable->pItems[*(int *)&v0->pInventoryItems[v1-1]].uEquipType == 1 )
     v51 = v1;
   v3 = pParty->pPickedItem.uItemID;
   if ( pParty->pPickedItem.uItemID )
@@ -14795,7 +14795,7 @@
     {
       if ( (v4 == 8 || v4 == 1 || v4 == 2)
         && v1
-        && pItemsTable->pItems[*(int *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v1 + 5]].uSkillType == 4 )
+        && pItemsTable->pItems[*(int *)&v0->pInventoryItems[v1-1]].uSkillType == 4 )
         goto LABEL_7;
     }
 LABEL_16:
@@ -15140,7 +15140,7 @@
     v35 = v0->pEquipment.uBow;
     if ( v35 )
     {
-      auto _a = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v35 + 5];
+      auto _a = (ItemGen *)&v0->pInventoryItems[v35-1];
       pParty->SetHoldingItem(_a);
       _a->Reset();
       v0->pEquipment.uBow = 0;
--- a/mm7_4.cpp	Sun Feb 17 14:47:34 2013 +0100
+++ b/mm7_4.cpp	Sun Feb 17 15:04:56 2013 +0100
@@ -9104,7 +9104,7 @@
           || pMouse->GetCursorPos((POINT *)&v12)->x >= 462
           || (v9 = v0->GetItemIDAtInventoryIndex(&v18)) == 0 )
           return;
-        v7 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v9 + 5];
+        v7 = (ItemGen *)&v0->pInventoryItems[v9-1];
 LABEL_15:
         GameUI_DrawItemInfo(v7);
         return;
@@ -12266,7 +12266,7 @@
                 {
                   v96 = 0;
                   v94 = 4;
-                  v4 = &_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
+                  v4 = (char *)&_this->pInventoryItems[result-1];
                   if ( v4[20] & 1 )
                   {
                     v5 = sub_495461("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)ptr_507BC0->ptr_1C, 4, 0);
@@ -12306,7 +12306,7 @@
       v96 = 0;
       v94 = 3;
       v93 = ptr_507BC0->ptr_1C;
-      v90 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5];
+      v90 = (ItemGen *)&_this->pInventoryItems[result-1];
       v12 = (int)ptr_507BC0->ptr_1C;
       uPlayerID = uActiveCharacter - 1;
       v13 = _this->_490EEE(v90, 3, v12, 3);
--- a/mm7_5.cpp	Sun Feb 17 14:47:34 2013 +0100
+++ b/mm7_5.cpp	Sun Feb 17 15:04:56 2013 +0100
@@ -5455,7 +5455,7 @@
       {
         if ( pPlayer->HasItemEquipped((ITEM_EQUIP_TYPE)v59) )
         {
-          auto _s = (ItemGen *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v57->uOffHand + 5];
+          auto _s = (ItemGen *)&pPlayer->pInventoryItems[v57->uOffHand-1];
           a4 = _s->_439DF3_get_additional_damage(&a2, &v62);
           if ( v62 && pMonster->sCurrentHP > 0 )
           {
@@ -5933,7 +5933,7 @@
     if ( v45->HasEnchantedItemEquipped(69) )
       v77 >>= 1;
     if ( v45->HasItemEquipped(EQUIP_ARMOUR)
-		&& *(_DWORD *)&v45->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v45->pEquipment.uBody + 5] == 504 )
+		&& *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uBody-1] == 504 )
       v77 >>= 1;
     v75 = 0;
 	v47 = (int)&v45->pEquipment;
@@ -7289,7 +7289,7 @@
     if ( !v21 )
       goto LABEL_59;
     v230 = pPlayer->pEquipment.uBow;
-    v22 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v21 + 5];
+    v22 = (int)&v217->pInventoryItems[v21-1];
     v23 = *(int *)v22;
     v24 = pPaperdoll_BodyX + array_4E4C30[pBodyComplection].equip_x - pItemsTable->pItems[v23].uEquipX;
     a3b = pPaperdoll_BodyY + array_4E4C30[pBodyComplection].equip_y - pItemsTable->pItems[v23].uEquipY;
@@ -7325,7 +7325,7 @@
       if ( !v31 )
         goto LABEL_93;
       v231 = v217->pEquipment.uCloak;
-      v32 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v31 + 5];
+      v32 = (int)&v217->pInventoryItems[v31-1];
       v219 = v32;
       if ( *(int *)v32 != 525 )
       {
@@ -7377,7 +7377,7 @@
                 if ( !v43 )
                   goto LABEL_127;
                 v232 = v217->pEquipment.uBody;
-                v44 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v43 + 5];
+                v44 = (int)&v217->pInventoryItems[v43-1];
                 v220 = v44;
                 if ( *(int *)v44 != 504 )
                 {
@@ -7436,7 +7436,7 @@
                           if ( !v56 )
                             goto LABEL_155;
                           v233 = v217->pEquipment.field_20;
-                          v57 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v56 + 5];
+                          v57 = (int)&v217->pInventoryItems[v56-1];
                           v221 = v57;
                           v58 = *(int *)v57;
                           if ( *(int *)v57 == 529 )
@@ -7500,7 +7500,7 @@
                             v68 = v217;
                             v69 = v217->pEquipment.uMainHand;
                             uPlayerID_a = 2 * pBodyComplection;
-                            if ( !v69 || (v70 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v69 + 5],
+                            if ( !v69 || (v70 = *(int *)&v217->pInventoryItems[v69-1],
                                   pItemsTable->pItems[v70].uEquipType != 1)
                               && (pItemsTable->pItems[v70].uSkillType != 4 || v217->pEquipment.uOffHand) )
                               pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[2 * pBodyComplection],
@@ -7510,7 +7510,7 @@
                             if ( v71 )
                             {
                               v234 = v217->pEquipment.uBelt;
-                              v72 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v71 + 5];
+                              v72 = (int)&v217->pInventoryItems[v71-1];
                               v222 = v72;
                               if ( *(int *)v72 == 524 )
                               {
@@ -7602,7 +7602,7 @@
                             v82 = v68->pEquipment.uMainHand;
                             if ( v82 )
                             {
-                              v83 = *(int *)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v82 + 5];
+                              v83 = *(int *)&v68->pInventoryItems[v82-1];
                               if ( pItemsTable->pItems[v83].uEquipType == 1
                                 || pItemsTable->pItems[v83].uSkillType == 4 && !v68->pEquipment.uOffHand )
                                 pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[uPlayerID_a],
@@ -7634,7 +7634,7 @@
                                       if ( !v111 )
                                         goto LABEL_293;
                                       v236 = v68->pEquipment.uCloak;
-                                      v112 = (int)&v68->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v111 + 5];
+                                      v112 = (int)&v68->pInventoryItems[v111-1];
                                       v225 = v112;
                                       v113 = *(int *)v112;
                                       if ( v113 != 525 )
@@ -7682,7 +7682,7 @@
                                                 if ( !v123 )
                                                   goto LABEL_335;
                                                 v237 = v123;
-                                                v124 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v123 + 5];
+                                                v124 = (int)&v217->pInventoryItems[v123-1];
                                                 v226 = v124;
                                                 if ( *(int *)v124 != 521 )
                                                 {
@@ -7787,7 +7787,7 @@
                                                   if ( !v134 )
                                                     goto LABEL_358;
                                                   v238 = v217->pEquipment.uMainHand;
-                                                  v135 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v134 + 5];
+                                                  v135 = (int)&v217->pInventoryItems[v134-1];
                                                   v227 = v135;
                                                   v136 = *(int *)v135;
                                                   v137 = *(int *)v135;
@@ -7832,7 +7832,7 @@
                                                     v249 = v217->pEquipment.uOffHand;
                                                     if ( !v145 )
                                                       goto LABEL_393;
-                                                    v146 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v145 + 5];
+                                                    v146 = (int)&v217->pInventoryItems[v145-1];
                                                     v228 = v146;
                                                     v147 = *(int *)v146;
                                                     v148 = *(int *)v146;
@@ -8459,7 +8459,7 @@
   uPlayerID_a = 2 * v5;
   v6 = pPlayer->pEquipment.uMainHand;
   if ( !v6
-    || (v7 = *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5], pItemsTable->pItems[v7].uEquipType != 1)
+    || (v7 = *(int *)&pPlayer->pInventoryItems[v6-1], pItemsTable->pItems[v7].uEquipType != 1)
     && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayer->pEquipment.uOffHand) )
     pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[2 * v5], pPaperdoll_BodyY + pPaperdoll_LeftHand[2 * v5 + 1],
       (Texture *)(*(unsigned int *)((char *)papredoll_dlads + v240) != -1 ? (int)&pIcons_LOD->pTextures[*(unsigned int *)((char *)papredoll_dlads + v240)] : 0));
@@ -8471,7 +8471,7 @@
   if ( v8 )
   {
     v229 = pPlayer->pEquipment.uMainHand;
-    v9 = (int)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5];
+    v9 = (int)&v217->pInventoryItems[v8-1];
     v10 = v5 << 7;
     v218 = v9;
     v11 = *(int *)v9;
@@ -8561,7 +8561,7 @@
   v161 = v217->pEquipment.uMainHand;
   if ( v161 )
   {
-    v162 = *(int *)&v217->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v161 + 5];
+    v162 = *(int *)&v217->pInventoryItems[v161-1];
     if ( pItemsTable->pItems[v162].uEquipType == 1
       || pItemsTable->pItems[v162].uSkillType == 4 && !v217->pEquipment.uOffHand )
       pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[uPlayerID_a],
@@ -8734,7 +8734,7 @@
   if ( !v15 )
     goto LABEL_46;
   v41 = pPlayer->pEquipment.field_24;
-  v49 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5];
+  v49 = (int)&pPlayer->pInventoryItems[v15-1];
   v16 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v49].pIconName, TEXTURE_16BIT_PALETTE);
   v17 = *(int *)(v49 + 20);
   if ( !(*(int *)(v49 + 20) & 0xF0) )
@@ -8816,7 +8816,7 @@
   if ( !v26 )
     return;
   v43 = pPlayer->pEquipment.field_1C;
-  v27 = (int)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v26 + 5];
+  v27 = (int)&pPlayer->pInventoryItems[v26-1];
   v28 = pIcons_LOD->LoadTexture(pItemsTable->pItems[*(int *)v27].pIconName, TEXTURE_16BIT_PALETTE);
   v29 = *(int *)(v27 + 20);
   if ( !(*(int *)(v27 + 20) & 0xF0) )
@@ -8988,7 +8988,7 @@
       if ( *v5 )
       {
         result = 9 * *v5;
-        if ( *(int *)&pPlayer->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v5 + 5] == uItemID )
+        if ( *(int *)&pPlayer->pInventoryItems[*v5-1] == uItemID )
           break;
       }
       ++v4;
--- a/mm7_6.cpp	Sun Feb 17 14:47:34 2013 +0100
+++ b/mm7_6.cpp	Sun Feb 17 15:04:56 2013 +0100
@@ -8016,7 +8016,7 @@
         v12 = v1->pEquipment.uMainHand;
         v29 = 1;
         _42777D_CastSpell_UseWand_ShootArrow(
-          *((int *)&pSpellDatas[66].field_8 + *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v12 + 5]),
+          *((int *)&pSpellDatas[66].field_8 + *(int *)&v1->pInventoryItems[v12-1]),
           v0 - 1,
           8u,
           0,
@@ -8039,7 +8039,7 @@
           {
             v15 = v1->pEquipment.uMainHand;
             if ( v1->HasItemEquipped(EQUIP_TWO_HANDED) )
-              v34 = pItemsTable->pItems[*(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v15 + 5]].uSkillType;
+              v34 = pItemsTable->pItems[*(int *)&v1->pInventoryItems[v15-1]].uSkillType;
             pTurnEngine->_40471C();
           }
           else