comparison UI/UIHouses.cpp @ 1629:2149b14614ad

Слияние
author Ritor1
date Mon, 16 Sep 2013 09:37:30 +0600
parents 7ce831a2a393 2d374de0a364
children ee4a65ac9d21
comparison
equal deleted inserted replaced
1628:7ce831a2a393 1629:2149b14614ad
89 { 89 {
90 { 0, 1, 1, 34}, // HOUSE_STABLES_HARMONDALE 90 { 0, 1, 1, 34}, // HOUSE_STABLES_HARMONDALE
91 { 2, 3, 4, 5}, // HOUSE_STABLES_STEADWICK 91 { 2, 3, 4, 5}, // HOUSE_STABLES_STEADWICK
92 { 6, 7, 8, 8}, // HOUSE_STABLES_TULAREAN_FOREST 92 { 6, 7, 8, 8}, // HOUSE_STABLES_TULAREAN_FOREST
93 { 9, 10, 10, 10}, // HOUSE_STABLES_DEYJA 93 { 9, 10, 10, 10}, // HOUSE_STABLES_DEYJA
94 { 11, 11, 12, 12}, // HOUSE_STABLES_58 94 { 11, 11, 12, 12}, // HOUSE_STABLES_BRACADA_DESERT
95 { 13, 13, 13, 13}, // HOUSE_STABLES_59 95 { 13, 13, 13, 13}, // HOUSE_STABLES_TATALIA
96 { 14, 14, 15, 15}, // HOUSE_STABLES_60 96 { 14, 14, 15, 15}, // HOUSE_STABLES_AVLEE
97 {255, 255, 255, 255}, // HOUSE_STABLES_61 97 {255, 255, 255, 255}, // HOUSE_STABLES_61
98 {255, 255, 255, 255}, // HOUSE_STABLES_62 98 {255, 255, 255, 255}, // HOUSE_STABLES_62
99 {255, 255, 255, 255}, // HOUSE_BOATS_63 99 {255, 255, 255, 255}, // HOUSE_BOATS_EMERALD_ISLE
100 { 16, 17, 18, 19}, // HOUSE_BOATS_64 100 { 16, 17, 18, 19}, // HOUSE_BOATS_ERATHIA
101 { 18, 20, 21, 21}, // HOUSE_BOATS_65 101 { 18, 20, 21, 21}, // HOUSE_BOATS_TULAREAN_FOREST
102 { 22, 23, 24, 25}, // HOUSE_BOATS_66 102 { 22, 23, 24, 25}, // HOUSE_BOATS_BRACADA_DESERT
103 { 22, 22, 23, 23}, // HOUSE_BOATS_67 103 { 22, 22, 23, 23}, // HOUSE_BOATS_EVENMORN_ISLAND
104 {255, 255, 255, 255}, // HOUSE_BOATS_68 104 {255, 255, 255, 255}, // HOUSE_BOATS_68
105 { 27, 28, 29, 30}, // HOUSE_BOATS_69 105 { 27, 28, 29, 30}, // HOUSE_BOATS_TATALIA
106 { 31, 32, 33, 33}, // HOUSE_BOATS_70 106 { 31, 32, 33, 33}, // HOUSE_BOATS_AVLEE
107 { 24, 24, 24, 24}, // HOUSE_BOATS_71 107 { 24, 24, 24, 24}, // HOUSE_BOATS_71
108 {255, 255, 255, 255}, // HOUSE_BOATS_72 108 {255, 255, 255, 255}, // HOUSE_BOATS_72
109 {255, 255, 255, 255} // HOUSE_BOATS_73 109 {255, 255, 255, 255} // HOUSE_BOATS_73
110 }; 110 };
111 111
1918 int pTextHeight; // eax@36 1918 int pTextHeight; // eax@36
1919 int pRealTextHeight; // esi@36 1919 int pRealTextHeight; // esi@36
1920 int schedule_id; // esi@39 1920 int schedule_id; // esi@39
1921 GUIButton *pButton; // ebx@39 1921 GUIButton *pButton; // ebx@39
1922 signed int v25; // eax@41 1922 signed int v25; // eax@41
1923 unsigned int v30; // ecx@62
1924 MapInfo pMap; // [sp-3Ch] [bp-2CCh]@62 1923 MapInfo pMap; // [sp-3Ch] [bp-2CCh]@62
1925 char pTopicArray[5][100]; // [sp+14h] [bp-27Ch]@37 1924 char pTopicArray[5][100]; // [sp+14h] [bp-27Ch]@37
1926 GUIWindow travel_window; // [sp+208h] [bp-88h]@1 1925 GUIWindow travel_window; // [sp+208h] [bp-88h]@1
1927 int pPrimaryTextHeight; // [sp+260h] [bp-30h]@36 1926 int pPrimaryTextHeight; // [sp+260h] [bp-30h]@36
1928 //unsigned int v60; // [sp+274h] [bp-1Ch]@36
1929 int index; // [sp+27Ch] [bp-14h]@36 1927 int index; // [sp+27Ch] [bp-14h]@36
1930 //char *a1; // [sp+284h] [bp-Ch]@37
1931 unsigned int pPrice; // [sp+288h] [bp-8h]@1 1928 unsigned int pPrice; // [sp+288h] [bp-8h]@1
1932 int travel_time; // [sp+28Ch] [bp-4h]@48 1929 int travel_time; // [sp+28Ch] [bp-4h]@48
1933 enum PlayerSpeech pSpeech; 1930 enum PlayerSpeech pSpeech;
1934 unsigned int pCurrentButton; 1931 unsigned int pCurrentButton;
1935 1932
1960 schedule_id = transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][index]; 1957 schedule_id = transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][index];
1961 pButton = pDialogueWindow->GetControl(i); 1958 pButton = pDialogueWindow->GetControl(i);
1962 1959
1963 if (schedule_id != 255) 1960 if (schedule_id != 255)
1964 { 1961 {
1965 if (schedule_id >= 25) 1962 //if (schedule_id >= 25)
1966 Log::Warning(L"Transport UI: scedule overflow"); 1963 //Log::Warning(L"Transport UI: schedule overflow");
1967 if ( pCurrentButton >= 6 ) 1964 if ( pCurrentButton >= 6 )
1968 v25 = true; 1965 v25 = true;
1969 else 1966 else
1970 v25 = transport_schedule[schedule_id].pSchedule[pParty->uDaysPlayed % 7]; 1967 v25 = transport_schedule[schedule_id].pSchedule[pParty->uDaysPlayed % 7];
1971 } 1968 }
1972 1969
1973 if (schedule_id != 255 && v25 && (!transport_schedule[schedule_id].uQuestBit 1970 if (schedule_id != 255 && v25 && (!transport_schedule[schedule_id].uQuestBit
1974 || _449B57_test_bit(pParty->_quest_bits, transport_schedule[schedule_id].uQuestBit)) ) 1971 || _449B57_test_bit(pParty->_quest_bits, transport_schedule[schedule_id].uQuestBit)) )//:
1975 { 1972 {
1976 //get color for current string( )------------ 1973 //get color for current string( )----------
1977 if ( pDialogueWindow->pCurrentPosActiveItem == pCurrentButton ) 1974 if ( pDialogueWindow->pCurrentPosActiveItem == pCurrentButton )
1978 sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 155)); 1975 sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 155));
1979 else 1976 else
1980 sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 255)); 1977 sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 255));
1981 //hired NPC premium( )---------------------------------- 1978 //hired NPC premium( )----------------------------------
2005 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[404], travel_time, pMap.pName); // Time - %d days, destination %s 2002 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[404], travel_time, pMap.pName); // Time - %d days, destination %s
2006 strcat(pTopicArray[index], pTmpBuf.data()); 2003 strcat(pTopicArray[index], pTmpBuf.data());
2007 strcat(pTopicArray[index], "\n \n"); 2004 strcat(pTopicArray[index], "\n \n");
2008 pButton->uY = pRealTextHeight; 2005 pButton->uY = pRealTextHeight;
2009 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0); 2006 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0);
2010 v30 = pButton->uY;
2011 pButton->uHeight = pTextHeight; 2007 pButton->uHeight = pTextHeight;
2012 pButton->uW = v30 + pTextHeight - 1; 2008 pButton->uW = pButton->uY + pTextHeight - 1;
2013 pRealTextHeight += (LOBYTE(pFontArrus->uFontHeight) - 3) + pTextHeight; 2009 pRealTextHeight += (LOBYTE(pFontArrus->uFontHeight) - 3) + pTextHeight;
2014 } 2010 }
2015 } 2011 }
2016 else 2012 else
2017 { 2013 {
2149 signed int pStringSum; // ebx@24 2145 signed int pStringSum; // ebx@24
2150 signed int v16; // ebx@28 2146 signed int v16; // ebx@28
2151 int v17; // ebx@28 2147 int v17; // ebx@28
2152 GUIButton *pButton; // eax@30 2148 GUIButton *pButton; // eax@30
2153 int pTextHeight; // eax@30 2149 int pTextHeight; // eax@30
2154 unsigned int v23; // ecx@30
2155 unsigned __int16 pTextColor; // ax@30 2150 unsigned __int16 pTextColor; // ax@30
2156 GUIWindow window; // [sp+60h] [bp-BCh]@21 2151 GUIWindow window; // [sp+60h] [bp-BCh]@21
2157 GUIWindow townHall_window; // [sp+B4h] [bp-68h]@1 2152 GUIWindow townHall_window; // [sp+B4h] [bp-68h]@1
2158 int v29; // [sp+10Ch] [bp-10h]@28 2153 int v29; // [sp+10Ch] [bp-10h]@28
2159 int v31; // [sp+114h] [bp-8h]@29 2154 int v31; // [sp+114h] [bp-8h]@29
2190 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) 2185 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
2191 { 2186 {
2192 pButton = pDialogueWindow->GetControl(i); 2187 pButton = pDialogueWindow->GetControl(i);
2193 pButton->uY = v29 + v17; 2188 pButton->uY = v29 + v17;
2194 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &townHall_window, 0, 0); 2189 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &townHall_window, 0, 0);
2195 v23 = pButton->uY;
2196 pButton->uHeight = pTextHeight; 2190 pButton->uHeight = pTextHeight;
2197 v17 = v23 + pTextHeight - 1; 2191 v17 = pButton->uY + pTextHeight - 1;
2198 pButton->uW = v17; 2192 pButton->uW = v17;
2199 pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu); 2193 pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
2200 if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) 2194 if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
2201 pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu); 2195 pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
2202 townHall_window.DrawTitleText(pFontArrus, 0, v23, pTextColor, pShopOptions[j], 3); 2196 townHall_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[j], 3);
2203 ++v31; 2197 ++v31;
2204 ++j; 2198 ++j;
2205 } 2199 }
2206 } 2200 }
2207 break; 2201 break;
2406 unsigned int pNumActiveItem; // esi@18 2400 unsigned int pNumActiveItem; // esi@18
2407 int v11; // eax@18 2401 int v11; // eax@18
2408 unsigned int v12; // eax@19 2402 unsigned int v12; // eax@19
2409 int v13; // eax@21 2403 int v13; // eax@21
2410 int v14; // ecx@26 2404 int v14; // ecx@26
2411 //GUIButton *v15; // eax@28
2412 //GUIButton *v16; // esi@28
2413 int v17; // eax@28 2405 int v17; // eax@28
2414 char *v18; // eax@30 2406 char *v18; // eax@30
2415 int v19; // eax@30 2407 int v19; // eax@30
2416 unsigned int v20; // ecx@30 2408 unsigned int v20; // ecx@30
2417 int v21; // edx@30 2409 int v21; // edx@30
2421 int v25; // eax@34 2413 int v25; // eax@34
2422 char *v26; // esi@36 2414 char *v26; // esi@36
2423 int v27; // edi@46 2415 int v27; // edi@46
2424 unsigned int pColorText; // eax@57 2416 unsigned int pColorText; // eax@57
2425 signed int v31; // eax@59 2417 signed int v31; // eax@59
2426 //GUIWindow *v33; // edi@64
2427 int v34; // eax@64 2418 int v34; // eax@64
2428 int v35; // ecx@64 2419 int v35; // ecx@64
2429 int v36; // esi@64 2420 int v36; // esi@64
2430 char v37; // sf@64
2431 GUIButton *pButton; // eax@65 2421 GUIButton *pButton; // eax@65
2432 int v39; // edx@69 2422 int v39; // edx@69
2433 int v40; // ecx@69 2423 int v40; // ecx@69
2434 int v41; // ecx@69 2424 int v41; // ecx@69
2435 int v42; // ecx@70 2425 int v42; // ecx@70
2439 int v46; // ecx@72 2429 int v46; // ecx@72
2440 int v47; // eax@74 2430 int v47; // eax@74
2441 signed int v48; // edi@77 2431 signed int v48; // edi@77
2442 signed int i; // esi@79 2432 signed int i; // esi@79
2443 int v50; // eax@80 2433 int v50; // eax@80
2444 //GUIWindow *v51; // ecx@81
2445 _QWORD v52; // qax@81 2434 _QWORD v52; // qax@81
2446 signed int v53; // edi@81 2435 signed int v53; // edi@81
2447 int v54; // edi@81 2436 int v54; // edi@81
2448 //GUIButton *v55; // esi@83
2449 const char **v56; // eax@83 2437 const char **v56; // eax@83
2450 int v57; // eax@83 2438 int v57; // eax@83
2451 unsigned int v58; // ecx@83 2439 unsigned int v58; // ecx@83
2452 //Player *v59; // edx@83
2453 unsigned __int16 v60; // ax@83 2440 unsigned __int16 v60; // ax@83
2454 int v61; // eax@99 2441 int v61; // eax@99
2455 char *v63; // eax@99 2442 char *v63; // eax@99
2456 GUIFont *v64; // edx@99 2443 GUIFont *v64; // edx@99
2457 GUIFont *v65; // edi@100 2444 GUIFont *v65; // edi@100
2465 unsigned int v73; // [sp-4h] [bp-278h]@99 2452 unsigned int v73; // [sp-4h] [bp-278h]@99
2466 char pTopic1[100]; // [sp+Ch] [bp-268h]@55 2453 char pTopic1[100]; // [sp+Ch] [bp-268h]@55
2467 char pTopic4[100]; // [sp+70h] [bp-204h]@59 2454 char pTopic4[100]; // [sp+70h] [bp-204h]@59
2468 char pTopic2[100]; // [sp+D4h] [bp-1A0h]@57 2455 char pTopic2[100]; // [sp+D4h] [bp-1A0h]@57
2469 char pTopic3[100]; // [sp+138h] [bp-13Ch]@59 2456 char pTopic3[100]; // [sp+138h] [bp-13Ch]@59
2470 //GUIWindow v78; // [sp+19Ch] [bp-D8h]@99
2471 GUIWindow dialog_window; // [sp+1F0h] [bp-84h]@1 2457 GUIWindow dialog_window; // [sp+1F0h] [bp-84h]@1
2472 char *Str[2]; // [sp+244h] [bp-30h]@30 2458 char *Str[2]; // [sp+244h] [bp-30h]@30
2473 unsigned int pColorWhite; // [sp+24Ch] [bp-28h]@1
2474 unsigned __int8 pTopic3Height; // [sp+253h] [bp-21h]@59 2459 unsigned __int8 pTopic3Height; // [sp+253h] [bp-21h]@59
2475 int v83; // [sp+254h] [bp-20h]@1 2460 int v83; // [sp+254h] [bp-20h]@1
2476 int pColorYellow; // [sp+258h] [bp-1Ch]@1
2477 Player *pPlayer; // [sp+25Ch] [bp-18h]@1
2478 int all_text_height; // [sp+260h] [bp-14h]@18 2461 int all_text_height; // [sp+260h] [bp-14h]@18
2479 unsigned __int8 v87; // [sp+266h] [bp-Eh]@59 2462 unsigned __int8 v87; // [sp+266h] [bp-Eh]@59
2480 unsigned __int8 pTopic2Height; // [sp+267h] [bp-Dh]@57 2463 unsigned __int8 pTopic2Height; // [sp+267h] [bp-Dh]@57
2481 int v89; // [sp+268h] [bp-Ch]@1 2464 int v89; // [sp+268h] [bp-Ch]@1
2482 unsigned int pTopic1Height; // [sp+26Fh] [bp-5h]@55 2465 unsigned int pTopic1Height; // [sp+26Fh] [bp-5h]@55
2483 int v91; // [sp+270h] [bp-4h]@3 2466 int v91; // [sp+270h] [bp-4h]@3
2484 GUIFont *pOutString; 2467 GUIFont *pOutString;
2485 unsigned __int8 pTopic4Height; 2468 unsigned __int8 pTopic4Height;
2486 int pTextHeight; 2469 int pTextHeight;
2487 2470
2488 pPlayer = pPlayers[uActiveCharacter];
2489 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); 2471 memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
2490 dialog_window.uFrameX = 483; 2472 dialog_window.uFrameX = 483;
2491 dialog_window.uFrameWidth = 148; 2473 dialog_window.uFrameWidth = 148;
2492 dialog_window.uFrameZ = 334; 2474 dialog_window.uFrameZ = 334;
2493 pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
2494 pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu);
2495 v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; 2475 v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
2496 *(float *)&v83 = v2; 2476 *(float *)&v83 = v2;
2497 *(float *)&v89 = v2 * v2; 2477 *(float *)&v89 = v2 * v2;
2498 v3 = (signed __int64)(*(float *)&v89 * 0.1); 2478 v3 = (signed __int64)(*(float *)&v89 * 0.1);
2499 pItemNum = v3 * (100 - pPlayer->GetMerchant()) / 100; 2479 pItemNum = v3 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
2500 if ( pItemNum < v3 / 3 ) 2480 if ( pItemNum < v3 / 3 )
2501 pItemNum = v3 / 3; 2481 pItemNum = v3 / 3;
2502 v5 = 1; 2482 v5 = 1;
2503 pOutString = (GUIFont *)pItemNum; 2483 pOutString = (GUIFont *)pItemNum;
2504 if ( pItemNum <= 0 ) 2484 if ( pItemNum <= 0 )
2505 pOutString = (GUIFont *)1; 2485 pOutString = (GUIFont *)1;
2506 v6 = (signed __int64)(*(float *)&v89 * *(float *)&v83 * 0.0099999998); 2486 v6 = (signed __int64)(*(float *)&v89 * *(float *)&v83 * 0.0099999998);
2507 v7 = v6 * (100 - pPlayer->GetMerchant()) / 100; 2487 v7 = v6 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
2508 if ( v7 < v6 / 3 ) 2488 if ( v7 < v6 / 3 )
2509 v7 = v6 / 3; 2489 v7 = v6 / 3;
2510 v83 = v7; 2490 v83 = v7;
2511 if ( v7 <= 0 ) 2491 if ( v7 <= 0 )
2512 { 2492 {
2519 case HOUSE_DIALOGUE_MAIN: 2499 case HOUSE_DIALOGUE_MAIN:
2520 { 2500 {
2521 if ( !HouseUI_CheckIfPlayerCanInteract() ) 2501 if ( !HouseUI_CheckIfPlayerCanInteract() )
2522 return; 2502 return;
2523 2503
2524 sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? pColorYellow : pColorWhite); 2504 sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
2525 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[178], pOutString); // Rent room for %d gold 2505 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[178], pOutString); // Rent room for %d gold
2526 strcat(pTopic1, pTmpBuf2.data()); 2506 strcat(pTopic1, pTmpBuf2.data());
2527 pTopic1Height = pFontArrus->CalcTextHeight(pTopic1, &dialog_window, 0, 0); 2507 pTopic1Height = pFontArrus->CalcTextHeight(pTopic1, &dialog_window, 0, 0);
2528 strcat(pTopic1, "\n \n"); 2508 strcat(pTopic1, "\n \n");
2529 2509
2530 sprintf(pTopic2, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? pColorYellow : pColorWhite); 2510 sprintf(pTopic2, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
2531 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[86], // Buy food for %d days for %d gold 2511 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[86], // Buy food for %d days for %d gold
2532 (unsigned int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, v83); 2512 (unsigned int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, v83);
2533 strcat(pTopic2, pTmpBuf2.data()); 2513 strcat(pTopic2, pTmpBuf2.data());
2534 pTopic2Height = pFontArrus->CalcTextHeight(pTopic2, &dialog_window, 0, 0); 2514 pTopic2Height = pFontArrus->CalcTextHeight(pTopic2, &dialog_window, 0, 0);
2535 strcat(pTopic2, "\n \n"); 2515 strcat(pTopic2, "\n \n");
2536 2516
2537 sprintf(pTopic3, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? pColorYellow : pColorWhite); 2517 sprintf(pTopic3, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
2538 strcat(pTopic3, pGlobalTXT_LocalizationStrings[160]); // Learn Skills 2518 strcat(pTopic3, pGlobalTXT_LocalizationStrings[160]); // Learn Skills
2539 pTopic3Height = pFontArrus->CalcTextHeight(pTopic3, &dialog_window, 0, 0); 2519 pTopic3Height = pFontArrus->CalcTextHeight(pTopic3, &dialog_window, 0, 0);
2540 strcat(pTopic3, "\n \n"); 2520 strcat(pTopic3, "\n \n");
2541 pTopic4[0] = 0; 2521 pTopic4[0] = 0;
2542 if ( (signed int)window_SpeakInHouse->par1C >= 108 && (signed int)window_SpeakInHouse->par1C <= 120 ) 2522 if ( (signed int)window_SpeakInHouse->par1C >= 108 && (signed int)window_SpeakInHouse->par1C <= 120 )
2543 { 2523 {
2544 sprintf(pTopic4, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? pColorYellow : pColorWhite); 2524 sprintf(pTopic4, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
2545 strcat(pTopic4, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage 2525 strcat(pTopic4, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage
2546 pTopic4Height = pFontArrus->CalcTextHeight(pTopic4, &dialog_window, 0, 0); 2526 pTopic4Height = pFontArrus->CalcTextHeight(pTopic4, &dialog_window, 0, 0);
2547 } 2527 }
2548 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; 2528
2549 v36 = LOBYTE(pFontArrus->uFontHeight) - 3; 2529 v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
2550 v37 = -pDialogueWindow->pNumPresenceButton < 0; 2530 if ( pDialogueWindow->pNumPresenceButton )
2551 if ( !(v37 ^ (pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton)) ) 2531 {
2552 { 2532 for ( pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
2553 do 2533 pNumActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++pNumActiveItem )
2554 { 2534 {
2555 pButton = pDialogueWindow->GetControl(pNumActiveItem); 2535 pButton = pDialogueWindow->GetControl(pNumActiveItem);
2556 if ( pButton->msg_param == 15 ) 2536 if ( pButton->msg_param == 15 )
2557 { 2537 {
2558 v46 = pTopic1Height; 2538 v46 = pTopic1Height;
2586 pButton->uHeight = pTopic4Height; 2566 pButton->uHeight = pTopic4Height;
2587 pButton->uY = v39; 2567 pButton->uY = v39;
2588 v41 = v39 + v40 - 1; 2568 v41 = v39 + v40 - 1;
2589 pButton->uW = v41; 2569 pButton->uW = v41;
2590 } 2570 }
2591 pNumActiveItem++; 2571 }
2592 if ( pNumActiveItem >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) 2572 sprintfex(pTmpBuf.data(), "%s%s%s%s", pTopic1, pTopic2, pTopic3, pTopic4);
2593 { 2573 dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf.data(), 3);
2594 sprintfex(pTmpBuf.data(), "%s%s%s%s", pTopic1, pTopic2, pTopic3, pTopic4);
2595 dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf.data(), 3);
2596 }
2597 }
2598 while ( pNumActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton );
2599 } 2574 }
2600 break; 2575 break;
2601 } 2576 }
2602 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: 2577 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES:
2603 { 2578 {
2647 { 2622 {
2648 v72 = pGlobalTXT_LocalizationStrings[639];// A tie! 2623 v72 = pGlobalTXT_LocalizationStrings[639];// A tie!
2649 } 2624 }
2650 strcpy(pTmpBuf.data(), v72); 2625 strcpy(pTmpBuf.data(), v72);
2651 v66 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; 2626 v66 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
2652 dialog_window.DrawTitleText(pFontArrus, 0, v66, pColorYellow, pTmpBuf.data(), 3); 2627 dialog_window.DrawTitleText(pFontArrus, 0, v66, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
2653 break; 2628 break;
2654 } 2629 }
2655 case HOUSE_DIALOGUE_TAVERN_REST: 2630 case HOUSE_DIALOGUE_TAVERN_REST:
2656 { 2631 {
2657 if ( pParty->uNumGold >= (unsigned int)pOutString ) 2632 if ( pParty->uNumGold >= (unsigned int)pOutString )
2683 { 2658 {
2684 if ( !HouseUI_CheckIfPlayerCanInteract() ) 2659 if ( !HouseUI_CheckIfPlayerCanInteract() )
2685 return; 2660 return;
2686 v0 = 0; 2661 v0 = 0;
2687 v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); 2662 v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
2688 pItemNum = v9 * (100 - pPlayer->GetMerchant()) / 100; 2663 pItemNum = v9 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
2689 if ( pItemNum < v9 / 3 ) 2664 if ( pItemNum < v9 / 3 )
2690 pItemNum = v9 / 3; 2665 pItemNum = v9 / 3;
2691 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; 2666 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
2692 all_text_height = 0; 2667 all_text_height = 0;
2693 if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) 2668 if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
2694 { 2669 {
2695 do 2670 do
2696 { 2671 {
2697 v12 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36; 2672 v12 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36;
2698 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v12] && !pPlayer->pActiveSkills[v12] ) 2673 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v12]
2674 && !pPlayers[uActiveCharacter]->pActiveSkills[v12] )
2699 { 2675 {
2700 all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v12], &dialog_window, 0, 0); 2676 all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v12], &dialog_window, 0, 0);
2701 v0++; 2677 v0++;
2702 } 2678 }
2703 ++pNumActiveItem; 2679 ++pNumActiveItem;
2717 pItemNum = 2; 2693 pItemNum = 2;
2718 do 2694 do
2719 { 2695 {
2720 pButton = pDialogueWindow->GetControl(pItemNum); 2696 pButton = pDialogueWindow->GetControl(pItemNum);
2721 v17 = pButton->msg_param - 36; 2697 v17 = pButton->msg_param - 36;
2722 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v17] || pPlayer->pActiveSkills[v17] ) 2698 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v17]
2699 || pPlayers[uActiveCharacter]->pActiveSkills[v17] )
2723 { 2700 {
2724 pButton->uW = 0; 2701 pButton->uW = 0;
2725 pButton->uHeight = 0; 2702 pButton->uHeight = 0;
2726 pButton->uY = 0; 2703 pButton->uY = 0;
2727 } 2704 }
2730 pButton->uY = v91 + v14; 2707 pButton->uY = v91 + v14;
2731 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v17], &dialog_window, 0, 0); 2708 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v17], &dialog_window, 0, 0);
2732 pButton->uHeight = pTextHeight; 2709 pButton->uHeight = pTextHeight;
2733 v14 = pTextHeight + pButton->uY - 1; 2710 v14 = pTextHeight + pButton->uY - 1;
2734 pButton->uW = v14; 2711 pButton->uW = v14;
2735 pColorText = pColorYellow; 2712 pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
2736 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) 2713 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
2737 pColorText = pColorWhite; 2714 pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
2738 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v17], 3); 2715 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v17], 3);
2739 } 2716 }
2740 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; 2717 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton;
2741 pItemNum++; 2718 pItemNum++;
2742 } 2719 }
2743 while ( pItemNum < pNumActiveItem ); 2720 while ( pItemNum < pNumActiveItem );
2744 } 2721 }
2745 return; 2722 return;
2746 } 2723 }
2747 } 2724 }
2748 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); 2725 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName,
2726 pClassNames[pPlayers[uActiveCharacter]->classType]);
2749 strcat(pTmpBuf.data(), "\n \n"); 2727 strcat(pTmpBuf.data(), "\n \n");
2750 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); 2728 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
2751 pTextHeight = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; 2729 pTextHeight = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
2752 dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorYellow, pTmpBuf.data(), 3); 2730 dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
2753 return; 2731 return;
2754 } 2732 }
2755 2733
2756 case HOUSE_DIALOGUE_TAVERN_BUY_FOOD: 2734 case HOUSE_DIALOGUE_TAVERN_BUY_FOOD:
2757 { 2735 {
2796 for ( i = 0; i < v48; ++i ) 2774 for ( i = 0; i < v48; ++i )
2797 all_text_height = pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); 2775 all_text_height = pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
2798 all_text_height = (174 - all_text_height) / v48; 2776 all_text_height = (174 - all_text_height) / v48;
2799 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; 2777 pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
2800 v54 = (174 - v48 * (174 - all_text_height) / v48 - all_text_height) / 2 - (174 - all_text_height) / v48 / 2 + 138; 2778 v54 = (174 - v48 * (174 - all_text_height) / v48 - all_text_height) / 2 - (174 - all_text_height) / v48 / 2 + 138;
2801 v37 = -pDialogueWindow->pNumPresenceButton < 0; 2779 //v37 = -pDialogueWindow->pNumPresenceButton < 0;
2802 if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) 2780 if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
2803 { 2781 {
2804 pItemNum = 2; 2782 pItemNum = 2;
2805 pNumString = 0; 2783 pNumString = 0;
2806 do 2784 do
2809 pButton->uY = all_text_height + v54; 2787 pButton->uY = all_text_height + v54;
2810 pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); 2788 pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
2811 pButton->uHeight = pTextHeight; 2789 pButton->uHeight = pTextHeight;
2812 v54 = pButton->uY + pTextHeight - 1; 2790 v54 = pButton->uY + pTextHeight - 1;
2813 pButton->uW = v54; 2791 pButton->uW = v54;
2814 pColorText = pColorYellow; 2792 pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
2815 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) 2793 if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
2816 pColorText = pColorWhite; 2794 pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
2817 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); 2795 dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
2818 pItemNum++; 2796 pItemNum++;
2819 ++pNumString; 2797 ++pNumString;
2820 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; 2798 pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
2821 } 2799 }
2831 } 2809 }
2832 } 2810 }
2833 2811
2834 //----- (004B705E) -------------------------------------------------------- 2812 //----- (004B705E) --------------------------------------------------------
2835 void TempleDialog() 2813 void TempleDialog()
2836 { 2814 {
2837 //GUIWindow *v0; // ebx@1 2815 int pPrice; // edi@1
2838 //Player *v1; // esi@1 2816 int pTextHeight; // eax@11
2839 int v2; // edi@1 2817 unsigned __int16 pTextColor; // ax@21
2840 int result; // eax@4 2818 DDM_DLV_Header *v26; // edi@29
2841 GUIWindow *v4; // edi@6 2819 unsigned int v30; // edx@36
2842 void *v5; // eax@6 2820 int v35; // edi@50
2843 int v6; // eax@6 2821 GUIButton *pButton; // edi@64
2844 unsigned int v7; // eax@8 2822 int v47; // edi@71
2845 int v8; // ecx@8 2823 GUIWindow tample_window; // [sp+13Ch] [bp-88h]@1
2846 unsigned int v9; // eax@9 2824 unsigned __int8 index; // [sp+1B7h] [bp-Dh]@64
2847 int v10; // eax@11 2825 int v64; // [sp+1B8h] [bp-Ch]@6
2848 int v11; // eax@12 2826 unsigned int pCurrentItem; // [sp+1BCh] [bp-8h]@6
2849 GUIWindow *v12; // ecx@16 2827 int all_text_height; // [sp+1C0h] [bp-4h]@6
2850 int v13; // edx@16 2828
2851 GUIButton *v14; // eax@19 2829 memcpy(&tample_window, window_SpeakInHouse, sizeof(tample_window));
2852 GUIButton *v15; // edi@19 2830 tample_window.uFrameX = 483;
2853 int v16; // eax@19 2831 tample_window.uFrameWidth = 148;
2854 const char *v17; // eax@21 2832 tample_window.uFrameZ = 334;
2855 int v18; // eax@21 2833 pPrice = pPlayers[uActiveCharacter]->GetTempleHealCostModifier(p2DEvents[window_SpeakInHouse->par1C - 1].fPriceMultiplier);
2856 unsigned int v19; // ecx@21 2834 if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN )
2857 int v20; // eax@21 2835 {
2858 unsigned __int16 v21; // ax@21 2836 index = 1;
2859 unsigned __int16 v22; // ST14_2@27 2837 pButton = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem);
2860 int v23; // eax@27 2838 pButton->uHeight = 0;
2861 double v24; // st7@28 2839 pButton->uY = 0;
2862 unsigned int v25; // ebx@28 2840 if ( pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
2863 DDM_DLV_Header *v26; // edi@29 2841 {
2864 int v27; // eax@31 2842 sprintfex(pTmpBuf.data(), "%s %d %s", pGlobalTXT_LocalizationStrings[104], pPrice, pGlobalTXT_LocalizationStrings[97]);//"" ""
2865 int v28; // eax@32 2843 pShopOptions[0] = pTmpBuf.data();
2866 unsigned int v30; // edx@36 2844 index = 0;
2867 unsigned int v31; // edx@38 2845 }
2868 unsigned int v32; // edx@40 2846 pShopOptions[1] = pGlobalTXT_LocalizationStrings[68];//""
2869 unsigned int v33; // edx@42 2847 pShopOptions[2] = pGlobalTXT_LocalizationStrings[160];//" "
2870 unsigned int v34; // edx@44 2848 all_text_height = 0;
2871 int v35; // edi@50 2849 if ( index < pDialogueWindow->pNumPresenceButton )
2872 signed int v36; // eax@50 2850 {
2873 unsigned __int8 v37; // al@54 2851 uint i = index;
2874 int v38; // ecx@54 2852 for ( uint j = index; j < pDialogueWindow->pNumPresenceButton; ++j )
2875 GUIWindow *v39; // eax@56 2853 {
2876 unsigned __int8 v40; // al@61 2854 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[1 * i], &tample_window, 0, 0);
2877 GUIButton *v41; // edi@64 2855 i++;
2878 int v42; // esi@66 2856 }
2879 GUIWindow *v43; // ecx@66 2857 }
2880 int v44; // edi@66 2858 v64 = (174 - (signed int)all_text_height) / (pDialogueWindow->pNumPresenceButton - index);
2881 int v45; // eax@68 2859 if ( v64 > 32 )
2882 signed int v46; // edi@69 2860 v64 = 32;
2883 int v47; // edi@71 2861 all_text_height = (174 - v64 * (pDialogueWindow->pNumPresenceButton - index) - (signed int)all_text_height) / 2 - v64 / 2 + 138;
2884 GUIButton *v48; // eax@73 2862 if ( index + pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
2885 const char *v49; // edx@73 2863 {
2886 GUIButton *v50; // esi@73 2864 uint i = index;
2887 int v51; // eax@73 2865 for ( pCurrentItem = index + pDialogueWindow->pStartingPosActiveItem;
2888 unsigned int v52; // ecx@73 2866 (signed int)pCurrentItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++pCurrentItem )
2889 unsigned __int16 v53; // ax@73 2867 {
2890 char a1[300]; // [sp+10h] [bp-1B4h]@64 2868 pButton = pDialogueWindow->GetControl(pCurrentItem);
2891 GUIWindow v57; // [sp+13Ch] [bp-88h]@1 2869 pButton->uY = v64 + all_text_height;
2892 __int64 v58; // [sp+190h] [bp-34h]@1 2870 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[1 * i], &tample_window, 0, 0);
2893 __int64 v59; // [sp+198h] [bp-2Ch]@1 2871 pButton->uHeight = pTextHeight;
2894 __int64 v60; // [sp+1A0h] [bp-24h]@1 2872 pButton->uW = pButton->uY + pTextHeight - 1;
2895 GUIWindow *v61; // [sp+1ACh] [bp-18h]@6 2873 all_text_height = pButton->uW;
2896 unsigned int v62; // [sp+1B0h] [bp-14h]@8 2874 pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
2897 unsigned __int8 v63; // [sp+1B7h] [bp-Dh]@64 2875 if ( pDialogueWindow->pCurrentPosActiveItem != index + 2 )
2898 int v64; // [sp+1B8h] [bp-Ch]@6 2876 pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
2899 unsigned int v65; // [sp+1BCh] [bp-8h]@6 2877 tample_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[1 * i], 3);
2900 DDM_DLV_Header *v66; // [sp+1C0h] [bp-4h]@6 2878 i++;
2901 2879 index++;
2902 //v0 = window_SpeakInHouse; 2880 }
2903 memcpy(&v57, window_SpeakInHouse, sizeof(v57)); 2881 }
2904 v57.uFrameX = 483; 2882 return;
2905 v57.uFrameWidth = 148; 2883 }
2906 v57.uFrameZ = 334; 2884 //-------------------------------------------------
2907 HIDWORD(v58) = TargetColor(0xFFu, 0xFFu, 0xFFu); 2885 if ( dialog_menu_id == HOUSE_DIALOGUE_TEMPLE_HEAL )
2908 HIDWORD(v59) = TargetColor(0xFFu, 0xFFu, 0x9Bu); 2886 {
2909 //v1 = pPlayers[uActiveCharacter]; 2887 if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
2910 //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]); 2888 return;
2911 v2 = pPlayers[uActiveCharacter]->GetTempleHealCostModifier(p2DEvents[window_SpeakInHouse->par1C - 1].fPriceMultiplier); 2889 if ( pParty->uNumGold < pPrice )
2912 HIDWORD(v60) = v2; 2890 {
2913 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) 2891 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//" "
2914 { 2892 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
2915 if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_HEAL ) 2893 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
2916 { 2894 return;
2917 if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_DONATE ) 2895 }
2918 { 2896 Party::TakeGold(pPrice);
2919 if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) 2897 v35 = LODWORD(pPlayers[uActiveCharacter]->pConditions[17]);
2920 { 2898 memset(pPlayers[uActiveCharacter], 0, 0xA0u);
2921 if ( HouseUI_CheckIfPlayerCanInteract() ) 2899 pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth();
2922 { 2900 pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana();
2923 v4 = pDialogueWindow; 2901 if ( (signed int)window_SpeakInHouse->ptr_1C != 78 && ((signed int)window_SpeakInHouse->ptr_1C <= 80 || (signed int)window_SpeakInHouse->ptr_1C > 82) )
2924 v61 = pDialogueWindow; 2902 {
2925 v5 = window_SpeakInHouse->ptr_1C; 2903 if ( (unsigned int)pPlayers[uActiveCharacter]->pConditions[17] | v35 )
2926 v66 = 0; 2904 {
2927 //v65 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v5] * 500.0); 2905 pPlayers[uActiveCharacter]->uCurrentFace = pPlayers[uActiveCharacter]->uPrevFace;
2928 v65 = (signed __int64)(p2DEvents[(signed int)v5 - 1].flt_24 * 500.0); 2906 pPlayers[uActiveCharacter]->uVoiceID = pPlayers[uActiveCharacter]->uPrevVoiceID;
2929 v6 = pPlayers[uActiveCharacter]->GetMerchant(); 2907 ReloadPlayerPortraits(uActiveCharacter - 1, pPlayers[uActiveCharacter]->uPrevFace);
2930 v64 = (signed int)(v65 * (100 - v6)) / 100; 2908 }
2931 if ( v64 < (signed int)v65 / 3 ) 2909 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
2932 v64 = (signed int)v65 / 3; 2910 pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
2933 v7 = v4->pStartingPosActiveItem; 2911 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
2934 v8 = v7 + v4->pNumPresenceButton; 2912 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
2935 v65 = 0; 2913 return;
2936 v62 = v7; 2914 }
2937 if ( (signed int)v7 >= v8 ) 2915 if ( (unsigned int)pPlayers[uActiveCharacter]->pConditions[17] | v35 )
2938 goto LABEL_78; 2916 {
2939 do 2917 LODWORD(pPlayers[uActiveCharacter]->pConditions[17]) = v35;
2940 { 2918 }
2941 v9 = v4->GetControl(v62)->msg_param - 36; 2919 else
2942 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v9] && !pPlayers[uActiveCharacter]->pActiveSkills[v9] ) 2920 {
2943 { 2921 if ( !pPlayers[uActiveCharacter]->pConditions[16]
2944 v10 = pFontArrus->CalcTextHeight(pSkillNames[v9], &v57, 0, 0); 2922 && !pPlayers[uActiveCharacter]->pConditions[15] && !pPlayers[uActiveCharacter]->pConditions[14] )
2945 v66 = (DDM_DLV_Header *)((char *)v66 + v10); 2923 {
2946 ++v65;
2947 }
2948 v11 = v4->pStartingPosActiveItem;
2949 ++v62;
2950 }
2951 while ( (signed int)v62 < v4->pNumPresenceButton + v11 );
2952 if ( v65 )
2953 {
2954 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v64);
2955 v57.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u);
2956 v64 = (149 - (signed int)v66) / (signed int)v65;
2957 if ( v64 > 32 )
2958 v64 = 32;
2959 v65 = (signed int)(149 - v65 * v64 - (int)v66) / 2 - v64 / 2 + 162;
2960 v12 = v61;
2961 result = v61->pStartingPosActiveItem;
2962 v13 = result + v61->pNumPresenceButton;
2963 v62 = v61->pStartingPosActiveItem;
2964 if ( result < v13 )
2965 {
2966 v66 = (DDM_DLV_Header *)2;
2967 while ( 1 )
2968 {
2969 v14 = v12->GetControl(v62);
2970 v15 = v14;
2971 v16 = v14->msg_param - 36;
2972 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v16] || pPlayers[uActiveCharacter]->pActiveSkills[v16] )
2973 {
2974 v15->uW = 0;
2975 v15->uHeight = 0;
2976 v15->uY = 0;
2977 }
2978 else
2979 {
2980 v17 = pSkillNames[v16];
2981 v15->uY = v64 + v65;
2982 HIDWORD(v60) = (uint32)v17;
2983 v18 = pFontArrus->CalcTextHeight(v17, &v57, 0, 0);
2984 v19 = v15->uY;
2985 v15->uHeight = v18;
2986 v20 = v19 + v18 - 1;
2987 v15->uW = v20;
2988 v65 = v20;
2989 v21 = WORD2(v59);
2990 if ( (DDM_DLV_Header *)pDialogueWindow->pCurrentPosActiveItem != v66 )
2991 v21 = WORD2(v58);
2992 v57.DrawTitleText(pFontArrus, 0, v19, v21, (const char *)HIDWORD(v60), 3u);
2993 }
2994 result = (int)v61;
2995 ++v62;
2996 v66 = (DDM_DLV_Header *)((char *)v66 + 1);
2997 if ( (signed int)v62 >= v61->pNumPresenceButton + v61->pStartingPosActiveItem )
2998 break;
2999 v12 = v61;
3000 }
3001 }
3002 }
3003 else
3004 {
3005 LABEL_78:
3006 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);
3007 strcat(pTmpBuf.data(), "\n \n");
3008 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
3009 v22 = WORD2(v59);
3010 v23 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v57, 0, 0);
3011 v57.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf.data(), 3u);
3012 }
3013 }
3014 }
3015 return;
3016 }
3017 // DONATION
3018 //v24 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
3019 v24 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
3020 v25 = 0;
3021 if ( pParty->uNumGold >= (unsigned int)(signed __int64)v24 )
3022 {
3023 Party::TakeGold((signed __int64)v24);
3024 v26 = &pOutdoor->ddm;
3025 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
3026 v26 = &pIndoor->dlv;
3027 v27 = v26->uReputation;
3028 v66 = v26;
3029 if ( v27 > -5 )
3030 {
3031 v28 = v27 - 1;
3032 v26->uReputation = v28;
3033 if ( v28 < -5 )
3034 v26->uReputation = -5;
3035 }
3036 if ( (unsigned __int8)byte_F8B1EF[uActiveCharacter] == pParty->uDaysPlayed % 7 )
3037 {
3038 if ( v26->uReputation <= -5 )
3039 {
3040 v30 = pParty->uDaysPlayed % 7 + 1;
3041 LOBYTE(v30) = v30 | 0x80;
3042 _42777D_CastSpell_UseWand_ShootArrow(SPELL_AIR_WIZARD_EYE, uActiveCharacter - 1, v30, 48, 0);
3043 }
3044 if ( v26->uReputation <= -10 )
3045 {
3046 v31 = pParty->uDaysPlayed % 7 + 1;
3047 LOBYTE(v31) = v31 | 0x80;
3048 _42777D_CastSpell_UseWand_ShootArrow(SPELL_SPIRIT_PRESERVATION, uActiveCharacter - 1, v31, 48, 0);
3049 v26 = v66;
3050 }
3051 if ( v26->uReputation <= -15 )
3052 {
3053 v32 = pParty->uDaysPlayed % 7 + 1;
3054 LOBYTE(v32) = v32 | 0x80;
3055 _42777D_CastSpell_UseWand_ShootArrow(SPELL_BODY_PROTECTION_FROM_MAGIC, uActiveCharacter - 1, v32, 48, 0);
3056 v26 = v66;
3057 }
3058 if ( v26->uReputation <= -20 )
3059 {
3060 v33 = pParty->uDaysPlayed % 7 + 1;
3061 LOBYTE(v33) = v33 | 0x80;
3062 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_HOUR_OF_POWER, uActiveCharacter - 1, v33, 48, 0);
3063 v26 = v66;
3064 }
3065 if ( v26->uReputation <= -25 )
3066 {
3067 v34 = pParty->uDaysPlayed % 7 + 1;
3068 LOBYTE(v34) = v34 | 0x80;
3069 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_DAY_OF_PROTECTION, uActiveCharacter - 1, v34, 48, 0);
3070 }
3071 }
3072 ++byte_F8B1EF[uActiveCharacter];
3073 pPlayers[uActiveCharacter]->PlaySound(SPEECH_83, 0);
3074 ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2u); // "Thank You!"
3075 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
3076 return;
3077 }
3078 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
3079 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
3080 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
3081 return;
3082 }
3083 if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() )
3084 return;
3085 v25 = 0;
3086 if ( pParty->uNumGold < v2 )
3087 {
3088 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
3089 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
3090 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
3091 return;
3092 }
3093 Party::TakeGold(v2);
3094 v35 = LODWORD(pPlayers[uActiveCharacter]->pConditions[17]);
3095 v59 = pPlayers[uActiveCharacter]->pConditions[14];
3096 v58 = pPlayers[uActiveCharacter]->pConditions[15];
3097 v60 = pPlayers[uActiveCharacter]->pConditions[16];
3098 v61 = (GUIWindow *)HIDWORD(pPlayers[uActiveCharacter]->pConditions[17]);
3099 memset(pPlayers[uActiveCharacter], 0, 0xA0u);
3100 pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth();
3101 pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana();
3102 v36 = (signed int)window_SpeakInHouse->ptr_1C;
3103 if ( v36 != 78 && (v36 <= 80 || v36 > 82) )
3104 {
3105 if ( (unsigned int)v61 | v35 )
3106 {
3107 v37 = LOBYTE(pPlayers[uActiveCharacter]->uPrevFace);
3108 v38 = pPlayers[uActiveCharacter]->uPrevVoiceID;
3109 pPlayers[uActiveCharacter]->uCurrentFace = v37;
3110 pPlayers[uActiveCharacter]->uVoiceID = v38;
3111 ReloadPlayerPortraits(uActiveCharacter - 1, (char)v37);
3112 }
3113 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
3114 pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
3115 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
3116 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
3117 return;
3118 }
3119 v39 = v61;
3120 if ( (unsigned int)v61 | v35 )
3121 {
3122 LODWORD(pPlayers[uActiveCharacter]->pConditions[17]) = v35;
3123 }
3124 else
3125 {
3126 if ( !v60 && !v58 && !v59 )
3127 {
3128 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
3129 pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
3130 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
3131 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
3132 return;
3133 }
3134 pPlayers[uActiveCharacter]->uPrevFace = pPlayers[uActiveCharacter]->uCurrentFace;
3135 pPlayers[uActiveCharacter]->uPrevVoiceID = pPlayers[uActiveCharacter]->uVoiceID;
3136 pPlayers[uActiveCharacter]->SetCondition(0x11u, 1);
3137 pPlayers[uActiveCharacter]->uVoiceID = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
3138 v40 = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
3139 pPlayers[uActiveCharacter]->uCurrentFace = v40;
3140 ReloadPlayerPortraits(uActiveCharacter - 1, (char)v40);
3141 LODWORD(pPlayers[uActiveCharacter]->pConditions[17]) = LODWORD(pParty->uTimePlayed);
3142 v39 = (GUIWindow *)HIDWORD(pParty->uTimePlayed);
3143 }
3144 HIDWORD(pPlayers[uActiveCharacter]->pConditions[17]) = (int)v39;
3145 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0); 2924 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
3146 pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0); 2925 pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
3147 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536); 2926 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
3148 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); 2927 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3149 return; // void func 2928 return;
3150 } 2929 }
3151 v63 = 1; 2930 pPlayers[uActiveCharacter]->uPrevFace = pPlayers[uActiveCharacter]->uCurrentFace;
3152 v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem); 2931 pPlayers[uActiveCharacter]->uPrevVoiceID = pPlayers[uActiveCharacter]->uVoiceID;
3153 strcpy(a1, ""); 2932 pPlayers[uActiveCharacter]->SetCondition(0x11u, 1);
3154 v41->uHeight = 0; 2933 pPlayers[uActiveCharacter]->uVoiceID = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
3155 v41->uY = 0; 2934 pPlayers[uActiveCharacter]->uCurrentFace = (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23;
3156 if ( pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() ) 2935 ReloadPlayerPortraits(uActiveCharacter - 1, (pPlayers[uActiveCharacter]->GetSexByVoice() != 0) + 23);
3157 { 2936 LODWORD(pPlayers[uActiveCharacter]->pConditions[17]) = LODWORD(pParty->uTimePlayed);
3158 sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]); 2937 //v39 = (GUIWindow *)HIDWORD(pParty->uTimePlayed);
3159 v63 = 0; 2938 }
3160 } 2939 //HIDWORD(pPlayers[uActiveCharacter]->pConditions[17]) = (int)v39;
3161 strcpy(&a1[100], pGlobalTXT_LocalizationStrings[68]); 2940 pPlayers[uActiveCharacter]->pConditions[17] =pParty->uTimePlayed;
3162 strcpy(&a1[200], pGlobalTXT_LocalizationStrings[160]); 2941 pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0);
3163 v42 = v63; 2942 pPlayers[uActiveCharacter]->PlaySound(SPEECH_82, 0);
3164 v43 = pDialogueWindow; 2943 pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
3165 v44 = v63; 2944 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3166 v66 = 0; 2945 return;
3167 if ( v63 < pDialogueWindow->pNumPresenceButton ) 2946 }
3168 { 2947 //---------------------------------------------------
3169 v61 = (GUIWindow *)&a1[100 * v63]; 2948 if ( dialog_menu_id == HOUSE_DIALOGUE_TEMPLE_DONATE )
3170 do 2949 {
2950 pPrice = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
2951 if ( pParty->uNumGold >= (unsigned int)pPrice )
2952 {
2953 Party::TakeGold((unsigned int)pPrice);
2954 v26 = &pOutdoor->ddm;
2955 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
2956 v26 = &pIndoor->dlv;
2957 if ( v26->uReputation > -5 )
2958 {
2959 v26->uReputation = v26->uReputation - 1;
2960 if ( v26->uReputation - 1 < -5 )
2961 v26->uReputation = -5;
2962 }
2963 if ( (unsigned __int8)byte_F8B1EF[uActiveCharacter] == pParty->uDaysPlayed % 7 )
2964 {
2965 if ( v26->uReputation <= -5 )
2966 {
2967 v30 = pParty->uDaysPlayed % 7 + 1;
2968 LOBYTE(v30) = v30 | 0x80;
2969 _42777D_CastSpell_UseWand_ShootArrow(SPELL_AIR_WIZARD_EYE, uActiveCharacter - 1, v30, 48, 0);
2970 }
2971 if ( v26->uReputation <= -10 )
2972 {
2973 v30 = pParty->uDaysPlayed % 7 + 1;
2974 LOBYTE(v30) = v30 | 0x80;
2975 _42777D_CastSpell_UseWand_ShootArrow(SPELL_SPIRIT_PRESERVATION, uActiveCharacter - 1, v30, 48, 0);
2976 }
2977 if ( v26->uReputation <= -15 )
2978 {
2979 v30 = pParty->uDaysPlayed % 7 + 1;
2980 LOBYTE(v30) = v30 | 0x80;
2981 _42777D_CastSpell_UseWand_ShootArrow(SPELL_BODY_PROTECTION_FROM_MAGIC, uActiveCharacter - 1, v30, 48, 0);
2982 }
2983 if ( v26->uReputation <= -20 )
2984 {
2985 v30 = pParty->uDaysPlayed % 7 + 1;
2986 LOBYTE(v30) = v30 | 0x80;
2987 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_HOUR_OF_POWER, uActiveCharacter - 1, v30, 48, 0);
2988 }
2989 if ( v26->uReputation <= -25 )
2990 {
2991 v30 = pParty->uDaysPlayed % 7 + 1;
2992 LOBYTE(v30) = v30 | 0x80;
2993 _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_DAY_OF_PROTECTION, uActiveCharacter - 1, v30, 48, 0);
2994 }
2995 }
2996 ++byte_F8B1EF[uActiveCharacter];
2997 pPlayers[uActiveCharacter]->PlaySound(SPEECH_83, 0);
2998 ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2); // "Thank You!"
2999 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3000 return;
3001 }
3002 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//" "
3003 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
3004 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3005 return;
3006 }
3007 //------------------------------------------------
3008 if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
3009 {
3010 if ( HouseUI_CheckIfPlayerCanInteract() )
3011 {
3012 all_text_height = 0;
3013 pCurrentItem = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
3014 v64 = (signed int)(pCurrentItem * (100 - pPlayers[uActiveCharacter]->GetMerchant())) / 100;
3015 if ( v64 < (signed int)pCurrentItem / 3 )
3016 v64 = (signed int)pCurrentItem / 3;
3017 pCurrentItem = 0;
3018 for ( int i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
3019 {
3020 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36]
3021 && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] )
3022 {
3023 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &tample_window, 0, 0);
3024 ++pCurrentItem;
3025 }
3026 }
3027 if ( pCurrentItem )
3028 {
3029 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v64);
3030 tample_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
3031 v64 = (149 - (signed int)all_text_height) / (signed int)pCurrentItem;
3032 if ( v64 > 32 )
3033 v64 = 32;
3034 all_text_height = (signed int)(149 - pCurrentItem * v64 - (int)all_text_height) / 2 - v64 / 2 + 162;
3035 if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
3036 {
3037 pCurrentItem = 2;
3038 for ( int i = pDialogueWindow->pStartingPosActiveItem;
3039 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
3040 {
3041 pButton = pDialogueWindow->GetControl(i);
3042 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36]
3043 || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
3171 { 3044 {
3172 v45 = pFontArrus->CalcTextHeight((const char *)v61, &v57, 0, 0); 3045 pButton->uW = 0;
3173 v66 = (DDM_DLV_Header *)((char *)v66 + v45); 3046 pButton->uHeight = 0;
3174 v43 = pDialogueWindow; 3047 pButton->uY = 0;
3175 v61 = (GUIWindow *)((char *)v61 + 100);
3176 ++v44;
3177 } 3048 }
3178 while ( v44 < pDialogueWindow->pNumPresenceButton ); 3049 else
3179 }
3180 v46 = v43->pNumPresenceButton - v42;
3181 v64 = (174 - (signed int)v66) / v46;
3182 if ( v64 > 32 )
3183 v64 = 32;
3184 v47 = (174 - v64 * v46 - (signed int)v66) / 2 - v64 / 2 + 138;
3185 v65 = v42 + v43->pStartingPosActiveItem;
3186 if ( v42 + v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton )
3187 {
3188 v61 = (GUIWindow *)(v42 + 2);
3189 v66 = (DDM_DLV_Header *)&a1[100 * v42];
3190 do
3191 { 3050 {
3192 v48 = v43->GetControl(v65); 3051 pButton->uY = v64 + all_text_height;
3193 v49 = (const char *)v66; 3052 pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &tample_window, 0, 0);
3194 v50 = v48; 3053 pButton->uHeight = pTextHeight;
3195 v48->uY = v64 + v47; 3054 pButton->uW = pButton->uY + pTextHeight - 1;
3196 v51 = pFontArrus->CalcTextHeight(v49, &v57, 0, 0); 3055 all_text_height = pButton->uW;
3197 v52 = v50->uY; 3056 pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
3198 v50->uHeight = v51; 3057 if ( pDialogueWindow->pCurrentPosActiveItem != pCurrentItem )
3199 v47 = v52 + v51 - 1; 3058 pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
3200 v50->uW = v47; 3059 tample_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
3201 v53 = WORD2(v59);
3202 if ( (GUIWindow *)pDialogueWindow->pCurrentPosActiveItem != v61 )
3203 v53 = WORD2(v58);
3204 v57.DrawTitleText(pFontArrus, 0, v52, v53, (const char *)v66, 3u);
3205 v43 = pDialogueWindow;
3206 v66 = (DDM_DLV_Header *)((char *)v66 + 100);
3207 v61 = (GUIWindow *)((char *)v61 + 1);
3208 ++v65;
3209 } 3060 }
3210 while ( (signed int)v65 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); 3061 pCurrentItem++;
3211 } 3062 }
3212 return; 3063 }
3213 } 3064 }
3065 else
3066 {
3067 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);//" %s %s -"
3068 strcat(pTmpBuf.data(), "\n \n");
3069 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//" ."
3070 pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &tample_window, 0, 0);
3071 tample_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
3072 }
3073 }
3074 }
3075 return;
3076 }
3214 3077
3215 //----- (004B4710) -------------------------------------------------------- 3078 //----- (004B4710) --------------------------------------------------------
3216 void TrainingDialog() 3079 void TrainingDialog()
3217 { 3080 {
3218 //Player *v0; // ebx@1
3219 int color2; // eax@1
3220 //unsigned int v2; // ecx@1
3221 //int v3; // eax@1
3222 //signed int v4; // edx@1
3223 unsigned __int64 v5; // edi@3 3081 unsigned __int64 v5; // edi@3
3224 //unsigned int v6; // esi@3
3225 //void *v7; // ecx@3
3226 int v8; // edx@4 3082 int v8; // edx@4
3227 double v9; // st7@6 3083 double v9; // st7@6
3228 signed int v10; // esi@6 3084 signed int v10; // esi@6
3229 int v11; // ecx@6 3085 int pPrice; // ecx@6
3230 //int result; // eax@9
3231 GUIWindow *v13; // edi@14
3232 signed int v14; // esi@14 3086 signed int v14; // esi@14
3233 unsigned int v15; // esi@16 3087 unsigned int v15; // esi@16
3234 int v16; // eax@16 3088 int v16; // eax@16
3235 unsigned int v17; // eax@17 3089 unsigned int v17; // eax@17
3236 int v18; // eax@19
3237 int v19; // ecx@24 3090 int v19; // ecx@24
3238 GUIButton *v20; // eax@26 3091 GUIButton *v20; // eax@26
3239 GUIButton *v21; // esi@26 3092 GUIButton *v21; // esi@26
3240 int v22; // eax@26 3093 int v22; // eax@26
3241 const char *v23; // eax@28 3094 const char *v23; // eax@28
3242 int v24; // eax@28 3095 int v24; // eax@28
3243 unsigned int v25; // ecx@28 3096 unsigned int v25; // ecx@28
3244 int v26; // eax@28 3097 int v26; // eax@28
3245 unsigned __int16 v27; // ax@28 3098 unsigned __int16 v27; // ax@28
3246 //int v28; // eax@32
3247 unsigned __int16 v29; // ST14_2@34 3099 unsigned __int16 v29; // ST14_2@34
3248 int v30; // eax@34 3100 int v30; // eax@34
3249 //const char *v31; // ST18_4@36
3250 //unsigned __int16 v32; // ST14_2@36
3251 int v33; // eax@36 3101 int v33; // eax@36
3252 int v34; // eax@37
3253 unsigned int v35; // edi@38
3254 unsigned int v36; // eax@38 3102 unsigned int v36; // eax@38
3255 //int v37; // ecx@41
3256 //char *v38; // eax@41
3257 //int *v39; // eax@45
3258 unsigned int v40; // eax@46
3259 //void *v41; // ecx@46
3260 unsigned int v42; // eax@46 3103 unsigned int v42; // eax@46
3261 GUIWindow *v43; // ecx@59 3104 int index;
3262 int v44; // edx@59 3105 int all_text_height; // eax@68
3263 char **v45; // esi@60
3264 //int v46; // eax@62
3265 int v47; // eax@68
3266 //int v48; // edx@69
3267 int v49; // ebx@69 3106 int v49; // ebx@69
3268 //unsigned __int8 v50; // sf@69 3107 GUIButton *pButton; // eax@71
3269 char **v51; // edi@70 3108 int pTextHeight; // eax@71
3270 GUIButton *v52; // eax@71 3109 unsigned __int16 pTextColor; // ax@71
3271 GUIButton *v53; // esi@71 3110 GUIWindow training_dialog_window; // [sp+Ch] [bp-78h]@1
3272 int v54; // eax@71
3273 unsigned int v55; // ecx@71
3274 int v56; // eax@71
3275 unsigned __int16 v57; // ax@71
3276 unsigned __int16 v58; // [sp-Ch] [bp-90h]@38
3277 //const char *v59; // [sp-Ch] [bp-90h]@63
3278 char *v60; // [sp-8h] [bp-8Ch]@38
3279 //char *v61; // [sp-8h] [bp-8Ch]@63
3280 unsigned int v62; // [sp-4h] [bp-88h]@38
3281 int v63; // [sp-4h] [bp-88h]@52
3282 //char *v64; // [sp-4h] [bp-88h]@63
3283 GUIWindow v65; // [sp+Ch] [bp-78h]@1
3284 //__int64 v66; // [sp+60h] [bp-24h]@3
3285 unsigned int white; // [sp+68h] [bp-1Ch]@1
3286 int v68; // [sp+6Ch] [bp-18h]@3 3111 int v68; // [sp+6Ch] [bp-18h]@3
3287 int v69; // [sp+70h] [bp-14h]@6 3112 int v69; // [sp+70h] [bp-14h]@6
3288 //unsigned int i; // [sp+74h] [bp-10h]@1
3289 //int v71; // [sp+78h] [bp-Ch]@1
3290 int v72; // [sp+7Ch] [bp-8h]@16
3291 int v73; // [sp+80h] [bp-4h]@14 3113 int v73; // [sp+80h] [bp-4h]@14
3292 3114
3293 //v0 = pPlayers[uActiveCharacter]; 3115 memcpy(&training_dialog_window, window_SpeakInHouse, sizeof(training_dialog_window));
3294 memcpy(&v65, window_SpeakInHouse, sizeof(v65)); 3116 training_dialog_window.uFrameX = 483;
3295 v65.uFrameX = 483; 3117 training_dialog_window.uFrameWidth = 148;
3296 v65.uFrameWidth = 148; 3118 training_dialog_window.uFrameZ = 334;
3297 v65.uFrameZ = 334;
3298 white = TargetColor(255, 255, 255);
3299 color2 = TargetColor(0xE1u, 0xCDu, 0x23u);
3300 //v71 = color2;
3301 //v2 = v0->uLevel;
3302 //v3 = 0;
3303 //v4 = 0;
3304 //for ( i = v2; v4 < (signed int)v2; ++v4 )
3305 // v3 += v4 + 1;
3306 //v5 = 1000 * v3;
3307 v5 = 1000ui64 * pPlayers[uActiveCharacter]->uLevel * (pPlayers[uActiveCharacter]->uLevel + 1) / 2; // E n = n(n + 1) / 2 3119 v5 = 1000ui64 * pPlayers[uActiveCharacter]->uLevel * (pPlayers[uActiveCharacter]->uLevel + 1) / 2; // E n = n(n + 1) / 2
3308 //v6 = HIDWORD(v0->uExperience);
3309 //v7 = window_SpeakInHouse->ptr_1C;
3310 v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE]; 3120 v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE];
3311 //v66 = 1000 * v3;
3312 if (pPlayers[uActiveCharacter]->uExperience >= v5) 3121 if (pPlayers[uActiveCharacter]->uExperience >= v5)
3313 { 3122 {
3314 v8 = pPlayers[uActiveCharacter]->classType % 4 + 1; 3123 v8 = pPlayers[uActiveCharacter]->classType % 4 + 1;
3315 if ( v8 == 4 ) 3124 if ( v8 == 4 )
3316 v8 = 3; 3125 v8 = 3;
3317 v9 = (double)pPlayers[uActiveCharacter]->uLevel; 3126 v9 = (double)pPlayers[uActiveCharacter]->uLevel;
3318 //i = 0;
3319 v69 = v8; 3127 v69 = v8;
3320 //v10 = (signed __int64)(v9 * p2DEvents_minus1__20[13 * (signed int)v7] * (double)v8);
3321 v10 = (signed __int64)(v9 * p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * (double)v8); 3128 v10 = (signed __int64)(v9 * p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * (double)v8);
3322 v11 = v10 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; 3129 pPrice = v10 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
3323 if ( v11 < v10 / 3 ) 3130 if ( pPrice < v10 / 3 )
3324 v11 = v10 / 3; 3131 pPrice = v10 / 3;
3325 //i = v11; 3132 }
3326 } 3133 //-------------------------------------------------------
3327 3134 all_text_height = 0;
3328 if (HouseUI_CheckIfPlayerCanInteract()) 3135 if (HouseUI_CheckIfPlayerCanInteract())
3329 { 3136 {
3330 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) 3137 if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN )
3331 { 3138 {
3332 if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) 3139 if (HouseUI_CheckIfPlayerCanInteract())
3333 { 3140 {
3334 if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) 3141 index = 0;
3335 { 3142 pShopOptions[0] = pTmpBuf.data();
3336 if (HouseUI_CheckIfPlayerCanInteract()) 3143 pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills"
3337 { 3144 if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
3338 //i = 0; 3145 {
3339 int _v0 = 0; 3146 for ( int i = pDialogueWindow->pStartingPosActiveItem;
3340 v13 = pDialogueWindow; 3147 i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
3341 //v14 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); 3148 {
3342 v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); 3149 if ( pDialogueWindow->GetControl(i)->msg_param == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
3343 v73 = v14 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
3344 if ( v73 < v14 / 3 )
3345 v73 = v14 / 3;
3346 v15 = v13->pStartingPosActiveItem;
3347 v16 = v13->pNumPresenceButton;
3348 v72 = 0;
3349 if ( (signed int)v15 >= (signed int)(v15 + v16) )
3350 goto LABEL_76;
3351 do
3352 { 3150 {
3353 v17 = v13->GetControl(v15)->msg_param - 36; 3151 if (pPlayers[uActiveCharacter]->uLevel >= v68)
3354 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v17] && !pPlayers[uActiveCharacter]->pActiveSkills[v17] ) 3152 sprintfex(pShopOptions[index], "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher." "Sorry, but we are unable to train you."
3153 else
3355 { 3154 {
3356 v18 = pFontArrus->CalcTextHeight(pSkillNames[v17], &v65, 0, 0); 3155 if (pPlayers[uActiveCharacter]->uExperience < v5)
3357 _v0 += v18; 3156 sprintfex(pShopOptions[index], pGlobalTXT_LocalizationStrings[538], (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1); // "You need %d more experience to train to level %d"
3358 ++v72; 3157 else
3359 } 3158 sprintfex(pShopOptions[index], pGlobalTXT_LocalizationStrings[537], pPlayers[uActiveCharacter]->uLevel + 1, pPrice); // "Train to level %d for %d gold"
3360 ++v15;
3361 }
3362 while ( (signed int)v15 < v13->pNumPresenceButton + v13->pStartingPosActiveItem );
3363 if ( v72 )
3364 {
3365 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
3366 v65.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u);
3367 v73 = (signed int)(149 - _v0) / v72;
3368 if ( v73 > 32 )
3369 v73 = 32;
3370 //result = v13->pStartingPosActiveItem;
3371 v19 = (signed int)(149 - v72 * v73 - _v0) / 2 - v73 / 2 + 162;
3372 int _v1 = v13->pStartingPosActiveItem;
3373 v68 = v19;
3374 if (v13->pStartingPosActiveItem < v13->pStartingPosActiveItem + v13->pNumPresenceButton )
3375 {
3376 v72 = 2;
3377 do
3378 {
3379 v20 = v13->GetControl(_v1);
3380 v21 = v20;
3381 v22 = v20->msg_param - 36;
3382 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v22] || pPlayers[uActiveCharacter]->pActiveSkills[v22] )
3383 {
3384 v21->uW = 0;
3385 v21->uHeight = 0;
3386 v21->uY = 0;
3387 }
3388 else
3389 {
3390 v23 = pSkillNames[v22];
3391 v21->uY = v73 + v68;
3392 //HIDWORD(v66) = (int)v23;
3393 v24 = pFontArrus->CalcTextHeight(v23, &v65, 0, 0);
3394 v25 = v21->uY;
3395 v21->uHeight = v24;
3396 v26 = v25 + v24 - 1;
3397 v21->uW = v26;
3398 v68 = v26;
3399 v27 = color2;
3400 if ( pDialogueWindow->pCurrentPosActiveItem != v72 )
3401 v27 = white;
3402 v65.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3u);
3403 }
3404 ++_v1;
3405 ++v72;
3406 }
3407 while ( (signed int)_v1 < v13->pStartingPosActiveItem + v13->pNumPresenceButton );
3408 } 3159 }
3409 } 3160 }
3410 else 3161 all_text_height += pFontArrus->CalcTextHeight(pShopOptions[index], &training_dialog_window, 0, 0);
3411 { 3162 ++index;
3412 LABEL_76: 3163 }
3413 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// 3164 }
3414 // "Seek knowledge elsewhere %s the %s" 3165 v49 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
3415 strcat(pTmpBuf.data(), "\n \n"); 3166 if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton)
3416 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." 3167 {
3417 v29 = color2; 3168 int pCurrentItem = 2;
3418 v30 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0); 3169 index = 0;
3419 v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf.data(), 3u); 3170 for ( int i = pDialogueWindow->pStartingPosActiveItem;
3420 } 3171 i < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; ++i )
3421 } 3172 {
3422 } 3173 pButton = pDialogueWindow->GetControl(i);
3423 return; 3174 pButton->uY = (174 - all_text_height) / 2 + v49;
3424 } 3175 pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[index], &training_dialog_window, 0, 0);
3176 pButton->uHeight = pTextHeight;
3177 pButton->uW = pTextHeight + pButton->uY - 1;
3178 v49 = pButton->uW;
3179 pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
3180 if ( pDialogueWindow->pCurrentPosActiveItem != pCurrentItem )
3181 pTextColor = TargetColor(255, 255, 255);
3182 training_dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[index], 3);
3183 ++pCurrentItem;
3184 ++index;
3185 }
3186 }
3187 }
3188 }
3189 //------------------------------------------------------------------
3190 if ( dialog_menu_id == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
3191 {
3425 if ( !HouseUI_CheckIfPlayerCanInteract() ) 3192 if ( !HouseUI_CheckIfPlayerCanInteract() )
3426 { 3193 {
3427 //v31 = pNPCTopics[122].pText; 3194 v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &training_dialog_window, 0, 0);
3428 //v32 = color2; 3195 training_dialog_window.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, TargetColor(0xE1u, 0xCDu, 0x23u), pNPCTopics[122].pText, 3);
3429 v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0);
3430 v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, color2, pNPCTopics[122].pText, 3);
3431 pDialogueWindow->pNumPresenceButton = 0; 3196 pDialogueWindow->pNumPresenceButton = 0;
3432 return; 3197 return;
3433 } 3198 }
3434 v34 = pPlayers[uActiveCharacter]->uLevel; 3199 //v34 = pPlayers[uActiveCharacter]->uLevel;
3435 if ( v34 < v68 ) 3200 if ( pPlayers[uActiveCharacter]->uLevel < v68 )
3436 { 3201 {
3437 if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience >= v5 ) 3202 if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience >= v5 )
3438 { 3203 {
3439 if ( pParty->uNumGold >= v11) 3204 if ( pParty->uNumGold >= pPrice)
3440 { 3205 {
3441 Party::TakeGold(v11); 3206 Party::TakeGold(pPrice);
3442 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); 3207 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
3443 ++pPlayers[uActiveCharacter]->uLevel; 3208 ++pPlayers[uActiveCharacter]->uLevel;
3444 pPlayers[uActiveCharacter]->uSkillPoints += pPlayers[uActiveCharacter]->uLevel / 10 + 5; 3209 pPlayers[uActiveCharacter]->uSkillPoints += pPlayers[uActiveCharacter]->uLevel / 10 + 5;
3445 pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth(); 3210 pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth();
3446 pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana(); 3211 pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana();
3447
3448 uint max_level_in_party = player_levels[0]; 3212 uint max_level_in_party = player_levels[0];
3449 for (uint _it = 1; _it < 4; ++_it) 3213 for (uint _it = 1; _it < 4; ++_it)
3450 { 3214 {
3451 if (player_levels[_it] > max_level_in_party) 3215 if (player_levels[_it] > max_level_in_party)
3452 max_level_in_party = player_levels[_it]; 3216 max_level_in_party = player_levels[_it];
3453 } 3217 }
3454
3455 ++player_levels[uActiveCharacter - 1]; 3218 ++player_levels[uActiveCharacter - 1];
3456 if (player_levels[uActiveCharacter - 1] > max_level_in_party) // if we reach new maximum party level 3219 if (player_levels[uActiveCharacter - 1] > max_level_in_party) // if we reach new maximum party level
3457 // feature is broken thou, since this array is always zeroed in EnterHouse 3220 // feature is broken thou, since this array is always zeroed in EnterHouse
3458 { 3221 {
3459 v40 = _494820_training_time(pParty->uCurrentHour); 3222 v42 = 60 * (_494820_training_time(pParty->uCurrentHour) + 4) - pParty->uCurrentMinute;
3460 //v41 = window_SpeakInHouse->ptr_1C;
3461 v42 = 60 * (v40 + 4) - pParty->uCurrentMinute;
3462 if ((unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_94 || 3223 if ((unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_94 ||
3463 (unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_95) 3224 (unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_95)
3464 v42 += 720; 3225 v42 += 720;
3465 RestAndHeal((signed int)(v42 + 10080)); 3226 RestAndHeal((signed int)(v42 + 10080));
3466 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) 3227 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
3472 ShowStatusBarString(pTmpBuf.data(), 2); 3233 ShowStatusBarString(pTmpBuf.data(), 2);
3473 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); 3234 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3474 return; 3235 return;
3475 } 3236 }
3476 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" 3237 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
3477 v63 = 4; 3238 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)4);
3478 LABEL_55:
3479 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v63);
3480 //LABEL_56:
3481 /*result = pMessageQueue_50CBD0->uNumMessages;
3482 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
3483 {
3484 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
3485 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
3486 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
3487 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
3488 ++pMessageQueue_50CBD0->uNumMessages;
3489 }
3490 return result;*/
3491 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); 3239 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3492 return; 3240 return;
3493 } 3241 }
3494 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), v34 + 1);// 3242 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1);//
3495 // "You need %d more experience to train to level %d" 3243 // "You need %d more experience to train to level %d"
3496 v35 = 0; 3244 v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0)) / 2 + 88;
3497 v62 = 3;
3498 v60 = pTmpBuf.data();
3499 v58 = color2;
3500 v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0)) / 2 + 88;
3501 } 3245 }
3502 else 3246 else
3503 { 3247 {
3504 sprintf(pTmpBuf.data(), "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);// 3248 sprintf(pTmpBuf.data(), "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);//
3505 // ""With your skills, you should be working here as a teacher."" 3249 // ""With your skills, you should be working here as a teacher.""
3506 // ""Sorry, but we are unable to train you."" 3250 // ""Sorry, but we are unable to train you.""
3507 v35 = 0; 3251 v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0)) / 2 + 101;
3508 v62 = 3; 3252 }
3509 v60 = pTmpBuf.data(); 3253 training_dialog_window.DrawTitleText(pFontArrus, 0, v36, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
3510 v58 = color2; 3254 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)3);
3511 v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0)) / 2 + 101; 3255 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
3512 } 3256 return;
3513 v65.DrawTitleText(pFontArrus, v35, v36, v58, v60, v62); 3257 }
3514 v63 = 3; 3258 }
3515 goto LABEL_55; 3259 //-------------------------------------------------------------
3516 } 3260 if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
3517 3261 {
3518 if (HouseUI_CheckIfPlayerCanInteract()) 3262 if (HouseUI_CheckIfPlayerCanInteract())
3519 { 3263 {
3520 v43 = pDialogueWindow; 3264 v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
3521 v72 = 0; 3265 v73 = v14 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
3522 pShopOptions[0] = pTmpBuf.data(); 3266 if ( v73 < v14 / 3 )
3523 pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills" 3267 v73 = v14 / 3;
3524 v44 = pDialogueWindow->pNumPresenceButton; 3268 v15 = pDialogueWindow->pStartingPosActiveItem;
3525 v73 = pDialogueWindow->pStartingPosActiveItem; 3269 v16 = pDialogueWindow->pNumPresenceButton;
3526 if ( v73 < v73 + v44 ) 3270 index = 0;
3527 { 3271 if ( (signed int)v15 >= (signed int)(v15 + v16) )
3528 v45 = pShopOptions.data(); 3272 goto LABEL_76;
3529 do 3273 do
3530 { 3274 {
3531 if ( v43->GetControl(v73)->msg_param == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) 3275 v17 = pDialogueWindow->GetControl(v15)->msg_param - 36;
3532 { 3276 if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v17] && !pPlayers[uActiveCharacter]->pActiveSkills[v17] )
3533 //v46 = pPlayers[uActiveCharacter]->uLevel; 3277 {
3534 if (pPlayers[uActiveCharacter]->uLevel >= v68) 3278 all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v17], &training_dialog_window, 0, 0);
3535 sprintfex(*v45, "%s\n \n%s", 3279 ++index;
3536 pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher." "Sorry, but we are unable to train you." 3280 }
3281 ++v15;
3282 }
3283 while ( (signed int)v15 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
3284 if ( index )
3285 {
3286 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
3287 training_dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
3288 v73 = (signed int)(149 - all_text_height) / index;
3289 if ( v73 > 32 )
3290 v73 = 32;
3291 v19 = (signed int)(149 - index * v73 - all_text_height) / 2 - v73 / 2 + 162;
3292 int _v1 = pDialogueWindow->pStartingPosActiveItem;
3293 v68 = v19;
3294 if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton )
3295 {
3296 index = 2;
3297 do
3298 {
3299 v20 = pDialogueWindow->GetControl(_v1);
3300 v21 = v20;
3301 v22 = v20->msg_param - 36;
3302 if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v22] || pPlayers[uActiveCharacter]->pActiveSkills[v22] )
3303 {
3304 v21->uW = 0;
3305 v21->uHeight = 0;
3306 v21->uY = 0;
3307 }
3537 else 3308 else
3538 { 3309 {
3539 if (pPlayers[uActiveCharacter]->uExperience < v5) 3310 v23 = pSkillNames[v22];
3540 sprintfex(*v45, pGlobalTXT_LocalizationStrings[538], // "You need %d more experience to train to level %d" 3311 v21->uY = v73 + v68;
3541 (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1); 3312 //HIDWORD(v66) = (int)v23;
3542 else 3313 v24 = pFontArrus->CalcTextHeight(v23, &training_dialog_window, 0, 0);
3543 sprintfex(*v45, pGlobalTXT_LocalizationStrings[537], // "Train to level %d for %d gold" 3314 v25 = v21->uY;
3544 pPlayers[uActiveCharacter]->uLevel + 1, v11); 3315 v21->uHeight = v24;
3316 v26 = v25 + v24 - 1;
3317 v21->uW = v26;
3318 v68 = v26;
3319 v27 = TargetColor(0xE1u, 0xCDu, 0x23u);
3320 if ( pDialogueWindow->pCurrentPosActiveItem != index )
3321 v27 = TargetColor(255, 255, 255);
3322 training_dialog_window.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3);
3545 } 3323 }
3546 } 3324 ++_v1;
3547 v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0); 3325 ++index;
3548 v43 = pDialogueWindow; 3326 }
3549 v72 += v47; 3327 while ( (signed int)_v1 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton );
3550 ++v45; 3328 }
3551 ++v73; 3329 }
3552 } 3330 else
3553 while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); 3331 {
3554 } 3332 LABEL_76:
3555 3333 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);//
3556 v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138; 3334 // "Seek knowledge elsewhere %s the %s"
3557 v73 = v43->pStartingPosActiveItem; 3335 strcat(pTmpBuf.data(), "\n \n");
3558 if (v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton) 3336 strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
3559 { 3337 v29 = TargetColor(0xE1u, 0xCDu, 0x23u);
3560 int _v3 = 2; 3338 v30 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0);
3561 v51 = pShopOptions.data(); 3339 training_dialog_window.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf.data(), 3);
3562 do 3340 }
3563 { 3341 }
3564 v52 = v43->GetControl(v73); 3342 }
3565 v53 = v52; 3343 return;
3566 v52->uY = (174 - v72) / 2 + v49;
3567 v54 = pFontArrus->CalcTextHeight(*v51, &v65, 0, 0);
3568 v55 = v53->uY;
3569 v53->uHeight = v54;
3570 v56 = v54 + v55 - 1;
3571 v53->uW = v56;
3572 v49 = v56;
3573 v57 = color2;
3574 if ( pDialogueWindow->pCurrentPosActiveItem != _v3 )
3575 v57 = white;
3576 v65.DrawTitleText(pFontArrus, 0, v55, v57, *v51, 3u);
3577 v43 = pDialogueWindow;
3578 ++_v3;
3579 ++v51;
3580 ++v73;
3581 }
3582 while ( v73 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton);
3583 }
3584 }
3585 }
3586 } 3344 }
3587 3345
3588 //----- (004B6478) -------------------------------------------------------- 3346 //----- (004B6478) --------------------------------------------------------
3589 void sub_4B6478() 3347 void sub_4B6478()
3590 { 3348 {
3808 unsigned int v36; // edi@51 3566 unsigned int v36; // edi@51
3809 GUIButton *v37; // eax@52 3567 GUIButton *v37; // eax@52
3810 int v38; // eax@52 3568 int v38; // eax@52
3811 signed int v39; // ecx@54 3569 signed int v39; // ecx@54
3812 int v40; // edi@57 3570 int v40; // edi@57
3813 GUIButton *v41; // eax@60
3814 GUIButton *v42; // esi@60
3815 const char *v43; // ebx@60 3571 const char *v43; // ebx@60
3816 int v44; // eax@60 3572 int v44; // eax@60
3817 unsigned int v45; // ecx@60 3573 unsigned int v45; // ecx@60
3818 unsigned __int16 v46; // ax@60 3574 unsigned __int16 v46; // ax@60
3819 GUIFont *v47; // ebx@64 3575 GUIFont *v47; // ebx@64
4022 pNPC = (NPCData *)32; 3778 pNPC = (NPCData *)32;
4023 pInString = (char *)2; 3779 pInString = (char *)2;
4024 v40 = (174 - (signed int)pNPC * v39 - v34) / 2 - (signed int)pNPC / 2 + 138; 3780 v40 = (174 - (signed int)pNPC * v39 - v34) / 2 - (signed int)pNPC / 2 + 138;
4025 for ( i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) 3781 for ( i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
4026 { 3782 {
4027 v41 = pDialogueWindow->GetControl(i); 3783 pButton = pDialogueWindow->GetControl(i);
4028 v42 = v41; 3784 //v42 = v41;
4029 v43 = v41->pButtonName; 3785 v43 = pButton->pButtonName;
4030 v41->uY = (unsigned int)((char *)pNPC + v40); 3786 pButton->uY = (unsigned int)((char *)pNPC + v40);
4031 v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0); 3787 v44 = pFontArrus->CalcTextHeight(pButton->pButtonName, &v52, 0, 0);
4032 v45 = v42->uY; 3788 v45 = pButton->uY;
4033 v42->uHeight = v44; 3789 pButton->uHeight = v44;
4034 v40 = v45 + v44 - 1; 3790 v40 = v45 + v44 - 1;
4035 v42->uW = v40; 3791 pButton->uW = v40;
4036 v46 = TargetColor(0xE1u, 0xCDu, 0x23u); 3792 v46 = TargetColor(0xE1u, 0xCDu, 0x23u);
4037 if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString ) 3793 if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString )
4038 v46 = TargetColor(0xFFu, 0xFFu, 0xFFu); 3794 v46 = TargetColor(0xFFu, 0xFFu, 0xFFu);
4039 v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3); 3795 v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3);
4040 ++pInString; 3796 ++pInString;
4058 } 3814 }
4059 3815
4060 //----- (004B4F4F) -------------------------------------------------------- 3816 //----- (004B4F4F) --------------------------------------------------------
4061 void JailDialog() 3817 void JailDialog()
4062 { 3818 {
4063 const char *v0; // esi@1 3819 GUIWindow jail_dialogue_window; // [sp+8h] [bp-54h]@1
4064 const char *v1; // ST10_4@1 3820
4065 unsigned __int16 v2; // ST0C_2@1 3821 memcpy(&jail_dialogue_window, window_SpeakInHouse, sizeof(jail_dialogue_window));
4066 int v3; // eax@1 3822 jail_dialogue_window.uFrameX = 483;
4067 GUIWindow v5; // [sp+8h] [bp-54h]@1 3823 jail_dialogue_window.uFrameWidth = 148;
4068 3824 jail_dialogue_window.uFrameZ = 334;
4069 memcpy(&v5, window_SpeakInHouse, sizeof(v5)); 3825 jail_dialogue_window.DrawTitleText(pFontArrus, 0, (310 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[672], &jail_dialogue_window, 0, 0)) / 2 + 18,
4070 v0 = pGlobalTXT_LocalizationStrings[672]; 3826 TargetColor(0xFFu, 0xFFu, 0x9Bu), pGlobalTXT_LocalizationStrings[672], 3);
4071 v1 = pGlobalTXT_LocalizationStrings[672];
4072 v5.uFrameX = 483;
4073 v5.uFrameWidth = 148;
4074 v5.uFrameZ = 334;
4075 v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
4076 v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0);
4077 v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u);
4078 } 3827 }