Mercurial > mm7
changeset 201:30aa44013f7a
On Items
author | Nomad |
---|---|
date | Sun, 17 Feb 2013 00:16:48 +0200 |
parents | 1527f66fd81b |
children | 037726ac5999 0c64754c7fd4 |
files | GUIWindow.h Items.cpp Items.h Party.cpp Player.cpp Player.h mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_5.cpp |
diffstat | 10 files changed, 208 insertions(+), 274 deletions(-) [+] |
line wrap: on
line diff
--- a/GUIWindow.h Sat Feb 16 22:35:58 2013 +0200 +++ b/GUIWindow.h Sun Feb 17 00:16:48 2013 +0200 @@ -298,7 +298,7 @@ UIMSG_ToggleFlipOnExit = 0xE2, UIMSG_16F = 0x16F, UIMSG_170 = 0x170, - UIMSG_194 = 0x194, + UIMSG_Game_Action = 0x194, UIMSG_195 = 0x195, UIMSG_OpenRestUI = 0x199, UIMSG_19A = 0x19A,
--- a/Items.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/Items.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -1029,18 +1029,10 @@ { switch ( v101 ) { - case 2: - pItems[v35].field_2C = atoi(v36); - break; - case 3: - pItems[v35].field_2D = atoi(v36); - break; - case 4: - pItems[v35].field_2E = atoi(v36); - break; - case 5: - pItems[v35].field_2F = atoi(v36); - break; + case 2: pItems[v35].field_2C[0] = atoi(v36); break; + case 3: pItems[v35].field_2C[1] = atoi(v36); break; + case 4: pItems[v35].field_2C[2] = atoi(v36); break; + case 5: pItems[v35].field_2C[3] = atoi(v36); break; case 6: *((unsigned char *)&pItems[0].uItemID + 16 * (3 * v35 + 3)) = atoi(v36); break; @@ -1073,7 +1065,7 @@ } v39 = (char *)field_11684; memset(field_11684, 0, 0x18u); - v40 = &pItems[0].field_2C; + v40 = pItems[0].field_2C; v77 = 6; do { @@ -1787,14 +1779,14 @@ //----- (00456620) -------------------------------------------------------- -void ItemsTable::GenerateItem(int a2, int a3, ItemGen *pItem) +void ItemsTable::GenerateItem(int a2, int a3, ItemGen *out_item) { - ItemGen *v4; // esi@1 - ItemsTable *v5; // edi@1 + //ItemGen *v4; // esi@1 + //ItemsTable *v5; // edi@1 int v6; // ebx@3 int *v7; // ecx@33 - int v8; // eax@34 - int v9; // eax@39 + //int v8; // eax@34 + //int v9; // eax@39 int v10; // ebx@43 int v11; // ecx@47 unsigned int *v12; // edx@48 @@ -1836,163 +1828,101 @@ unsigned int v48; // ecx@123 int v49; // eax@123 int v50; // eax@123 - unsigned char Dst[0xC80]; // [sp+Ch] [bp-C88h]@33 + int Dst[800]; // [sp+Ch] [bp-C88h]@33 int v52; // [sp+C8Ch] [bp-8h]@33 - int v53; // [sp+C90h] [bp-4h]@1 + //int v53; // [sp+C90h] [bp-4h]@1 int v54; // [sp+C9Ch] [bp+8h]@3 - int v55; // [sp+CA0h] [bp+Ch]@34 + //int v55; // [sp+CA0h] [bp+Ch]@34 signed int v56; // [sp+CA0h] [bp+Ch]@55 int v57; // [sp+CA0h] [bp+Ch]@62 int *v58; // [sp+CA0h] [bp+Ch]@102 int v59; // [sp+CA0h] [bp+Ch]@123 - signed int a2a; // [sp+CA4h] [bp+10h]@33 + //signed int a2a; // [sp+CA4h] [bp+10h]@33 int a2b; // [sp+CA4h] [bp+10h]@101 int a2c; // [sp+CA4h] [bp+10h]@120 - v53 = -1; - v4 = pItem; - v5 = this; - if ( !pItem ) - v4 = (ItemGen *)pAllocator->AllocNamedChunk(pItem, 0x24u, "newItemGen"); - memset(v4, 0, 0x24u); + //v53 = -1; + //v4 = pItem; + //v5 = this; + if ( !out_item ) + out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen"); + memset(out_item, 0, sizeof(*out_item)); v6 = a2 - 1; v54 = a2 - 1; if ( a3 ) { - switch ( a3 ) + ITEM_EQUIP_TYPE requested_equip; + PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; + switch (a3) { - case 20: - a3 = EQUIP_ONE_OR_TWO_HANDS; - break; - case 21: - a3 = 3; - break; - case 22: - v53 = 38; - break; - case 23: - v53 = 1; - break; - case 24: - v53 = 2; - break; - case 25: - v53 = 3; - break; - case 26: - v53 = 4; - break; - case 27: - v53 = 5; - break; - case 28: - v53 = 6; - break; - case 30: - v53 = 0; - break; - case 31: - v53 = 9; - break; - case 32: - v53 = 10; - break; - case 33: - v53 = 0xBu; - break; - case 34: - a3 = 4; - break; - case 35: - a3 = 5; - break; - case 36: - a3 = 6; - break; - case 37: - a3 = 7; - break; - case 38: - a3 = 8; - break; - case 39: - a3 = EQUIP_BOOTS; - break; - case 40: - a3 = EQUIP_RING; - break; - case 41: - a3 = 0xBu; - break; - case 42: - a3 = EQUIP_C; - break; - case 43: - a3 = EQUIP_F; - break; - case 44: - a3 = EQUIP_POTION; - break; - case 45: - a3 = EQUIP_REAGENT; - break; - case 46: - a3 = EQUIP_GEM; - break; - case 29: - v53 = 37; - break; + case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break; + case 21: requested_equip = EQUIP_ARMOUR; break; + case 22: requested_skill = (PLAYER_SKILL_TYPE)38; __debugbreak();/*check this skill*/ break; + case 23: requested_skill = PLAYER_SKILL_SWORD; break; + case 24: requested_skill = PLAYER_SKILL_DAGGER; break; + case 25: requested_skill = PLAYER_SKILL_AXE; break; + case 26: requested_skill = PLAYER_SKILL_SPEAR; break; + case 27: requested_skill = PLAYER_SKILL_BOW; break; + case 28: requested_skill = PLAYER_SKILL_MACE; break; + case 29: requested_skill = (PLAYER_SKILL_TYPE)37; __debugbreak();/*check this skill*/break; + case 30: requested_skill = PLAYER_SKILL_STAFF; break; + case 31: requested_skill = PLAYER_SKILL_LEATHER; break; + case 32: requested_skill = PLAYER_SKILL_CHAIN; break; + case 33: requested_skill = PLAYER_SKILL_PLATE; break; + case 34: requested_equip = EQUIP_SHIELD; break; + case 35: requested_equip = EQUIP_HELMET; break; + case 36: requested_equip = EQUIP_BELT; break; + case 37: requested_equip = EQUIP_CLOAK; break; + case 38: requested_equip = EQUIP_GAUNTLETS; break; + case 39: requested_equip = EQUIP_BOOTS; break; + case 40: requested_equip = EQUIP_RING; break; + case 41: requested_equip = EQUIP_AMULET; break; + case 42: requested_equip = EQUIP_C; break; + case 43: requested_equip = EQUIP_F; break; + case 44: requested_equip = EQUIP_POTION; break; + case 45: requested_equip = EQUIP_REAGENT; break; + case 46: requested_equip = EQUIP_GEM; break; default: - --a3; + __debugbreak(); // check this condition + requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1); break; } - memset(&Dst, 0, 0xC80u); + + memset(Dst, 0, sizeof(Dst)); + v52 = 0; - v7 = (int *)&Dst; - a2a = 1; - if ( v53 == -1 ) + v7 = Dst; + + if (requested_skill == PLAYER_SKILL_INVALID) { - v53 = (int)&v5->pItems[1].uEquipType; - v9 = (int)(&v5->pItems[1].field_2C + v6); - do + for (uint i = 1; i < 500; ++i) { - if ( *(unsigned char *)v53 == a3 ) + if (pItems[i].uEquipType == requested_equip) { - *v7 = a2a; - ++v7; - v52 += *(unsigned char *)v9; + *v7++ = i; + v52 += pItems[i].field_2C[v6]; } - ++a2a; - v53 += 48; - v9 += 48; } - while ( a2a < 500 ); } else { - v55 = (int)&v5->pItems[1].uSkillType; - v8 = (int)(&v5->pItems[1].field_2C + v6); - do + for (uint i = 1; i < 500; ++i) { - if ( *(unsigned char *)v55 == v53 ) + if (pItems[i].uSkillType == requested_skill) { - *v7 = a2a; - ++v7; - v52 += *(unsigned char *)v8; + *v7++ = i; + v52 += pItems[i].field_2C[v6]; } - ++a2a; - v55 += 48; - v8 += 48; } - while ( a2a < 500 ); } + v10 = 0; if ( v52 ) v10 = rand() % v52; - v4->uItemID = *(uint *)Dst; - if ( !Dst ) - v4->uItemID = 1; - v11 = *(&v5->pItems[v4->uItemID].field_2C + v54); + out_item->uItemID = *Dst; + if ( !*Dst ) + out_item->uItemID = 1; + v11 = pItems[out_item->uItemID].field_2C[v54]; if ( v11 < v10 ) { v12 = (uint *)Dst; @@ -2000,24 +1930,24 @@ { ++v12; v13 = *v12; - v4->uItemID = *v12; - v11 += *(&v5->pItems[v13].field_2C + v54); + out_item->uItemID = *v12; + v11 += pItems[v13].field_2C[v54]; } while ( v11 < v10 ); } - if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) + if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE) { - v4->_bonus_type = 0; + out_item->_bonus_type = 0; v14 = 2; do { - v4->_bonus_type += rand() % 4 + 1; - v15 = v4->_bonus_type; + out_item->_bonus_type += rand() % 4 + 1; + v15 = out_item->_bonus_type; --v14; } while ( v14 ); LABEL_72: - v4->_bonus_type = v15 * (v54 + 1); + out_item->_bonus_type = v15 * (v54 + 1); goto LABEL_73; } } @@ -2032,32 +1962,32 @@ if ( v54 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) { pParty->field_7BA[v17] = 1; - v4->uAttributes = 0; - v4->uItemID = v17 + 500; - v5->SetSpecialBonus(v4); + out_item->uAttributes = 0; + out_item->uItemID = v17 + 500; + SetSpecialBonus(out_item); return; } v57 = 0; - v18 = rand() % v5->field_11684[v54]; - v4->uItemID = 0; + v18 = rand() % field_11684[v54]; + out_item->uItemID = 0; if ( v18 > 0 ) { do - v57 += *(&v5->pItems[v4->uItemID++ + 1].field_2C + v54); + v57 += pItems[out_item->uItemID++ + 1].field_2C[v54]; while ( v57 < v18 ); } if ( !v18 ) - v4->uItemID = 1; - if ( !v4->uItemID ) - v4->uItemID = 1; - if ( v5->pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) + out_item->uItemID = 1; + if ( !out_item->uItemID ) + out_item->uItemID = 1; + if ( pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) { - v4->_bonus_type = 0; + out_item->_bonus_type = 0; v19 = 2; do { - v4->_bonus_type += rand() % 4 + 1; - v15 = v4->_bonus_type; + out_item->_bonus_type += rand() % 4 + 1; + v15 = out_item->_bonus_type; --v19; } while ( v19 ); @@ -2065,22 +1995,22 @@ } } LABEL_73: - if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION + if (out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) - v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; - if ( BYTE2(pItemsTable->pItems[v4->uItemID + 1].uItemID) ) - v4->uAttributes = 0; + out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; + if ( BYTE2(pItems[out_item->uItemID + 1].uItemID) ) + out_item->uAttributes = 0; else - v4->uAttributes = 1; - if ( v5->pItems[v4->uItemID].uEquipType != EQUIP_POTION ) + out_item->uAttributes = 1; + if (pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) { - v4->uAdditionalValue = 0; - v4->_bonus_type = 0; + out_item->uAdditionalValue = 0; + out_item->_bonus_type = 0; } - v20 = v5->pItems[v4->uItemID].uEquipType; + v20 = pItems[out_item->uItemID].uEquipType; if ( v20 <= EQUIP_BOW ) { - v37 = (int)&v5->field_1169C[4 * v54 + 48]; + v37 = (int)&field_1169C[4 * v54 + 48]; if ( !*(unsigned int *)v37 ) return; v38 = rand() % 100; @@ -2093,13 +2023,13 @@ { if ( v20 == EQUIP_C ) { - v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; - v4->uNumCharges = v21; - v4->uMaxCharges = v21; + v21 = rand() % 6 + pItems[out_item->uItemID].uDamageMod + 1; + out_item->uNumCharges = v21; + out_item->uMaxCharges = v21; } return; } - v22 = (int)&v5->field_1169C[4 * v54]; + v22 = (int)&field_1169C[4 * v54]; if ( !*(unsigned int *)v22 ) return; v23 = rand(); @@ -2107,34 +2037,34 @@ v25 = v23 % 100; if ( v23 % 100 < v24 ) goto LABEL_127; - if ( !*(unsigned int *)&v5->field_1169C[4 * v54 + 24] ) + if ( !*(unsigned int *)&field_1169C[4 * v54 + 24] ) return; if ( v25 < v24 ) { LABEL_127: - v26 = rand() % v5->field_116D8[v5->pItems[v4->uItemID].uEquipType]; - v27 = v4->uItemID; - v4->_bonus_type = 0; - for ( i = v5->pEnchantments[0].field_8[v5->pItems[v27].uEquipType + 1]; + v26 = rand() % field_116D8[pItems[out_item->uItemID].uEquipType]; + v27 = out_item->uItemID; + out_item->_bonus_type = 0; + for ( i = pEnchantments[0].field_8[pItems[v27].uEquipType + 1]; i < v26; - i += v5->pEnchantments[v4->_bonus_type].field_8[v5->pItems[v29].uEquipType + 1] ) + i += pEnchantments[out_item->_bonus_type].field_8[pItems[v29].uEquipType + 1] ) { - v29 = v4->uItemID; - ++v4->_bonus_type; + v29 = out_item->uItemID; + ++out_item->_bonus_type; } - ++v4->_bonus_type; - v30 = v5->field_116D8[2 * v54 + 12]; + ++out_item->_bonus_type; + v30 = field_116D8[2 * v54 + 12]; v31 = rand(); - v32 = v4->_bonus_type - 1; - v33 = v31 % (v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; - v4->_bonus_strength = v33; + v32 = out_item->_bonus_type - 1; + v33 = v31 % (field_116D8[2 * v54 + 13] - v30 + 1) + v30; + out_item->_bonus_strength = v33; if ( v32 == 21 || v32 == 22 || v32 == 23 ) - v4->_bonus_strength = v33 >> 1; - if ( v4->_bonus_strength <= 0 ) - v4->_bonus_strength = 1; + out_item->_bonus_strength = v33 >> 1; + if ( out_item->_bonus_strength <= 0 ) + out_item->_bonus_strength = 1; return; } - v34 = v24 + *(unsigned int *)&v5->field_1169C[4 * v54 + 24]; + v34 = v24 + *(unsigned int *)&field_1169C[4 * v54 + 24]; v36 = __OFSUB__(v25, v34); v35 = v25 - v34 < 0; } @@ -2143,11 +2073,11 @@ memset(&Dst, 0, 0xC80u); v39 = 0; a2b = 0; - if ( v5->field_11798 > 0 ) + if ( field_11798 > 0 ) { - v52 = -16 - (uint)v5; + v52 = -16 - (uint)this; v58 = (int *)&Dst; - v40 = (int)&v5->pSpecialEnchantments[1]; + v40 = (int)&pSpecialEnchantments[1]; do { switch ( v54 ) @@ -2162,8 +2092,8 @@ if ( !*(unsigned char *)v40 || v43 == 1 ) { LABEL_117: - v39 += *((unsigned char *)&v5->pItems[0].uItemID + v40 + v52 + v5->pItems[v4->uItemID].uEquipType); - if ( *((unsigned char *)&v5->pItems[0].uItemID + v40 + v52 + v5->pItems[v4->uItemID].uEquipType) ) + v39 += *((unsigned char *)&pItems[0].uItemID + v40 + v52 + pItems[out_item->uItemID].uEquipType); + if ( *((unsigned char *)&pItems[0].uItemID + v40 + v52 + pItems[out_item->uItemID].uEquipType) ) { v44 = v58; ++v58; @@ -2191,27 +2121,27 @@ ++a2b; v40 += 28; } - while ( a2b < v5->field_11798 ); + while ( a2b < field_11798 ); } v45 = rand(); - v4->uAdditionalValue = *(uint *)Dst; + out_item->uAdditionalValue = *Dst; v46 = v45 % v39 + 1; - a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + v5->pItems[v4->uItemID].uEquipType); + a2c = *((unsigned char *)&pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + pItems[out_item->uItemID].uEquipType); if ( a2c < v46 ) { for ( j = (int *)&Dst; ; j = (int *)v59 ) { - v48 = v4->uItemID; + v48 = out_item->uItemID; v49 = (int)(j + 1); v59 = v49; v50 = *(unsigned int *)v49; - v4->uAdditionalValue = v50; - a2c += *((unsigned char *)&v5->pItems[0].uItemID + 28 * (v50 + 1389) + v5->pItems[v48].uEquipType); + out_item->uAdditionalValue = v50; + a2c += *((unsigned char *)&pItems[0].uItemID + 28 * (v50 + 1389) + pItems[v48].uEquipType); if ( a2c >= v46 ) break; } } - ++v4->uAdditionalValue; + ++out_item->uAdditionalValue; } //----- (004505CC) --------------------------------------------------------
--- a/Items.h Sat Feb 16 22:35:58 2013 +0200 +++ b/Items.h Sun Feb 17 00:16:48 2013 +0200 @@ -72,7 +72,7 @@ EQUIP_BOOTS = 0x9, EQUIP_RING = 0xA, EQUIP_AMULET = 0xB, - EQUIP_C = 0xC, + EQUIP_C = 0xC, // wand? EQUIP_REAGENT = 0xD, EQUIP_POTION = 0xE, EQUIP_F = 0xF, @@ -146,10 +146,7 @@ char field_29; char field_2A; char field_2B; - char field_2C; - char field_2D; - char field_2E; - char field_2F; + char field_2C[4]; }; #pragma pack(pop)
--- a/Party.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/Party.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -71,12 +71,9 @@ //----- (004936E1) -------------------------------------------------------- void Party::SetHoldingItem(ItemGen *pItem) { - Party *v2; // esi@1 - - v2 = this; sub_421B2C_PlaceInInventory_or_DropPickedItem(); - memcpy(&v2->pPickedItem, pItem, sizeof(v2->pPickedItem)); - pMouse->SetCursorBitmapFromItemID(v2->pPickedItem.uItemID); + memcpy(&pPickedItem, pItem, sizeof(pPickedItem)); + pMouse->SetCursorBitmapFromItemID(pPickedItem.uItemID); } //----- (0049370F) --------------------------------------------------------
--- a/Player.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/Player.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -1463,7 +1463,7 @@ if ( v12 == -1 ) { if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_15, 0); + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); result = 0; } else
--- a/Player.h Sat Feb 16 22:35:58 2013 +0200 +++ b/Player.h Sun Feb 17 00:16:48 2013 +0200 @@ -24,14 +24,14 @@ SPEECH_11 = 11, SPEECH_12 = 12, SPEECH_14 = 14, - SPEECH_15 = 15, + SPEECH_NoRoom = 15, // when placing to inventory SPEECH_16 = 16, SPEECH_17 = 17, SPEECH_18 = 18, SPEECH_19 = 19, SPEECH_20 = 20, SPEECH_21 = 21, - SPEECH_GoodDay = 22, + SPEECH_GoodDay = 22, // greets on dialogue start SPEECH_GoodEvening = 23, SPEECH_24 = 24, SPEECH_25 = 25, @@ -215,6 +215,8 @@ PLAYER_SKILL_STEALING = 34, PLAYER_SKILL_ALCHEMY = 35, PLAYER_SKILL_LEARNING = 36, + + PLAYER_SKILL_INVALID = -1 }; /* 329 */
--- a/mm7_1.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/mm7_1.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -3432,6 +3432,7 @@ a4 = (char *)v106.uViewportY; if ( v119 ) { + __debugbreak(); // following format strings are decompiled incorrectly sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; @@ -3442,6 +3443,7 @@ } else { + __debugbreak(); // following format strings are decompiled incorrectly sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630]; @@ -3466,6 +3468,7 @@ v105 = pGlobalTXT_LocalizationStrings[54]; if ( v116 ) { + __debugbreak(); // following format strings are decompiled incorrectly sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, (&v95)[4 * v121->pMonsterInfo.uAttack1Type]); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; @@ -3490,6 +3493,7 @@ } else { + __debugbreak(); // following format strings are decompiled incorrectly sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; @@ -3597,7 +3601,8 @@ i = 0; do { - sprintf(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]); + __debugbreak(); // string argument is decompiled incorrectry + sprintf(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]); // "?" a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0); v65 = LOBYTE(v56->uFontHeight); ++i; @@ -4090,7 +4095,7 @@ if ( v22 == v5 ) { if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_15, 0); + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); return 0; } v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE); @@ -5729,46 +5734,46 @@ //----- (00421D00) -------------------------------------------------------- void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID) { - unsigned int v1; // esi@1 - int v2; // eax@2 - Player *v3; // ecx@2 - Player *v4; // ecx@5 + //unsigned int v1; // esi@1 + //int v2; // eax@2 + //Player *v3; // ecx@2 + //Player *v4; // ecx@5 unsigned int v5; // [sp-4h] [bp-10h]@21 - v1 = uPlayerID; - if ( pParty->pPickedItem.uItemID ) - { - v2 = pPlayers[uPlayerID]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID); - v3 = pPlayers[v1]; - if ( v2 ) - { - memcpy(&v3->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v2 + 5], &pParty->pPickedItem, 0x24u); - viewparams->bRedrawGameUI = 1; + //v1 = uPlayerID; + auto player = &pParty->pPlayers[uPlayerID - 1]; + if (pParty->pPickedItem.uItemID) + { + //v3 = player; + if (auto slot = player->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) + { + __debugbreak(); // invalid inventory indexing + memcpy(&player->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * slot + 5], &pParty->pPickedItem, 0x24u); + viewparams->bRedrawGameUI = true; pMouse->RemoveHoldingItem(); return; } - if ( v3->CanAct() ) - { - v4 = pPlayers[v1]; - } - else - { - if ( !pPlayers[uActiveCharacter]->CanAct() ) + + if (!player->CanAct()) + { + if ( pPlayers[uActiveCharacter]->CanAct()) goto LABEL_9; - v4 = pPlayers[uActiveCharacter]; - } - v4->PlaySound(SPEECH_15, 0); - } + player = pPlayers[uActiveCharacter]; + } + player->PlaySound(SPEECH_NoRoom, 0); + } + LABEL_9: - if ( !pCurrentScreen ) - { - viewparams->bRedrawGameUI = 1; - if ( uActiveCharacter != v1 ) + if (pCurrentScreen == SCREEN_GAME) + { + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter != uPlayerID ) //goto LABEL_27; { - if ( pPlayers[v1]->uTimeToRecovery ) + if ( pPlayers[uPlayerID]->uTimeToRecovery ) return; - uActiveCharacter = v1; + + uActiveCharacter = uPlayerID; return; } v5 = 7; @@ -5781,20 +5786,20 @@ if ( pCurrentScreen == SCREEN_CHEST ) { //LABEL_23: - viewparams->bRedrawGameUI = 1; - if ( uActiveCharacter == v1 ) + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter == uPlayerID ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; pCurrentScreen = SCREEN_F; //goto LABEL_28; - uActiveCharacter = v1; + uActiveCharacter = uPlayerID; return; } //LABEL_27: - if ( pPlayers[v1]->uTimeToRecovery ) + if ( pPlayers[uPlayerID]->uTimeToRecovery ) return; //goto LABEL_28; - uActiveCharacter = v1; + uActiveCharacter = uPlayerID; return; } if ( pCurrentScreen != SCREEN_HOUSE ) @@ -5802,40 +5807,40 @@ if ( pCurrentScreen == SCREEN_E ) { //LABEL_28: - uActiveCharacter = v1; + uActiveCharacter = uPlayerID; return; } if ( pCurrentScreen != SCREEN_F ) { - viewparams->bRedrawGameUI = 1; - uActiveCharacter = v1; + viewparams->bRedrawGameUI = true; + uActiveCharacter = uPlayerID; if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 ) sub_419100(); return; } //goto LABEL_23; - viewparams->bRedrawGameUI = 1; - if ( uActiveCharacter == v1 ) + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter == uPlayerID ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; pCurrentScreen = SCREEN_F; //goto LABEL_28; - uActiveCharacter = v1; + uActiveCharacter = uPlayerID; return; } //LABEL_27: - if ( pPlayers[v1]->uTimeToRecovery ) + if ( pPlayers[uPlayerID]->uTimeToRecovery ) return; //goto LABEL_28; - uActiveCharacter = v1; + uActiveCharacter = uPlayerID; return; } if ( ptr_507BC0->field_40 == 1 ) return; - viewparams->bRedrawGameUI = 1; - if ( uActiveCharacter != v1 ) + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter != uPlayerID ) //goto LABEL_28; - uActiveCharacter = v1; + uActiveCharacter = uPlayerID; return; if ( dword_F8B19C == 2 || dword_F8B19C == 6 ) {
--- a/mm7_2.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/mm7_2.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -4599,7 +4599,7 @@ memcpy(&v0->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v25 + 5], v20, 0x24u); goto LABEL_42; } - v0->PlaySound(SPEECH_15, 0); + v0->PlaySound(SPEECH_NoRoom, 0); v54 = 5; LABEL_70: v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" @@ -4694,7 +4694,7 @@ v27->PlaySound((PlayerSpeech)v51, v53); return; } - v0->PlaySound(SPEECH_15, 0); + v0->PlaySound(SPEECH_NoRoom, 0); v54 = 2; goto LABEL_70; }
--- a/mm7_3.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/mm7_3.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -16478,8 +16478,8 @@ GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0)); + pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[0]); if ( pNPC->uProfession ) {
--- a/mm7_5.cpp Sat Feb 16 22:35:58 2013 +0200 +++ b/mm7_5.cpp Sun Feb 17 00:16:48 2013 +0200 @@ -342,7 +342,7 @@ if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; uAction = 0; - uNumSeconds = uMessage - 134; + int hireling_idx = uMessage - UIMSG_StartHireling1Dialogue; v4 = 0; for (uint i = 0; i < 2; ++i) @@ -377,11 +377,12 @@ //} //while ( _this < (signed int)pNPCStats->uNumNewNPCs ); } - if ( (signed int)(uNumSeconds + (unsigned __int8)pParty->field_709) < uAction ) + + if ( (signed int)(hireling_idx + (unsigned __int8)pParty->field_709) < uAction ) { //Actor::Actor(&actor); memset(&actor, 0, 0x344u); - actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - uNumSeconds; + actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx; pActor = &actor; //_actor_init_dlg: pActor->InitializeDialogue(v0); @@ -3624,7 +3625,7 @@ //LABEL_733: GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); continue; - case UIMSG_194: + case UIMSG_Game_Action: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; OnPressSpace(); @@ -16172,6 +16173,7 @@ return; } } + if ( pParty->pPickedItem.uItemID )//нажатие на портрет перса правой кнопкой мыши с раствором { //v1 = 0; @@ -16188,6 +16190,7 @@ } //while ( v1 < 4 ); } + pEventTimer->Pause(); if ( pCurrentScreen <= SCREEN_CHEST ) {