# HG changeset patch # User Ritor1 # Date 1367033842 -21600 # Node ID befaac4bc0e3b893eb9010dda3a1c9389e2aa8f9 # Parent 47bbd8969f534725c7f847623a7c9694a79c3b53# Parent ae9e2a339b098f78df25b9e640299ee20bcaf535 Слияние diff -r 47bbd8969f53 -r befaac4bc0e3 GUIWindow.h --- a/GUIWindow.h Sat Apr 27 09:37:09 2013 +0600 +++ b/GUIWindow.h Sat Apr 27 09:37:22 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; diff -r 47bbd8969f53 -r befaac4bc0e3 Player.cpp --- a/Player.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/Player.cpp Sat Apr 27 09:37:22 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; @@ -366,7 +366,7 @@ } //----- (004B8179) -------------------------------------------------------- -int Player::_4B8179(float a2) +int Player::GetPriceIdentification(float a2) { signed int v2; // esi@1 int v3; // ecx@1 @@ -383,7 +383,7 @@ } //----- (004B81C3) -------------------------------------------------------- -int Player::_4B81C3(int a2, float a3) +int Player::GetPriceRepair(int a2, float a3) { signed int v3; // esi@1 int v4; // ecx@1 @@ -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->_4B8179(*v14); - goto LABEL_35; - } - if ( a5 == 5 ) - { - v20 = *v14; - v21 = pItem->GetValue(); - v22 = v27->_4B81C3(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; diff -r 47bbd8969f53 -r befaac4bc0e3 Player.h --- a/Player.h Sat Apr 27 09:37:09 2013 +0600 +++ b/Player.h Sat Apr 27 09:37:22 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); @@ -559,10 +559,10 @@ int _4B8265(int a2, float a3); int _4B8233(int a2, float a3); int _4B8213(int a2, float a3); - int _4B81C3(int a2, float a3); - int _4B8179(float a2); + 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(); diff -r 47bbd8969f53 -r befaac4bc0e3 UICharacter.cpp --- a/UICharacter.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/UICharacter.cpp Sat Apr 27 09:37:22 2013 +0600 @@ -2401,7 +2401,6 @@ } } } - memset(byte_5111F6, 0, 16); for (uint i = 0; i < 4; ++i) { diff -r 47bbd8969f53 -r befaac4bc0e3 UIHouses.cpp --- a/UIHouses.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/UIHouses.cpp Sat Apr 27 09:37:22 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; } } diff -r 47bbd8969f53 -r befaac4bc0e3 Vis.cpp --- a/Vis.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/Vis.cpp Sat Apr 27 09:37:22 2013 +0600 @@ -24,23 +24,23 @@ //----- (004C1026) -------------------------------------------------------- -Vis_ObjectInfo *Vis::_4C1026(BLVFace *face, unsigned int a3, float pick_depth) +Vis_ObjectInfo *Vis::DetermineFacetIntersection(BLVFace *face, unsigned int a3, float pick_depth) { char *v4; // eax@4 signed int v5; // ecx@4 RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17 int v20; // [sp+84h] [bp-Ch]@10 - static Vis_SelectionList static_sub_4C1026_stru_F8FE00; - static_sub_4C1026_stru_F8FE00.uNumPointers = 0; + static Vis_SelectionList static_DetermineFacetIntersection_stru_F8FE00; + static_DetermineFacetIntersection_stru_F8FE00.uNumPointers = 0; static bool _init_flag = false; - static RenderVertexSoft static_sub_4C1026_array_F8F200[64]; + static RenderVertexSoft static_DetermineFacetIntersection_array_F8F200[64]; if (!_init_flag) { _init_flag = true; for (uint i = 0; i < 64; ++i) - static_sub_4C1026_array_F8F200[i].flt_2C = 0.0f; + static_DetermineFacetIntersection_array_F8F200[i].flt_2C = 0.0f; } if (uCurrentlyLoadedLevelType == LEVEL_Indoor) @@ -49,9 +49,9 @@ { for ( int i = 0; i < face->uNumVertices; i++) { - static_sub_4C1026_array_F8F200[i].vWorldPosition.x = (double)pIndoor->pVertices[face->pVertexIDs[i]].x; - static_sub_4C1026_array_F8F200[i].vWorldPosition.y = (double)pIndoor->pVertices[face->pVertexIDs[i]].y; - static_sub_4C1026_array_F8F200[i].vWorldPosition.z = (double)pIndoor->pVertices[face->pVertexIDs[i]].z; + static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.x = (double)pIndoor->pVertices[face->pVertexIDs[i]].x; + static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.y = (double)pIndoor->pVertices[face->pVertexIDs[i]].y; + static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.z = (double)pIndoor->pVertices[face->pVertexIDs[i]].z; } } } @@ -61,48 +61,48 @@ auto v = (Vec3_int_ *)pOutdoor->pBModels[bmodel_id].pVertices.pVertices; for (uint i = 0; i < face->uNumVertices; ++i) { - static_sub_4C1026_array_F8F200[i].vWorldPosition.x = v[face->pVertexIDs[i]].x; - static_sub_4C1026_array_F8F200[i].vWorldPosition.y = v[face->pVertexIDs[i]].y; - static_sub_4C1026_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z; + static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.x = v[face->pVertexIDs[i]].x; + static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.y = v[face->pVertexIDs[i]].y; + static_DetermineFacetIntersection_array_F8F200[i].vWorldPosition.z = v[face->pVertexIDs[i]].z; } } else assert(false); - pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, face->uNumVertices); - pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, face->uNumVertices, 1); + pGame->pIndoorCameraD3D->ViewTransform(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices); + pGame->pIndoorCameraD3D->Project(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, 1); //v15 = this; - SortVectors_x(static_sub_4C1026_array_F8F200, 0, face->uNumVertices - 1); - if (static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > pick_depth) + SortVectors_x(static_DetermineFacetIntersection_array_F8F200, 0, face->uNumVertices - 1); + if (static_DetermineFacetIntersection_array_F8F200[0].vWorldViewPosition.x > pick_depth) return nullptr; float screenspace_center_x, screenspace_center_y; - GetPolygonScreenSpaceCenter(static_sub_4C1026_array_F8F200, face->uNumVertices, &screenspace_center_x, &screenspace_center_y); - if (IsPolygonOccludedByBillboard(static_sub_4C1026_array_F8F200, face->uNumVertices, screenspace_center_x, screenspace_center_y)) + GetPolygonScreenSpaceCenter(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, &screenspace_center_x, &screenspace_center_y); + if (IsPolygonOccludedByBillboard(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, screenspace_center_x, screenspace_center_y)) return nullptr; CastPickRay(pRay, screenspace_center_x, screenspace_center_y, pick_depth); if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - PickOutdoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter, true); + PickOutdoorFaces_Mouse(pick_depth, pRay, &static_DetermineFacetIntersection_stru_F8FE00, &vis_face_filter, true); else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - PickIndoorFaces_Mouse(pick_depth, pRay, &static_sub_4C1026_stru_F8FE00, &vis_face_filter); + PickIndoorFaces_Mouse(pick_depth, pRay, &static_DetermineFacetIntersection_stru_F8FE00, &vis_face_filter); else assert(false); - static_sub_4C1026_stru_F8FE00.create_object_pointers(); - sort_object_pointers(static_sub_4C1026_stru_F8FE00.object_pointers, 0, static_sub_4C1026_stru_F8FE00.uNumPointers - 1); - if (!static_sub_4C1026_stru_F8FE00.uNumPointers) + static_DetermineFacetIntersection_stru_F8FE00.create_object_pointers(); + sort_object_pointers(static_DetermineFacetIntersection_stru_F8FE00.object_pointers, 0, static_DetermineFacetIntersection_stru_F8FE00.uNumPointers - 1); + if (!static_DetermineFacetIntersection_stru_F8FE00.uNumPointers) return nullptr; - if (!static_sub_4C1026_stru_F8FE00.sub_4C2551(2, a3)) + if (!static_DetermineFacetIntersection_stru_F8FE00.sub_4C2551(2, a3)) return nullptr; - if (static_sub_4C1026_stru_F8FE00.uNumPointers) - return static_sub_4C1026_stru_F8FE00.object_pointers[0]; + if (static_DetermineFacetIntersection_stru_F8FE00.uNumPointers) + return static_DetermineFacetIntersection_stru_F8FE00.object_pointers[0]; else return nullptr; } -// F91E08: using guessed type char static_sub_4C1026_byte_F91E08__init_flags; +// F91E08: using guessed type char static_DetermineFacetIntersection_byte_F91E08__init_flags; //----- (004C12C3) -------------------------------------------------------- bool Vis::IsPolygonOccludedByBillboard(RenderVertexSoft *vertices, int num_vertices, float x, float y) @@ -214,7 +214,7 @@ { for (uint i = 0; i < pRenderer->uNumBillboardsToDraw; ++i) { - auto d3d_billboard = pRenderer->pBillboardRenderListD3D + i; + auto d3d_billboard = &pRenderer->pBillboardRenderListD3D[i]; if (is_part_of_selection((void *)i, filter) && IsPointInsideD3DBillboard(d3d_billboard, fX, fY)) { if (DoesRayIntersectBillboard(fPickDepth, i)) @@ -366,7 +366,7 @@ auto bmodel = &pOutdoor->pBModels[i]; for (uint j = 0; j < bmodel->uNumFaces; ++j) { - auto face = bmodel->pFaces + j; + auto face = &bmodel->pFaces[j]; if (is_part_of_selection(face, filter)) { BLVFace blv_face; @@ -375,7 +375,7 @@ RenderVertexSoft intersection; if (Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &intersection, &blv_face, i)) { - pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1u); + pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1); int v13 = _48B561_mess_with_scaling_along_z(/*v12, */intersection.vWorldViewPosition.x); v13 += PID(OBJECT_BModel, j | (i << 6)); @@ -1819,7 +1819,7 @@ { if ( is_part_of_selection(pFace, filter) ) { - v8 = _4C1026(pFace, PID(OBJECT_BModel, pFaceID), pick_depth); + v8 = DetermineFacetIntersection(pFace, PID(OBJECT_BModel, pFaceID), pick_depth); if ( v8 ) list->AddObject(v8->object, v8->object_type, v8->sZValue); } @@ -1844,7 +1844,7 @@ auto bmodel = pOutdoor->pBModels + i; for (uint j = 0; j < bmodel->uNumFaces; ++j) { - auto face = bmodel->pFaces + j; + auto face = &bmodel->pFaces[j]; if (is_part_of_selection(face, filter) ) { @@ -1852,7 +1852,7 @@ blv_face.FromODM(face); int pid = PID(OBJECT_BModel, j | (i << 6)); - if (auto object_info = _4C1026(&blv_face, pid, pick_depth)) + if (auto object_info = DetermineFacetIntersection(&blv_face, pid, pick_depth)) list->AddObject(object_info->object, object_info->object_type, object_info->sZValue); } } diff -r 47bbd8969f53 -r befaac4bc0e3 Vis.h --- a/Vis.h Sat Apr 27 09:37:09 2013 +0600 +++ b/Vis.h Sat Apr 27 09:37:22 2013 +0600 @@ -100,7 +100,7 @@ bool is_part_of_selection(void *uD3DBillboardIdx_or_pBLVFace_or_pODMFace, Vis_SelectionFilter *filter); bool DoesRayIntersectBillboard(float fDepth, unsigned int uD3DBillboardIdx); - Vis_ObjectInfo *_4C1026(struct BLVFace *face, unsigned int a3, float pick_depth); + Vis_ObjectInfo *DetermineFacetIntersection(struct BLVFace *face, unsigned int a3, float pick_depth); bool IsPolygonOccludedByBillboard(struct RenderVertexSoft *vertices, int num_vertices, float x, float y); void GetPolygonCenter(struct RenderVertexD3D3 *pVertices, unsigned int uNumVertices, float *pCenterX, float *pCenterY); void GetPolygonScreenSpaceCenter(struct RenderVertexSoft *vertices, int num_vertices, float *out_center_x, float *out_center_y); diff -r 47bbd8969f53 -r befaac4bc0e3 mm7_2.cpp --- a/mm7_2.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/mm7_2.cpp Sat Apr 27 09:37:22 2013 +0600 @@ -890,91 +890,28 @@ //----- (004BDB56) -------------------------------------------------------- void __cdecl UIShop_Buy_Identify_Repair() { - Player *v0; // edi@1 - signed int v1; // esi@9 - unsigned int v2; // eax@11 - int v3; // esi@12 - float v4; // ST1C_4@12 - signed int v5; // eax@12 - signed int v6; // eax@12 - char v7; // zf@12 int v8; // eax@15 - const char *v9; // ecx@15 - signed int v10; // esi@18 - unsigned int v11; // esi@20 - int v12; // esi@21 - void *v13; // ecx@26 - signed int v14; // esi@31 + unsigned int pItemID; // esi@20 + ItemGen *item; // esi@21 unsigned int v15; // eax@33 - GUIWindow *v16; // esi@34 - POINT *v17; // esi@37 + POINT *pCursorPos; // esi@37 int v18; // ecx@37 - void *v19; // eax@38 - ItemGen *v20; // esi@38 - float v21; // ST1C_4@38 - signed int v22; // eax@38 - int v23; // ebx@38 - int v24; // edx@39 - int v25; // eax@40 - int v26; // ebx@41 - Player *v27; // ecx@43 - POINT *v28; // esi@49 - int v29; // ecx@49 - void *v30; // eax@50 - int v31; // ecx@50 - ItemGen *v32; // esi@51 - //float v33; // ST1C_4@53 - //signed int v34; // eax@53 - //int v35; // eax@53 - //bool v36; // eax@53 - unsigned int v37; // eax@53 - int v38; // eax@55 + float pPriceMultiplier; // ST1C_4@38 + int taken_item; // eax@40 + ItemGen *bought_item; // esi@51 + int party_reputation; // eax@55 int v39; // eax@63 - //int v40; // eax@64 - int v41; // edx@66 int v42; // esi@74 signed int v43; // ebx@74 - int v44; // ecx@74 unsigned __int16 *pSkill; // esi@77 - signed int v46; // [sp-18h] [bp-CCh]@36 - unsigned int v47; // [sp-14h] [bp-C8h]@36 - signed int v48; // [sp-10h] [bp-C4h]@36 - signed int v49; // [sp-Ch] [bp-C0h]@36 - int v50; // [sp-8h] [bp-BCh]@36 - int v51; // [sp-4h] [bp-B8h]@28 - unsigned int v52; // [sp-4h] [bp-B8h]@36 - int v53; // [sp+0h] [bp-B4h]@16 - unsigned int v54; // [sp+0h] [bp-B4h]@25 int v55; // [sp+0h] [bp-B4h]@26 - int v56; // [sp+0h] [bp-B4h]@36 - //POINT v57; // [sp+10h] [bp-A4h]@49 - //POINT v58; // [sp+18h] [bp-9Ch]@18 - POINT v59; // [sp+20h] [bp-94h]@49 - POINT v60; // [sp+28h] [bp-8Ch]@9 - POINT v61; // [sp+30h] [bp-84h]@37 - POINT v62; // [sp+38h] [bp-7Ch]@18 - POINT v63; // [sp+40h] [bp-74h]@37 - //POINT v64; // [sp+48h] [bp-6Ch]@19 - POINT v65; // [sp+50h] [bp-64h]@32 - //POINT v66; // [sp+58h] [bp-5Ch]@18 - POINT v67; // [sp+60h] [bp-54h]@31 - POINT a2; // [sp+68h] [bp-4Ch]@9 - POINT v69; // [sp+70h] [bp-44h]@31 - POINT v70; // [sp+78h] [bp-3Ch]@9 - POINT v71; // [sp+80h] [bp-34h]@31 - POINT v72; // [sp+88h] [bp-2Ch]@10 - //bool v73; // [sp+90h] [bp-24h]@53 - int v74; // [sp+94h] [bp-20h]@53 + POINT cursor; // [sp+40h] [bp-74h]@37 int a6; // [sp+98h] [bp-1Ch]@57 int a3; // [sp+9Ch] [bp-18h]@53 - //Player *v77; // [sp+A0h] [bp-14h]@1 unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 unsigned int v79; // [sp+A8h] [bp-Ch]@9 - int v80; // [sp+ACh] [bp-8h]@12 - ItemGen *_this; // [sp+B0h] [bp-4h]@13 - - v0 = pPlayers[uActiveCharacter]; - //v77 = pPlayers[uActiveCharacter]; + int uPriceItemService; // [sp+ACh] [bp-8h]@12 + if ( pCurrentScreen == SCREEN_E ) { sub_421EA6_OnInventoryLeftClick(); @@ -996,34 +933,29 @@ } case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: { - v17 = pMouse->GetCursorPos(&v63); - v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF; + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF; if ( !v18 ) return; - v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); - v21 = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - _this = v20; - v22 = v20->GetValue(); - v23 = pPlayers[uActiveCharacter]->GetBuyingPrice(v22, v21); - v80 = v23; + bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); + pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); GetAsyncKeyState(VK_CONTROL); - if ( pParty->uNumGold < v23 ) - { - v24 = 2; - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24); + if ( pParty->uNumGold < uPriceItemService ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); return; } - v25 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v20->uItemID); - if ( v25 ) - { - v26 = 1; - v20->SetIdentified(); - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v25-1], v20, 0x24u); - dword_F8B1E4 = v26; - Party::TakeGold(v80); - viewparams->bRedrawGameUI = v26; - _this->Reset(); + taken_item = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID); + if ( taken_item ) + { + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; @@ -1034,17 +966,15 @@ } case HOUSE_DIALOGUE_SHOP_SELL: { - v14 = pMouse->GetCursorPos(&v71)->x - 14; - v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&v67)->x <= 13 - || pMouse->GetCursorPos(&v65)->x >= 462 + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x <= 13 + || pMouse->GetCursorPos(&cursor)->x >= 462 || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) ) return; - v16 = window_SpeakInHouse; - if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) ) + if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) ) { dword_F8B1E4 = 1; - pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)v16->ptr_1C); + pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); viewparams->bRedrawGameUI = 1; pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); @@ -1056,33 +986,29 @@ } case HOUSE_DIALOGUE_SHOP_IDENTIFY: { - pMouse->GetCursorPos(&v62); - v10 = v62.x - 14; - v79 = (v10 >> 5) + 14 * ((v62.y - 17) >> 5); - if (v62.x > 13 && v62.x < 462) - { - v11 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); - if ( v11 ) - { - //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]); - v80 = pPlayers[uActiveCharacter]->_4B8179(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); - v12 = (int)&pPlayers[uActiveCharacter]->pInventoryItems[v11-1]; - if ( !(*(char *)(v12 + 20) & 1) ) - { - _this = (ItemGen *)window_SpeakInHouse->ptr_1C; - if ( MerchandiseTest((ItemGen *)v12, (int)_this) ) + pMouse->GetCursorPos(&cursor); + v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); + if (cursor.x > 13 && cursor.x < 462) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + if ( !(item->uAttributes & 1) ) + { + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) { - if ( pParty->uNumGold >= v80 ) + if ( pParty->uNumGold >= uPriceItemService ) { dword_F8B1E4 = 1; - Party::TakeGold(v80); - *(int *)(v12 + 20) |= 1u; + Party::TakeGold(uPriceItemService); + item->uAttributes |= 1; pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); - v9 = pGlobalTXT_LocalizationStrings[569]; - ShowStatusBarString(v9, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); return; } - PlayHouseSound((unsigned int)_this, (HouseSoundID)2); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); @@ -1097,41 +1023,34 @@ } case HOUSE_DIALOGUE_SHOP_REPAIR: { - v1 = pMouse->GetCursorPos(&a2)->x - 14; - v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&v60)->x > 13 ) - { - if ( pMouse->GetCursorPos(&v72)->x < 462 ) - { - v2 = v0->GetItemIDAtInventoryIndex((int *)&v79); - if ( v2 ) - { - v3 = (int)&v0->pInventoryItems[v2-1]; - //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]; - v4 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1]; - v5 = _v->GetValue(); - v6 = pPlayers[uActiveCharacter]->_4B81C3(v5, v4); - v7 = (*(char *)(v3 + 20) & 2) == 0; - v80 = v6; - if ( !v7 ) + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x > 13 ) + { + if ( pMouse->GetCursorPos(&cursor)->x < 462 ) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); + if ( item->uAttributes & 2 ) { - _this = (ItemGen *)window_SpeakInHouse->ptr_1C; - if ( MerchandiseTest((ItemGen *)v3, (int)_this) ) + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) { - if ( pParty->uNumGold >= v80 ) + if ( pParty->uNumGold >= uPriceItemService ) { dword_F8B1E4 = 1; - Party::TakeGold(v80); - v8 = *(int *)(v3 + 20); + Party::TakeGold(uPriceItemService); + v8 = item->uAttributes; LOBYTE(v8) = v8 & 0xFD; - *(int *)(v3 + 20) = v8 | 1; + item->uAttributes = v8 | 1; pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); - v9 = pGlobalTXT_LocalizationStrings[570]; - ShowStatusBarString(v9, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); return; } - PlayHouseSound((unsigned int)_this, (HouseSoundID)2); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); @@ -1148,42 +1067,25 @@ case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { - v28 = pMouse->GetCursorPos(&v59); - v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[v28->y]] & 0xFFFF; - if ( !v29 ) + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; + if ( !v18 ) return; - v30 = window_SpeakInHouse->ptr_1C; - // v31 = 9 * (v29 - 1 + 12 * (int)v30); if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - { - v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1]; - _this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1]; - } + bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; else - { - _this =&pParty->SpecialItemsInShops[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724]; - v32 = &pParty->SpecialItemsInShops[(int)v30][v29-1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; - } - //v33 = p2DEvents_minus1__20[13 * (signed int)v30]; - //v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier; - //v34 = v32->GetValue(); - v80 = pPlayers[uActiveCharacter]->GetBuyingPrice(v32->GetValue(), p2DEvents[(unsigned int)v30 - 1].fPriceMultiplier); - //LOWORD(v35) = GetAsyncKeyState(VK_CONTROL); - v74 = GetAsyncKeyState(VK_CONTROL); - //v36 = v0->CanSteal(); + bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); uNumSeconds = 0; a3 = 0; - //v73 = v0->CanSteal(); - v37 = pMapStats->GetMapInfo(pCurrentMapName); - if ( v37 ) - a3 = pMapStats->pInfos[v37]._steal_perm; - v38 = GetPartyReputation(); - v26 = 1; + if ( pMapStats->GetMapInfo(pCurrentMapName) ) + a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm; + party_reputation = GetPartyReputation(); if (pPlayers[uActiveCharacter]->CanSteal()) { - if ( v74 ) - { - uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(v32, a3, v38, 0, &a6); + if ( GetAsyncKeyState(VK_CONTROL) ) + { + uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); if ( !uNumSeconds ) { sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); @@ -1191,56 +1093,49 @@ } } } - if ( pParty->uNumGold < v80 ) - { - v24 = 2; + if ( pParty->uNumGold < uPriceItemService ) + { if ( uNumSeconds != 2 ) { if ( uNumSeconds != 1 ) { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" return; } } } - v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v32->uItemID); + v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID); if ( v39 ) { - v32->SetIdentified(); - v7 = pPlayers[uActiveCharacter]->CanSteal(); - //v40 = (int)((char *)v0 + 36 * v39); - //memcpy((void *)(v40 + 496), v32, 0x24u); - memcpy(&v0->pInventoryItems[v39 - 1], v32, sizeof(ItemGen)); - if ( v7 ) - { - if ( v74 ) - { - v41 = uNumSeconds; + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen)); + if ( pPlayers[uActiveCharacter]->CanSteal() ) + { + if ( GetAsyncKeyState(VK_CONTROL) ) + { if ( uNumSeconds == 1 || uNumSeconds == 2 ) { - //*(char *)(v40 + 517) |= 1u; pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen(); - sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6); - viewparams->bRedrawGameUI = v26; - _this->Reset(); + sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } } } - dword_F8B1E4 = v26; - Party::TakeGold(v80); - viewparams->bRedrawGameUI = v26; - _this->Reset(); + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); pRenderer->ClearZBuffer(0, 479); pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" - ShowStatusBarString(v9, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" break; } default:// if click video screen in shop @@ -1251,15 +1146,15 @@ v42 = dialog_menu_id - 36; //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); - v44 = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; - if ( v44 < v43 / 3 ) - v44 = v43 / 3; + uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( uPriceItemService < v43 / 3 ) + uPriceItemService = v43 / 3; if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) { pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; if ( !*pSkill ) { - if ( pParty->uNumGold < v44 ) + if ( pParty->uNumGold < uPriceItemService ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" if ( in_current_building_type == BildingType_Training ) @@ -1269,7 +1164,7 @@ PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); return; } - Party::TakeGold(v44); + Party::TakeGold(uPriceItemService); dword_F8B1E4 = 1; *pSkill = 1; pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); @@ -9466,7 +9361,7 @@ int v1; // ecx@1 unsigned int v2; // edi@1 unsigned int v3; // edx@4 - unsigned int v4; // esi@5 + unsigned int pSkillType; // esi@5 unsigned __int16 v5; // ax@7 unsigned int v6; // edi@19 int v7; // esi@27 @@ -9508,24 +9403,24 @@ unsigned int v50; // [sp+38h] [bp-14h]@50 int v51; // [sp+3Ch] [bp-10h]@1 unsigned int v52; // [sp+40h] [bp-Ch]@5 - int v53; // [sp+44h] [bp-8h]@1 - unsigned int v54; // [sp+48h] [bp-4h]@1 + //int v53; // [sp+44h] [bp-8h]@1 + //unsigned int v54; // [sp+48h] [bp-4h]@1 v51 = 0; _this.Reset(); //v0 = pPlayers[uActiveCharacter]; v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; - v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; - v53 = v1; - if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uEquipType == 1 ) + //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; + //v53 = v1; + if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) v51 = v1; v3 = pParty->pPickedItem.uItemID; if ( pParty->pPickedItem.uItemID ) { v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; - v4 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; - if ( v4 == 4 ) + pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; + if ( pSkillType == 4 ) { if ( v2 ) { @@ -9540,7 +9435,7 @@ } else { - if ( (v4 == 8 || v4 == 1 || v4 == 2) + if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) && v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) { @@ -9575,7 +9470,7 @@ case 8u: case 9u: case 0xBu: - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; @@ -9637,21 +9532,21 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( v54 ) - { - --v54; + if ( v2 ) + { + --v2; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v54); + v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); *(char *)(v12 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v12 + 532)); _this.uBodyAnchor = 1; - v13 = v54 + 1; + v13 = v2 + 1; v14 = v51 == 0; memcpy((void *)(v12 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uShield = v13; @@ -9673,7 +9568,7 @@ return; } memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v53 - 1)); + v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); *(char *)(v15 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v15 + 532)); @@ -9693,14 +9588,14 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } v50 = 0; - if ( v4 == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) - || v4 == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) + if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) + || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) { if (pAsyncMouse) { @@ -9717,16 +9612,16 @@ { if ( !v51 ) { - if ( v54 ) + if ( v2 ) { - --v54; + --v2; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v54); + v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); *(char *)(v20 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v20 + 532)); _this.uBodyAnchor = 1; - v21 = v54 + 1; + v21 = v2 + 1; v14 = v52 == 12; memcpy((void *)(v20 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uShield = v21; @@ -9737,9 +9632,7 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), - uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; } @@ -9758,14 +9651,13 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; } } } - if ( !v53 ) + if ( !v1 ) { v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); if ( (v26 & 0x80000000u) != 0 ) @@ -9782,20 +9674,18 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), - uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; } - --v53; + --v1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v53); + v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); *(char *)(v24 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v24 + 532)); _this.uBodyAnchor = 2; - v25 = v53 + 1; + v25 = v1 + 1; v14 = v52 == 12; memcpy((void *)(v24 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; @@ -9806,9 +9696,7 @@ if ( v50 ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( - *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), - uActiveCharacter - 1 + 9); + stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; case 1u: @@ -9817,26 +9705,26 @@ pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(v4) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( v53 ) - { - if ( v54 ) + if ( v1 ) + { + if ( v2 ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - --v53; + --v1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v53); + v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); *(char *)(v27 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v27 + 532)); _this.uBodyAnchor = 2; - v28 = v53 + 1; + v28 = v1 + 1; memcpy((void *)(v27 + 532), &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; } @@ -9845,10 +9733,10 @@ v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); if ( (v52 & 0x80000000u) == 0 ) { - if ( v54 ) + if ( v2 ) { memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v54 - 1)); + v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); *(char *)(v29 + 556) = 0; pParty->pPickedItem.Reset(); pParty->SetHoldingItem((ItemGen *)(v29 + 532)); @@ -9936,7 +9824,7 @@ v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; if ( v35 ) { - auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35-1]; + auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; pParty->SetHoldingItem(_a); _a->Reset(); pPlayers[uActiveCharacter]->pEquipment.uBow = 0; diff -r 47bbd8969f53 -r befaac4bc0e3 mm7_4.cpp --- a/mm7_4.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/mm7_4.cpp Sat Apr 27 09:37:22 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; @@ -3768,7 +3768,7 @@ { v32 = *v26; v33 = a3->GetValue(); - v29 = pPlayer->_4B81C3(v33, v32); + v29 = pPlayer->GetPriceRepair(v33, v32); } else { @@ -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) @@ -3792,7 +3792,7 @@ v34 = *v26; v48 = v34; - v29 = pPlayer->_4B8179(v48); + v29 = pPlayer->GetPriceIdentification(v48); goto _continue_sprintf; } @@ -3808,7 +3808,7 @@ //v34 = p2DEvents_minus1__20[13 * (signed int)a4]; v34 = p2DEvents[(signed int)a4 - 1].fPriceMultiplier; v48 = v34; - v29 = pPlayer->_4B8179(v48); + v29 = pPlayer->GetPriceIdentification(v48); goto _continue_sprintf; } diff -r 47bbd8969f53 -r befaac4bc0e3 mm7_5.cpp --- a/mm7_5.cpp Sat Apr 27 09:37:09 2013 +0600 +++ b/mm7_5.cpp Sat Apr 27 09:37:22 2013 +0600 @@ -56,8 +56,8 @@ //NPCData *pNPCData0; // eax@18 //int v6; // edx@20 //int v7; // ecx@29 - unsigned int v8; // edx@59 - unsigned int v9; // ecx@60 + //unsigned int v8; // edx@59 + //unsigned int v9; // ecx@60 unsigned int v10; // ecx@73 //unsigned int v11; // eax@75 unsigned __int8 v12; // sf@75 @@ -127,8 +127,8 @@ int v76; // esi@535 int v77; // eax@537 Player *pPlayer2; // ecx@549 - int v79; // ecx@550 - unsigned int v80; // edx@550 + //int v79; // ecx@550 + //unsigned int v80; // edx@550 signed int v81; // eax@552 POINT *pPoint2; // eax@553 signed int v83; // ecx@554 @@ -137,14 +137,14 @@ unsigned int v86; // eax@583 const char *v87; // ecx@595 const char *v88; // ecx@596 - unsigned int v89; // eax@598 + //unsigned int v89; // eax@598 unsigned int v90; // eax@602 int v91; // edx@605 int v92; // eax@605 int v93; // edx@605 int pPlayerNum; // edx@611 int v95; // eax@611 - const char *v96; // ecx@621 + //const char *v96; // ecx@621 unsigned int v97; // eax@624 int v98; // eax@636 unsigned __int8 v99; // al@643 @@ -178,42 +178,42 @@ int v127; // [sp-1Ch] [bp-618h]@107 unsigned int v128; // [sp-1Ch] [bp-618h]@711 int v129; // [sp-18h] [bp-614h]@86 - signed int v130; // [sp-18h] [bp-614h]@107 + //signed int v130; // [sp-18h] [bp-614h]@107 int v131; // [sp-14h] [bp-610h]@86 - unsigned int v132; // [sp-14h] [bp-610h]@107 - unsigned int v133; // [sp-10h] [bp-60Ch]@60 + //unsigned int v132; // [sp-14h] [bp-610h]@107 + //unsigned int v133; // [sp-10h] [bp-60Ch]@60 unsigned int v134; // [sp-10h] [bp-60Ch]@86 - signed int v135; // [sp-10h] [bp-60Ch]@107 + //signed int v135; // [sp-10h] [bp-60Ch]@107 unsigned int v136; // [sp-10h] [bp-60Ch]@121 - unsigned int v137; // [sp-Ch] [bp-608h]@60 + //unsigned int v137; // [sp-Ch] [bp-608h]@60 unsigned int v138; // [sp-Ch] [bp-608h]@86 - signed int v139; // [sp-Ch] [bp-608h]@107 + //signed int v139; // [sp-Ch] [bp-608h]@107 unsigned int v140; // [sp-Ch] [bp-608h]@121 enum WindowType pWindowType; // [sp-8h] [bp-604h]@56 - enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60 + //enum WindowType pWindowType1; // [sp-8h] [bp-604h]@60 unsigned __int8 v143; // [sp-8h] [bp-604h]@86 - int v144; // [sp-8h] [bp-604h]@107 + //int v144; // [sp-8h] [bp-604h]@107 enum WindowType pWindowType2; // [sp-8h] [bp-604h]@121 - const char *v146; // [sp-8h] [bp-604h]@449 - unsigned int v147; // [sp-8h] [bp-604h]@550 + //const char *v146; // [sp-8h] [bp-604h]@449 + //unsigned int v147; // [sp-8h] [bp-604h]@550 //int v148; // [sp-4h] [bp-600h]@56 GUIButton *pButton2; // [sp-4h] [bp-600h]@59 const char *v150; // [sp-4h] [bp-600h]@86 - unsigned int v151; // [sp-4h] [bp-600h]@107 + //unsigned int v151; // [sp-4h] [bp-600h]@107 int v152; // [sp-4h] [bp-600h]@121 int v153; // [sp-4h] [bp-600h]@135 int v154; // [sp-4h] [bp-600h]@149 int v155; // [sp-4h] [bp-600h]@165 int v156; // [sp-4h] [bp-600h]@204 - const char *v157; // [sp-4h] [bp-600h]@444 + //const char *v157; // [sp-4h] [bp-600h]@444 unsigned int v158; // [sp-4h] [bp-600h]@449 - __int16 v159; // [sp-4h] [bp-600h]@550 + //__int16 v159; // [sp-4h] [bp-600h]@550 int v160; // [sp-4h] [bp-600h]@599 const char *v161; // [sp-4h] [bp-600h]@637 //int v162; // [sp+0h] [bp-5FCh]@56 - int v163; // [sp+0h] [bp-5FCh]@59 + //int v163; // [sp+0h] [bp-5FCh]@59 Texture *pTexture; // [sp+0h] [bp-5FCh]@86 - int v165; // [sp+0h] [bp-5FCh]@107 + //int v165; // [sp+0h] [bp-5FCh]@107 int v166; // [sp+0h] [bp-5FCh]@121 int v167; // [sp+0h] [bp-5FCh]@135 int v168; // [sp+0h] [bp-5FCh]@149 @@ -223,7 +223,7 @@ KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287 char *v173; // [sp+0h] [bp-5FCh]@444 char *v174; // [sp+0h] [bp-5FCh]@449 - int v175; // [sp+0h] [bp-5FCh]@550 + //int v175; // [sp+0h] [bp-5FCh]@550 int v176; // [sp+0h] [bp-5FCh]@599 const char *v177; // [sp+0h] [bp-5FCh]@629 char *v178; // [sp+0h] [bp-5FCh]@637 @@ -1248,7 +1248,7 @@ } } break; - case SCREEN_REST: + case SCREEN_REST://close rest screen if ( dword_506F14 ) { Rest(_506F18_num_hours_to_sleep); @@ -1749,10 +1749,8 @@ if ( v45 == 3 ) { v47 = pActors[v46].uAIState == Dead; - //goto LABEL_400; if ( !v47 ) continue; - //goto LABEL_415; v51 = pGUIWindow_Settings->ptr_1C; *((char *)v51 + 8) &= 0xBFu; *((short *)v51 + 2) = uMessageParam; @@ -1770,10 +1768,8 @@ if ( v45 == 2 ) { v47 = (pObjectList->pObjects[pSpriteObjects[v46].uObjectDescID].uFlags & 0x10) == 0; -//LABEL_400: if ( !v47 ) continue; - //goto LABEL_415; v51 = pGUIWindow_Settings->ptr_1C; *((char *)v51 + 8) &= 0xBFu; *((short *)v51 + 2) = uMessageParam; @@ -1924,16 +1920,11 @@ continue; case UIMSG_B2: - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; + __debugbreak;//UIMSG_B2 -??? bRecallingBeacon = uMessageParam; - v135 = -1; - v132 = 0; - v130 = 0; v127 = uMessageParam + 204; - goto _play_sound_and_continue; + pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); + continue; case UIMSG_B4: if ( !pGUIWindow_CurrentMenu ) continue; @@ -1944,8 +1935,9 @@ if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) ) continue; v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName; - v157 = pGlobalTXT_LocalizationStrings[474];// "Recall to %s" - goto _sprintex_2args_draw_status_and_continue; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s" + sub_41C0B8_set_status_string(pTmpBuf); + continue; } v59 = pMapStats->GetMapInfo(pCurrentMapName); thise = "Not in Map Stats"; @@ -1953,18 +1945,17 @@ thise = pMapStats->pInfos[v59].pName; if ( !*((int *)&pSavegameThumbnails->pPixels + 10 * uMessageParam) || !v59 ) { - v173 = thise; - v157 = pGlobalTXT_LocalizationStrings[476];// "Set to %s" - goto _sprintex_2args_draw_status_and_continue; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[476], thise);// "Set to %s" + sub_41C0B8_set_status_string(pTmpBuf); + continue; } v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; v158 = (unsigned int)thise; - v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s" -//_sprintex_draw_status_and_continue: - sprintf(pTmpBuf, v146, v158, v174); + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[475], v158, v174);// "Set %s over %s" sub_41C0B8_set_status_string(pTmpBuf); continue; case UIMSG_B5: + __debugbreak;//UIMSG_B5 - ??? dword_50CDC8 = v0; //goto LABEL_453; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); @@ -2179,9 +2170,9 @@ default: if ( uMessageParam != 5 ) { - v173 = v200; - v157 = pGlobalTXT_LocalizationStrings[35]; - goto _sprintex_2args_draw_status_and_continue; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v200); + sub_41C0B8_set_status_string(pTmpBuf); + continue; } v69 = pMapStats->pInfos[8].pName; break; @@ -2191,10 +2182,9 @@ { v69 = pMapStats->pInfos[21].pName; } - v200 = v69; - v173 = v200; - v157 = pGlobalTXT_LocalizationStrings[35]; - goto _sprintex_2args_draw_status_and_continue; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v69); + sub_41C0B8_set_status_string(pTmpBuf); + continue; } v68 = 210; break; @@ -2230,9 +2220,9 @@ if ( uMessageParam != 5 ) //goto LABEL_519; { - v173 = v200; - v157 = pGlobalTXT_LocalizationStrings[35]; - goto _sprintex_2args_draw_status_and_continue; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v200); + sub_41C0B8_set_status_string(pTmpBuf); + continue; } v69 = pMapStats->pInfos[8].pName; break; @@ -2242,11 +2232,9 @@ { v69 = pMapStats->pInfos[21].pName; } - v200 = v69; -//LABEL_519: - v173 = v200; - v157 = pGlobalTXT_LocalizationStrings[35]; - goto _sprintex_2args_draw_status_and_continue; + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[35], v69); + sub_41C0B8_set_status_string(pTmpBuf); + continue; case UIMSG_ShowFinalWindow: sprintf(pFinalMessage, "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." @@ -2255,10 +2243,12 @@ uGameState = GAME_STATE_FINAL_WINDOW; continue; case UIMSG_C4: + __debugbreak; uGameState = 0; strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2"); goto LABEL_524; case UIMSG_DD: + __debugbreak; LABEL_524: sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer); memcpy(&v216, txt_file_frametable_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216)); @@ -2499,24 +2489,12 @@ _42ECB5_PlayerAttacksActor(); continue; case UIMSG_ExitRest: - v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest" - pButton = pButton_RestUI_Exit; - pButton2 = pButton_RestUI_Exit; - pWindowType1 = (WindowType)96; - //goto LABEL_731; - v8 = pButton->uY; - v9 = pButton->uX; - //goto LABEL_732; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, (WindowType)96, (int)pButton_RestUI_Exit, (int)pGlobalTXT_LocalizationStrings[81]);// "Exit Rest" continue; case UIMSG_Wait5Minutes: if ( dword_506F14 == 2 ) - //goto LABEL_621; - { - v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!" - ShowStatusBarString(v96, 2); + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); continue; } @@ -2527,10 +2505,8 @@ continue; case UIMSG_Wait1Hour: if ( dword_506F14 == 2 ) - //goto LABEL_621; - { - v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!" - ShowStatusBarString(v96, 2); + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); continue; } @@ -2546,7 +2522,6 @@ _506F18_num_hours_to_sleep = v86; if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) _506F18_num_hours_to_sleep = v86 + 720; - //goto LABEL_615; dword_506F14 = 2; pParty->RestAndHeal(); pParty->days_played_without_rest = 0; @@ -2561,34 +2536,28 @@ if ( pCurrentScreen ) continue; if ( sub_42F4DA() ) - //goto LABEL_594; { if ( pParty->bTurnBasedModeOn == v0 ) { - v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!" - ShowStatusBarString(v87, 2u); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" continue; } v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!" if ( pParty->uFlags & 0x88 ) v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!" - ShowStatusBarString(v88, 2u); - v89 = uActiveCharacter; + ShowStatusBarString(v88, 2); if ( !uActiveCharacter ) { v1 = ""; v0 = 1; continue; } - v176 = 0; - v160 = 13; - goto LABEL_619; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0); + continue; } if ( pParty->bTurnBasedModeOn == v0 ) - //goto LABEL_595; - { - v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!" - ShowStatusBarString(v87, 2u); + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" continue; } if ( !(pParty->uFlags & 0x88) ) @@ -2596,36 +2565,27 @@ RestUI_Initialize(); continue; } -//LABEL_594: if ( pParty->bTurnBasedModeOn == v0 ) { -//LABEL_595: - v87 = pGlobalTXT_LocalizationStrings[478];// "You can't rest in turn-based mode!" - //goto _draw_status_string_and_continue; - ShowStatusBarString(v87, 2u); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" continue; } v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!" if ( pParty->uFlags & 0x88 ) v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!" ShowStatusBarString(v88, 2u); - v89 = uActiveCharacter; if ( !uActiveCharacter ) - //goto LABEL_90; { v1 = ""; v0 = 1; continue; } - v176 = 0; - v160 = 13; - goto LABEL_619; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0); + continue; case UIMSG_Rest8Hour: if ( dword_506F14 ) - //goto LABEL_621; - { - v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!" - ShowStatusBarString(v96, 2); + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); continue; } @@ -2633,13 +2593,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest" if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() ) - { - v89 = uActiveCharacter; - v176 = 0; - v160 = SPEECH_108; -LABEL_619: - pPlayers[v89]->PlaySound((PlayerSpeech)v160, v176); - } + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_108, 0); } else { @@ -2679,21 +2633,13 @@ ++pMessageQueue_50CBD0->uNumMessages; }*/ pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!" - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; - v130 = 0; - v127 = 227; - goto _play_sound_and_continue; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2);// "Encounter!" + pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0); + continue; } } Party::TakeFood(uRestUI_FoodRequiredToRest); _506F18_num_hours_to_sleep = 480; -//LABEL_615: dword_506F14 = 2; pParty->RestAndHeal(); pParty->days_played_without_rest = 0; @@ -2706,9 +2652,7 @@ case UIMSG_AlreadyResting: if ( dword_506F14 == 2 ) { -//LABEL_621: - v96 = pGlobalTXT_LocalizationStrings[477];// "You are already resting!" - ShowStatusBarString(v96, 2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); continue; } @@ -2719,12 +2663,11 @@ _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute; continue; case UIMSG_4E: + __debugbreak;//UIMSG_4E -??? if ( quick_spell_at_page && byte_506550 ) { v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName; - v157 = pGlobalTXT_LocalizationStrings[483]; -_sprintex_2args_draw_status_and_continue: - sprintfex(pTmpBuf, v157, v173); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[483], v173); } else { @@ -2734,7 +2677,6 @@ v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell" strcpy(pTmpBuf, v177); } -//_set_status_string_pTmpBuf_and_continue: sub_41C0B8_set_status_string(pTmpBuf); continue; case UIMSG_SPellbook_ShowHightlightedSpellInfo: @@ -2756,27 +2698,20 @@ } sprintfex(pTmpBuf, v161, v178); sub_41C0B8_set_status_string(pTmpBuf); - //goto LABEL_91; v0 = 1; continue; case UIMSG_58: + __debugbreak;//UIMSG_58 - ??? GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, WINDOW_5A, (int)pBtn_InstallRemoveSpell, 0); if ( !uActiveCharacter ) continue; pPlayer10 = pPlayers[uActiveCharacter]; if ( !byte_506550 || !quick_spell_at_page ) { - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; pPlayer10->uQuickSpell = 0; - v130 = 0; quick_spell_at_page = 0; - v127 = 203; - goto _play_sound_and_continue; + pAudioPlayer->PlaySound((SoundID)203, 0, 0, -1, 0, 0, 0, 0); + continue; } v99 = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage; pPlayers[uActiveCharacter]->uQuickSpell = v99; @@ -2786,6 +2721,7 @@ byte_506550 = 0; continue; case UIMSG_33: + __debugbreak;//UIMSG_33 - ??? if ( !uActiveCharacter ) continue; pPlayer3 = pPlayers[uActiveCharacter]; @@ -2809,15 +2745,9 @@ while ( v101 < 9 ); if ( !pNPCData4 ) { - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; - v130 = 0; v127 = rand() % 2 + 204; - goto _play_sound_and_continue; + pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); + continue; } if ( GetAsyncKeyState(16) ) { @@ -2834,30 +2764,18 @@ sub_41140B(); pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]); pGUIWindow_CurrentMenu->OpenSpellBook(); - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; - v130 = 0; v127 = rand() % 2 + 204; - goto _play_sound_and_continue; + pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); + continue; case UIMSG_OpenSpellbookPage: if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage ) continue; sub_41140B(); pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam; pGUIWindow_CurrentMenu->OpenSpellBook(); - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; - v130 = 0; v127 = rand() % 2 + 204; - goto _play_sound_and_continue; + pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); + continue; case UIMSG_SelectSpell: { if (pTurnEngine->field_4 == 3) @@ -2901,17 +2819,9 @@ continue; case UIMSG_92: + __debugbreak;//UIMSG_92 - ??? if ( pTurnEngine->field_4 != 3 ) - { - v175 = 0; - v159 = v0; - v147 = 133; -//LABEL_678: - v80 = v199; - v79 = uMessageParam; -//LABEL_679: - _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175); - } + _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 133, v0, 0); continue; case UIMSG_SpellBookWindow: if ( pTurnEngine->field_4 == 3 ) @@ -2919,16 +2829,7 @@ if ( bUnderwater == 1 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2);// "You can not do that while you are underwater!" - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; - v130 = 0; - v127 = 27; -_play_sound_and_continue: - pAudioPlayer->PlaySound((SoundID)v127, v130, v132, v135, v139, v144, v151, v165); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); } else { @@ -2953,7 +2854,6 @@ || pCurrentScreen > SCREEN_67) ) { pGUIWindow_CurrentMenu->Release(); -//LABEL_693: GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, WINDOW_5A, (int)pBtn_CastSpell, 0); pCurrentScreen = SCREEN_SPELL_BOOK; pEventTimer->Pause(); @@ -3010,18 +2910,19 @@ pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; case UIMSG_C0: + __debugbreak;//UIMSG_C0 - ??? dword_50651C = v0; if ( pMouse->GetCursorPos(&v211)->y > 178 ) dword_50651C = -1; continue; case UIMSG_A9: + __debugbreak; GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_5B, (int)pBtn_Up, 0); -//LABEL_707: dword_506548 = v0; continue; case UIMSG_AA: + __debugbreak; GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, WINDOW_5B, (int)pBtn_Down, 0); -//LABEL_709: dword_506544 = v0; continue; case UIMSG_ChangeDetaliz: @@ -3052,37 +2953,19 @@ OnPaperdollLeftClick(); continue; case UIMSG_73: + __debugbreak; pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; sub_4196A0(); sub_419379(); - pButton = pCharacterScreen_StatsBtn; - //goto LABEL_716; - v163 = 0; - pButton2 = pButton; - pWindowType1 = (WindowType)91; - v8 = pButton->uY; - v9 = pButton->uX; - //goto LABEL_732; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(pCharacterScreen_StatsBtn->uX, pCharacterScreen_StatsBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_StatsBtn, 0); continue; case UIMSG_72: + __debugbreak; pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101; sub_4196A0(); sub_419379(); CharacterUI_SkillScreen_Draw(); - pButton = pCharacterScreen_SkillsBtn; - //goto LABEL_716; - v163 = 0; - pButton2 = pButton; - pWindowType1 = (WindowType)91; - v8 = pButton->uY; - v9 = pButton->uX; - //goto LABEL_732; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(pCharacterScreen_SkillsBtn->uX, pCharacterScreen_SkillsBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_SkillsBtn, 0); continue; case UIMSG_SkillUp: pPlayer4 = pPlayers[uActiveCharacter]; @@ -3100,52 +2983,26 @@ *(short *)v105 = uNumSeconds + 1; pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F; pPlayer4->PlaySound(SPEECH_14, 0); - v165 = 0; - v151 = 0; - v144 = 0; - v139 = 0; - v135 = -1; - v132 = 0; - v130 = 0; - v127 = 20001; - goto _play_sound_and_continue; + pAudioPlayer->PlaySound((SoundID)20001, 0, 0, -1, 0, 0, 0, 0); + continue; } v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!" } -//_draw_status_string_and_continue: - ShowStatusBarString(v87, 2u); + ShowStatusBarString(v87, 2); continue; case UIMSG_74: + __debugbreak; pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; sub_419379(); sub_4196A0(); - pButton = pCharacterScreen_InventoryBtn; -//LABEL_716: - v163 = 0; - pButton2 = pButton; - pWindowType1 = (WindowType)91; - //goto LABEL_731; - v8 = pButton->uY; - v9 = pButton->uX; - //goto LABEL_732; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(pCharacterScreen_InventoryBtn->uX, pCharacterScreen_InventoryBtn->uY, 0, 0, (WindowType)91, (int)pCharacterScreen_InventoryBtn, 0); continue; case UIMSG_A8: - pButton = pCharacterScreen_ExitBtn; - v163 = 0; - pButton2 = pCharacterScreen_ExitBtn; - pWindowType1 = (WindowType)97; - //goto LABEL_731; - v8 = pButton->uY; - v9 = pButton->uX; - //goto LABEL_732; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + __debugbreak; + GUIWindow::Create(pCharacterScreen_ExitBtn->uX, pCharacterScreen_ExitBtn->uY, 0, 0, (WindowType)97, (int)pCharacterScreen_ExitBtn, 0); continue; case UIMSG_75: + __debugbreak; sub_419379(); sub_4196A0(); sub_419220(); @@ -3160,11 +3017,9 @@ default: continue; case 11: - //goto LABEL_707; dword_506548 = v0; continue; case 10: - //goto LABEL_709; dword_506544 = v0; continue; case 0: @@ -3208,16 +3063,7 @@ dword_50652C = v0; break; } - v163 = v0; - pButton2 = pButton; - pWindowType1 = (WindowType)92; -//LABEL_731: - v8 = pButton->uY; - v9 = pButton->uX; - //goto LABEL_732; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (WindowType)92, (int)pButton, v0); continue; case UIMSG_SelectCharacter: if ( pMessageQueue_50CBD0->uNumMessages ) @@ -3227,9 +3073,7 @@ case UIMSG_ShowStatus_Funds: v174 = (char *)pParty->uNumGoldInBank; v158 = pParty->uNumGold + pParty->uNumGoldInBank; - v146 = pGlobalTXT_LocalizationStrings[489];// "You have %d total gold, %d in the Bank"" - //goto _sprintex_draw_status_and_continue; - sprintfex(pTmpBuf, v146, v158, v174); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[489], v158, v174);// "You have %d total gold, %d in the Bank" sub_41C0B8_set_status_string(pTmpBuf); continue; case UIMSG_ShowStatus_DateTime: @@ -3275,6 +3119,7 @@ sub_41C0B8_set_status_string(pTmpBuf); continue; case UIMSG_C: + __debugbreak; if ( pCurrentScreen == SCREEN_F ) { sub_421EA6_OnInventoryLeftClick(); @@ -3286,8 +3131,8 @@ sub_421EA6_OnInventoryLeftClick(); continue; case UIMSG_A: + __debugbreak; if ( !pRenderer->pRenderD3D ) - //goto LABEL_772; { if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; @@ -3337,11 +3182,13 @@ }*/ continue; case UIMSG_E: + __debugbreak; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; OnGameViewportClick(); continue; case UIMSG_F: + __debugbreak; if ( pRenderer->pRenderD3D ) { LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val(); @@ -3356,6 +3203,7 @@ GUIWindow::Create(0, 0, 0, 0, (WindowType)15, (int)pButton2, 0); continue; case UIMSG_54: + __debugbreak; pButton2 = (GUIButton *)uMessageParam; GUIWindow::Create(0, 0, 0, 0, (WindowType)22, (int)pButton2, 0); continue; @@ -3365,6 +3213,7 @@ OnPressSpace(); continue; case UIMSG_16F: + __debugbreak; if ( pCurrentScreen ) continue; pParty->uFlags |= 2u; @@ -3388,6 +3237,7 @@ viewparams->field_28 = 11; goto LABEL_788; case UIMSG_170: + __debugbreak; if ( pCurrentScreen ) continue; pParty->uFlags |= 2u;