Mercurial > mm7
diff Player.cpp @ 1384:b51332ab228f
changed a few member variables in Player to slightly less confusing names
author | Grumpy7 |
---|---|
date | Tue, 16 Jul 2013 20:51:29 +0200 |
parents | 0a4254e80036 |
children | 5644aecb5082 |
line wrap: on
line diff
--- a/Player.cpp Tue Jul 16 00:40:01 2013 +0200 +++ b/Player.cpp Tue Jul 16 20:51:29 2013 +0200 @@ -476,11 +476,11 @@ return 0; } - inv_index = this->pInventoryIndices[item_idx]; + inv_index = this->pInventoryMatrix[item_idx]; if ( inv_index < 0 ) { *pitem_index = -1 - inv_index; - inv_index = this->pInventoryIndices[-1 - inv_index]; + inv_index = this->pInventoryMatrix[-1 - inv_index]; } return inv_index; @@ -510,15 +510,15 @@ { for ( i = 0; i < enchant_count; ++i ) { - if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED)) - pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_ENCHANTED; + if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED)) + pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_ENCHANTED; } } else { for ( i = 0; i < avalible_items; ++i ) { - pInventoryItems[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED; + pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED; } } } @@ -849,7 +849,7 @@ int innerLoopPos = startOfInnerLoop; for (unsigned int x = 0; x < slotWidth; x++) { - if (pInventoryIndices[innerLoopPos] != 0) + if (pInventoryMatrix[innerLoopPos] != 0) { return false; } @@ -864,11 +864,11 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (004925E6) -------------------------------------------------------- -int Player::FindFreeInventorySlot() +int Player::FindFreeInventoryListSlot() { for (int i = 0; i < 126; i++ ) { - if (pInventoryItems[i].uItemID == 0) + if (pInventoryItemList[i].uItemID == 0) { return i; } @@ -886,7 +886,7 @@ signed int freeSlot; // [sp+8h] [bp-4h]@4 unsigned int heightInSlots; // [sp+18h] [bp+Ch]@10 - freeSlot = FindFreeInventorySlot(); + freeSlot = FindFreeInventoryListSlot(); if ( freeSlot == -1 ) { if ( uActiveCharacter ) @@ -897,7 +897,7 @@ { PutItemArInventoryIndex(uItemID, freeSlot, uSlot); result = freeSlot + 1; - this->pInventoryItems[freeSlot].uItemID = uItemID; + this->pInventoryItemList[freeSlot].uItemID = uItemID; } return result; } @@ -925,23 +925,23 @@ { int item_body_anch; // edi@6 int item_indx; - item_indx = FindFreeInventorySlot(); + item_indx = FindFreeInventoryListSlot(); if ( item_indx != -1 ) { - pInventoryItems[item_indx].uItemID = uItemID; + pInventoryItemList[item_indx].uItemID = uItemID; item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; pEquipment.pIndices[item_body_anch] = item_indx + 1; - pInventoryItems[item_indx].uBodyAnchor = item_body_anch + 1; + pInventoryItemList[item_indx].uBodyAnchor = item_body_anch + 1; } } //----- (004927A8) -------------------------------------------------------- -int Player::AddItem(int uSlot, unsigned int uItemID) +int Player::AddItem(int index, unsigned int uItemID) { int xStartValue = 0; - if ( uSlot == -1 ) + if ( index == -1 ) { for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) { @@ -956,21 +956,21 @@ } return 0; } - if ( !CanFitItem(uSlot, uItemID) ) + if ( !CanFitItem(index, uItemID) ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return 0; } - return CreateItemInInventory(uSlot, uItemID); + return CreateItemInInventory(index, uItemID); } //----- (00492826) -------------------------------------------------------- -int Player::AddItem2(int uSlot, ItemGen *Src) +int Player::AddItem2(int index, ItemGen *Src) { int xStartValue = 0; pItemsTable->SetSpecialBonus(Src); - if ( uSlot == -1 ) + if ( index == -1 ) { for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) { @@ -985,13 +985,13 @@ } return 0; } - if ( !CanFitItem(uSlot, Src->uItemID) ) + if ( !CanFitItem(index, Src->uItemID) ) return 0; - return CreateItemInInventory2(uSlot, Src); + return CreateItemInInventory2(index, Src); } //----- (0049289C) -------------------------------------------------------- -int Player::CreateItemInInventory2(unsigned int uSlot, ItemGen *Src) +int Player::CreateItemInInventory2( unsigned int index, ItemGen *Src ) { signed int freeSlot; // ebx@1 int result; // eax@6 @@ -1001,15 +1001,15 @@ unsigned int slot_height; // [sp+8h] [bp-8h]@7 - freeSlot = FindFreeInventorySlot(); + freeSlot = FindFreeInventoryListSlot(); if ( freeSlot == -1 ) { result = 0; } else { - PutItemArInventoryIndex(Src->uItemID, freeSlot, uSlot); - memcpy(&pInventoryItems[freeSlot], Src, sizeof(ItemGen)); + PutItemArInventoryIndex(Src->uItemID, freeSlot, index); + memcpy(&pInventoryItemList[freeSlot], Src, sizeof(ItemGen)); result = freeSlot + 1; } return result; @@ -1017,7 +1017,7 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (0049298B) -------------------------------------------------------- -void Player::PutItemArInventoryIndex( int uItemID, int item_id, int uSlot ) +void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) { Texture *item_texture; // esi@1 int *pInvPos; // esi@4 @@ -1034,20 +1034,20 @@ } if ( slot_width > 0 ) { - pInvPos = &pInventoryIndices[uSlot]; + pInvPos = &pInventoryMatrix[index]; for (unsigned int i = 0; i < slot_height; i++) { - memset32(pInvPos, -1 - uSlot, slot_width);//TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn + memset32(pInvPos, -1 - index, slot_width);//TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn pInvPos += INVETORYSLOTSWIDTH; } } - pInventoryIndices[uSlot] = item_id + 1; + pInventoryMatrix[index] = itemListPos + 1; } // 506128: using guessed type int areWeLoadingTexture; //----- (00492A36) -------------------------------------------------------- -void Player::RemoveItemAtInventoryIndex( unsigned int uSlot ) +void Player::RemoveItemAtInventoryIndex( unsigned int index ) { ItemGen *item_in_slot; // ecx@1 Texture *item_texture; // esi@1 @@ -1055,7 +1055,7 @@ int *pInvPos; // edx@4 unsigned int slot_width; // [sp+14h] [bp+4h]@1 - item_in_slot = &this->pInventoryItems[pInventoryIndices[uSlot]-1]; + item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1]; item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item_in_slot->uItemID].pIconName, TEXTURE_16BIT_PALETTE); item_in_slot->Reset(); slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); @@ -1067,7 +1067,7 @@ } if ( slot_width > 0 ) { - pInvPos = &pInventoryIndices[uSlot]; + pInvPos = &pInventoryMatrix[index]; for (unsigned int i = 0; i < slot_height; i++) { memset32(pInvPos, 0, slot_width); @@ -1558,9 +1558,9 @@ Player::Player() { memset(&pEquipment, 0, sizeof(PlayerEquipment)); - memset(pInventoryIndices, 0, 126 * sizeof(int)); + memset(pInventoryMatrix, 0, 126 * sizeof(int)); for (uint i = 0; i < 126; ++i) - pInventoryItems[i].Reset(); + pInventoryItemList[i].Reset(); for (uint i = 0; i < 12; ++i) pEquippedItems[i].Reset(); @@ -1734,7 +1734,7 @@ goto LABEL_15; } } - memcpy(&v9->pInventoryItems[v10-1], pItem, 0x24u); + memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); pItem->Reset(); pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); v19->PlaySound(SPEECH_60, 0); @@ -2034,7 +2034,7 @@ } if ( HasItemEquipped(EQUIP_MAIN_HAND) ) { - v6 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uMainHand-1]; + v6 = (ItemGen *)&v5->pInventoryItemList[v5->pEquipment.uMainHand-1]; v7 = v6->uItemID; v8 = v6->uItemID; v9 = pItemsTable->pItems[v8].uDamageDice; @@ -2106,7 +2106,7 @@ { if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) ) { - v15 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uShield - 1]; + v15 = (ItemGen *)&v5->pInventoryItemList[v5->pEquipment.uShield - 1]; v16 = v15->uItemID; v17 = v15->uItemID; if ( pItemsTable->pItems[v17].uEquipType != 4 ) @@ -2199,7 +2199,7 @@ int v7; // edi@4 v1 = this; - v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; + v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1]; if ( v2 < 64 || v2 > 65 ) { v4 = GetActualAccuracy(); @@ -2289,7 +2289,7 @@ result = HasItemEquipped(EQUIP_BOW); if ( !result ) return result; - v4 = (ItemGen *)&v2->pInventoryItems[v2->pEquipment.uBow-1]; + v4 = (ItemGen *)&v2->pInventoryItemList[v2->pEquipment.uBow-1]; v5 = v4->uItemID; v6 = v4->uItemID; v15 = pItemsTable->pItems[v6].uDamageRoll; @@ -2539,13 +2539,13 @@ //----- (0048D62C) -------------------------------------------------------- ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) { - return pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uEquipType; + return pItemsTable->pItems[pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uEquipType; } //----- (0048D651) -------------------------------------------------------- PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) { - return (PLAYER_SKILL_TYPE)pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType; + return (PLAYER_SKILL_TYPE)pItemsTable->pItems[pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType; } //----- (0048D676) -------------------------------------------------------- @@ -2588,7 +2588,7 @@ { v6 = 0; while ( !HasItemEquipped((ITEM_EQUIP_TYPE)v6) - || pInventoryItems[pEquipment.pIndices[v6] - 1].uItemID != item_id ) + || pInventoryItemList[pEquipment.pIndices[v6] - 1].uItemID != item_id ) { ++v6; if ( (signed int)v6 >= 16 ) @@ -2596,7 +2596,7 @@ } return 1; } - if ( HasItemEquipped(equip_type) && pInventoryItems[pEquipment.pIndices[equip_type - 1]].uItemID == item_id ) + if ( HasItemEquipped(equip_type) && pInventoryItemList[pEquipment.pIndices[equip_type - 1]].uItemID == item_id ) return 1; return 0; } @@ -2973,7 +2973,7 @@ break; case 17: v12 = 0; - v13 = this->pInventoryItems; + v13 = this->pInventoryItemList; do { if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->Broken()) @@ -3016,17 +3016,17 @@ LABEL_36: if ( !v4 ) goto LABEL_87; - v48 = (int)&v5->pInventoryItems[(unsigned __int8)v46[rand() % v4]]; + v48 = (int)&v5->pInventoryItemList[(unsigned __int8)v46[rand() % v4]]; v11 = 3 * (pItemsTable->pItems[*(int *)v48].uMaterial + pItemsTable->pItems[*(int *)v48].uDamageMod); break; case 20: v19 = 0; - v20 = this->pInventoryIndices; + v20 = this->pInventoryMatrix; do { if ( *v20 > 0 ) { - v21 = *(int *)&v5->pInventoryItems[*v20-1]; + v21 = *(int *)&v5->pInventoryItemList[*v20-1]; if ( v21 > 0 ) { if ( v21 <= 134 ) @@ -3199,7 +3199,7 @@ goto LABEL_84; } v28 = v47; - memcpy(v27, &v5->pInventoryItems[v5->pInventoryIndices[v47]-1], 0x24u); + memcpy(v27, &v5->pInventoryItemList[v5->pInventoryMatrix[v47]-1], 0x24u); RemoveItemAtInventoryIndex(v28); LABEL_79: v42 = 0; @@ -3253,7 +3253,7 @@ { if ( !HasItemEquipped(EQUIP_BOW) ) goto LABEL_17; - weapon = &pInventoryItems[pEquipment.uBow - 1]; + weapon = &pInventoryItemList[pEquipment.uBow - 1]; weapon_desc = &pItemsTable->pItems[weapon->uItemID]; weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType]; goto LABEL_17; @@ -3269,7 +3269,7 @@ if ( HasItemEquipped(EQUIP_MAIN_HAND) ) { - weapon = &pInventoryItems[pEquipment.uMainHand - 1]; + weapon = &pInventoryItemList[pEquipment.uMainHand - 1]; weapon_desc = &pItemsTable->pItems[weapon->uItemID]; if (weapon_desc->uEquipType == EQUIP_WAND) { @@ -3283,11 +3283,11 @@ if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) // ADD: shield check because shield recovery is added later and can be accidentally doubled { - auto v12 = &pInventoryItems[pEquipment.uShield - 1]; + auto v12 = &pInventoryItemList[pEquipment.uShield - 1]; auto v12_desc = &pItemsTable->pItems[v12->uItemID]; if (base_recovery_times_per_weapon_type[v12_desc->uSkillType] > weapon_recovery) { - weapon = &pInventoryItems[pEquipment.uShield - 1]; + weapon = &pInventoryItemList[pEquipment.uShield - 1]; weapon_desc = &pItemsTable->pItems[weapon->uItemID]; weapon_recovery = base_recovery_times_per_weapon_type[pItemsTable->pItems[weapon->uItemID].uSkillType]; } @@ -3297,7 +3297,7 @@ uint armour_recovery = 0; if ( HasItemEquipped(EQUIP_ARMOUR) ) { - auto armour_skill_type = pItemsTable->pItems[pInventoryItems[pEquipment.uArmor - 1].uItemID].uSkillType; + auto armour_skill_type = pItemsTable->pItems[pInventoryItemList[pEquipment.uArmor - 1].uItemID].uSkillType; uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; float armour_recovery_multipliers[4]; @@ -3340,7 +3340,7 @@ { float shield_recovery_multipliers[4] = {1, 0, 0, 0}; - auto shield = &pInventoryItems[pEquipment.uShield - 1]; + auto shield = &pInventoryItemList[pEquipment.uShield - 1]; auto skill_type = pItemsTable->pItems[shield->uItemID].uSkillType; uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; @@ -3773,12 +3773,12 @@ inv_indx = pEquipment.pIndices[i] - 1; if (a2==17) { - if ((pInventoryItems[inv_indx].uSpecEnchantmentType==17)||(pInventoryItems[inv_indx].uItemID==533)) //Elven Chainmail+Increases rate of Recovery + if ((pInventoryItemList[inv_indx].uSpecEnchantmentType==17)||(pInventoryItemList[inv_indx].uItemID==533)) //Elven Chainmail+Increases rate of Recovery return 50; } if (a2==24) { - if (pInventoryItems[inv_indx].uSpecEnchantmentType==24) //Increased Knockback. + if (pInventoryItemList[inv_indx].uSpecEnchantmentType==24) //Increased Knockback. return 5; } } @@ -3940,7 +3940,7 @@ { if ( v32 <= 11 ) { - v33 = v6->pInventoryItems[v31].uItemID; + v33 = v6->pInventoryItemList[v31].uItemID; v5 += pItemsTable->pItems[v33].uDamageDice + pItemsTable->pItems[v33].uDamageMod; } } @@ -5240,7 +5240,7 @@ { if ( v2->HasItemEquipped(v71) ) { - v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItems[*(_DWORD *)v9].uItemID].uEquipType; + v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[*(_DWORD *)v9].uItemID].uEquipType; LOBYTE(v12) = this->GetActualSkillLevel(v11); a1 = v12; SkillToMastery(v12); @@ -5298,7 +5298,7 @@ { if ( v2->HasItemEquipped(v20) ) { - v22 = this->pInventoryItems[this->pEquipment.pIndices[v20]].uItemID; + v22 = this->pInventoryItemList[this->pEquipment.pIndices[v20]].uItemID; if ( pItemsTable->pItems[v22].uEquipType <= 1u ) break; } @@ -6670,7 +6670,7 @@ v23 = pParty->pPlayers;//[0].pInventoryItems; do { - v24 = v23->pInventoryItems; + v24 = v23->pInventoryItemList; v25 = 138; do { @@ -6759,7 +6759,7 @@ return v4 >= pValue; } while ( !v3->HasItemEquipped(v26) - || *(int *)&v3->pInventoryItems[*(int *)v27-1] != pValue ) + || *(int *)&v3->pInventoryItemList[*(int *)v27-1] != pValue ) { v26 = (ITEM_EQUIP_TYPE)((int)v26 + 1); v27 += 4; @@ -6856,7 +6856,7 @@ return false; case VAR_PlayerItemInHands: v15 = 0; - v16 = v3->pInventoryItems; + v16 = v3->pInventoryItemList; break; case VAR_FixedGold: v4 = pParty->uNumGold; @@ -7241,7 +7241,7 @@ v9 = NULL; for (int i = 0; i < 138; i++) { - v9 = &this->pInventoryItems[i]; + v9 = &this->pInventoryItemList[i]; if (v9->uItemID == ITEM_LICH_JAR_EMPTY) break; } @@ -8386,7 +8386,7 @@ pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0); return true; case VAR_PlayerItemInHands: - v15 = this->pInventoryIndices; + v15 = this->pInventoryMatrix; break; case VAR_FixedGold: if ( (unsigned int)pValue > pParty->uNumGold ) @@ -8747,7 +8747,7 @@ } for (v3 = 1; v3 < 126; v3++) { - if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue ) + if ( *(&this->pInventoryItemList[pInventoryMatrix[v3] - 1].uItemID) == pValue ) { RemoveItemAtInventoryIndex(v3); return true; @@ -8801,11 +8801,11 @@ } else { - v7 = v3->FindFreeInventorySlot(); + v7 = v3->FindFreeInventoryListSlot(); if (v7 >= 0) { pParty->pPickedItem.uBodyAnchor = v2 + 1; - memcpy(&v3->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItems[v7])); + memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItemList[v7])); *v11 = v7 + 1; pMouse->RemoveHoldingItem(); } @@ -8907,9 +8907,9 @@ { for ( uint i = 0; i < 126; ++i ) { - if ( pPlayer->pInventoryIndices[i] > 0 ) - { - if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pInventoryIndices[i] - 1].uItemID == uItemID ) + if ( pPlayer->pInventoryMatrix[i] > 0 ) + { + if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pInventoryMatrix[i] - 1].uItemID == uItemID ) return true; } } @@ -8917,7 +8917,7 @@ { if ( pPlayer->pEquipment.pIndices[i] ) { - if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) + if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) return true; } } @@ -9335,7 +9335,7 @@ if ( v45->HasEnchantedItemEquipped(69) ) v77 >>= 1; if ( v45->HasItemEquipped(EQUIP_ARMOUR) - && *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uArmor-1] == 504 ) + && *(_DWORD *)&v45->pInventoryItemList[v45->pEquipment.uArmor-1] == 504 ) v77 >>= 1; v75 = 0; v47 = (int)&v45->pEquipment; @@ -9558,7 +9558,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->pInventoryItems[v6-1]; + ptr_50C9A4 = (ItemGen *)&v0->pInventoryItemList[v6-1]; unk_50C9A0 = 0; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; @@ -9577,7 +9577,7 @@ { if ( !v8 ) return; - memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); + memcpy(&pParty->pPickedItem, &v0->pInventoryItemList[v8-1], sizeof(pParty->pPickedItem)); v0->RemoveItemAtInventoryIndex(a4); v9 = pParty->pPickedItem.uItemID; pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); @@ -9586,7 +9586,7 @@ v13 = v8; if ( v8 ) { - a2.y = (LONG)&v0->pInventoryItems[v8-1]; + a2.y = (LONG)&v0->pInventoryItemList[v8-1]; memcpy(&this_, (const void *)a2.y, sizeof(this_)); v0->RemoveItemAtInventoryIndex(a4); pX = v0->AddItem2(a4, &pParty->pPickedItem); @@ -9609,7 +9609,7 @@ pX = v10; if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) { - memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); + memcpy(&v0->pInventoryItemList[v10-1], &pParty->pPickedItem, 0x24u); pMouse->RemoveHoldingItem(); } }