diff UI/UIHouses.cpp @ 1441:b67a3e0d6fc3

Слияние
author Ritor1
date Sat, 27 Jul 2013 09:36:55 +0600
parents 468f434a8d8a 2423bc2af692
children 6de9c1316852
line wrap: on
line diff
--- a/UI/UIHouses.cpp	Sat Jul 27 09:36:29 2013 +0600
+++ b/UI/UIHouses.cpp	Sat Jul 27 09:36:55 2013 +0600
@@ -13,7 +13,6 @@
 #include "..\Mouse.h"
 #include "..\GUIWindow.h"
 #include "..\GUIFont.h"
-#include "..\Events2D.h"
 #include "..\Overlays.h"
 #include "..\Outdoor.h"
 #include "..\AudioPlayer.h"
@@ -31,7 +30,7 @@
 
 int dword_591080; // weak
 
-int in_current_building_type; // 00F8B198
+BuildingType in_current_building_type; // 00F8B198
 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C
 
 #pragma pack(push, 1)
@@ -315,6 +314,438 @@
 }};
 
 
+
+//----- (004B3A72) --------------------------------------------------------
+void InitializaDialogueOptions_Tavern(BuildingType type)
+{
+  int num_buttons; // esi@1
+
+  num_buttons = 0;
+  if (type == BuildingType_Tavern)
+  {
+    num_buttons = 2;
+    CreateButtonInColumn(0, 102);
+    CreateButtonInColumn(1, 103);
+	if ( pParty->HasItem(651) ) //Arcomage Deck
+    {
+      num_buttons = 3;
+      CreateButtonInColumn(2, 104);
+    }
+  }
+  pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2);
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
+}
+// F8B1E0: using guessed type int dword_F8B1E0;
+
+//----- (004B3AD4) --------------------------------------------------------
+void InitializaDialogueOptions_Shops(BuildingType type)
+{
+  switch (type)
+  {
+    case BuildingType_WeaponShop:
+    case BuildingType_ArmorShop:
+    case BuildingType_MagicShop:
+    {
+      CreateButtonInColumn(0, 3);
+      CreateButtonInColumn(1, 4);
+      CreateButtonInColumn(2, 5);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+    
+    case BuildingType_AlchemistShop:
+    {
+      CreateButtonInColumn(0, 3);
+      CreateButtonInColumn(1, 4);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
+    }
+    break;
+  }
+
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
+}
+// F8B1E0: using guessed type int dword_F8B1E0;
+
+//----- (004B3B42) --------------------------------------------------------
+void InitializaDialogueOptions(BuildingType type)
+{
+  /*int v1; // ecx@18
+  int v2; // ecx@19
+  int v3; // ecx@20
+  signed int v4; // esi@22
+  signed int v5; // eax@22
+  unsigned int v6; // edx@24
+  int v7; // ecx@24
+  int result; // eax@43
+  int v9; // [sp-10h] [bp-14h]@28
+  int v10; // [sp-Ch] [bp-10h]@28
+  int v11; // [sp-8h] [bp-Ch]@28
+  unsigned int v12; // [sp-4h] [bp-8h]@4
+  unsigned int v13; // [sp-4h] [bp-8h]@5
+  unsigned int v14; // [sp-4h] [bp-8h]@9
+  unsigned int v15; // [sp-4h] [bp-8h]@10
+  unsigned int v16; // [sp-4h] [bp-8h]@14
+  int v17; // [sp-4h] [bp-8h]@28*/
+
+  switch (type)
+  {
+    case BuildingType_WeaponShop:
+    case BuildingType_ArmorShop:
+    case BuildingType_MagicShop:
+    case BuildingType_AlchemistShop:
+    {
+      CreateButtonInColumn(0, 2);
+      CreateButtonInColumn(1, 95);
+      CreateButtonInColumn(2, 94);
+      CreateButtonInColumn(3, 96);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_FireGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 48);
+      CreateButtonInColumn(2, 72);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_AirGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 49);
+      CreateButtonInColumn(2, 72);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_WaterGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 50);
+      CreateButtonInColumn(2, 72);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_EarthGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 51);
+      CreateButtonInColumn(2, 72);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_SpiritGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 52);
+      CreateButtonInColumn(2, 61);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_MindGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 53);
+      CreateButtonInColumn(2, 61);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_BodyGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 54);
+      CreateButtonInColumn(2, 61);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_LightGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 55);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_DarkGuild:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 56);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_14:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 48);
+      CreateButtonInColumn(2, 49);
+      CreateButtonInColumn(3, 50);
+      CreateButtonInColumn(4, 51);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(5, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_15:
+    {
+      CreateButtonInColumn(0, 18);
+      CreateButtonInColumn(1, 52);
+      CreateButtonInColumn(2, 53);
+      CreateButtonInColumn(3, 54);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_16:
+    case BuildingType_TownHall:
+    {
+      int num_buttons = 1;
+      CreateButtonInColumn(0, 99);
+
+      if (pParty->uFine)
+      {
+        num_buttons++;
+        CreateButtonInColumn(1, 100);
+      }
+
+      pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_Bank:
+    {
+      CreateButtonInColumn(0, 7);
+      CreateButtonInColumn(1, 8);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_Temple:
+    {
+      CreateButtonInColumn(0, 10);
+      CreateButtonInColumn(1, 11);
+      CreateButtonInColumn(2, 96);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_Stables:
+    case BuildingType_Boats:
+    {
+      CreateButtonInColumn(0, 105);
+      CreateButtonInColumn(1, 106);
+      CreateButtonInColumn(2, 107);
+      CreateButtonInColumn(3, 108);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
+    }
+    break;
+
+    case BuildingType_Training:
+    {
+      CreateButtonInColumn(0, 17);
+      CreateButtonInColumn(1, 96);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
+    }
+    break;
+    
+    case BuildingType_18:
+    case BuildingType_19:
+    case BuildingType_Throne_Room:
+    case BuildingType_24:
+    case BuildingType_Unic:
+    case BuildingType_1A:
+    case BuildingType_House:
+    case BuildingType_Jail:
+      break;
+
+    default:
+      assert(false && "Invalid enumeration value");
+  }
+
+/*  if ( a1 > 13 )
+  {
+    if ( a1 > 22 )
+    {
+      if ( a1 == 23 )
+      {
+        CreateButtonInColumn(0, 0xAu);
+        CreateButtonInColumn(1, 0xBu);
+        v14 = 96;
+LABEL_41:
+        CreateButtonInColumn(2, v14);
+        v17 = 2;
+        v11 = 0;
+        v10 = 1;
+        v9 = 3;
+        goto LABEL_42;
+      }
+      if ( a1 <= 26 )
+        goto LABEL_43;
+      if ( a1 > 28 )
+      {
+        if ( a1 != 30 )
+          goto LABEL_43;
+        CreateButtonInColumn(0, 0x11u);
+        v16 = 96;
+        goto LABEL_37;
+      }
+      CreateButtonInColumn(0, 0x69u);
+      CreateButtonInColumn(1, 0x6Au);
+      CreateButtonInColumn(2, 0x6Bu);
+      v12 = 108;
+    }
+    else
+    {
+      if ( a1 == 22 )
+      {
+        CreateButtonInColumn(0, 7u);
+        v16 = 8;
+        goto LABEL_37;
+      }
+      v1 = a1 - 14;
+      if ( !v1 ) // == 14
+      {
+        CreateButtonInColumn(0, 0x12u);
+        CreateButtonInColumn(1, 0x30u);
+        CreateButtonInColumn(2, 0x31u);
+        CreateButtonInColumn(3, 0x32u);
+        CreateButtonInColumn(4, 0x33u);
+        v17 = 2;
+        v11 = 0;
+        v10 = 1;
+        v9 = 5;
+        goto LABEL_42;
+      }
+      v2 = v1 - 1;
+      if ( v2 ) // > 15
+      {
+        v3 = v2 - 2;
+        if ( v3 ) // > 17
+        {
+          if ( v3 != 4 ) // 18, 19, 20
+            goto LABEL_43;
+          CreateButtonInColumn(0, 0xFu); // 21
+          CreateButtonInColumn(1, 0x10u);
+          v4 = 3;
+          CreateButtonInColumn(2, 0x60u);
+          v5 = (signed int)window_SpeakInHouse->ptr_1C;
+          if ( v5 < 108 || v5 > 120 )
+            goto LABEL_28;
+          v4 = 4;
+          v6 = 101;
+          v7 = 3;
+        }
+        else // 16, 17
+        {
+          v4 = 1;
+          CreateButtonInColumn(0, 0x63u);
+          if ( !pParty->uFine )
+          {
+LABEL_28:
+            v17 = 2;
+            v11 = 0;
+            v10 = 1;
+            v9 = v4;
+LABEL_42:
+            pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17);
+            goto LABEL_43;
+          }
+          v4 = 2;
+          v7 = 1;
+          v6 = 100;
+        }
+        CreateButtonInColumn(v7, v6);
+        goto LABEL_28;
+      }
+      CreateButtonInColumn(0, 0x12u); // 15
+      CreateButtonInColumn(1, 0x34u);
+      CreateButtonInColumn(2, 0x35u);
+      v12 = 54;
+    }
+LABEL_39:
+    CreateButtonInColumn(3, v12);
+    v17 = 2;
+    v11 = 0;
+    v10 = 1;
+    v9 = 4;
+    goto LABEL_42;
+  }
+  if ( a1 == 13 )
+  {
+    CreateButtonInColumn(0, 0x12u);
+    v16 = 56;
+LABEL_37:
+    CreateButtonInColumn(1, v16);
+    v17 = 2;
+    v11 = 0;
+    v10 = 1;
+    v9 = 2;
+    goto LABEL_42;
+  }
+  switch ( a1 )
+  {
+    case 1:
+    case 2:
+    case 3:
+    case 4:
+      CreateButtonInColumn(0, 2u);
+      CreateButtonInColumn(1, 0x5Fu);
+      CreateButtonInColumn(2, 0x5Eu);
+      v12 = 96;
+      goto LABEL_39;
+    case 5:
+      CreateButtonInColumn(0, 0x12u);
+      v13 = 48;
+      goto LABEL_9;
+    case 6:
+      CreateButtonInColumn(0, 0x12u);
+      v13 = 49;
+      goto LABEL_9;
+    case 7:
+      CreateButtonInColumn(0, 0x12u);
+      v13 = 50;
+      goto LABEL_9;
+    case 8:
+      CreateButtonInColumn(0, 0x12u);
+      v13 = 51;
+LABEL_9:
+      CreateButtonInColumn(1, v13);
+      v14 = 72;
+      goto LABEL_41;
+    case 9:
+      CreateButtonInColumn(0, 0x12u);
+      v15 = 52;
+      goto LABEL_13;
+    case 10:
+      CreateButtonInColumn(0, 0x12u);
+      v15 = 53;
+      goto LABEL_13;
+    case 11:
+      CreateButtonInColumn(0, 0x12u);
+      v15 = 54;
+LABEL_13:
+      CreateButtonInColumn(1, v15);
+      v14 = 61;
+      goto LABEL_41;
+    case 12:
+      CreateButtonInColumn(0, 0x12u);
+      v16 = 55;
+      goto LABEL_37;
+    default:
+      break;
+  }
+LABEL_43:*/
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
+}
+// F8B1E0: using guessed type int dword_F8B1E0;
+
+
 //----- (004B1784) --------------------------------------------------------
 bool __cdecl HouseUI_CheckIfPlayerCanInteract()
 {
@@ -441,13 +872,13 @@
         pAudioPlayer->StopChannels(-1, -1);
 
 		uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
-		in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType;
-		if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine )   // going 2 jail
+		in_current_building_type = (BuildingType)pAnimatedRooms[uCurrentHouse_Animation].uBuildingType;
+		if ( in_current_building_type == BuildingType_Throne_Room && pParty->uFine )   // going 2 jail
 			{
 			uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
 			uHouseID = HOUSE_JAIL;
 			pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000;
-			in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType;
+			in_current_building_type = (BuildingType)pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType;
 			++pParty->uNumPrisonTerms;
 			pParty->uFine = 0;
 			for (uint i = 0; i < 4; ++i)
@@ -587,11 +1018,8 @@
 //----- (004B1E92) --------------------------------------------------------
 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound)
 {
-    //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
-    if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId )
-        pAudioPlayer->PlaySound(
-        //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
-        (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
+  if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId )
+    pAudioPlayer->PlaySound((SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
         806, 0, -1, 0, 0, 0, 0);
 }
 
@@ -667,7 +1095,7 @@
   //else
   if (dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
-	  if ( in_current_building_type == BildingType_Training )
+	  if ( in_current_building_type == BuildingType_Training )
 	  {
 		if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN )
 		{
@@ -695,12 +1123,12 @@
 		v8 = window_SpeakInHouse;
 	  }
 	  //else
-	  if ( in_current_building_type != BildingType_Training )
+	  if ( in_current_building_type != BuildingType_Training )
 	  {
 		  v8 = window_SpeakInHouse;
-		  if ((in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) &&
+		  if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) &&
 			  transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7]
-			|| in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild )
+			|| in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
 		  {
 		//LABEL_9:
 			pDialogueWindow->Release();
@@ -721,9 +1149,9 @@
 	  }
 	//LABEL_11:
 	  dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam;
-	  if ( in_current_building_type < BildingType_19 )
+	  if ( in_current_building_type < BuildingType_19 )
 	  {
-		v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE);
+		v9 = pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE);
 		//v3 = dword_F8B198;
 		ShopTexture = &pIcons_LOD->pTextures[v9];
 	//LABEL_13:
@@ -732,20 +1160,20 @@
   }
   
   //NEW
-  switch(in_current_building_type)
+  switch (in_current_building_type)
   {
-    case BildingType_FireGuild:
-    case BildingType_AirGuild:
-    case BildingType_WaterGuild:
-    case BildingType_EarthGuild:
-    case BildingType_SpiritGuild:
-    case BildingType_MindGuild:
-    case BildingType_BodyGuild:
-    case BildingType_LightGuild:
-    case BildingType_DarkGuild:
-    case BildingType_14:
-    case BildingType_15:
-    case BildingType_16:
+    case BuildingType_FireGuild:
+    case BuildingType_AirGuild:
+    case BuildingType_WaterGuild:
+    case BuildingType_EarthGuild:
+    case BuildingType_SpiritGuild:
+    case BuildingType_MindGuild:
+    case BuildingType_BodyGuild:
+    case BuildingType_LightGuild:
+    case BuildingType_DarkGuild:
+    case BuildingType_14:
+    case BuildingType_15:
+    case BuildingType_16:
     {
       if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed &&
           *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed )
@@ -778,7 +1206,7 @@
       //return;
       break;
     }
-    case BildingType_TownHall:
+    case BuildingType_TownHall:
     {
       if ( uMessageParam == 99 )
       {
@@ -984,20 +1412,20 @@
 	}
 	break;
 	}
-    case BildingType_Bank:
+    case BuildingType_Bank:
     {
       if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
         pKeyActionMap->EnterText(1, 10, v8);
       return;
       break;
     }
-    case BildingType_WeaponShop:
-    case BildingType_ArmorShop:
-    case BildingType_MagicShop:
-    case BildingType_AlchemistShop:
-    case BildingType_Tavern:
-    case BildingType_Temple:
-    case BildingType_Training:
+    case BuildingType_WeaponShop:
+    case BuildingType_ArmorShop:
+    case BuildingType_MagicShop:
+    case BuildingType_AlchemistShop:
+    case BuildingType_Tavern:
+    case BuildingType_Temple:
+    case BuildingType_Training:
     {
       break;
     }
@@ -1009,25 +1437,25 @@
   }
 
   /*
-  if ( in_current_building_type > BildingType_Tavern )
+  if ( in_current_building_type > BuildingType_Tavern )
   {
-    if ( in_current_building_type == BildingType_Bank )
+    if ( in_current_building_type == BuildingType_Bank )
     {
       if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
         pKeyActionMap->EnterText(1, 10, v8);
       return;
     }
-    if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training )
+    if ( in_current_building_type != BuildingType_Temple && in_current_building_type != BuildingType_Training )
       return;
   }
   //else
-  if ( in_current_building_type < BildingType_Tavern )
+  if ( in_current_building_type < BuildingType_Tavern )
   {
       if (in_current_building_type <= 0)
         return;
-      if ( in_current_building_type > BildingType_AlchemistShop )
+      if ( in_current_building_type > BuildingType_AlchemistShop )
       {
-        if ( in_current_building_type <= BildingType_16 )
+        if ( in_current_building_type <= BuildingType_16 )
         {
           if ( (signed __int64)__PAIR__(
                                  *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
@@ -1062,9 +1490,9 @@
           }
           return;
         }
-        if ( in_current_building_type != BildingType_TownHall )
+        if ( in_current_building_type != BuildingType_TownHall )
           return;
-		if ( in_current_building_type == BildingType_TownHall )
+		if ( in_current_building_type == BuildingType_TownHall )
 		{
 			if ( uMessageParam == 99 )
 			{
@@ -1287,7 +1715,7 @@
     {
       pDialogueWindow->eWindowType = WINDOW_MainMenu;
       UI_CreateEndConversationButton();
-      sub_4B3A72(in_current_building_type);
+      InitializaDialogueOptions_Tavern(in_current_building_type);
       break;
     }
     case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES:
@@ -1331,7 +1759,7 @@
             }
           }
         }
-        if ( in_current_building_type == BildingType_WeaponShop )
+        if ( in_current_building_type == BuildingType_WeaponShop )
         {
           v48 = 0;
           if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
@@ -1359,7 +1787,7 @@
               }
             }
           }
-          if ( in_current_building_type == BildingType_WeaponShop )
+          if ( in_current_building_type == BuildingType_WeaponShop )
           {
             v53 = 0;
             if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
@@ -1388,7 +1816,7 @@
     {
       pDialogueWindow->eWindowType = WINDOW_MainMenu;
       UI_CreateEndConversationButton();
-      sub_4B3AD4(in_current_building_type);
+      InitializaDialogueOptions_Shops(in_current_building_type);
       break;
     }
     default:
@@ -1411,7 +1839,7 @@
             if ( pParty->uNumGold < v37 )
             {
               ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
-              if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern )
+              if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern )
                 v39 = 4;
               else
                 v39 = 2;
@@ -1474,7 +1902,7 @@
                   if ( pParty->uNumGold < v37 )
                   {
                     ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-                    if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern )
+                    if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern )
                       v39 = 4;
                     else
                       v39 = 2;
@@ -1496,7 +1924,7 @@
               {
                 pDialogueWindow->eWindowType = WINDOW_MainMenu;
                 UI_CreateEndConversationButton();
-                sub_4B3AD4(in_current_building_type);
+                InitializaDialogueOptions_Shops(in_current_building_type);
               }
             }
           }
@@ -1546,7 +1974,7 @@
       //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
       while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
     }
-    if ( in_current_building_type == BildingType_WeaponShop )
+    if ( in_current_building_type == BuildingType_WeaponShop )
     {
       v47 = v8->ptr_1C;
       v48 = 0;
@@ -1591,7 +2019,7 @@
       //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
       while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
     }
-    if ( in_current_building_type == BildingType_WeaponShop )
+    if ( in_current_building_type == BuildingType_WeaponShop )
     {
       v52 = v8->ptr_1C;
       v53 = 0;
@@ -1700,10 +2128,10 @@
   auto color_selected = TargetColor(255, 255, 155);
   v3 = 52 * (unsigned int)v0->ptr_1C;
   //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50);
-  //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50);
+  //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BuildingType_Stables) - 1) & 0xFFFFFFE7) + 50);
   //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]);
 
-  v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BildingType_Stables ? 25 : 50;
+  v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50;
   v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier;
 
   s1 = v4 * (100 - v1->GetMerchant()) / 100;
@@ -2538,7 +2966,7 @@
         PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
         dialog_menu_id = HOUSE_DIALOGUE_NULL;
         sub_4BD8B5();
-        sub_4B1D27();
+        GetHouseGoodbyeSpeech();
         pVideoPlayer->Unload();
         window_SpeakInHouse->Release();
         window_SpeakInHouse = 0;