# HG changeset patch # User Ritor1 # Date 1382510965 -21600 # Node ID 05b433b8cb376a717faac5cc3349a81d3901cda0 # Parent 140ca812338463383d117b5c5d2f5e6b7c45cc0a GuildDialog fix and cleared diff -r 140ca8123384 -r 05b433b8cb37 Items.cpp --- a/Items.cpp Wed Oct 23 10:24:38 2013 +0600 +++ b/Items.cpp Wed Oct 23 12:49:25 2013 +0600 @@ -2428,109 +2428,109 @@ } //----- (004B8E3D) -------------------------------------------------------- void GenerateStandartShopItems() - { - signed int item_count; - signed int shop_index; - int treasure_lvl; - int item_class; - int mdf; +{ + signed int item_count; + signed int shop_index; + int treasure_lvl; + int item_class; + int mdf; - shop_index = (signed int)window_SpeakInHouse->ptr_1C; - if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) - { - for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) - { - if (shop_index<=14) //weapon shop - { - treasure_lvl = shopWeap_variation_ord[shop_index].treasure_level; - item_class =shopWeap_variation_ord[shop_index].item_class[rand() % 4]; - } - else if (shop_index<=28) //armor shop - { - mdf =0; - if (item_count > 3) - ++mdf;// rechek offsets - treasure_lvl = shopArmr_variation_ord[2*(shop_index-15)+mdf].treasure_level; - item_class =shopArmr_variation_ord[2*(shop_index-15)+mdf].item_class[rand() % 4]; - } - else if (shop_index<=41) //magic shop - { - treasure_lvl = shopMagic_treasure_lvl[shop_index-28]; - item_class = 22; //misc - } - else if (shop_index<=53) //alchemist shop - { - if (item_count<6) - { - pParty->StandartItemsInShops[shop_index][item_count].Reset(); - pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle - continue; - } - else - { - treasure_lvl = shopAlch_treasure_lvl[shop_index-41]; - item_class = 45; //reagent - } - } - pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->StandartItemsInShops[shop_index][item_count]); - pParty->StandartItemsInShops[shop_index][item_count].SetIdentified(); //identified - } - } - pParty->InTheShopFlags[shop_index] = 0; - } + shop_index = (signed int)window_SpeakInHouse->ptr_1C; + if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) + { + for (item_count = 0; item_count < uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) + { + if (shop_index <= 14) //weapon shop + { + treasure_lvl = shopWeap_variation_ord[shop_index].treasure_level; + item_class = shopWeap_variation_ord[shop_index].item_class[rand() % 4]; + } + else if (shop_index <= 28) //armor shop + { + mdf = 0; + if (item_count > 3) + ++mdf;// rechek offsets + treasure_lvl = shopArmr_variation_ord[2*(shop_index - 15) + mdf].treasure_level; + item_class = shopArmr_variation_ord[2*(shop_index - 15) + mdf].item_class[rand() % 4]; + } + else if (shop_index <= 41) //magic shop + { + treasure_lvl = shopMagic_treasure_lvl[shop_index - 28]; + item_class = 22; //misc + } + else if (shop_index <= 53) //alchemist shop + { + if (item_count < 6) + { + pParty->StandartItemsInShops[shop_index][item_count].Reset(); + pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle + continue; + } + else + { + treasure_lvl = shopAlch_treasure_lvl[shop_index - 41]; + item_class = 45; //reagent + } + } + pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->StandartItemsInShops[shop_index][item_count]); + pParty->StandartItemsInShops[shop_index][item_count].SetIdentified(); //identified + } + } + pParty->InTheShopFlags[shop_index] = 0; +} //----- (004B8F94) -------------------------------------------------------- void GenerateSpecialShopItems() - { - signed int item_count; - signed int shop_index; - int treasure_lvl; - int item_class; - int mdf; +{ + signed int item_count; + signed int shop_index; + int treasure_lvl; + int item_class; + int mdf; - shop_index = (signed int)window_SpeakInHouse->ptr_1C; - if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) - { - for (item_count=0; item_count<=uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) - { - if (shop_index<=14) //weapon shop - { - treasure_lvl = shopWeap_variation_spc[shop_index].treasure_level; - item_class = shopWeap_variation_spc[shop_index].item_class[rand() % 4]; - } - else if (shop_index<=28) //armor shop - { - mdf =0; - if (item_count > 3) - ++mdf; - treasure_lvl = shopArmr_variation_spc[2*(shop_index-15)+mdf].treasure_level; - item_class =shopArmr_variation_spc[2*(shop_index-15)+mdf].item_class[rand() % 4]; - } - else if (shop_index<=41) //magic shop - { - treasure_lvl = shopMagicSpc_treasure_lvl[shop_index-28]; - item_class = 22; //misc - } - else if (shop_index<=53) //alchemist shop - { - if (item_count<6) - { - pParty->SpecialItemsInShops[shop_index][item_count].Reset(); - pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool - continue; - } - else - { - treasure_lvl = shopAlchSpc_treasure_lvl[shop_index-41]; - item_class = 44; //potion - } - } - pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->SpecialItemsInShops[shop_index][item_count]); - pParty->SpecialItemsInShops[shop_index][item_count].SetIdentified(); //identified - } - } - pParty->InTheShopFlags[shop_index] = 0; - } + shop_index = (signed int)window_SpeakInHouse->ptr_1C; + if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) + { + for ( item_count = 0; item_count < uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) + { + if (shop_index <= 14) //weapon shop + { + treasure_lvl = shopWeap_variation_spc[shop_index].treasure_level; + item_class = shopWeap_variation_spc[shop_index].item_class[rand() % 4]; + } + else if (shop_index <= 28) //armor shop + { + mdf = 0; + if (item_count > 3) + ++mdf; + treasure_lvl = shopArmr_variation_spc[2*(shop_index - 15) + mdf].treasure_level; + item_class = shopArmr_variation_spc[2*(shop_index - 15) + mdf].item_class[rand() % 4]; + } + else if (shop_index <= 41) //magic shop + { + treasure_lvl = shopMagicSpc_treasure_lvl[shop_index - 28]; + item_class = 22; //misc + } + else if (shop_index <= 53) //alchemist shop + { + if (item_count < 6) + { + pParty->SpecialItemsInShops[shop_index][item_count].Reset(); + pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool + continue; + } + else + { + treasure_lvl = shopAlchSpc_treasure_lvl[shop_index - 41]; + item_class = 44; //potion + } + } + pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->SpecialItemsInShops[shop_index][item_count]); + pParty->SpecialItemsInShops[shop_index][item_count].SetIdentified(); //identified + } + } + pParty->InTheShopFlags[shop_index] = 0; +} //----- (00450218) -------------------------------------------------------- diff -r 140ca8123384 -r 05b433b8cb37 UI/UIGuilds.cpp --- a/UI/UIGuilds.cpp Wed Oct 23 10:24:38 2013 +0600 +++ b/UI/UIGuilds.cpp Wed Oct 23 12:49:25 2013 +0600 @@ -16,46 +16,20 @@ void GuildDialog() { signed int base_teach_price; // ebx@1 - int v3; // edi@6 - int result; // eax@11 int v6; // esi@13 signed int v7; // esi@17 int v8; // esi@22 - signed int v9; // ecx@22 - char *v10; // eax@22 const char *statusbar_string; // ecx@26 - POINT *v12; // esi@30 int v13; // ecx@30 ItemGen *v15; // ST18_4@31 int v17; // eax@31 char *v18; // edx@31 - int pActiveItem; // esi@35 - int v24; // eax@39 - int v25; // eax@40 int v26; // ecx@47 GUIButton *pButton; // eax@49 int pTextHeight; // eax@55 unsigned __int16 pTextColor; // ax@55 - int v35; // eax@58 - const char *v36; // ST20_4@61 - unsigned __int16 v37; // ST1C_2@61 - int v40; // [sp-14h] [bp-300h]@31 - int v41; // [sp-10h] [bp-2FCh]@31 - unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31 - char *v43; // [sp-8h] [bp-2F4h]@31 - unsigned int v44; // [sp-4h] [bp-2F0h]@31 - char Dest[100]; // [sp+Ch] [bp-2E0h]@3 - char v46[100]; // [sp+70h] [bp-27Ch]@3 - char v47[100]; // [sp+D4h] [bp-218h]@3 - char v48[100]; // [sp+138h] [bp-1B4h]@3 - char v49[100]; // [sp+19Ch] [bp-150h]@3 - POINT v50; // [sp+264h] [bp-88h]@30 - POINT v51; // [sp+26Ch] [bp-80h]@30 + POINT cursor; // [sp+26Ch] [bp-80h]@30 GUIWindow working_window; // [sp+274h] [bp-78h]@1 - signed int v53; // [sp+27Ch] [bp-70h]@1 - signed int v54; // [sp+284h] [bp-68h]@1 - int pColorWhite; // [sp+2CCh] [bp-20h]@1 - int pColorYellow; // [sp+2D0h] [bp-1Ch]@1 int v58; // [sp+2D4h] [bp-18h]@1 bool pSkillFlag; // [sp+2DCh] [bp-10h]@35 int v61; // [sp+2E0h] [bp-Ch]@35 @@ -68,24 +42,17 @@ working_window.uFrameX = 483; working_window.uFrameWidth = 148; working_window.uFrameZ = 334; - pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); - pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu); base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0); pPrice = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; if ( pPrice < base_teach_price / 3 ) pPrice = base_teach_price / 3; - strcpy(Dest, ""); - strcpy(v46, ""); - strcpy(v47, ""); - strcpy(v48, ""); - strcpy(v49, ""); if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN ) { if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, - guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) ) + guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C - 139]) ) { //you must me member pTextHeight = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0); - working_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3); + working_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, TargetColor(0xFFu, 0xFFu, 0x9Bu), pNPCTopics[121].pText, 3); pDialogueWindow->pNumPresenceButton = 0; return; } @@ -97,7 +64,7 @@ strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); - working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); return; } v61 = 0; @@ -128,7 +95,7 @@ strcat(pTmpBuf.data(), "\n \n"); strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); - working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); return; } if ( pSkillFlag ) @@ -151,9 +118,9 @@ pButton->uHeight = pTextHeight; v26 = pButton->uY + pTextHeight - 1; pButton->uW = v26; - pTextColor = pColorYellow; + pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu); if ( pDialogueWindow->pCurrentPosActiveItem != i ) - pTextColor = pColorWhite; + pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu); working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pGlobalTXT_LocalizationStrings[400], 3);//"Buy Spells" } else @@ -166,9 +133,9 @@ pButton->uHeight = pTextHeight; v26 = pButton->uY + pTextHeight - 1; pButton->uW = v26; - pTextColor = pColorYellow; + pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu); if ( pDialogueWindow->pCurrentPosActiveItem != i ) - pTextColor = pColorWhite; + pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu); working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3); } else @@ -211,63 +178,56 @@ if ( HouseUI_CheckIfPlayerCanInteract() ) { v8 = 0; - for ( v9 = 12; v9; --v9 ) + for ( uint i = 0; i < 12; ++i ) { - if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID > 0 ) + if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C - 139][i].uItemID > 0 ) ++v8; } GetAsyncKeyState(17); - statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" - if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy" - DrawTextAtStatusBar(statusbar_string, 0); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0);//"Select the Item to Buy" if ( !v8 ) { - working_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C] - pParty->uTimePlayed);//"Приходите через 14 дней" + working_window.DrawShops_next_generation_time_string(pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C - 139] - pParty->uTimePlayed);//"Приходите через 14 дней" return; } - v12 = pMouse->GetCursorPos(&v51); - result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y]; - v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF; - if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) + pMouse->GetCursorPos(&cursor); + v13 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; + if ( v13 ) { v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)window_SpeakInHouse->ptr_1C)); v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)window_SpeakInHouse->ptr_1C, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v18 = BuildDialogueString(pMerchantsBuyPhrases[v17], uActiveCharacter - 1, v15, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); - working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v18, 3); + working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), v18, 3); return; } } return; } - if ( dialog_menu_id == HOUSE_DIALOGUE_GUILD_LEARN_SKILL ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { - if ( HouseUI_CheckIfPlayerCanInteract() ) + if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) { - if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pSkillNames[dialog_menu_id-36]); //"You already know the %s skill" + ShowStatusBarString(pTmpBuf.data(), 2); + pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); + } + else + { + if ( pParty->uNumGold < pPrice ) { - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill" - ShowStatusBarString(pTmpBuf.data(), 2); - pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); //"You don't have enough gold" + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); } else { - if ( pParty->uNumGold < pPrice ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); //"You don't have enough gold" - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); - } - else - { - Party::TakeGold(pPrice); - pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; - } + Party::TakeGold(pPrice); + pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; } } - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - return; } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; } //----- (004BC8D5) -------------------------------------------------------- void SpellBookGenerator()//for GuildDialogs diff -r 140ca8123384 -r 05b433b8cb37 UI/UIHouses.cpp --- a/UI/UIHouses.cpp Wed Oct 23 10:24:38 2013 +0600 +++ b/UI/UIHouses.cpp Wed Oct 23 12:49:25 2013 +0600 @@ -1057,7 +1057,7 @@ case BuildingType_SelfGuild: case BuildingType_16: { - if ( pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed ) + if ( pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C - 139] >= (signed __int64)pParty->uTimePlayed ) { for ( uint i = 0; i < 12; ++i ) { @@ -1068,7 +1068,7 @@ else//generation new books { SpellBookGenerator(); - pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000 + pParty->PartyTimes.Shops_next_generation_time[window_SpeakInHouse->par1C - 139] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); } break; @@ -2076,13 +2076,13 @@ if ( pPriceSkill < v9 / 3 ) pPriceSkill = v9 / 3; all_text_height = 0; - for ( pItemNum = pDialogueWindow->pStartingPosActiveItem; - pItemNum < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++pItemNum ) + for ( int i = pDialogueWindow->pStartingPosActiveItem; + i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++i ) { - if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(pItemNum)->msg_param - 36] - && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(pItemNum)->msg_param - 36] ) + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36] + && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] ) { - all_text_height = pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(pItemNum)->msg_param - 36], &dialog_window, 0, 0); + all_text_height = pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0); pSkillCount++; } } @@ -2094,10 +2094,10 @@ if ( (149 - all_text_height) / pSkillCount > 32 ) v91 = 32; v54 = (149 - pSkillCount * v91 - all_text_height) / 2 - v91 / 2 + 162; - for ( pItemNum = pDialogueWindow->pStartingPosActiveItem; - pItemNum < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; pItemNum++ ) + for ( int i = pDialogueWindow->pStartingPosActiveItem; + i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; i++ ) { - pButton = pDialogueWindow->GetControl(pItemNum); + pButton = pDialogueWindow->GetControl(i); if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36] || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] ) { @@ -2113,7 +2113,7 @@ v54 = pTextHeight + pButton->uY - 1; pButton->uW = v54; pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu); - if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + if ( pDialogueWindow->pCurrentPosActiveItem != i ) pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu); dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3); }