changeset 480:d4ea191229ff

BildingType
author Ritor1
date Tue, 26 Feb 2013 15:23:15 +0600
parents 89f6107c3362
children 5b6e2021c6fe 9898e6b413d8
files Events.cpp GUIWindow.cpp GUIWindow.h MM7.h VideoPlayer.cpp mm7_2.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 9 files changed, 123 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Tue Feb 26 12:01:54 2013 +0600
+++ b/Events.cpp	Tue Feb 26 15:23:15 2013 +0600
@@ -607,7 +607,7 @@
 						sub_4BD8B5();
 						window_SpeakInHouse->Release();
 						pParty->uFlags &= 0xFFFFFFFDu;
-						if ( EnterHouse((enum HOUSE_TYPE)170) )
+						if ( EnterHouse((enum HOUSE_ID)170) )
 							{
 							pAudioPlayer->StopChannels(-1, -1);
 							window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
@@ -722,7 +722,7 @@
 						window_SpeakInHouse->Release();
 						pParty->uFlags &= 0xFFFFFFFDu;
 						GlobalEventInfo = 1;
-						if ( EnterHouse((enum HOUSE_TYPE)165) )
+						if ( EnterHouse((enum HOUSE_ID)165) )
 							{
 							pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
 							v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
@@ -1536,7 +1536,7 @@
 				//v7 = "";
 				break;
 			case EVENT_SpeakInHouse: 
-				if ( EnterHouse((enum HOUSE_TYPE)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
+				if ( EnterHouse((enum HOUSE_ID)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
 					{
 					if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
 						pRenderer->_49FD3A();
--- a/GUIWindow.cpp	Tue Feb 26 12:01:54 2013 +0600
+++ b/GUIWindow.cpp	Tue Feb 26 15:23:15 2013 +0600
@@ -1070,9 +1070,9 @@
   v18.uFrameZ += 8;
   if ( !pDialogueNPCCount )
   {
-    if ( in_current_bilding_type == 31 )
+    if ( in_current_bilding_type == BildingType_Jail )
     {
-      sub_4B4F4F();
+      JailDialog();
       goto LABEL_58;
     }
     if ( ptr_F8B1E8 )
@@ -1151,73 +1151,62 @@
       //p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]);
       p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle);
     v18.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v19, pTmpBuf, 3u);
-    if ( in_current_bilding_type <= 18 )
-    {
       switch ( in_current_bilding_type )
       {
-        case 18:
-          sub_4B6478();
-          break;
-        case 1:
+        case BildingType_WeaponShop:
           WeaponShopDialog();
           break;
-        case 2:
+        case BildingType_ArmorShop:
           ArmorShopDialog();
           break;
-        case 3:
+        case BildingType_MagicShop:
           MagicShopDialog();
           break;
-        case 4:
+        case BildingType_AlchemistShop:
           AlchemistDialog();
           break;
+        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_Dark:
+        //case BildingType_14:
+        //case BildingType_15:
+        //case BildingType_16:
+          GuildDialog();
+          break;
+        case BildingType_18:
+          __debugbreak; //What over the dialog?
+          sub_4B6478();
+          break;
+        case BildingType_TownHall:
+          TownHallDialog();
+          break;
+        case BildingType_Tavern:
+          TavernDialog();
+          break;
+        case BildingType_Bank:
+          BankDialog();
+          break;
+        case BildingType_Tample:
+          TampleDialog();
+          break;
+        case BildingType_Stables:
+          TravelByTransport();
+          break;
+        case BildingType_Training:
+          TrainingDialog();
+          break;
+        case BildingType_Jail:
+          JailDialog();
+          break;
         default:
-          if ( in_current_bilding_type > 4 )
-          {
-            if ( in_current_bilding_type <= 16 )
-            {
-              GuildDialog();
-            }
-            else
-            {
-              if ( in_current_bilding_type == 17 )
-                sub_4B7911();
-            }
-          }
           break;
       }
-      goto LABEL_58;
-    }
-    switch ( in_current_bilding_type )
-    {
-      case 21:
-        TavernDialog();
-        break;
-      case 22:
-        _4B7D7E_bank();
-        break;
-      case 23:
-        TampleDialog();
-        break;
-      default:
-        if ( in_current_bilding_type <= 26 )
-          break;
-        if ( in_current_bilding_type <= 28 )
-        {
-          TravelByTransport();
-        }
-        else
-        {
-          if ( in_current_bilding_type != 30 )
-          {
-            if ( in_current_bilding_type != 31 )
-              break;
-            sub_4B4F4F();
-            goto LABEL_58;
-          }
-          TrainingDialog();
-        }
-        break;
-    }
   }
 LABEL_58:
   if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic )
--- a/GUIWindow.h	Tue Feb 26 12:01:54 2013 +0600
+++ b/GUIWindow.h	Tue Feb 26 15:23:15 2013 +0600
@@ -157,6 +157,38 @@
 
 
 /*  296 */
+enum BildingType
+{
+  BildingType_WeaponShop = 0x1,
+  BildingType_ArmorShop = 0x2,
+  BildingType_MagicShop = 0x3,
+  BildingType_AlchemistShop = 0x4,
+  BildingType_FireGuild = 0x5,
+  BildingType_AirGuild = 0x6,
+  BildingType_WaterGuild = 0x7,
+  BildingType_EarthGuild = 0x8,
+  BildingType_SpiritGuild = 0x9,
+  BildingType_MindGuild = 0xA,
+  BildingType_BodyGuild = 0xB,
+  BildingType_LightGuild = 0xC,
+  BildingType_Dark = 0xD,
+  BildingType_14 = 0xE,
+  BildingType_15 = 0xF,
+  BildingType_16 = 0x10,
+  BildingType_TownHall = 0x11,
+  BildingType_18 = 0x12,
+  BildingType_19 = 0x13,
+  BildingType_20 = 0x14,
+  BildingType_Tavern = 0x15,
+  BildingType_Bank = 0x16,
+  BildingType_Tample = 0x17,
+  BildingType_1A = 0x1A,
+  BildingType_Stables = 0x1B,
+  BildingType_Boats = 0x1C,
+  BildingType_House = 0x1D,
+  BildingType_Training = 0x1E,
+  BildingType_Jail = 0x1F,
+};
 enum UIMessageType
 {
   UIMSG_00 = 0x0,
--- a/MM7.h	Tue Feb 26 12:01:54 2013 +0600
+++ b/MM7.h	Tue Feb 26 15:23:15 2013 +0600
@@ -163,7 +163,7 @@
 
 
 /*  349 */
-enum HOUSE_TYPE
+enum HOUSE_ID
 {
   HOUSE_SMITH_EMERALD_ISLE = 1,
   HOUSE_BODY_GUILD_NOVICE_EMERALD_ISLE = 163,
--- a/VideoPlayer.cpp	Tue Feb 26 12:01:54 2013 +0600
+++ b/VideoPlayer.cpp	Tue Feb 26 15:23:15 2013 +0600
@@ -1123,7 +1123,7 @@
     sub_4BD8B5();
     window_SpeakInHouse->Release();
     pParty->uFlags &= 0xFFFFFFFDu;
-    if ( EnterHouse((enum HOUSE_TYPE)165) )
+    if ( EnterHouse((enum HOUSE_ID)165) )
     {
       pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0);
       window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
--- a/mm7_2.cpp	Tue Feb 26 12:01:54 2013 +0600
+++ b/mm7_2.cpp	Tue Feb 26 15:23:15 2013 +0600
@@ -56,7 +56,7 @@
 
 
 //----- (004B4F4F) --------------------------------------------------------
-char *__cdecl sub_4B4F4F()
+char *__cdecl JailDialog()
 {
   const char *v0; // esi@1
   const char *v1; // ST10_4@1
@@ -104,7 +104,7 @@
 
 
 //----- (004B7911) --------------------------------------------------------
-void __cdecl sub_4B7911()
+void __cdecl TownHallDialog()
 {
   GUIWindow *v0; // eax@4
   int v1; // eax@10
@@ -288,7 +288,7 @@
 // F8B1A0: using guessed type __int16 word_F8B1A0;
 
 //----- (004B7D7E) --------------------------------------------------------
-void __cdecl _4B7D7E_bank()
+void __cdecl BankDialog()
 {
   GUIWindow *v0; // eax@4
   int v1; // ecx@5
@@ -3757,7 +3757,7 @@
   //v3 = dword_F8B198;
   if ( dword_F8B19C != 1 )
     goto LABEL_13;
-  if ( in_current_bilding_type == 30 )
+  if ( in_current_bilding_type == BildingType_Training )
   {
     if ( uMessageParam == 17 )
     {
@@ -3778,9 +3778,9 @@
     goto LABEL_9;
   }
   v8 = window_SpeakInHouse;
-  if ( (in_current_bilding_type == 27 || in_current_bilding_type == 28)
+  if ( (in_current_bilding_type == BildingType_Stables || in_current_bilding_type == BildingType_Boats)
     && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7))
-    || in_current_bilding_type != 23 || uMessageParam != 10 )
+    || in_current_bilding_type != BildingType_Tample || uMessageParam != BildingType_MindGuild )
   {
 LABEL_9:
     pDialogueWindow->Release();
@@ -3801,7 +3801,7 @@
   }
 LABEL_11:
   dword_F8B19C = uMessageParam;
-  if ( in_current_bilding_type < 19 )
+  if ( in_current_bilding_type < BildingType_19 )
   {
     v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_bilding_type], TEXTURE_16BIT_PALETTE);
     //v3 = dword_F8B198;
@@ -3809,26 +3809,26 @@
 LABEL_13:
     v8 = window_SpeakInHouse;
   }
-  if ( in_current_bilding_type > 21 )
-  {
-    if ( in_current_bilding_type == 22 )
+  if ( in_current_bilding_type > BildingType_Tavern )
+  {
+    if ( in_current_bilding_type == BildingType_Bank )
     {
       if ( dword_F8B19C >= 7 && dword_F8B19C <= 8 )
         pKeyActionMap->EnterText(1, 10, v8);
       return;
     }
-    if ( in_current_bilding_type != 23 && in_current_bilding_type != 30 )
+    if ( in_current_bilding_type != BildingType_Tample && in_current_bilding_type != BildingType_Training )
       return;
   }
   else
   {
-    if ( in_current_bilding_type != 21 )
+    if ( in_current_bilding_type != BildingType_Tavern )
     {
       if ( in_current_bilding_type <= (signed int)v1 )
         return;
-      if ( in_current_bilding_type > 4 )
-      {
-        if ( in_current_bilding_type <= 16 )
+      if ( in_current_bilding_type > BildingType_AlchemistShop )
+      {
+        if ( in_current_bilding_type <= BildingType_16 )
         {
           if ( (signed __int64)__PAIR__(
                                  *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
@@ -3840,9 +3840,7 @@
               v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C));
               if ( v33 )
               {
-                v34 = pIcons_LOD->LoadTexture(
-                        pItemsTable->pItems[v33].pIconName,
-                        TEXTURE_16BIT_PALETTE);
+                v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v33].pIconName, TEXTURE_16BIT_PALETTE);
                 v8 = window_SpeakInHouse;
                 ItemsInShopTexture[v32] = &pIcons_LOD->pTextures[v34];
               }
@@ -3864,7 +3862,7 @@
           }
           return;
         }
-        if ( in_current_bilding_type != 17 )
+        if ( in_current_bilding_type != BildingType_TownHall )
           return;
         if ( uMessageParam == 99 )
         {
@@ -4150,7 +4148,7 @@
                   if ( pParty->uNumGold < v37 )
                   {
                     ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-                    if ( in_current_bilding_type == 30 || in_current_bilding_type == 21 )
+                    if ( in_current_bilding_type == BildingType_Training || in_current_bilding_type == BildingType_Tavern )
                       v39 = 4;
                     else
                       v39 = 2;
@@ -4222,7 +4220,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_bilding_type == 1 )
+    if ( in_current_bilding_type == BildingType_WeaponShop )
     {
       v47 = v8->ptr_1C;
       v48 = 0;
@@ -4267,7 +4265,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_bilding_type == 1 )
+    if ( in_current_bilding_type == BildingType_WeaponShop )
     {
       v52 = v8->ptr_1C;
       v53 = 0;
@@ -4514,7 +4512,7 @@
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
             v13 = window_SpeakInHouse->ptr_1C;
-            if ( in_current_bilding_type == 30 )
+            if ( in_current_bilding_type == BildingType_Training )
               v55 = 4;
             else
               v55 = 2;
--- a/mm7_4.cpp	Tue Feb 26 12:01:54 2013 +0600
+++ b/mm7_4.cpp	Tue Feb 26 15:23:15 2013 +0600
@@ -9082,7 +9082,7 @@
   //v0 = pPlayers[uActiveCharacter];
   if ( in_current_bilding_type <= 0 )
     return;
-  if ( in_current_bilding_type <= 4 )
+  if ( in_current_bilding_type <= BildingType_AlchemistShop )
   {
     if ( dword_F8B19C != 2 )
     {
@@ -9116,7 +9116,7 @@
 		v7 =&pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5];
     goto LABEL_15;
   }
-  if ( in_current_bilding_type <= 16 && dword_F8B19C == 18 )
+  if ( in_current_bilding_type <= BildingType_16 && dword_F8B19C == BildingType_18 )
   {
     v1 = pMouse->GetCursorPos(&a2);
     v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y];
@@ -9183,16 +9183,16 @@
   if ( in_current_bilding_type > 0 )
   {
     v0 = 3;
-    if ( in_current_bilding_type > 3 )
-    {
-      if ( in_current_bilding_type == 22 )
+    if ( in_current_bilding_type > BildingType_MagicShop )
+    {
+      if ( in_current_bilding_type == BildingType_Bank )
       {
         if ( !dword_F8B1E4 )
           return;
       }
       else
       {
-        if ( in_current_bilding_type != 23 )
+        if ( in_current_bilding_type != BildingType_Tample )
           return;
       }
       v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
@@ -9637,7 +9637,7 @@
   strcpy(v22, v24);
   pParty->field_709 = 0;
   sub_44A56A();
-  PrepareHouse((HOUSE_TYPE)(int)window_SpeakInHouse->ptr_1C);
+  PrepareHouse((HOUSE_ID)(int)window_SpeakInHouse->ptr_1C);
   dword_F8B19C = 1;
 
   pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
@@ -13133,9 +13133,7 @@
     pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5);
     return result; // void func
   }
-  if ( !(unsigned __int16)_449B57_test_bit(
-                            (unsigned __int8 *)v1->field_152,
-                            word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
+  if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->field_152, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
   {
     v24 = pNPCTopics[171].pText;
     v25 = v31;
@@ -14210,7 +14208,7 @@
 }
 
 //----- (0044606A) --------------------------------------------------------
-void PrepareHouse(HOUSE_TYPE house)
+void PrepareHouse(HOUSE_ID house)
 {
   //unsigned int v1; // ebx@1
   //signed int v2; // esi@1
@@ -14333,9 +14331,9 @@
 
 
 //----- (0044622E) --------------------------------------------------------
-bool __fastcall EnterHouse(HOUSE_TYPE uHouseID)
-{
-  //enum HOUSE_TYPE v1; // edi@1
+bool __fastcall EnterHouse(HOUSE_ID uHouseID)
+{
+  //enum HOUSE_ID v1; // edi@1
   //int v2; // edi@5
   unsigned int uOpenTime; // eax@5
   int uCloseTime; // esi@5
@@ -14358,7 +14356,7 @@
   //const char *v22; // [sp-4h] [bp-40h]@33
   char pContainer[40]; // [sp+Ch] [bp-30h]@32
   unsigned int v24; // [sp+34h] [bp-8h]@5
-  //enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1
+  //enum HOUSE_ID v25; // [sp+38h] [bp-4h]@1
 
   //v1 = uHouseID;
   //v25 = uHouseID;
@@ -14438,7 +14436,7 @@
     //uCurrentHouse_Animation = p2DEvents_minus1___02[v2];
     uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
     in_current_bilding_type = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C);
-    if ( in_current_bilding_type == 20 && pParty->uFine )   // going 2 jail
+    if ( in_current_bilding_type == BildingType_20 && pParty->uFine )   // going 2 jail
     {
       uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
       //v25 = HOUSE_187;
--- a/mm7_data.cpp	Tue Feb 26 12:01:54 2013 +0600
+++ b/mm7_data.cpp	Tue Feb 26 15:23:15 2013 +0600
@@ -2341,7 +2341,7 @@
 __int16 word_F8B158[777]; // weak
 struct Texture *dword_F8B164; // idb
 struct Texture *ItemsInShopTexture[12];
-int in_current_bilding_type; // weak
+int in_current_bilding_type; // 0xF8B198
 int dword_F8B19C; // weak
 __int16 word_F8B1A0; // weak
 const char *dword_F8B1A4; // idb
--- a/mm7_data.h	Tue Feb 26 12:01:54 2013 +0600
+++ b/mm7_data.h	Tue Feb 26 15:23:15 2013 +0600
@@ -2025,8 +2025,8 @@
 struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2);
 int __fastcall sub_445C8B(signed int a1);
 void __cdecl sub_44603D();
-void PrepareHouse(enum HOUSE_TYPE house); // idb
-bool __fastcall EnterHouse(enum HOUSE_TYPE uHouseID);
+void PrepareHouse(enum HOUSE_ID house); // idb
+bool __fastcall EnterHouse(enum HOUSE_ID uHouseID);
 int sub_4465DF_check_season(int a1);
 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive); // idb
 // void __cdecl crt_construct_5773C4();
@@ -2320,15 +2320,15 @@
 char __fastcall DrawTextAtStatusBar(const char *Str, int a5);
 int __fastcall sub_4B46F8(int a1);
 int __cdecl TrainingDialog();
-char *__cdecl sub_4B4F4F();
+char *__cdecl JailDialog();
 int __cdecl MagicShopDialog();
 int __cdecl GuildDialog();
 int __cdecl sub_4B6478();
 bool __fastcall sub_4B68EA(int a1);
 void __cdecl TravelByTransport();
 int __cdecl TampleDialog();
-void __cdecl sub_4B7911();
-void __cdecl _4B7D7E_bank();
+void __cdecl TownHallDialog();
+void __cdecl BankDialog();
 void __cdecl TavernDialog();
 
 char *__cdecl WeaponShopDialog();