# HG changeset patch # User Grumpy7 # Date 1379912826 -7200 # Node ID f8414042db1f1211023211760e68d754ee415820 # Parent 5cbd88f8a2ebe5f8d5c18b9d5934f3778305da46 Moving NZIArray to a separate class, fixing a few inventory bugs diff -r 5cbd88f8a2eb -r f8414042db1f Items.h --- a/Items.h Sun Sep 22 19:48:02 2013 +0200 +++ b/Items.h Mon Sep 23 07:07:06 2013 +0200 @@ -1,6 +1,7 @@ #pragma once #include #include +#include "NZIArray.h" enum DAMAGE_TYPE:unsigned int { @@ -380,7 +381,7 @@ void Release(); int uAllItemsCount; - ItemDesc pItems[800]; //4-9604h + NZIArray pItems; //4-9604h ItemEnchantment pEnchantments[24]; //9604h ItemSpecialEnchantment pSpecialEnchantments[72]; //97E4h -9FC4h char field_9FC4[5000]; diff -r 5cbd88f8a2eb -r f8414042db1f NZIArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NZIArray.h Mon Sep 23 07:07:06 2013 +0200 @@ -0,0 +1,43 @@ +#pragma once +#include +#include + + +template +class NZIArray : std::array<_Ty, _Size> +{ +public: + reference ZerothIndex() + { + return std::array<_Ty, _Size>::operator [](0); + } + + reference operator[](size_type _Pos) + { // subscript nonmutable sequence +#if _ITERATOR_DEBUG_LEVEL == 2 + assert(_Pos != 0 && "not allowed to access zeroth element"); + +#elif _ITERATOR_DEBUG_LEVEL == 1 + _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); +#endif /* _ITERATOR_DEBUG_LEVEL */ + + __analysis_assume(_Pos != 0); + + return std::array<_Ty, _Size>::operator [](_Pos); + } + + const_reference operator[](size_type _Pos) const + { // subscript nonmutable sequence +#if _ITERATOR_DEBUG_LEVEL == 2 + assert(_Pos != 0 && "not allowed to access zeroth element"); + +#elif _ITERATOR_DEBUG_LEVEL == 1 + _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); +#endif /* _ITERATOR_DEBUG_LEVEL */ + + __analysis_assume(_Pos != 0); + + return std::array<_Ty, _Size>::operator [](_Pos); + } +}; diff -r 5cbd88f8a2eb -r f8414042db1f Player.cpp --- a/Player.cpp Sun Sep 22 19:48:02 2013 +0200 +++ b/Player.cpp Mon Sep 23 07:07:06 2013 +0200 @@ -3139,7 +3139,7 @@ v22 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); if ( v22 >= 0 && v22 <= 2) { - v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID; + v23 = this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID; v26 = pItemsTable->pItems[v23].uDamageRoll; if ( this->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) { @@ -3152,13 +3152,13 @@ v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26; } } - if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0 && GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2)) + if ( getOnlyMainHandDmg || !this->HasItemEquipped(EQUIP_OFF_HAND) || (GetEquippedItemEquipType(EQUIP_OFF_HAND) < 0 || GetEquippedItemEquipType(EQUIP_OFF_HAND) > 2)) { return v5; } else { - v23 = this->pOwnItems[this->pEquipment.uShield].uItemID; + v23 = this->pOwnItems[this->pEquipment.uShield - 1].uItemID; v15 = pItemsTable->pItems[v23].uDamageMod; v14 = pItemsTable->pItems[v23].uDamageDice * pItemsTable->pItems[v23].uDamageRoll; return v5 + v15 + v14; @@ -3200,9 +3200,9 @@ v9 = this->GetEquippedItemEquipType(EQUIP_MAIN_HAND); if ( v9 >= 0 && v9 <= 2) { - v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageDice + - pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uDamageMod; - if ( !this->pEquipment.uShield && pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand].uItemID].uSkillType == 4) + v5 = pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID].uDamageDice + + pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID].uDamageMod; + if ( !this->pEquipment.uShield && pItemsTable->pItems[this->pOwnItems[this->pEquipment.uMainHand - 1].uItemID].uSkillType == 4) { ++v5; } @@ -3773,7 +3773,7 @@ { if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) { - int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i]].uItemID; + int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID; if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND ) { PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType; diff -r 5cbd88f8a2eb -r f8414042db1f mm7_data.h --- a/mm7_data.h Sun Sep 22 19:48:02 2013 +0200 +++ b/mm7_data.h Mon Sep 23 07:07:06 2013 +0200 @@ -4,6 +4,7 @@ #include "OSAPI.h" #include #include +#include "NZIArray.h" typedef char _UNKNOWN; typedef unsigned int uint; @@ -283,44 +284,6 @@ return uint64(x) > uint64(x+y); } -template -class NZIArray : std::array<_Ty, _Size> -{ -public: - reference ZerothIndex() - { - return std::array<_Ty, _Size>::operator [](0); - } - - reference operator[](size_type _Pos) - { // subscript nonmutable sequence -#if _ITERATOR_DEBUG_LEVEL == 2 - assert(_Pos != 0 && "not allowed to access zeroth element"); - -#elif _ITERATOR_DEBUG_LEVEL == 1 - _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); -#endif /* _ITERATOR_DEBUG_LEVEL */ - - __analysis_assume(_Pos != 0); - - return std::array<_Ty, _Size>::operator [](_Pos); - } - - const_reference operator[](size_type _Pos) const - { // subscript nonmutable sequence -#if _ITERATOR_DEBUG_LEVEL == 2 - assert(_Pos != 0 && "not allowed to access zeroth element"); - -#elif _ITERATOR_DEBUG_LEVEL == 1 - _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); -#endif /* _ITERATOR_DEBUG_LEVEL */ - - __analysis_assume(_Pos != 0); - - return std::array<_Ty, _Size>::operator [](_Pos); - } -}; //------------------------------------------------------------------------- // Data declarations