Mercurial > mm7
comparison Player.cpp @ 232:c879446b4a22
inventory indexing fixed
author | zipi |
---|---|
date | Sun, 17 Feb 2013 15:04:56 +0100 |
parents | 1bd823f52e3a |
children | 47e06334c564 ccf14ac29caf |
comparison
equal
deleted
inserted
replaced
231:a69fc44061d5 | 232:c879446b4a22 |
---|---|
255 while ( 1 ) | 255 while ( 1 ) |
256 { | 256 { |
257 result = v2->uOffHand; | 257 result = v2->uOffHand; |
258 if ( v2->uOffHand ) | 258 if ( v2->uOffHand ) |
259 { | 259 { |
260 result = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * result + 5]; | 260 result = *(int *)&this->pInventoryItems[result-1]; |
261 if ( result ) | 261 if ( result ) |
262 { | 262 { |
263 if ( result != 64 && result != 65 ) | 263 if ( result != 64 && result != 65 ) |
264 break; | 264 break; |
265 } | 265 } |
1759 void *v9; // edx@4 | 1759 void *v9; // edx@4 |
1760 unsigned int uSlota; // [sp+14h] [bp+4h]@1 | 1760 unsigned int uSlota; // [sp+14h] [bp+4h]@1 |
1761 | 1761 |
1762 pIndices = &this->pInventoryIndices[uSlot]; | 1762 pIndices = &this->pInventoryIndices[uSlot]; |
1763 | 1763 |
1764 __debugbreak(); // the following indexing is invalid | 1764 v3 = &this->pInventoryItems[*pIndices-1]; |
1765 v3 = (ItemGen *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *pIndices + 5]; | |
1766 v4 = v3->uItemID; | 1765 v4 = v3->uItemID; |
1767 v3->Reset(); | 1766 v3->Reset(); |
1768 v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE); | 1767 v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE); |
1769 v6 = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0); | 1768 v6 = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0); |
1770 uSlota = GetSizeInInventorySlots(v5 != -1 ? pIcons_LOD->pTextures[v5].uTextureWidth : 24); | 1769 uSlota = GetSizeInInventorySlots(v5 != -1 ? pIcons_LOD->pTextures[v5].uTextureWidth : 24); |
2389 pIcons_LOD->_40F9C5(); | 2388 pIcons_LOD->_40F9C5(); |
2390 } | 2389 } |
2391 goto LABEL_15; | 2390 goto LABEL_15; |
2392 } | 2391 } |
2393 } | 2392 } |
2394 memcpy(&v9->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v10 + 5], pItem, 0x24u); | 2393 memcpy(&v9->pInventoryItems[v10-1], pItem, 0x24u); |
2395 pItem->Reset(); | 2394 pItem->Reset(); |
2396 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); | 2395 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); |
2397 v19->PlaySound(SPEECH_60, 0); | 2396 v19->PlaySound(SPEECH_60, 0); |
2398 if ( !v21 ) | 2397 if ( !v21 ) |
2399 { | 2398 { |
2784 v34 = v4; | 2783 v34 = v4; |
2785 goto LABEL_62; | 2784 goto LABEL_62; |
2786 } | 2785 } |
2787 if ( HasItemEquipped(EQUIP_TWO_HANDED) ) | 2786 if ( HasItemEquipped(EQUIP_TWO_HANDED) ) |
2788 { | 2787 { |
2789 v6 = (ItemGen *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pEquipment.uMainHand + 5]; | 2788 v6 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uMainHand-1]; |
2790 v7 = v6->uItemID; | 2789 v7 = v6->uItemID; |
2791 v8 = v6->uItemID; | 2790 v8 = v6->uItemID; |
2792 v9 = pItemsTable->pItems[v8].uDamageDice; | 2791 v9 = pItemsTable->pItems[v8].uDamageDice; |
2793 if ( pItemsTable->pItems[v8].uSkillType == PLAYER_SKILL_SPEAR && !v5->pEquipment.uOffHand ) | 2792 if ( pItemsTable->pItems[v8].uSkillType == PLAYER_SKILL_SPEAR && !v5->pEquipment.uOffHand ) |
2794 ++v9; | 2793 ++v9; |
2856 v29 = 0; | 2855 v29 = 0; |
2857 if ( !a3 ) | 2856 if ( !a3 ) |
2858 { | 2857 { |
2859 if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) ) | 2858 if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) ) |
2860 { | 2859 { |
2861 v15 = (ItemGen *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v5->pEquipment.uOffHand + 5]; | 2860 v15 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uOffHand-1]; |
2862 v16 = v15->uItemID; | 2861 v16 = v15->uItemID; |
2863 v17 = v15->uItemID; | 2862 v17 = v15->uItemID; |
2864 if ( pItemsTable->pItems[v17].uEquipType != 4 ) | 2863 if ( pItemsTable->pItems[v17].uEquipType != 4 ) |
2865 { | 2864 { |
2866 v31 = pItemsTable->pItems[v17].uDamageRoll; | 2865 v31 = pItemsTable->pItems[v17].uDamageRoll; |
2949 int v5; // edi@4 | 2948 int v5; // edi@4 |
2950 int v6; // edi@4 | 2949 int v6; // edi@4 |
2951 int v7; // edi@4 | 2950 int v7; // edi@4 |
2952 | 2951 |
2953 v1 = this; | 2952 v1 = this; |
2954 v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5]; | 2953 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; |
2955 if ( v2 < 64 || v2 > 65 ) | 2954 if ( v2 < 64 || v2 > 65 ) |
2956 { | 2955 { |
2957 v4 = GetActualAccuracy(); | 2956 v4 = GetActualAccuracy(); |
2958 v5 = _48EA1B_get_static_effect(v4); | 2957 v5 = _48EA1B_get_static_effect(v4); |
2959 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5; | 2958 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5; |
3039 v2 = this; | 3038 v2 = this; |
3040 v14 = this; | 3039 v14 = this; |
3041 result = HasItemEquipped(EQUIP_BOW); | 3040 result = HasItemEquipped(EQUIP_BOW); |
3042 if ( !result ) | 3041 if ( !result ) |
3043 return result; | 3042 return result; |
3044 v4 = (ItemGen *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2->pEquipment.uBow + 5]; | 3043 v4 = (ItemGen *)&v2->pInventoryItems[v2->pEquipment.uBow-1]; |
3045 v5 = v4->uItemID; | 3044 v5 = v4->uItemID; |
3046 v6 = v4->uItemID; | 3045 v6 = v4->uItemID; |
3047 v15 = pItemsTable->pItems[v6].uDamageRoll; | 3046 v15 = pItemsTable->pItems[v6].uDamageRoll; |
3048 if ( (signed int)pItemsTable->pItems[v6].uDamageDice > 0 ) | 3047 if ( (signed int)pItemsTable->pItems[v6].uDamageDice > 0 ) |
3049 { | 3048 { |
3110 signed int v9; // esi@9 | 3109 signed int v9; // esi@9 |
3111 | 3110 |
3112 static char player__getmeleedamagestring_static_buff[40]; // idb | 3111 static char player__getmeleedamagestring_static_buff[40]; // idb |
3113 | 3112 |
3114 v1 = this; | 3113 v1 = this; |
3115 v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5]; | 3114 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; |
3116 if ( v2 < 64 || v2 > 65 ) | 3115 if ( v2 < 64 || v2 > 65 ) |
3117 { | 3116 { |
3118 v3 = GetMeleeDamageMinimal(); | 3117 v3 = GetMeleeDamageMinimal(); |
3119 v4 = GetMeleeDamageMaximal(); | 3118 v4 = GetMeleeDamageMaximal(); |
3120 } | 3119 } |
3136 sprintf(player__getmeleedamagestring_static_buff, "%d - %d", v7, v4); | 3135 sprintf(player__getmeleedamagestring_static_buff, "%d - %d", v7, v4); |
3137 } | 3136 } |
3138 v8 = v1->pEquipment.uMainHand; | 3137 v8 = v1->pEquipment.uMainHand; |
3139 if ( v8 ) | 3138 if ( v8 ) |
3140 { | 3139 { |
3141 v9 = *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5]; | 3140 v9 = *(int *)&v1->pInventoryItems[v8-1]; |
3142 if ( v9 >= 135 ) | 3141 if ( v9 >= 135 ) |
3143 { | 3142 { |
3144 if ( v9 <= 159 ) | 3143 if ( v9 <= 159 ) |
3145 strcpy(v6, pGlobalTXT_LocalizationStrings[595]); | 3144 strcpy(v6, pGlobalTXT_LocalizationStrings[595]); |
3146 } | 3145 } |
3162 signed int v9; // esi@11 | 3161 signed int v9; // esi@11 |
3163 | 3162 |
3164 static char player__getrangeddamagestring_static_buff[40]; // idb | 3163 static char player__getrangeddamagestring_static_buff[40]; // idb |
3165 | 3164 |
3166 v1 = this; | 3165 v1 = this; |
3167 v2 = *(int *)&this->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * this->pEquipment.uMainHand + 5]; | 3166 v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; |
3168 if ( v2 < 64 || v2 > 65 ) | 3167 if ( v2 < 64 || v2 > 65 ) |
3169 { | 3168 { |
3170 v3 = GetRangedDamageMin(); | 3169 v3 = GetRangedDamageMin(); |
3171 v4 = GetRangedDamageMax(); | 3170 v4 = GetRangedDamageMax(); |
3172 } | 3171 } |
3196 strcpy(player__getrangeddamagestring_static_buff, "N/A"); | 3195 strcpy(player__getrangeddamagestring_static_buff, "N/A"); |
3197 } | 3196 } |
3198 v8 = v1->pEquipment.uMainHand; | 3197 v8 = v1->pEquipment.uMainHand; |
3199 if ( v8 ) | 3198 if ( v8 ) |
3200 { | 3199 { |
3201 v9 = *(int *)&v1->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v8 + 5]; | 3200 v9 = *(int *)&v1->pInventoryItems[v8-1]; |
3202 if ( v9 >= 135 ) | 3201 if ( v9 >= 135 ) |
3203 { | 3202 { |
3204 if ( v9 <= 159 ) | 3203 if ( v9 <= 159 ) |
3205 strcpy(v5, pGlobalTXT_LocalizationStrings[595]); | 3204 strcpy(v5, pGlobalTXT_LocalizationStrings[595]); |
3206 } | 3205 } |
3860 v20 = this->pInventoryIndices; | 3859 v20 = this->pInventoryIndices; |
3861 do | 3860 do |
3862 { | 3861 { |
3863 if ( *v20 > 0 ) | 3862 if ( *v20 > 0 ) |
3864 { | 3863 { |
3865 v21 = *(int *)&v5->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *v20 + 5]; | 3864 v21 = *(int *)&v5->pInventoryItems[*v20-1]; |
3866 if ( v21 > 0 ) | 3865 if ( v21 > 0 ) |
3867 { | 3866 { |
3868 if ( v21 <= 134 ) | 3867 if ( v21 <= 134 ) |
3869 v46[v4++] = v19; | 3868 v46[v4++] = v19; |
3870 } | 3869 } |
4140 v46 = 0; | 4139 v46 = 0; |
4141 if ( a2 ) | 4140 if ( a2 ) |
4142 { | 4141 { |
4143 if ( !HasItemEquipped(EQUIP_BOW) ) | 4142 if ( !HasItemEquipped(EQUIP_BOW) ) |
4144 goto LABEL_17; | 4143 goto LABEL_17; |
4145 v5 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uBow + 5]; | 4144 v5 = (int)&v4->pInventoryItems[v4->pEquipment.uBow-1]; |
4146 v46 = v5; | 4145 v46 = v5; |
4147 v3 = (char *)&pItemsTable->pItems[*(int *)v5].pIconName; | 4146 v3 = (char *)&pItemsTable->pItems[*(int *)v5].pIconName; |
4148 v6 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]]; | 4147 v6 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]]; |
4149 goto LABEL_4; | 4148 goto LABEL_4; |
4150 } | 4149 } |
4159 goto LABEL_17; | 4158 goto LABEL_17; |
4160 } | 4159 } |
4161 } | 4160 } |
4162 if ( HasItemEquipped(EQUIP_TWO_HANDED) ) | 4161 if ( HasItemEquipped(EQUIP_TWO_HANDED) ) |
4163 { | 4162 { |
4164 v8 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uMainHand + 5]; | 4163 v8 = (int)&v4->pInventoryItems[v4->pEquipment.uMainHand-1]; |
4165 v46 = v8; | 4164 v46 = v8; |
4166 v9 = *(int *)v8; | 4165 v9 = *(int *)v8; |
4167 v3 = (char *)&pItemsTable->pItems[v9].pIconName; | 4166 v3 = (char *)&pItemsTable->pItems[v9].pIconName; |
4168 if ( v3[28] == 12 ) | 4167 if ( v3[28] == 12 ) |
4169 v10 = *(&pSpellDatas[0].field_A + 10 * *((int *)&pSpellDatas[66].field_8 + v9)); | 4168 v10 = *(&pSpellDatas[0].field_A + 10 * *((int *)&pSpellDatas[66].field_8 + v9)); |
4171 v10 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]]; | 4170 v10 = (unsigned __int16)word_4EDED8[(unsigned __int8)v3[29]]; |
4172 v47 = v10; | 4171 v47 = v10; |
4173 } | 4172 } |
4174 if ( HasItemEquipped((ITEM_EQUIP_TYPE)0) ) | 4173 if ( HasItemEquipped((ITEM_EQUIP_TYPE)0) ) |
4175 { | 4174 { |
4176 v12 = (int)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uOffHand + 5]; | 4175 v12 = (int)&v4->pInventoryItems[v4->pEquipment.uOffHand-1]; |
4177 v42 = (unsigned __int16)word_4EDED8[pItemsTable->pItems[*(int *)v12].uSkillType]; | 4176 v42 = (unsigned __int16)word_4EDED8[pItemsTable->pItems[*(int *)v12].uSkillType]; |
4178 if ( (signed int)v42 > v47 ) | 4177 if ( (signed int)v42 > v47 ) |
4179 { | 4178 { |
4180 v13 = *(int *)v12; | 4179 v13 = *(int *)v12; |
4181 v46 = v12; | 4180 v46 = v12; |
4185 v2 = 0; | 4184 v2 = 0; |
4186 } | 4185 } |
4187 LABEL_17: | 4186 LABEL_17: |
4188 if ( HasItemEquipped(EQUIP_ARMOUR) ) | 4187 if ( HasItemEquipped(EQUIP_ARMOUR) ) |
4189 { | 4188 { |
4190 v14 = pItemsTable->pItems[*(int *)&v4->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v4->pEquipment.uBody + 5]].uSkillType; | 4189 v14 = pItemsTable->pItems[*(int *)&v4->pInventoryItems[v4->pEquipment.uBody-1]].uSkillType; |
4191 SkillToMastery(v4->pActiveSkills[9]); | 4190 SkillToMastery(v4->pActiveSkills[9]); |
4192 v15 = (unsigned __int16)word_4EDED8[v14]; | 4191 v15 = (unsigned __int16)word_4EDED8[v14]; |
4193 v35 = 1.0; | 4192 v35 = 1.0; |
4194 v43 = v15; | 4193 v43 = v15; |
4195 if ( v14 == 9 ) | 4194 if ( v14 == 9 ) |
4868 if ( (signed int)attr < 29 ) | 4867 if ( (signed int)attr < 29 ) |
4869 return v5 + v62 + v61; | 4868 return v5 + v62 + v61; |
4870 if ( (signed int)attr <= 30 ) | 4869 if ( (signed int)attr <= 30 ) |
4871 { | 4870 { |
4872 if ( HasItemEquipped(EQUIP_BOW) ) | 4871 if ( HasItemEquipped(EQUIP_BOW) ) |
4873 v5 = pItemsTable->pItems[*(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5]].uDamageMod; | 4872 v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]].uDamageMod; |
4874 return v5 + v62 + v61; | 4873 return v5 + v62 + v61; |
4875 } | 4874 } |
4876 if ( attr == 31 ) | 4875 if ( attr == 31 ) |
4877 { | 4876 { |
4878 if ( !HasItemEquipped(EQUIP_BOW) ) | 4877 if ( !HasItemEquipped(EQUIP_BOW) ) |
4879 return v5 + v62 + v61; | 4878 return v5 + v62 + v61; |
4880 v57 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5]; | 4879 v57 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]; |
4881 v5 = pItemsTable->pItems[v57].uDamageMod; | 4880 v5 = pItemsTable->pItems[v57].uDamageMod; |
4882 v56 = pItemsTable->pItems[v57].uDamageDice; | 4881 v56 = pItemsTable->pItems[v57].uDamageDice; |
4883 goto LABEL_366; | 4882 goto LABEL_366; |
4884 } | 4883 } |
4885 if ( attr == 32 ) | 4884 if ( attr == 32 ) |
4886 { | 4885 { |
4887 if ( !HasItemEquipped(EQUIP_BOW) ) | 4886 if ( !HasItemEquipped(EQUIP_BOW) ) |
4888 return v5 + v62 + v61; | 4887 return v5 + v62 + v61; |
4889 v20 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uBow + 5]; | 4888 v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uBow-1]; |
4890 v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll; | 4889 v5 = pItemsTable->pItems[v20].uDamageDice * pItemsTable->pItems[v20].uDamageRoll; |
4891 LABEL_365: | 4890 LABEL_365: |
4892 v56 = pItemsTable->pItems[v20].uDamageMod; | 4891 v56 = pItemsTable->pItems[v20].uDamageMod; |
4893 LABEL_366: | 4892 LABEL_366: |
4894 v5 += v56; | 4893 v5 += v56; |
5517 { | 5516 { |
5518 v17 = this->GetEquippedItemEquipType(1u); | 5517 v17 = this->GetEquippedItemEquipType(1u); |
5519 if ( v17 >= 0 ) | 5518 if ( v17 >= 0 ) |
5520 { | 5519 { |
5521 if ( v17 <= 2 ) | 5520 if ( v17 <= 2 ) |
5522 v5 = pItemsTable->pItems[*(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uMainHand + 5]].uDamageMod; | 5521 v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uMainHand-1]].uDamageMod; |
5523 } | 5522 } |
5524 } | 5523 } |
5525 if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v19 = v18->GetEquippedItemEquipType(0), v19 < 0) || v19 > 2 ) | 5524 if ( a3 || !v6->HasItemEquipped((ITEM_EQUIP_TYPE)0) || (v19 = v18->GetEquippedItemEquipType(0), v19 < 0) || v19 > 2 ) |
5526 return v5 + v62 + v61; | 5525 return v5 + v62 + v61; |
5527 v20 = *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v6->pEquipment.uOffHand + 5]; | 5526 v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uOffHand-1]; |
5528 goto LABEL_365; | 5527 goto LABEL_365; |
5529 } | 5528 } |
5530 if ( attr == 27 ) | 5529 if ( attr == 27 ) |
5531 { | 5530 { |
5532 if ( IsUnarmed() == 1 ) | 5531 if ( IsUnarmed() == 1 ) |