Mercurial > mm7
changeset 917:ae9e2a339b09
disappear items fix
author | Ritor1 |
---|---|
date | Fri, 26 Apr 2013 17:35:19 +0600 |
parents | 897b10712a1a |
children | befaac4bc0e3 aa7bd15e2655 |
files | GUIWindow.h Player.cpp Player.h UIHouses.cpp mm7_4.cpp |
diffstat | 5 files changed, 393 insertions(+), 377 deletions(-) [+] |
line wrap: on
line diff
--- a/GUIWindow.h Thu Apr 25 17:37:00 2013 +0600 +++ b/GUIWindow.h Fri Apr 26 17:35:19 2013 +0600 @@ -343,7 +343,7 @@ unsigned int uFrameW; WindowType eWindowType; union{ - void *ptr_1C; + void *ptr_1C;// sometimes BuildID_2Events unsigned int par1C; }; unsigned int uNumControls;
--- a/Player.cpp Thu Apr 25 17:37:00 2013 +0600 +++ b/Player.cpp Fri Apr 26 17:35:19 2013 +0600 @@ -234,7 +234,7 @@ v6 = p2DEvents[a4 - 1].fPriceMultiplier; //v6 = p2DEvents_minus1__20[13 * a4]; v7 = ((ItemGen *)(v5 + 532))->GetValue(); - v8 = _4B8102(v7, v6); + v8 = GetPriceSell(v7, v6); if ( v5[552] & 2 ) v8 = 1; if ( v8 < 1 ) @@ -340,14 +340,14 @@ } //----- (004B8102) -------------------------------------------------------- -int Player::_4B8102(int a2, float a3) +int Player::GetPriceSell(int uRealValue, float price_multiplier) { signed int v3; // esi@1 signed int result; // eax@3 - v3 = (unsigned __int64)(signed __int64)((double)a2 / (a3 + 2.0)) + a2 * GetMerchant() / 100; - if ( v3 > a2 ) - v3 = a2; + v3 = (unsigned __int64)(signed __int64)((double)uRealValue / (price_multiplier + 2.0)) + uRealValue * GetMerchant() / 100; + if ( v3 > uRealValue ) + v3 = uRealValue; result = 1; if ( v3 >= 1 ) result = v3; @@ -1794,124 +1794,180 @@ //identf //----- (00490EEE) -------------------------------------------------------- -int Player::_490EEE(ItemGen *pItem, int a3, int a4, int a5) -{ - int v5; // eax@1 - int result; // eax@1 - unsigned int v7; // edx@1 - unsigned int v8; // ecx@1 - signed int v9; // esi@1 - char v10; // zf@14 - unsigned __int8 v11; // zf@22 - char v12; // sf@22 - unsigned __int8 v13; // of@22 - float *v14; // esi@26 - float v15; // ST04_4@26 - signed int v16; // eax@26 - int v17; // edi@26 - float v18; // ST04_4@30 - signed int v19; // eax@30 - float v20; // ST04_4@34 - signed int v21; // eax@34 - signed int v22; // eax@34 - float v23; // ST04_4@37 - signed int v24; // eax@37 - int v26; // [sp+10h] [bp-8h]@1 - Player *v27; // [sp+14h] [bp-4h]@1 - - v27 = this; - v5 = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); - v26 = v5; - result = 4; - v7 = pItem->uItemID; - v8 = pItem->uItemID; - v9 = pItemsTable->pItems[v8].uEquipType; - if ( (a3 != 4 || (signed int)v7 < 740 || (signed int)v7 > 771) - && ((signed int)v7 >= 600 || (signed int)v7 >= 529 && (signed int)v7 <= 599) ) +int Player::SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int ShopMenuType) +{ + int pSkillLevel; // eax@1 + int NotBuy; // eax@1 + int result; + signed int pEquipType; // esi@1 + float *pPriceMultiplier; // esi@26 + int pPriceItemService; // edi@26 + + pSkillLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); + NotBuy = 4; + pEquipType = pItemsTable->pItems[pItem->uItemID].uEquipType; + if ( (building_type != 4 || (signed int)pItem->uItemID < 740 || (signed int)pItem->uItemID > 771) + && ((signed int)pItem->uItemID >= 600 || (signed int)pItem->uItemID >= 529 && (signed int)pItem->uItemID <= 599) ) return 5; - if ( a3 == 1 ) - { - v13 = __OFSUB__(v9, 2); - v11 = v9 == 2; - v12 = v9 - 2 < 0; - goto LABEL_24; - } - if ( a3 == 2 ) - { - if ( v9 < 3 ) - return result; - v13 = __OFSUB__(v9, 9); - v11 = v9 == 9; - v12 = v9 - 9 < 0; -LABEL_24: - if ( !((unsigned __int8)(v12 ^ v13) | v11) ) + if ( building_type == BildingType_WeaponShop ) + { + if ( pEquipType > EQUIP_BOW ) + return NotBuy; + if (pItem->Stolen()) + return 6; + } + if ( building_type == BildingType_ArmorShop ) + { + if ( pEquipType < 3 && pEquipType > 9 ) + return NotBuy; + if (pItem->Stolen()) + return 6; + } + if ( building_type == BildingType_MagicShop ) + { + if ( pItemsTable->pItems[pItem->uItemID].uSkillType == 38 ) + { + if (pItem->Stolen()) + return 6; + pPriceMultiplier = &p2DEvents[BuildID_2Events - 1].fPriceMultiplier; + pPriceItemService = GetBuyingPrice(pItem->GetValue(), *pPriceMultiplier); + if ( ShopMenuType == 3 )//Sell + { + pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier); + if (!pItem->Broken()) + { + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + pPriceItemService = 1; + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + if ( ShopMenuType == 4 )//Identify + { + pPriceItemService = this->GetPriceIdentification(*pPriceMultiplier); + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + if ( ShopMenuType == 5 )//Repair + { + pPriceItemService = this->GetPriceRepair(pItem->GetValue(), *pPriceMultiplier); + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + if ( ShopMenuType != 6 )//Buy and ??? + { + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier) / 2; + if (pItem->Broken()) + pPriceItemService = 1; + if ( pPriceItemService >= 1 ) + { + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + pPriceItemService = 1; + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; return result; - goto LABEL_16; - } - if ( a3 == 3 ) - { - if ( pItemsTable->pItems[v8].uSkillType == 38 ) - goto LABEL_16; - v10 = v9 == 16; - goto LABEL_15; - } - if ( a3 != 4 ) - goto LABEL_26; - if ( v9 < 13 ) - return result; - if ( v9 > 14 ) - { - v10 = v9 == 17; -LABEL_15: - if ( !v10 ) + } + if ( pEquipType != EQUIP_BOOK ) + return NotBuy; + } + if ( building_type == BildingType_AlchemistShop ) + { + if ( pEquipType < EQUIP_REAGENT ) + return NotBuy; + if ( pEquipType > EQUIP_POTION ) + { + if ( pEquipType != EQUIP_MESSAGE_SCROLL ) + return NotBuy; + } + if (pItem->Stolen()) + return 6; + } + pPriceMultiplier = &p2DEvents[BuildID_2Events - 1].fPriceMultiplier; + pPriceItemService = GetBuyingPrice(pItem->GetValue(), *pPriceMultiplier); + if ( ShopMenuType == 3 )//Sell + { + pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier); + if (!pItem->Broken()) + { + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; return result; - } -LABEL_16: - if (pItem->Stolen()) - return 6; -LABEL_26: - //v14 = &p2DEvents_minus1__20[13 * a4]; - v14 = &p2DEvents[a4 - 1].fPriceMultiplier; - v15 = *v14; - v16 = pItem->GetValue(); - v17 = GetBuyingPrice(v16, v15); - if ( a5 == 3 ) - { - v23 = *v14; - v24 = pItem->GetValue(); - v17 = v27->_4B8102(v24, v23); - if (!pItem->Broken()) - goto LABEL_39; - goto LABEL_38; - } - if ( a5 == 4 ) - { - v22 = v27->GetPriceIdentification(*v14); - goto LABEL_35; - } - if ( a5 == 5 ) - { - v20 = *v14; - v21 = pItem->GetValue(); - v22 = v27->GetPriceRepair(v21, v20); -LABEL_35: - v17 = v22; - goto LABEL_39; - } - if ( a5 != 6 ) - goto LABEL_39; - v18 = *v14; - v19 = pItem->GetValue(); - v17 = v27->_4B8102(v19, v18) / 2; + } + pPriceItemService = 1; + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + if ( ShopMenuType == 4 )//Identify + { + pPriceItemService = this->GetPriceIdentification(*pPriceMultiplier); + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + if ( ShopMenuType == 5 )//Repair + { + pPriceItemService = this->GetPriceRepair(pItem->GetValue(), *pPriceMultiplier); + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + if ( ShopMenuType != 6 )//Buy and ??? + { + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier) / 2; if (pItem->Broken()) - v17 = 1; - if ( v17 >= 1 ) - goto LABEL_39; -LABEL_38: - v17 = 1; -LABEL_39: - if ( v26 ) - result = (v17 == pItem->GetValue()) + 2; + pPriceItemService = 1; + if ( pPriceItemService >= 1 ) + { + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; + else + result = 1; + return result; + } + pPriceItemService = 1; + if ( pSkillLevel ) + result = (pPriceItemService == pItem->GetValue()) + 2; else result = 1; return result;
--- a/Player.h Thu Apr 25 17:37:00 2013 +0600 +++ b/Player.h Fri Apr 26 17:35:19 2013 +0600 @@ -526,7 +526,7 @@ void Player::Zero(); unsigned int GetStatColor(int uStat); bool DiscardConditionIfLastsLongerThan(unsigned int uCondition, unsigned __int64 uTime); - int _490EEE(ItemGen *pItem, int a3, int a4, int a5); + int SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int a5); int GetBodybuilding(); int GetMeditation(); int CanIdentify(ItemGen *pItem); @@ -562,7 +562,7 @@ int GetPriceRepair(int a2, float a3); int GetPriceIdentification(float a2); int GetBuyingPrice(unsigned int uRealValue, float price_multiplier); - int _4B8102(int a2, float a3); + int GetPriceSell(int uRealValue, float price_multiplier); int _4B807C(float a2); int _4B8040_condition_time(unsigned int uCondition); bool _43EEF3();
--- a/UIHouses.cpp Thu Apr 25 17:37:00 2013 +0600 +++ b/UIHouses.cpp Fri Apr 26 17:35:19 2013 +0600 @@ -2827,7 +2827,7 @@ LONG v60; // ecx@90 int v61; // eax@90 int v62; // ecx@90 - ItemGen *v63; // esi@90 + ItemGen *pItemInShop; // esi@90 int v64; // eax@95 int all_text_height; // esi@96 char **v66; // edi@96 @@ -2984,23 +2984,23 @@ { v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; v106.x = v60; - v61 = (int)window_SpeakInHouse->ptr_1C; + v61 = (int)window_SpeakInHouse->ptr_1C;//maybe ptr_1C - BuildID_2Events // v62 = 9 * (v60 + 12 * v61); - v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; + pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; + pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; if ( !v56 || !Str ) { - v64 = pPlayer->_490EEE(v63, 1, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); + v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0); - pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); - dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } } } @@ -3025,7 +3025,7 @@ || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; v79 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; - v13 = pPlayer->_490EEE(v79, 1, (int)window_SpeakInHouse->ptr_1C, 3); + v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); @@ -3046,7 +3046,7 @@ v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; if (!v4->Identified()) { - v10 = pPlayer->_490EEE(v4, 1, (int)window_SpeakInHouse->ptr_1C, 4); + v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); @@ -3073,7 +3073,7 @@ || (pNumActiveItem = 9 * pNumActiveItem, !(pPlayer->field_1F5[4 * pNumActiveItem + 15] & 2)) ) return; v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; - v10 = pPlayer->_490EEE(v4, 2, (int)window_SpeakInHouse->ptr_1C, 5); + v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3); @@ -3177,19 +3177,19 @@ v106.x = v60; v61 = (int)window_SpeakInHouse->ptr_1C; // v62 = 9 * (v60 + 12 * v61); - v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; + pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; + pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { - v64 = pPlayer->_490EEE(v63, 1, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); + v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, v63, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -3487,7 +3487,7 @@ v114 = 0; do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114 + 6].uItemID) { v50 = ItemsInShopTexture[v114 + 6]; v51 = 308 - v50->uTextureHeight; @@ -3556,7 +3556,7 @@ v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->_490EEE(v70, 4, (int)window_SpeakInHouse->ptr_1C, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else @@ -3583,7 +3583,7 @@ || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; v87 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; - v45 = pPlayer->_490EEE(v87, 4, (int)window_SpeakInHouse->ptr_1C, 3); + v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3); @@ -3603,7 +3603,7 @@ v37 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; if (!v37->Identified()) { - v42 = pPlayer->_490EEE(v37, 4, (int)window_SpeakInHouse->ptr_1C, 4); + v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); v38 = (char *)pMerchantsIdentifyPhrases[v42]; } else @@ -3689,7 +3689,7 @@ v114 = 0; do { - if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114 + 6].uItemID) //not itemid { v58 = ItemsInShopTexture[v114 + 6]; v59 = 308 - v58->uTextureHeight; @@ -3759,7 +3759,7 @@ v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->_490EEE(v70, 4, v68, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else @@ -4085,7 +4085,7 @@ pItemCount = v74 - 1; selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->_490EEE(selected_item, 2, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); @@ -4153,11 +4153,11 @@ return; pItemCount = v74 - 1; if ( dialog_menu_id == 2 ) - selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; + selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; else selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->_490EEE(selected_item, 2, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); @@ -4219,8 +4219,8 @@ || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) ) return; v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10 - 1]; - v13 = pPlayers[uActiveCharacter]->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3); - v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3)]; + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); + v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); @@ -4248,7 +4248,7 @@ v5 = "%24"; else { - v8 = pPlayers[uActiveCharacter]->_490EEE(v3, 2, (int)window_SpeakInHouse->ptr_1C, 4); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); v5 = (char *)pMerchantsIdentifyPhrases[v8]; } v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); @@ -4276,7 +4276,7 @@ || (v33 = 9 * v32, !(pPlayers[uActiveCharacter]->field_1F5[4 * v33 + 15] & 2)) ) return; v116 = &pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1]; - v35 = pPlayers[uActiveCharacter]->_490EEE(&pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1], 2, (int)window_SpeakInHouse->ptr_1C, 5); + v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1], BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); v15 = (char *)pMerchantsRepairPhrases[v35]; v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; @@ -4303,7 +4303,7 @@ { --pItemCount; v97 = uActiveCharacter - 1; - v99 = pPlayers[uActiveCharacter]->_490EEE(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], 2, window_SpeakInHouse->par1C, 2); + v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2); v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3); @@ -4598,7 +4598,7 @@ v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); v16 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; - v17 = pPlayers[uActiveCharacter]->_490EEE( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, 3, v16, 2); + v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BildingType_MagicShop, v16, 2); v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); @@ -5509,11 +5509,11 @@ unsigned int v24; // ecx@25 const char **v25; // edx@25 unsigned __int16 text_color; // ax@25 - signed int v27; // esi@30 + signed int pTextHeight; // esi@30 int v28; // ST08_4@34 int v29; // eax@34 char *v30; // edx@35 - GUIWindow *v31; // edi@40 + //GUIWindow *v31; // edi@40 void *v32; // eax@40 signed int v33; // esi@40 unsigned int v34; // esi@42 @@ -5521,8 +5521,8 @@ unsigned int v36; // eax@43 int v37; // eax@45 int v38; // ecx@50 - GUIButton *v39; // eax@52 - GUIButton *v40; // esi@52 + //GUIButton *v39; // eax@52 + //GUIButton *v40; // esi@52 int v41; // eax@52 char *v42; // eax@54 int v43; // eax@54 @@ -5558,18 +5558,18 @@ int v73; // ecx@125 ItemGen *v74; // esi@125 int v75; // eax@130 - int v76; // esi@131 - char **v77; // edi@131 + //int v76; // esi@131 + //char **v77; // edi@131 int v78; // eax@132 - GUIWindow *v79; // ecx@133 + //GUIWindow *v79; // ecx@133 int v80; // edx@133 int v81; // edi@133 - GUIButton *v82; // esi@135 + //GUIButton *v82; // esi@135 const char **v83; // eax@135 int v84; // eax@135 unsigned int v85; // ecx@135 int v86; // edx@135 - unsigned __int16 v87; // ax@135 + //unsigned __int16 v87; // ax@135 GUIWindow *v88; // [sp-18h] [bp-110h]@35 int v89; // [sp-14h] [bp-10Ch]@35 ItemGen *v90; // [sp-10h] [bp-108h]@14 @@ -5597,24 +5597,26 @@ GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 char *Str; // [sp+D0h] [bp-28h]@54 int v146; // [sp+D4h] [bp-24h]@23 - unsigned int hilight_color; // [sp+D8h] [bp-20h]@1 - unsigned int m_text_color; // [sp+DCh] [bp-1Ch]@1 + unsigned int pYellowColor; // [sp+D8h] [bp-20h]@1 + unsigned int pWhiteColor; // [sp+DCh] [bp-1Ch]@1 __int32 v117; // [sp+E0h] [bp-18h]@8 int v118; // [sp+E4h] [bp-14h]@40 const char **v119; // [sp+E8h] [bp-10h]@24 - Player *_this; // [sp+ECh] [bp-Ch]@1 + int _this; // [sp+ECh] [bp-Ch]@1 unsigned __int8 uPlayerID; // [sp+F3h] [bp-5h]@14 int v152; // [sp+F4h] [bp-4h]@23 int v122; int v114; + int pSrtingNum; + int pActiveItemNum; + ItemGen *item; - _this = pPlayers[uActiveCharacter]; memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; dialog_window.uFrameZ = 334; - m_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); - hilight_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); + pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255); + pYellowColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(225, 205, 35); if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) { if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) @@ -5636,13 +5638,13 @@ { control_button = pDialogueWindow->GetControl(v152); control_button->uY = v146 + v23; - v27 = pFontArrus->CalcTextHeight(pShopOptions[j], &dialog_window, 0, 0); - control_button->uHeight = v27; + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &dialog_window, 0, 0); + control_button->uHeight = pTextHeight; v23 = control_button->uY + control_button->uHeight - 1; control_button->uW = v23; - text_color = hilight_color; + text_color = pYellowColor; if ( pDialogueWindow->pCurrentPosActiveItem != th ) - text_color = m_text_color; + text_color = pWhiteColor; dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[j], 3); ++th; ++j; @@ -5650,246 +5652,204 @@ } return; } - if ( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR ) - { - if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) + + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) { draw_leather(); CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];// "Sell" pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];// "Identify" pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];// "Repair" - v76 = 0; - v77 = pShopOptions; - do - { - v78 = pFontArrus->CalcTextHeight(*v77, &dialog_window, 0, 0); - ++v77; - v76 += v78; - } - while ( (signed int)v77 < (signed int)&pShopOptions[3] ); - v79 = pDialogueWindow; - _this = (Player *)((174 - v76) / 3); - result = pDialogueWindow->pStartingPosActiveItem; - v80 = result + pDialogueWindow->pNumPresenceButton; - v81 = (3 * (58 - (signed int)_this) - v76) / 2 - (174 - v76) / 3 / 2 + 138; + all_text_height = 0; + for ( uint i = 0; i < 3; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + _this = ((174 - all_text_height) / 3); + v81 = (3 * (58 - (signed int)_this) - all_text_height) / 2 - (174 - all_text_height) / 3 / 2 + 138; v20 = -pDialogueWindow->pNumPresenceButton < 0; v118 = pDialogueWindow->pStartingPosActiveItem; - if ( v20 ^ __OFSUB__(result, v80) ) + if ( v20 ^ pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) { v122 = 2; - v119 = (const char **)pShopOptions; + pSrtingNum = 0; do { - v82 = v79->GetControl(v118); - v83 = v119; - v82->uY = (unsigned int)((char *)_this + v81); - v84 = pFontArrus->CalcTextHeight(*v83, &dialog_window, 0, 0); - v85 = v82->uY; - v86 = v122; - v82->uHeight = v84; - v81 = v84 + v85 - 1; - v82->uW = v81; - v87 = hilight_color; - if ( pDialogueWindow->pCurrentPosActiveItem != v86 ) - v87 = m_text_color; - dialog_window.DrawTitleText(pFontArrus, 0, v85, v87, *v119, 3u); - v79 = pDialogueWindow; + control_button = pDialogueWindow->GetControl(v118); + control_button->uY = (unsigned int)((char *)_this + v81); + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pSrtingNum], &dialog_window, 0, 0); + v85 = control_button->uY; + control_button->uHeight = pTextHeight; + v81 = pTextHeight + v85 - 1; + control_button->uW = v81; + text_color = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != v122 ) + text_color = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, v85, text_color, pShopOptions[pSrtingNum], 3); ++v122; - ++v119; + ++pSrtingNum; ++v118; - result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } - while ( v118 < result ); + while ( v118 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } return; } - if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) + + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR) { - result = dialog_menu_id - HOUSE_DIALOGUE_LEARN_SKILLS; - if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) + draw_leather(); + CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair" + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() + || (pTextHeight = pMouse->GetCursorPos(&v110)->x - 14, + v117 = (pTextHeight >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5), + result = (int)pMouse->GetCursorPos(&v106), + *(int *)result <= 13) + || (result = (int)pMouse->GetCursorPos(&v104), *(int *)result >= 462) + || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) + || (result *= 9, !(pPlayers[uActiveCharacter]->field_1F5[4 * result + 15] & 2)) ) + return; + item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; + v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); + v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { - result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) + v3 = 0; + all_text_height = 0; + v33 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + v119 = (const char **)(v33 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100); + if ( (signed int)v119 < v33 / 3 ) + v119 = (const char **)(v33 / 3); + pActiveItemNum = pDialogueWindow->pStartingPosActiveItem; + v122 = 0; + if ( (signed int)pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) { - v31 = pDialogueWindow; - v3 = 0; - v32 = window_SpeakInHouse->ptr_1C; - v118 = 0; - //v33 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v32] * 500.0); - v33 = (signed __int64)(p2DEvents[(signed int)v32 - 1].flt_24 * 500.0); - v119 = (const char **)(v33 * (100 - _this->GetMerchant()) / 100); - if ( (signed int)v119 < v33 / 3 ) - v119 = (const char **)(v33 / 3); - v34 = v31->pStartingPosActiveItem; - v35 = v34 + v31->pNumPresenceButton; - v122 = 0; - if ( (signed int)v34 >= v35 ) + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// + // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf, "\n \n"); + strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." + v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf, 3); + return; + } + do + { + v36 = pDialogueWindow->GetControl(pActiveItemNum)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v36] && !pPlayers[uActiveCharacter]->pActiveSkills[v36] ) { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->classType]);// - // "Seek knowledge elsewhere %s the %s" - strcat(pTmpBuf, "\n \n"); - strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." - v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0)) / 2 + 138; - dialog_window.DrawTitleText(pFontArrus, v3, v6, hilight_color, pTmpBuf, 3); - return; + all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v36], &dialog_window, 0, 0); + ++v122; } + ++pActiveItemNum; + } + while ( pActiveItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + if ( !v122 ) + { + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// + // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf, "\n \n"); + strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." + v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf, 3); + return; + } + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu" + dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u); + v119 = (const char **)((149 - all_text_height) / v122); + if ( (149 - all_text_height) / v122 > 32 ) + v119 = (const char **)32; + v38 = (149 - v122 * (signed int)v119 - all_text_height) / 2 - (signed int)v119 / 2 + 162; + v118 = 2; + if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) + { + v122 = 2; do { - v36 = v31->GetControl(v34)->msg_param - 36; - if ( byte_4ED970_skill_learn_ability_by_class_table[_this->classType][v36] && !_this->pActiveSkills[v36] ) + control_button = pDialogueWindow->GetControl(v122); + v41 = control_button->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] || pPlayers[uActiveCharacter]->pActiveSkills[v41] ) + { + control_button->uW = 0; + control_button->uHeight = 0; + control_button->uY = 0; + } + else { - v37 = pFontArrus->CalcTextHeight(pSkillNames[v36], &dialog_window, 0, 0); - v118 += v37; - ++v122; + control_button->uY = (unsigned int)((char *)v119 + v38); + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0); + v44 = control_button->uY; + control_button->uHeight = pTextHeight; + v38 = v44 + pTextHeight - 1; + control_button->uW = v38; + text_color = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != v122 ) + text_color = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, v44, text_color, pSkillNames[v41], 3); } - ++v34; + ++v122; } - while ( (signed int)v34 < v31->pNumPresenceButton + v31->pStartingPosActiveItem ); - if ( !v122 ) - { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->classType]);// - // "Seek knowledge elsewhere %s the %s" - strcat(pTmpBuf, "\n \n"); - strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." - v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 0, 0)) / 2 + 138; - dialog_window.DrawTitleText(pFontArrus, v3, v6, hilight_color, pTmpBuf, 3); - return; - } - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu" - dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u); - v119 = (const char **)((149 - v118) / v122); - if ( (149 - v118) / v122 > 32 ) - v119 = (const char **)32; - result = v31->pStartingPosActiveItem; - v38 = (149 - v122 * (signed int)v119 - v118) / 2 - (signed int)v119 / 2 + 162; - v118 = result; - v114 = v38; - if ( result < result + v31->pNumPresenceButton ) + while ( v122 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + } + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY) + { + draw_leather(); + CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify" + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v2 = pMouse->GetCursorPos(&a2)->x - 14; + v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5); + result = (int)pMouse->GetCursorPos(&v111); + if ( *(int *)result > 13 ) + { + result = (int)pMouse->GetCursorPos(&v103); + if ( *(int *)result < 462 ) { - v122 = 2; - do + result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117); + if ( result ) { - v39 = v31->GetControl(v118); - v40 = v39; - v41 = v39->msg_param - 36; - if ( !byte_4ED970_skill_learn_ability_by_class_table[_this->classType][v41] || _this->pActiveSkills[v41] ) - { - v40->uW = 0; - v40->uHeight = 0; - v40->uY = 0; - } - else + item = &pPlayers[uActiveCharacter]->pInventoryItems[result-1]; + if ( item->uAttributes & 1 ) { - v42 = pSkillNames[v41]; - v40->uY = (unsigned int)((char *)v119 + v114); - Str = v42; - v43 = pFontArrus->CalcTextHeight(v42, &dialog_window, 0, 0); - v44 = v40->uY; - v45 = v122; - v40->uHeight = v43; - v46 = v44 + v43 - 1; - v40->uW = v46; - v114 = v46; - v47 = hilight_color; - if ( pDialogueWindow->pCurrentPosActiveItem != v45 ) - v47 = m_text_color; - dialog_window.DrawTitleText(pFontArrus, 0, v44, v47, Str, 3u); + v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; + dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3); + return; } - v48 = v31->pStartingPosActiveItem; - ++v118; - result = v31->pNumPresenceButton + v48; - ++v122; + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); + v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3); + return; } - while ( v118 < result ); } } } return; } + if ( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) + { + result = dialog_menu_id - HOUSE_DIALOGUE_LEARN_SKILLS; + + } } else { - if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR) - { - draw_leather(); - CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); - DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair" - result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( !result - || (v27 = pMouse->GetCursorPos(&v110)->x - 14, - v117 = (v27 >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5), - result = (int)pMouse->GetCursorPos(&v106), - *(int *)result <= 13) - || (result = (int)pMouse->GetCursorPos(&v104), *(int *)result >= 462) - || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) - || (result *= 9, !(_this->field_1F5[4 * result + 15] & 2)) ) - return; - v96 = 0; - v94 = 5; - v93 = window_SpeakInHouse->ptr_1C; - v90 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5]; - v28 = (int)window_SpeakInHouse->ptr_1C; - uPlayerID = uActiveCharacter - 1; - v29 = _this->_490EEE((ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5], 3, v28, 5); - v9 = uPlayerID; - v10 = (char *)pMerchantsRepairPhrases[v29]; - v30 = BuilDialogueString(v10, v9, v90, (char *)v93, v94, v96); - v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; - dialog_window.DrawTitleText(pFontArrus, v3, v6, m_text_color, v30, 3); - return; - } + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL) { result = dialog_menu_id - HOUSE_DIALOGUE_SHOP_IDENTIFY; - if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY) - { - draw_leather(); - CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); - DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify" - result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); - if ( result ) - { - v2 = pMouse->GetCursorPos(&a2)->x - 14; - v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5); - result = (int)pMouse->GetCursorPos(&v111); - if ( *(int *)result > 13 ) - { - result = (int)pMouse->GetCursorPos(&v103); - if ( *(int *)result < 462 ) - { - result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117); - v3 = 0; - if ( result ) - { - v96 = 0; - v94 = 4; - v4 = (char *)&_this->pInventoryItems[result-1]; - if ( v4[20] & 1 ) - { - v5 = BuilDialogueString("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); - v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; - dialog_window.DrawTitleText(pFontArrus, v3, v6, m_text_color, v5, 3); - return; - } - v93 = window_SpeakInHouse->ptr_1C; - v90 = (ItemGen *)v4; - v7 = (int)window_SpeakInHouse->ptr_1C; - uPlayerID = uActiveCharacter - 1; - v8 = ((Player *)_this)->_490EEE((ItemGen *)v4, 3, v7, 4); - v9 = uPlayerID; - v10 = (char *)pMerchantsIdentifyPhrases[v8]; - v30 = BuilDialogueString(v10, v9, v90, (char *)v93, v94, v96); - v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; - dialog_window.DrawTitleText(pFontArrus, v3, v6, m_text_color, v30, 3); - return; - } - } - } - } - } return; } draw_leather(); @@ -5907,15 +5867,15 @@ v96 = 0; v94 = 3; v93 = window_SpeakInHouse->ptr_1C; - v90 = (ItemGen *)&_this->pInventoryItems[result-1]; + v90 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; v12 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; - v13 = _this->_490EEE(v90, 3, v12, 3); + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v90, BildingType_MagicShop, v12, 3); v9 = uPlayerID; v10 = (char *)pMerchantsSellPhrases[v13]; v30 = BuilDialogueString(v10, v9, v90, (char *)v93, v94, v96); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; - dialog_window.DrawTitleText(pFontArrus, v3, v6, m_text_color, v30, 3); + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } } @@ -5959,7 +5919,7 @@ v122 = 0; do { - if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 1].uItemID) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID) { v54 = ItemsInShopTexture[v122 + 6]; v55 = 306 - v54->uTextureHeight; @@ -6023,7 +5983,7 @@ do { //if ( pParty->Spell_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49] + 778] ) //weak - if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uAttributes) + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID) { v62 = ItemsInShopTexture[v122 + 6]; v63 = 306 - v62->uTextureHeight; @@ -6078,7 +6038,7 @@ while ( v66 < 12 ); } v67 = GetAsyncKeyState(VK_CONTROL); - v68 = _this->CanSteal(); + v68 = pPlayers[uActiveCharacter]->CanSteal(); Str = (char *)v68; if ( v67 && v68 ) { @@ -6110,12 +6070,12 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = _this->_490EEE(v74, 3, v72, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v74, BildingType_MagicShop, v72, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } v30 = BuilDialogueString(v10, uActiveCharacter - 1, v74, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; - dialog_window.DrawTitleText(pFontArrus, v3, v6, m_text_color, v30, 3); + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } }
--- a/mm7_4.cpp Thu Apr 25 17:37:00 2013 +0600 +++ b/mm7_4.cpp Fri Apr 26 17:35:19 2013 +0600 @@ -3757,7 +3757,7 @@ { v35 = *v26; v36 = a3->GetValue(); - v29 = pPlayer->_4B8102(v36, v35); + v29 = pPlayer->GetPriceSell(v36, v35); if (a3->Broken()) v29 = 1; goto _continue_sprintf; @@ -3776,7 +3776,7 @@ { v30 = *v26; v31 = a3->GetValue(); - v29 = pPlayer->_4B8102(v31, v30) / 2; + v29 = pPlayer->GetPriceSell(v31, v30) / 2; if (a3->Broken()) v29 = 1; if (!v29)