comparison mm7_1.cpp @ 232:c879446b4a22

inventory indexing fixed
author zipi
date Sun, 17 Feb 2013 15:04:56 +0100
parents 1bd823f52e3a
children 0d9d30a1efc9 2799737f8a74
comparison
equal deleted inserted replaced
231:a69fc44061d5 232:c879446b4a22
5274 } 5274 }
5275 } 5275 }
5276 uLastPointedObjectID = pMouse->uPointingObjectID; 5276 uLastPointedObjectID = pMouse->uPointingObjectID;
5277 return; 5277 return;
5278 } 5278 }
5279 pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v14 + 5]; 5279 pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v14-1];
5280 //goto LABEL_49; 5280 //goto LABEL_49;
5281 v17 = pItemGen->GetDisplayName(); 5281 v17 = pItemGen->GetDisplayName();
5282 sub_41C0B8_set_status_string(v17); 5282 sub_41C0B8_set_status_string(v17);
5283 uLastPointedObjectID = 1; 5283 uLastPointedObjectID = 1;
5284 if ( pMouse->uPointingObjectID == 0 ) 5284 if ( pMouse->uPointingObjectID == 0 )
5661 v1 = (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0); 5661 v1 = (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0);
5662 v11 = areWeLoadingTexture; 5662 v11 = areWeLoadingTexture;
5663 if ( uActiveCharacter 5663 if ( uActiveCharacter
5664 && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 ) 5664 && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
5665 { 5665 {
5666 memcpy(&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u); 5666 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u);
5667 } 5667 }
5668 else 5668 else
5669 { 5669 {
5670 v12 = 0; 5670 v12 = 0;
5671 v3 = pParty->pPlayers; 5671 v3 = pParty->pPlayers;
5746 { 5746 {
5747 //v3 = player; 5747 //v3 = player;
5748 if (auto slot = player->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) 5748 if (auto slot = player->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID))
5749 { 5749 {
5750 __debugbreak(); // invalid inventory indexing 5750 __debugbreak(); // invalid inventory indexing
5751 memcpy(&player->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * slot + 5], &pParty->pPickedItem, 0x24u); 5751 memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u);
5752 viewparams->bRedrawGameUI = true; 5752 viewparams->bRedrawGameUI = true;
5753 pMouse->RemoveHoldingItem(); 5753 pMouse->RemoveHoldingItem();
5754 return; 5754 return;
5755 } 5755 }
5756 5756
5899 { 5899 {
5900 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; 5900 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
5901 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; 5901 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
5902 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; 5902 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1;
5903 *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; 5903 *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4;
5904 ptr_50C9A4 = (ItemGen *)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6 + 5]; 5904 ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1];
5905 unk_50C9A0 = 0; 5905 unk_50C9A0 = 0;
5906 if ( pMessageQueue_50CBD0->uNumMessages ) 5906 if ( pMessageQueue_50CBD0->uNumMessages )
5907 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 5907 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
5908 pMouse->SetCursorBitmap("MICON1"); 5908 pMouse->SetCursorBitmap("MICON1");
5909 dword_50C9D0 = 113; 5909 dword_50C9D0 = 113;
5918 v8 = v0->GetItemIDAtInventoryIndex(&a4); 5918 v8 = v0->GetItemIDAtInventoryIndex(&a4);
5919 if ( !v7 ) 5919 if ( !v7 )
5920 { 5920 {
5921 if ( !v8 ) 5921 if ( !v8 )
5922 return; 5922 return;
5923 memcpy(&pParty->pPickedItem, &v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5], sizeof(pParty->pPickedItem)); 5923 memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem));
5924 v0->RemoveItemAtInventoryIndex(a4); 5924 v0->RemoveItemAtInventoryIndex(a4);
5925 v9 = pParty->pPickedItem.uItemID; 5925 v9 = pParty->pPickedItem.uItemID;
5926 goto LABEL_24; 5926 goto LABEL_24;
5927 } 5927 }
5928 v13 = v8; 5928 v13 = v8;
5929 if ( v8 ) 5929 if ( v8 )
5930 { 5930 {
5931 a2.y = (LONG)&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5]; 5931 a2.y = (LONG)&v0->pInventoryItems[v8-1];
5932 memcpy(&this_, (const void *)a2.y, sizeof(this_)); 5932 memcpy(&this_, (const void *)a2.y, sizeof(this_));
5933 v0->RemoveItemAtInventoryIndex(a4); 5933 v0->RemoveItemAtInventoryIndex(a4);
5934 pX = v0->AddItem2(a4, &pParty->pPickedItem); 5934 pX = v0->AddItem2(a4, &pParty->pPickedItem);
5935 if ( !pX ) 5935 if ( !pX )
5936 { 5936 {
5950 } 5950 }
5951 v10 = v0->AddItem(a4, v7); 5951 v10 = v0->AddItem(a4, v7);
5952 pX = v10; 5952 pX = v10;
5953 if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) 5953 if ( v10 || (v10 = v0->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID), (pX = v10) != 0) )
5954 { 5954 {
5955 memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], &pParty->pPickedItem, 0x24u); 5955 memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u);
5956 pMouse->RemoveHoldingItem(); 5956 pMouse->RemoveHoldingItem();
5957 } 5957 }
5958 } 5958 }
5959 5959
5960 5960