# HG changeset patch # User Grumpy7 # Date 1373925605 -7200 # Node ID 270134611caf3746c4dcb6fc2b87e35ce54e17b9 # Parent 2e5c994f0833eae55af4da30a1af7f3c75fc5319# Parent 87155494292cfbb5fd878bfa14b3e4d820013b56 Merge diff -r 87155494292c -r 270134611caf Player.cpp --- a/Player.cpp Mon Jul 15 17:09:48 2013 +0600 +++ b/Player.cpp Tue Jul 16 00:00:05 2013 +0200 @@ -84,6 +84,30 @@ }; +unsigned char pEquipTypeToBodyAnchor[21] = // 4E8398 +{ + 1, // EQUIP_OFF_HAND + 1, // EQUIP_MAIN_HAND + 2, // EQUIP_BOW + 3, // EQUIP_ARMOUR + 0, // EQUIP_SHIELD + 4, // EQUIP_HELMET + 5, // EQUIP_BELT + 6, // EQUIP_CLOAK + 7, // EQUIP_GAUNTLETS + 8, // EQUIP_BOOTS + 10, // EQUIP_RING + 9, // EQUIP_AMULET + 1, // EQUIP_WAND + 0, // EQUIP_REAGENT + 0, // EQUIP_POTION + 0, // EQUIP_SPELL_SCROLL + 0, // EQUIP_BOOK + 0, // EQUIP_MESSAGE_SCROLL + 0, // EQUIP_GOLD + 0, // EQUIP_GEM + 0 // EQUIP_NONE +}; unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; @@ -119,9 +143,6 @@ signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6}; -unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0}; - - unsigned short base_recovery_times_per_weapon_type[12] = { 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill @@ -904,17 +925,16 @@ { signed int result; // eax@3 - if ( (signed int)uSkillType >= 37 || this->pActiveSkills[uSkillType] ) - { - result = 1; + if ( uSkillType >= 37 || this->pActiveSkills[uSkillType] ) + { + return 1; } else { sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName); ShowStatusBarString(pTmpBuf.data(), 2u); - result = 0; - } - return result; + return 0; + } } //----- (00492745) -------------------------------------------------------- @@ -922,21 +942,14 @@ { int item_body_anch; // edi@6 int item_indx; - //find empty slot - for(item_indx=0;item_indx<126;++item_indx) - if (pInventoryItems[item_indx].uItemID==0) - break; - if (item_indx==126) //not found - item_indx=-1; + item_indx = FindFreeInventorySlot(); if ( item_indx != -1 ) { - - pInventoryItems[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; - + pInventoryItems[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; } return 0; } @@ -944,37 +957,20 @@ //----- (004927A8) -------------------------------------------------------- int Player::AddItem(int uSlot, unsigned int uItemID) { - signed int v3; // ebx@2 - signed int v4; // edi@3 - unsigned int v5; // esi@3 - unsigned int v7; // [sp-8h] [bp-18h]@8 - unsigned int v8; // [sp-4h] [bp-14h]@8 - Player *thisa; // [sp+Ch] [bp-4h]@1 - - thisa = this; + int xStartValue = 0; + if ( uSlot == -1 ) { - v3 = 0; - while ( true ) - { - v4 = 0; - v5 = v3; - do - { - if ( CanFitItem(v5, uItemID) ) + for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) + { + for (int xcoord = xStartValue; xcoord < INVETORYSLOTSWIDTH; xcoord++) + { + if ( CanFitItem(xcoord, uItemID) ) { - v8 = uItemID; - v7 = v5; - return CreateItemInInventory(v7, v8); + return CreateItemInInventory(xcoord, uItemID); } - ++v4; - v5 += 14; - } - while ( v4 < 9 ); - ++v3; - if ( v3 < 14 ) - continue; - break; + } + xStartValue += INVETORYSLOTSWIDTH; } return 0; } @@ -983,9 +979,7 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return 0; } - v8 = uItemID; - v7 = uSlot; - return CreateItemInInventory(v7, v8); + return CreateItemInInventory(uSlot, uItemID); } //----- (00492826) -------------------------------------------------------- @@ -8873,42 +8867,9 @@ int v10; // [sp+34h] [bp-8h]@1 int *v11; // [sp+38h] [bp-4h]@1 - static unsigned char byte_4E8398[200] = // 4E8398 - { - 1, // EQUIP_OFF_HAND - 1, // EQUIP_MAIN_HAND - 2, // EQUIP_BOW - 3, // EQUIP_ARMOUR - 0, // EQUIP_SHIELD - 4, // EQUIP_HELMET - 5, // EQUIP_BELT - 6, // EQUIP_CLOAK - 7, // EQUIP_GAUNTLETS - 8, // EQUIP_BOOTS - 10, // EQUIP_RING - 9, // EQUIP_AMULET - 1, // EQUIP_WAND - 0, // EQUIP_REAGENT - 0, // EQUIP_POTION - 0, // EQUIP_SPELL_SCROLL - 0, // EQUIP_BOOK - 0, // EQUIP_MESSAGE_SCROLL - 0, // EQUIP_GOLD - 0, // EQUIP_GEM - 0, // EQUIP_NONE - // ??? - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, - 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0 - }; _this.Reset(); - v2 = byte_4E8398[uEquipType]; + v2 = pEquipTypeToBodyAnchor[uEquipType]; v3 = pPlayers[uActiveCharacter]; v11 = (int *)&v3->pEquipment.pIndices[v2]; v4 = *v11;