comparison UI/UIHouses.cpp @ 1441:b67a3e0d6fc3

Слияние
author Ritor1
date Sat, 27 Jul 2013 09:36:55 +0600
parents 468f434a8d8a 2423bc2af692
children 6de9c1316852
comparison
equal deleted inserted replaced
1440:a72236d60edc 1441:b67a3e0d6fc3
11 #include "..\Arcomage.h" 11 #include "..\Arcomage.h"
12 #include "..\LOD.h" 12 #include "..\LOD.h"
13 #include "..\Mouse.h" 13 #include "..\Mouse.h"
14 #include "..\GUIWindow.h" 14 #include "..\GUIWindow.h"
15 #include "..\GUIFont.h" 15 #include "..\GUIFont.h"
16 #include "..\Events2D.h"
17 #include "..\Overlays.h" 16 #include "..\Overlays.h"
18 #include "..\Outdoor.h" 17 #include "..\Outdoor.h"
19 #include "..\AudioPlayer.h" 18 #include "..\AudioPlayer.h"
20 #include "..\VideoPlayer.h" 19 #include "..\VideoPlayer.h"
21 #include "..\Monsters.h" 20 #include "..\Monsters.h"
29 #include "..\stru159.h" 28 #include "..\stru159.h"
30 int uHouse_ExitPic; // weak 29 int uHouse_ExitPic; // weak
31 30
32 int dword_591080; // weak 31 int dword_591080; // weak
33 32
34 int in_current_building_type; // 00F8B198 33 BuildingType in_current_building_type; // 00F8B198
35 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C 34 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C
36 35
37 #pragma pack(push, 1) 36 #pragma pack(push, 1)
38 struct stru365_travel_info 37 struct stru365_travel_info
39 { 38 {
313 {"Player Castle Good", 0x24, 0, 25, 0, 0 }, 312 {"Player Castle Good", 0x24, 0, 25, 0, 0 },
314 {"Player Castle Bad", 0x24, 0, 25, 0, 0} 313 {"Player Castle Bad", 0x24, 0, 25, 0, 0}
315 }}; 314 }};
316 315
317 316
317
318 //----- (004B3A72) --------------------------------------------------------
319 void InitializaDialogueOptions_Tavern(BuildingType type)
320 {
321 int num_buttons; // esi@1
322
323 num_buttons = 0;
324 if (type == BuildingType_Tavern)
325 {
326 num_buttons = 2;
327 CreateButtonInColumn(0, 102);
328 CreateButtonInColumn(1, 103);
329 if ( pParty->HasItem(651) ) //Arcomage Deck
330 {
331 num_buttons = 3;
332 CreateButtonInColumn(2, 104);
333 }
334 }
335 pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2);
336 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
337 }
338 // F8B1E0: using guessed type int dword_F8B1E0;
339
340 //----- (004B3AD4) --------------------------------------------------------
341 void InitializaDialogueOptions_Shops(BuildingType type)
342 {
343 switch (type)
344 {
345 case BuildingType_WeaponShop:
346 case BuildingType_ArmorShop:
347 case BuildingType_MagicShop:
348 {
349 CreateButtonInColumn(0, 3);
350 CreateButtonInColumn(1, 4);
351 CreateButtonInColumn(2, 5);
352 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
353 }
354 break;
355
356 case BuildingType_AlchemistShop:
357 {
358 CreateButtonInColumn(0, 3);
359 CreateButtonInColumn(1, 4);
360 pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
361 }
362 break;
363 }
364
365 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
366 }
367 // F8B1E0: using guessed type int dword_F8B1E0;
368
369 //----- (004B3B42) --------------------------------------------------------
370 void InitializaDialogueOptions(BuildingType type)
371 {
372 /*int v1; // ecx@18
373 int v2; // ecx@19
374 int v3; // ecx@20
375 signed int v4; // esi@22
376 signed int v5; // eax@22
377 unsigned int v6; // edx@24
378 int v7; // ecx@24
379 int result; // eax@43
380 int v9; // [sp-10h] [bp-14h]@28
381 int v10; // [sp-Ch] [bp-10h]@28
382 int v11; // [sp-8h] [bp-Ch]@28
383 unsigned int v12; // [sp-4h] [bp-8h]@4
384 unsigned int v13; // [sp-4h] [bp-8h]@5
385 unsigned int v14; // [sp-4h] [bp-8h]@9
386 unsigned int v15; // [sp-4h] [bp-8h]@10
387 unsigned int v16; // [sp-4h] [bp-8h]@14
388 int v17; // [sp-4h] [bp-8h]@28*/
389
390 switch (type)
391 {
392 case BuildingType_WeaponShop:
393 case BuildingType_ArmorShop:
394 case BuildingType_MagicShop:
395 case BuildingType_AlchemistShop:
396 {
397 CreateButtonInColumn(0, 2);
398 CreateButtonInColumn(1, 95);
399 CreateButtonInColumn(2, 94);
400 CreateButtonInColumn(3, 96);
401 pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
402 }
403 break;
404
405 case BuildingType_FireGuild:
406 {
407 CreateButtonInColumn(0, 18);
408 CreateButtonInColumn(1, 48);
409 CreateButtonInColumn(2, 72);
410 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
411 }
412 break;
413
414 case BuildingType_AirGuild:
415 {
416 CreateButtonInColumn(0, 18);
417 CreateButtonInColumn(1, 49);
418 CreateButtonInColumn(2, 72);
419 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
420 }
421 break;
422
423 case BuildingType_WaterGuild:
424 {
425 CreateButtonInColumn(0, 18);
426 CreateButtonInColumn(1, 50);
427 CreateButtonInColumn(2, 72);
428 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
429 }
430 break;
431
432 case BuildingType_EarthGuild:
433 {
434 CreateButtonInColumn(0, 18);
435 CreateButtonInColumn(1, 51);
436 CreateButtonInColumn(2, 72);
437 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
438 }
439 break;
440
441 case BuildingType_SpiritGuild:
442 {
443 CreateButtonInColumn(0, 18);
444 CreateButtonInColumn(1, 52);
445 CreateButtonInColumn(2, 61);
446 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
447 }
448 break;
449
450 case BuildingType_MindGuild:
451 {
452 CreateButtonInColumn(0, 18);
453 CreateButtonInColumn(1, 53);
454 CreateButtonInColumn(2, 61);
455 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
456 }
457 break;
458
459 case BuildingType_BodyGuild:
460 {
461 CreateButtonInColumn(0, 18);
462 CreateButtonInColumn(1, 54);
463 CreateButtonInColumn(2, 61);
464 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
465 }
466 break;
467
468 case BuildingType_LightGuild:
469 {
470 CreateButtonInColumn(0, 18);
471 CreateButtonInColumn(1, 55);
472 pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
473 }
474 break;
475
476 case BuildingType_DarkGuild:
477 {
478 CreateButtonInColumn(0, 18);
479 CreateButtonInColumn(1, 56);
480 pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
481 }
482 break;
483
484 case BuildingType_14:
485 {
486 CreateButtonInColumn(0, 18);
487 CreateButtonInColumn(1, 48);
488 CreateButtonInColumn(2, 49);
489 CreateButtonInColumn(3, 50);
490 CreateButtonInColumn(4, 51);
491 pDialogueWindow->_41D08F_set_keyboard_control_group(5, 1, 0, 2);
492 }
493 break;
494
495 case BuildingType_15:
496 {
497 CreateButtonInColumn(0, 18);
498 CreateButtonInColumn(1, 52);
499 CreateButtonInColumn(2, 53);
500 CreateButtonInColumn(3, 54);
501 pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
502 }
503 break;
504
505 case BuildingType_16:
506 case BuildingType_TownHall:
507 {
508 int num_buttons = 1;
509 CreateButtonInColumn(0, 99);
510
511 if (pParty->uFine)
512 {
513 num_buttons++;
514 CreateButtonInColumn(1, 100);
515 }
516
517 pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2);
518 }
519 break;
520
521 case BuildingType_Bank:
522 {
523 CreateButtonInColumn(0, 7);
524 CreateButtonInColumn(1, 8);
525 pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
526 }
527 break;
528
529 case BuildingType_Temple:
530 {
531 CreateButtonInColumn(0, 10);
532 CreateButtonInColumn(1, 11);
533 CreateButtonInColumn(2, 96);
534 pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
535 }
536 break;
537
538 case BuildingType_Stables:
539 case BuildingType_Boats:
540 {
541 CreateButtonInColumn(0, 105);
542 CreateButtonInColumn(1, 106);
543 CreateButtonInColumn(2, 107);
544 CreateButtonInColumn(3, 108);
545 pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
546 }
547 break;
548
549 case BuildingType_Training:
550 {
551 CreateButtonInColumn(0, 17);
552 CreateButtonInColumn(1, 96);
553 pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
554 }
555 break;
556
557 case BuildingType_18:
558 case BuildingType_19:
559 case BuildingType_Throne_Room:
560 case BuildingType_24:
561 case BuildingType_Unic:
562 case BuildingType_1A:
563 case BuildingType_House:
564 case BuildingType_Jail:
565 break;
566
567 default:
568 assert(false && "Invalid enumeration value");
569 }
570
571 /* if ( a1 > 13 )
572 {
573 if ( a1 > 22 )
574 {
575 if ( a1 == 23 )
576 {
577 CreateButtonInColumn(0, 0xAu);
578 CreateButtonInColumn(1, 0xBu);
579 v14 = 96;
580 LABEL_41:
581 CreateButtonInColumn(2, v14);
582 v17 = 2;
583 v11 = 0;
584 v10 = 1;
585 v9 = 3;
586 goto LABEL_42;
587 }
588 if ( a1 <= 26 )
589 goto LABEL_43;
590 if ( a1 > 28 )
591 {
592 if ( a1 != 30 )
593 goto LABEL_43;
594 CreateButtonInColumn(0, 0x11u);
595 v16 = 96;
596 goto LABEL_37;
597 }
598 CreateButtonInColumn(0, 0x69u);
599 CreateButtonInColumn(1, 0x6Au);
600 CreateButtonInColumn(2, 0x6Bu);
601 v12 = 108;
602 }
603 else
604 {
605 if ( a1 == 22 )
606 {
607 CreateButtonInColumn(0, 7u);
608 v16 = 8;
609 goto LABEL_37;
610 }
611 v1 = a1 - 14;
612 if ( !v1 ) // == 14
613 {
614 CreateButtonInColumn(0, 0x12u);
615 CreateButtonInColumn(1, 0x30u);
616 CreateButtonInColumn(2, 0x31u);
617 CreateButtonInColumn(3, 0x32u);
618 CreateButtonInColumn(4, 0x33u);
619 v17 = 2;
620 v11 = 0;
621 v10 = 1;
622 v9 = 5;
623 goto LABEL_42;
624 }
625 v2 = v1 - 1;
626 if ( v2 ) // > 15
627 {
628 v3 = v2 - 2;
629 if ( v3 ) // > 17
630 {
631 if ( v3 != 4 ) // 18, 19, 20
632 goto LABEL_43;
633 CreateButtonInColumn(0, 0xFu); // 21
634 CreateButtonInColumn(1, 0x10u);
635 v4 = 3;
636 CreateButtonInColumn(2, 0x60u);
637 v5 = (signed int)window_SpeakInHouse->ptr_1C;
638 if ( v5 < 108 || v5 > 120 )
639 goto LABEL_28;
640 v4 = 4;
641 v6 = 101;
642 v7 = 3;
643 }
644 else // 16, 17
645 {
646 v4 = 1;
647 CreateButtonInColumn(0, 0x63u);
648 if ( !pParty->uFine )
649 {
650 LABEL_28:
651 v17 = 2;
652 v11 = 0;
653 v10 = 1;
654 v9 = v4;
655 LABEL_42:
656 pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17);
657 goto LABEL_43;
658 }
659 v4 = 2;
660 v7 = 1;
661 v6 = 100;
662 }
663 CreateButtonInColumn(v7, v6);
664 goto LABEL_28;
665 }
666 CreateButtonInColumn(0, 0x12u); // 15
667 CreateButtonInColumn(1, 0x34u);
668 CreateButtonInColumn(2, 0x35u);
669 v12 = 54;
670 }
671 LABEL_39:
672 CreateButtonInColumn(3, v12);
673 v17 = 2;
674 v11 = 0;
675 v10 = 1;
676 v9 = 4;
677 goto LABEL_42;
678 }
679 if ( a1 == 13 )
680 {
681 CreateButtonInColumn(0, 0x12u);
682 v16 = 56;
683 LABEL_37:
684 CreateButtonInColumn(1, v16);
685 v17 = 2;
686 v11 = 0;
687 v10 = 1;
688 v9 = 2;
689 goto LABEL_42;
690 }
691 switch ( a1 )
692 {
693 case 1:
694 case 2:
695 case 3:
696 case 4:
697 CreateButtonInColumn(0, 2u);
698 CreateButtonInColumn(1, 0x5Fu);
699 CreateButtonInColumn(2, 0x5Eu);
700 v12 = 96;
701 goto LABEL_39;
702 case 5:
703 CreateButtonInColumn(0, 0x12u);
704 v13 = 48;
705 goto LABEL_9;
706 case 6:
707 CreateButtonInColumn(0, 0x12u);
708 v13 = 49;
709 goto LABEL_9;
710 case 7:
711 CreateButtonInColumn(0, 0x12u);
712 v13 = 50;
713 goto LABEL_9;
714 case 8:
715 CreateButtonInColumn(0, 0x12u);
716 v13 = 51;
717 LABEL_9:
718 CreateButtonInColumn(1, v13);
719 v14 = 72;
720 goto LABEL_41;
721 case 9:
722 CreateButtonInColumn(0, 0x12u);
723 v15 = 52;
724 goto LABEL_13;
725 case 10:
726 CreateButtonInColumn(0, 0x12u);
727 v15 = 53;
728 goto LABEL_13;
729 case 11:
730 CreateButtonInColumn(0, 0x12u);
731 v15 = 54;
732 LABEL_13:
733 CreateButtonInColumn(1, v15);
734 v14 = 61;
735 goto LABEL_41;
736 case 12:
737 CreateButtonInColumn(0, 0x12u);
738 v16 = 55;
739 goto LABEL_37;
740 default:
741 break;
742 }
743 LABEL_43:*/
744 dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
745 }
746 // F8B1E0: using guessed type int dword_F8B1E0;
747
748
318 //----- (004B1784) -------------------------------------------------------- 749 //----- (004B1784) --------------------------------------------------------
319 bool __cdecl HouseUI_CheckIfPlayerCanInteract() 750 bool __cdecl HouseUI_CheckIfPlayerCanInteract()
320 { 751 {
321 Player *pPlayer; // ebx@1 752 Player *pPlayer; // ebx@1
322 bool result; // eax@2 753 bool result; // eax@2
439 } 870 }
440 } 871 }
441 pAudioPlayer->StopChannels(-1, -1); 872 pAudioPlayer->StopChannels(-1, -1);
442 873
443 uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID; 874 uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
444 in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; 875 in_current_building_type = (BuildingType)pAnimatedRooms[uCurrentHouse_Animation].uBuildingType;
445 if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine ) // going 2 jail 876 if ( in_current_building_type == BuildingType_Throne_Room && pParty->uFine ) // going 2 jail
446 { 877 {
447 uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; 878 uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
448 uHouseID = HOUSE_JAIL; 879 uHouseID = HOUSE_JAIL;
449 pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000; 880 pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000;
450 in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; 881 in_current_building_type = (BuildingType)pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType;
451 ++pParty->uNumPrisonTerms; 882 ++pParty->uNumPrisonTerms;
452 pParty->uFine = 0; 883 pParty->uFine = 0;
453 for (uint i = 0; i < 4; ++i) 884 for (uint i = 0; i < 4; ++i)
454 { 885 {
455 pParty->pPlayers[i].uTimeToRecovery = 0; 886 pParty->pPlayers[i].uTimeToRecovery = 0;
585 } 1016 }
586 } 1017 }
587 //----- (004B1E92) -------------------------------------------------------- 1018 //----- (004B1E92) --------------------------------------------------------
588 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound) 1019 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound)
589 { 1020 {
590 //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) ) 1021 if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId )
591 if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) 1022 pAudioPlayer->PlaySound((SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
592 pAudioPlayer->PlaySound(
593 //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
594 (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
595 806, 0, -1, 0, 0, 0, 0); 1023 806, 0, -1, 0, 0, 0, 0);
596 } 1024 }
597 1025
598 //----- (004BCACC) -------------------------------------------------------- 1026 //----- (004BCACC) --------------------------------------------------------
599 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam) 1027 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam)
665 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN) 1093 if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN)
666 v8 = window_SpeakInHouse; 1094 v8 = window_SpeakInHouse;
667 //else 1095 //else
668 if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) 1096 if (dialog_menu_id == HOUSE_DIALOGUE_MAIN)
669 { 1097 {
670 if ( in_current_building_type == BildingType_Training ) 1098 if ( in_current_building_type == BuildingType_Training )
671 { 1099 {
672 if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) 1100 if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
673 { 1101 {
674 v4 = 0; 1102 v4 = 0;
675 v5 = 0; 1103 v5 = 0;
693 // LABEL_10: 1121 // LABEL_10:
694 //v3 = dword_F8B198; 1122 //v3 = dword_F8B198;
695 v8 = window_SpeakInHouse; 1123 v8 = window_SpeakInHouse;
696 } 1124 }
697 //else 1125 //else
698 if ( in_current_building_type != BildingType_Training ) 1126 if ( in_current_building_type != BuildingType_Training )
699 { 1127 {
700 v8 = window_SpeakInHouse; 1128 v8 = window_SpeakInHouse;
701 if ((in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) && 1129 if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) &&
702 transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] 1130 transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7]
703 || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) 1131 || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
704 { 1132 {
705 //LABEL_9: 1133 //LABEL_9:
706 pDialogueWindow->Release(); 1134 pDialogueWindow->Release();
707 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); 1135 pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
708 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" 1136 pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
719 v8 = window_SpeakInHouse; 1147 v8 = window_SpeakInHouse;
720 } 1148 }
721 } 1149 }
722 //LABEL_11: 1150 //LABEL_11:
723 dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; 1151 dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
724 if ( in_current_building_type < BildingType_19 ) 1152 if ( in_current_building_type < BuildingType_19 )
725 { 1153 {
726 v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); 1154 v9 = pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE);
727 //v3 = dword_F8B198; 1155 //v3 = dword_F8B198;
728 ShopTexture = &pIcons_LOD->pTextures[v9]; 1156 ShopTexture = &pIcons_LOD->pTextures[v9];
729 //LABEL_13: 1157 //LABEL_13:
730 v8 = window_SpeakInHouse; 1158 v8 = window_SpeakInHouse;
731 } 1159 }
732 } 1160 }
733 1161
734 //NEW 1162 //NEW
735 switch(in_current_building_type) 1163 switch (in_current_building_type)
736 { 1164 {
737 case BildingType_FireGuild: 1165 case BuildingType_FireGuild:
738 case BildingType_AirGuild: 1166 case BuildingType_AirGuild:
739 case BildingType_WaterGuild: 1167 case BuildingType_WaterGuild:
740 case BildingType_EarthGuild: 1168 case BuildingType_EarthGuild:
741 case BildingType_SpiritGuild: 1169 case BuildingType_SpiritGuild:
742 case BildingType_MindGuild: 1170 case BuildingType_MindGuild:
743 case BildingType_BodyGuild: 1171 case BuildingType_BodyGuild:
744 case BildingType_LightGuild: 1172 case BuildingType_LightGuild:
745 case BildingType_DarkGuild: 1173 case BuildingType_DarkGuild:
746 case BildingType_14: 1174 case BuildingType_14:
747 case BildingType_15: 1175 case BuildingType_15:
748 case BildingType_16: 1176 case BuildingType_16:
749 { 1177 {
750 if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed && 1178 if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed &&
751 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed ) 1179 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed )
752 { 1180 {
753 v32 = 0; 1181 v32 = 0;
776 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31); 1204 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31);
777 } 1205 }
778 //return; 1206 //return;
779 break; 1207 break;
780 } 1208 }
781 case BildingType_TownHall: 1209 case BuildingType_TownHall:
782 { 1210 {
783 if ( uMessageParam == 99 ) 1211 if ( uMessageParam == 99 )
784 { 1212 {
785 v10 = (int)((char *)v8->ptr_1C - 102); 1213 v10 = (int)((char *)v8->ptr_1C - 102);
786 v56 = v10; 1214 v56 = v10;
982 { 1410 {
983 pKeyActionMap->EnterText(1, 10, v8); 1411 pKeyActionMap->EnterText(1, 10, v8);
984 } 1412 }
985 break; 1413 break;
986 } 1414 }
987 case BildingType_Bank: 1415 case BuildingType_Bank:
988 { 1416 {
989 if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) 1417 if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
990 pKeyActionMap->EnterText(1, 10, v8); 1418 pKeyActionMap->EnterText(1, 10, v8);
991 return; 1419 return;
992 break; 1420 break;
993 } 1421 }
994 case BildingType_WeaponShop: 1422 case BuildingType_WeaponShop:
995 case BildingType_ArmorShop: 1423 case BuildingType_ArmorShop:
996 case BildingType_MagicShop: 1424 case BuildingType_MagicShop:
997 case BildingType_AlchemistShop: 1425 case BuildingType_AlchemistShop:
998 case BildingType_Tavern: 1426 case BuildingType_Tavern:
999 case BildingType_Temple: 1427 case BuildingType_Temple:
1000 case BildingType_Training: 1428 case BuildingType_Training:
1001 { 1429 {
1002 break; 1430 break;
1003 } 1431 }
1004 default: 1432 default:
1005 { 1433 {
1007 break; 1435 break;
1008 } 1436 }
1009 } 1437 }
1010 1438
1011 /* 1439 /*
1012 if ( in_current_building_type > BildingType_Tavern ) 1440 if ( in_current_building_type > BuildingType_Tavern )
1013 { 1441 {
1014 if ( in_current_building_type == BildingType_Bank ) 1442 if ( in_current_building_type == BuildingType_Bank )
1015 { 1443 {
1016 if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) 1444 if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
1017 pKeyActionMap->EnterText(1, 10, v8); 1445 pKeyActionMap->EnterText(1, 10, v8);
1018 return; 1446 return;
1019 } 1447 }
1020 if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training ) 1448 if ( in_current_building_type != BuildingType_Temple && in_current_building_type != BuildingType_Training )
1021 return; 1449 return;
1022 } 1450 }
1023 //else 1451 //else
1024 if ( in_current_building_type < BildingType_Tavern ) 1452 if ( in_current_building_type < BuildingType_Tavern )
1025 { 1453 {
1026 if (in_current_building_type <= 0) 1454 if (in_current_building_type <= 0)
1027 return; 1455 return;
1028 if ( in_current_building_type > BildingType_AlchemistShop ) 1456 if ( in_current_building_type > BuildingType_AlchemistShop )
1029 { 1457 {
1030 if ( in_current_building_type <= BildingType_16 ) 1458 if ( in_current_building_type <= BuildingType_16 )
1031 { 1459 {
1032 if ( (signed __int64)__PAIR__( 1460 if ( (signed __int64)__PAIR__(
1033 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472], 1461 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
1034 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468]) >= (signed __int64)pParty->uTimePlayed ) 1462 *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468]) >= (signed __int64)pParty->uTimePlayed )
1035 { 1463 {
1060 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31; 1488 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31;
1061 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31); 1489 *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31);
1062 } 1490 }
1063 return; 1491 return;
1064 } 1492 }
1065 if ( in_current_building_type != BildingType_TownHall ) 1493 if ( in_current_building_type != BuildingType_TownHall )
1066 return; 1494 return;
1067 if ( in_current_building_type == BildingType_TownHall ) 1495 if ( in_current_building_type == BuildingType_TownHall )
1068 { 1496 {
1069 if ( uMessageParam == 99 ) 1497 if ( uMessageParam == 99 )
1070 { 1498 {
1071 v10 = (int)((char *)v8->ptr_1C - 102); 1499 v10 = (int)((char *)v8->ptr_1C - 102);
1072 v56 = v10; 1500 v56 = v10;
1285 } 1713 }
1286 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN: 1714 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN:
1287 { 1715 {
1288 pDialogueWindow->eWindowType = WINDOW_MainMenu; 1716 pDialogueWindow->eWindowType = WINDOW_MainMenu;
1289 UI_CreateEndConversationButton(); 1717 UI_CreateEndConversationButton();
1290 sub_4B3A72(in_current_building_type); 1718 InitializaDialogueOptions_Tavern(in_current_building_type);
1291 break; 1719 break;
1292 } 1720 }
1293 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: 1721 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES:
1294 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS: 1722 case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS:
1295 { 1723 {
1329 v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v43].uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1757 v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v43].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1330 ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v46]; 1758 ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v46];
1331 } 1759 }
1332 } 1760 }
1333 } 1761 }
1334 if ( in_current_building_type == BildingType_WeaponShop ) 1762 if ( in_current_building_type == BuildingType_WeaponShop )
1335 { 1763 {
1336 v48 = 0; 1764 v48 = 0;
1337 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) 1765 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
1338 { 1766 {
1339 do 1767 do
1357 v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v43].uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1785 v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v43].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1358 ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v51]; 1786 ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v51];
1359 } 1787 }
1360 } 1788 }
1361 } 1789 }
1362 if ( in_current_building_type == BildingType_WeaponShop ) 1790 if ( in_current_building_type == BuildingType_WeaponShop )
1363 { 1791 {
1364 v53 = 0; 1792 v53 = 0;
1365 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) 1793 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
1366 { 1794 {
1367 do 1795 do
1386 } 1814 }
1387 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: 1815 case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
1388 { 1816 {
1389 pDialogueWindow->eWindowType = WINDOW_MainMenu; 1817 pDialogueWindow->eWindowType = WINDOW_MainMenu;
1390 UI_CreateEndConversationButton(); 1818 UI_CreateEndConversationButton();
1391 sub_4B3AD4(in_current_building_type); 1819 InitializaDialogueOptions_Shops(in_current_building_type);
1392 break; 1820 break;
1393 } 1821 }
1394 default: 1822 default:
1395 { 1823 {
1396 if( uMessageParam >= HOUSE_DIALOGUE_36 && uMessageParam <= HOUSE_DIALOGUE_GUILD_LEARN_SKILL ) 1824 if( uMessageParam >= HOUSE_DIALOGUE_36 && uMessageParam <= HOUSE_DIALOGUE_GUILD_LEARN_SKILL )
1409 if ( !pPlayers[uActiveCharacter]->pActiveSkills[uMessageParam - 36] ) 1837 if ( !pPlayers[uActiveCharacter]->pActiveSkills[uMessageParam - 36] )
1410 { 1838 {
1411 if ( pParty->uNumGold < v37 ) 1839 if ( pParty->uNumGold < v37 )
1412 { 1840 {
1413 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); 1841 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
1414 if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) 1842 if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern )
1415 v39 = 4; 1843 v39 = 4;
1416 else 1844 else
1417 v39 = 2; 1845 v39 = 2;
1418 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v39); 1846 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v39);
1419 } 1847 }
1472 if ( !*(short *)v38 ) 1900 if ( !*(short *)v38 )
1473 { 1901 {
1474 if ( pParty->uNumGold < v37 ) 1902 if ( pParty->uNumGold < v37 )
1475 { 1903 {
1476 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); 1904 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
1477 if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) 1905 if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern )
1478 v39 = 4; 1906 v39 = 4;
1479 else 1907 else
1480 v39 = 2; 1908 v39 = 2;
1481 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, v39); 1909 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, v39);
1482 } 1910 }
1494 { 1922 {
1495 if ( uMessageParam == 94 ) 1923 if ( uMessageParam == 94 )
1496 { 1924 {
1497 pDialogueWindow->eWindowType = WINDOW_MainMenu; 1925 pDialogueWindow->eWindowType = WINDOW_MainMenu;
1498 UI_CreateEndConversationButton(); 1926 UI_CreateEndConversationButton();
1499 sub_4B3AD4(in_current_building_type); 1927 InitializaDialogueOptions_Shops(in_current_building_type);
1500 } 1928 }
1501 } 1929 }
1502 } 1930 }
1503 return; 1931 return;
1504 } 1932 }
1544 ++v43; 1972 ++v43;
1545 } 1973 }
1546 //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); 1974 //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
1547 while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); 1975 while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
1548 } 1976 }
1549 if ( in_current_building_type == BildingType_WeaponShop ) 1977 if ( in_current_building_type == BuildingType_WeaponShop )
1550 { 1978 {
1551 v47 = v8->ptr_1C; 1979 v47 = v8->ptr_1C;
1552 v48 = 0; 1980 v48 = 0;
1553 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ) 1981 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] )
1554 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ) 1982 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] )
1589 ++v43; 2017 ++v43;
1590 } 2018 }
1591 //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); 2019 //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
1592 while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); 2020 while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
1593 } 2021 }
1594 if ( in_current_building_type == BildingType_WeaponShop ) 2022 if ( in_current_building_type == BuildingType_WeaponShop )
1595 { 2023 {
1596 v52 = v8->ptr_1C; 2024 v52 = v8->ptr_1C;
1597 v53 = 0; 2025 v53 = 0;
1598 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ) 2026 //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] )
1599 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ) 2027 if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] )
1698 v53.uFrameZ = 334; 2126 v53.uFrameZ = 334;
1699 auto color_default = TargetColor(255, 255, 255); 2127 auto color_default = TargetColor(255, 255, 255);
1700 auto color_selected = TargetColor(255, 255, 155); 2128 auto color_selected = TargetColor(255, 255, 155);
1701 v3 = 52 * (unsigned int)v0->ptr_1C; 2129 v3 = 52 * (unsigned int)v0->ptr_1C;
1702 //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50); 2130 //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50);
1703 //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50); 2131 //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BuildingType_Stables) - 1) & 0xFFFFFFE7) + 50);
1704 //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]); 2132 //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]);
1705 2133
1706 v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BildingType_Stables ? 25 : 50; 2134 v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50;
1707 v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier; 2135 v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier;
1708 2136
1709 s1 = v4 * (100 - v1->GetMerchant()) / 100; 2137 s1 = v4 * (100 - v1->GetMerchant()) / 100;
1710 if ( (signed int)s1 < v4 / 3 ) 2138 if ( (signed int)s1 < v4 / 3 )
1711 s1 = v4 / 3; 2139 s1 = v4 / 3;
2536 Party::TakeGold((unsigned int)pOutString); 2964 Party::TakeGold((unsigned int)pOutString);
2537 v27 = (int)window_SpeakInHouse->ptr_1C;//107 2965 v27 = (int)window_SpeakInHouse->ptr_1C;//107
2538 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); 2966 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
2539 dialog_menu_id = HOUSE_DIALOGUE_NULL; 2967 dialog_menu_id = HOUSE_DIALOGUE_NULL;
2540 sub_4BD8B5(); 2968 sub_4BD8B5();
2541 sub_4B1D27(); 2969 GetHouseGoodbyeSpeech();
2542 pVideoPlayer->Unload(); 2970 pVideoPlayer->Unload();
2543 window_SpeakInHouse->Release(); 2971 window_SpeakInHouse->Release();
2544 window_SpeakInHouse = 0; 2972 window_SpeakInHouse = 0;
2545 if ( pMessageQueue_50CBD0->uNumMessages ) 2973 if ( pMessageQueue_50CBD0->uNumMessages )
2546 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 2974 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;