diff mm7_4.cpp @ 423:88c30918eef7

NPC_EventProcessor
author Gloval
date Sat, 23 Feb 2013 23:09:48 +0400
parents d8b3056df4e2
children afad358dc684
line wrap: on
line diff
--- a/mm7_4.cpp	Sat Feb 23 19:35:32 2013 +0400
+++ b/mm7_4.cpp	Sat Feb 23 23:09:48 2013 +0400
@@ -11187,72 +11187,34 @@
 
 
 //----- (004B4224) --------------------------------------------------------
-GUIButton *_4B4224_UpdateNPCTopics(int _this)
-{
-  int v1; // ebx@1
-  GUIButton *result; // eax@3
+void _4B4224_UpdateNPCTopics( int _this )
+	{
+  int num_menu_buttons; // ebx@1
   int i; // ebp@5
-  signed int v4; // ebp@9
-  void *v5; // ecx@14
-  bool v6; // eax@16
-  void *v7; // ecx@19
-  bool v8; // eax@21
-  void *v9; // ecx@24
-  bool v10; // eax@26
-  void *v11; // ecx@29
-  bool v12; // eax@31
-  void *v13; // ecx@34
-  bool v14; // eax@36
-  void *v15; // ecx@39
-  bool v16; // eax@41
+ // signed int v4; // ebp@9
+  int v6; // eax@16
+  int v8; // eax@21
+  int v10; // eax@26
+  int v12; // eax@31
+  int v14; // eax@36
+  int v16; // eax@41
   NPCData *v17; // [sp+10h] [bp-4h]@4
 
-  v1 = 0;
+  num_menu_buttons = 0;
   array_5913D8[6] = (NPCData *)(_this + 1);
   if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     pDialogueWindow->Release();
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
-    sprintf(byte_591098, pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);
-    pBtn_ExitCancel = pDialogueWindow->CreateButton(
-                   0x236u,
-                   0x1BDu,
-                   0x4Bu,
-                   0x21u,
-                   1,
-                   0,
-                   0x71u,
-                   0,
-                   0x4Eu,
+    sprintf(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName);
+    pBtn_ExitCancel = pDialogueWindow->CreateButton( 566, 445, 75, 33, 1, 0, 0x71u, 0, 0x4Eu,
                    pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                   (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
-                   0);
-    pBtn_YES = pDialogueWindow->CreateButton(
-                   486u,
-                   445u,
-                   75u,
-                   33u,
-                   1,
-                   0,
-                   0xBFu,
-                   1u,
-                   0x59u,
-                   byte_591098,
-                   (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
-                   0);
-    pDialogueWindow->CreateButton(
-      pNPCPortraits_x,
-      pNPCPortraits_y,
-      63u,
-      73u,
-      1,
-      0,
-      0xBFu,
-      1u,
-      0x20u,
-      byte_591098,
-      0);
-    result = pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, 0xBFu, 1u, 0x59u, byte_591098, 0);
+                   (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+    pBtn_YES = pDialogueWindow->CreateButton( 486u, 445u,  75u, 33u, 1, 0,  0xBFu,  1u,  0x59u,
+                   sHouseName,
+                   (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0);
+    pDialogueWindow->CreateButton(pNPCPortraits_x, pNPCPortraits_y, 63u, 73u, 1, 0,  0xBFu, 1u, 0x20u,  sHouseName, 0);
+    pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, 0xBFu, 1u, 0x59u, sHouseName, 0);
   }
   else
   {
@@ -11266,167 +11228,83 @@
       for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
         GUIButton::_41D0D8((GUIButton *)array_5913D8[i + 7]);
     }
-    v4 = 1;
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
-    pBtn_ExitCancel = pDialogueWindow->CreateButton(
-                   471u,
-                   445u,
-                   169u,
-                   35u,
-                   1,
-                   0,
-                   0x71u,
-                   0,
-                   0,
+    pBtn_ExitCancel = pDialogueWindow->CreateButton(  471u,  445u,  169u, 35u,  1,   0, 0x71u,  0,  0,
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
-                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
-                   0);
+                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),   0);
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
     if ( array_5913D8[6] == (NPCData *)1 && dword_591080 )
     {
-      result = (GUIButton *)sub_4B3B42(dword_F8B198);
+      sub_4B3B42(dword_F8B198);
     }
     else
     {
       if ( v17->joins )
       {
-        v1 = 1;
+        num_menu_buttons = 1;
         pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, "", 0);
       }
-      v5 = (void *)v17->evt_A;
-      if ( v5 )
-      {
-        if ( v1 < 4 )
-        {
-          v6 = sub_4466C4(v5);
+      if ( v17->evt_A)
+      {
+        if ( num_menu_buttons < 4 )
+        {
+          v6 = NPC_EventProcessor(v17->evt_A);
           if ( v6 == 1 || v6 == 2 )
-            pDialogueWindow->CreateButton(
-              480u,
-              30 * v1++ + 160,
-              140u,
-              30u,
-              1,
-              0,
-              0xAFu,
-              0x13u,
-              0,
-              "",
-              0);
-        }
-      }
-      v7 = (void *)v17->evt_B;
-      if ( v7 )
-      {
-        if ( v1 < 4 )
-        {
-          v8 = sub_4466C4(v7);
+            pDialogueWindow->CreateButton(  480u, 30 * num_menu_buttons++ + 160,  140u, 30u, 1, 0, 0xAFu, 0x13u,  0, "",  0);
+        }
+      }
+      if ( v17->evt_B )
+      {
+        if ( num_menu_buttons < 4 )
+        {
+          v8 = NPC_EventProcessor(v17->evt_B);
           if ( v8 == 1 || v8 == 2 )
-            pDialogueWindow->CreateButton(
-              480u,
-              30 * v1++ + 160,
-              140u,
-              30u,
-              1,
-              0,
-              0xAFu,
-              0x14u,
-              0,
-              "",
-              0);
-        }
-      }
-      v9 = (void *)v17->evt_C;
-      if ( v9 )
-      {
-        if ( v1 < 4 )
-        {
-          v10 = sub_4466C4(v9);
+            pDialogueWindow->CreateButton( 480u,  30 * num_menu_buttons++ + 160,  140u, 30u,  1, 0,  0xAFu,  0x14u,  0, "",  0);
+        }
+      }
+      if ( v17->evt_C )
+      {
+        if ( num_menu_buttons < 4 )
+        {
+          v10 = NPC_EventProcessor(v17->evt_C);
           if ( v10 == 1 || v10 == 2 )
-            pDialogueWindow->CreateButton(
-              480u,
-              30 * v1++ + 160,
-              140u,
-              30u,
-              1,
-              0,
-              0xAFu,
-              0x15u,
-              0,
-              "",
-              0);
-        }
-      }
-      v11 = (void *)v17->evt_D;
-      if ( v11 )
-      {
-        if ( v1 < 4 )
-        {
-          v12 = sub_4466C4(v11);
+            pDialogueWindow->CreateButton(  480u,  30 * num_menu_buttons++ + 160,  140u, 30u,  1,  0, 0xAFu, 0x15u, 0, "",  0);
+        }
+      }
+ 
+      if ( v17->evt_D )
+      {
+        if ( num_menu_buttons < 4 )
+        {
+          v12 = NPC_EventProcessor(v17->evt_D);
           if ( v12 == 1 || v12 == 2 )
-            pDialogueWindow->CreateButton(
-              0x1E0u,
-              30 * v1++ + 160,
-              0x8Cu,
-              0x1Eu,
-              1,
-              0,
-              0xAFu,
-              0x16u,
-              0,
-              "",
-              0);
-        }
-      }
-      v13 = (void *)v17->evt_E;
-      if ( v13 )
-      {
-        if ( v1 < 4 )
-        {
-          v14 = sub_4466C4(v13);
+            pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160,  0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x16u,  0, "",  0);
+        }
+      }
+      if ( v17->evt_E )
+      {
+        if ( num_menu_buttons < 4 )
+        {
+          v14 = NPC_EventProcessor(v17->evt_E);
           if ( v14 == 1 || v14 == 2 )
-            pDialogueWindow->CreateButton(
-              0x1E0u,
-              30 * v1++ + 160,
-              0x8Cu,
-              0x1Eu,
-              1,
-              0,
-              0xAFu,
-              0x17u,
-              0,
-              "",
-              0);
-        }
-      }
-      v15 = (void *)v17->evt_F;
-      if ( v15 )
-      {
-        if ( v1 < 4 )
-        {
-          v16 = sub_4466C4(v15);
+            pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160,  0x8Cu,  0x1Eu,  1,  0,  0xAFu, 0x17u,  0, "",  0);
+        }
+      }
+      if ( v17->evt_F )
+      {
+        if ( num_menu_buttons < 4 )
+        {
+          v16 = NPC_EventProcessor(v17->evt_F);
           if ( v16 == 1 || v16 == 2 )
-            pDialogueWindow->CreateButton(
-              0x1E0u,
-              30 * v1++ + 160,
-              0x8Cu,
-              0x1Eu,
-              1,
-              0,
-              0xAFu,
-              0x18u,
-              0,
-              "",
-              0);
-        }
-      }
-      pDialogueWindow->_41D08F(v1, 1, 0, 2);
-      v4 = 1;
-      result = (GUIButton *)pDialogueWindow->pNumPresenceButton;
+            pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160,  0x8Cu,  0x1Eu, 1, 0, 0xAFu, 0x18u, 0, "",  0);
+        }
+      }
+      pDialogueWindow->_41D08F(num_menu_buttons, 1, 0, 2);
       dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
     }
-    dword_F8B19C = v4;
-  }
-  return result;
+    dword_F8B19C = 1;
+  }
+ 
 }
 
 
@@ -14834,7 +14712,7 @@
         v20 = pMapStats->pInfos[v14].pName;
         v18 = pGlobalTXT_LocalizationStrings[410];
 LABEL_10:
-        sprintf(byte_591098, v18, v20);
+        sprintf(sHouseName, v18, v20);
         goto LABEL_20;
       }
       v21 = pGlobalTXT_LocalizationStrings[79];
@@ -14853,9 +14731,9 @@
   }
   v21 = pGlobalTXT_LocalizationStrings[73];
 LABEL_19:
-  strcpy(byte_591098, v21);
+  strcpy(sHouseName, v21);
 LABEL_20:
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)byte_591098);
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)sHouseName);
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
   if ( BYTE1(pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_C) )
     HousePlaySomeSound(v9, 1);