changeset 457:e5cf03a3d98e

m
author Ritor1
date Sun, 24 Feb 2013 20:39:03 +0600
parents 20d96ec810c8
children c0ab5f64b37b
files Actor.cpp Events.cpp GUIWindow.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 9 files changed, 149 insertions(+), 209 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/Actor.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -202,7 +202,7 @@
   }
 
   v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-  array_5913D8[6] = 0;
+  pDialogueNPCCount = 0;
   uNumDialogueNPCPortraits = 1;
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v8];
   sprintf(pContainer, "npc%03u", v5->uPortraitID);
--- a/Events.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/Events.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -1519,7 +1519,7 @@
 								pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
 							pCurrentScreen = SCREEN_GAME;
 							viewparams->bRedrawGameUI = 1;
-							array_5913D8[6] = 0;
+							pDialogueNPCCount = 0;
 							pDialogueWindow->Release();
 							dword_F8B19C = 0;
 							pDialogueWindow = 0;
--- a/GUIWindow.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/GUIWindow.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -1048,7 +1048,7 @@
   v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_507B04]);
-  if ( array_5913D8[6] != (NPCData *)uNumDialogueNPCPortraits || !uHouse_ExitPic )
+  if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic )
   {
     w.uFrameWidth = 130;
     w.uFrameHeight = 2 * LOBYTE(pFontCreate->uFontHeight);
@@ -1068,7 +1068,7 @@
   }
   v18.uFrameWidth += 8;
   v18.uFrameZ += 8;
-  if ( !array_5913D8[6] )
+  if ( !pDialogueNPCCount )
   {
     if ( dword_F8B198 == 31 )
     {
@@ -1123,7 +1123,7 @@
         goto LABEL_57;
       }
       v15 = 3;
-      v13 = array_5913D8[v8 - (dword_591080 != 0)]->pName;
+      v13 = HouseNPCData[v8 - (dword_591080 != 0)]->pName;
       v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2;
     }
     v11 = v19;
@@ -1131,7 +1131,7 @@
     v18.DrawTitleText(pFontCreate, 0x1E3u, v10, v11, v13, v15);
     goto LABEL_57;
   }
-  v4 = (char *)array_5913D8[6] - 1;
+  v4 = (char *)pDialogueNPCCount - 1;
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]);
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[(signed int)v4]);
   if ( pCurrentScreen == SCREEN_E )
@@ -1220,7 +1220,7 @@
     }
   }
 LABEL_58:
-  if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic )
+  if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]);
     pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]);
@@ -1948,7 +1948,7 @@
         else
         {
           if ( v26 || !dword_591080 )
-            v27 = array_5913D8[v26 - (dword_591080 != 0)]->pName;
+            v27 = HouseNPCData[v26 - (dword_591080 != 0)]->pName;
           else
             //v27 = (char *)p2DEvents_minus1_::08[13 * a4];
             v27 = (char *)p2DEvents[pButton - 1].pProprieterName;
@@ -1956,7 +1956,7 @@
           v29 = (char*)pGlobalTXT_LocalizationStrings[435];// "Converse with %s" Побеседовать с ^Pt[%s]
         }
         sprintf(&byte_591180[100 * v26], v29, v30);
-        array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26],
+        HouseNPCData[v26 + 7] = (NPCData *)pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26],
                                                                  pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26],
                                              0x3Fu, 0x49u, 1, 0, 0x19Au, v26, 0, &byte_591180[100 * v26], 0, 0, 0);
         ++v26;
--- a/mm7_2.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/mm7_2.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -4311,7 +4311,7 @@
   pKeyActionMap->ResetKeys();
   _5C3420_pDecoration = 0;
   ptr_F8B1E8 = 0;
-  if ( array_5913D8[6] )
+  if ( pDialogueNPCCount )
   {
     v0 = dword_F8B19C;
     if ( dword_F8B19C != 2
@@ -4329,7 +4329,7 @@
     {
       if ( v0 == -1 )
       {
-        _4B4224_UpdateNPCTopics((int)((char *)array_5913D8[6] - 1));
+        _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1));
 LABEL_33:
         pVideoPlayer->_4BF5B2();
         return 1;
@@ -4363,7 +4363,7 @@
       UI_CreateEndConversationButton();
       goto LABEL_28;
     }
-    array_5913D8[6] = 0;
+    pDialogueNPCCount = 0;
     pDialogueWindow->Release();
     dword_F8B19C = 0;
     pDialogueWindow = 0;
@@ -4378,7 +4378,7 @@
         v3 = byte_591180;
         do
         {
-          array_5913D8[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2],
+          HouseNPCData[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2],
                                               0x3Fu, 0x49u, 1, 0, 0x19Au, v2, 0, v3, 0, 0, 0);
           v1 = uNumDialogueNPCPortraits;
           ++v2;
@@ -11957,7 +11957,7 @@
         }
         if ( wParam == 27 )
         {
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, !v12, 0);
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
             v12 = window_SpeakInHouse == 0;
--- a/mm7_3.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/mm7_3.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -17445,7 +17445,7 @@
   signed int v44; // [sp+1Ch] [bp-8h]@25
   int v45; // [sp+20h] [bp-4h]@1
 
-  __debugbreak(); // refactor for blv ai
+//  __debugbreak(); // refactor for blv ai
   pParty->uFlags &= 0xFFFFFFCFu;
   v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   v45 = 0;
--- a/mm7_4.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/mm7_4.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -4916,7 +4916,7 @@
   if ( dword_5C35D4 )
   {
     __debugbreak(); // fix
-    npc = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
+    npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
   }
   else
     npc = GetNPCData(uDialogue_SpeakingActorNPC_ID);
@@ -9375,11 +9375,11 @@
 // F8B1A8: using guessed type int dword_F8B1A8;
 
 //----- (004B2001) --------------------------------------------------------
-void __fastcall sub_4B2001(signed int a1)
-{
-  signed int v1; // eax@1
-  NPCData *v2; // ebp@1
-  int v3; // ecx@8
+void __fastcall ClickNPCTopic(signed int uMessageParam)
+{
+  //signed int v1; // eax@1
+  NPCData *pCurrentNPCInfo; // ebp@1
+  int pEventNumber; // ecx@8
   Player *v4; // esi@20
   int v5; // eax@28
   int v6; // eax@31
@@ -9403,60 +9403,49 @@
   char *v24; // [sp-8h] [bp-14h]@73
   int v25; // [sp-4h] [bp-10h]@49
 
-  v1 = a1;
-  uDialogueType = a1 + 1;
-  v2 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
-  if ( a1 <= 23 )
-  {
-    if ( a1 == 23 )
-    {
-      v3 = v2->evt_E;
-    }
-    else
-    {
-      if ( a1 == 13 )
-      {
-        ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
-        ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
-        sub_4B40E6();
-        dialogue_show_profession_details = false;
+  //v1 = a1;
+  uDialogueType = uMessageParam + 1;
+  pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
+  switch ( uMessageParam )
+  {
+    case 13:
+      ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
+      ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
+      sub_4B40E6();
+      dialogue_show_profession_details = false;
+      goto _return;
+    case 19:
+      pEventNumber = pCurrentNPCInfo->evt_A;
+      break;
+    case 20:
+      pEventNumber = pCurrentNPCInfo->evt_B;
+      break;
+    case 21:
+      pEventNumber = pCurrentNPCInfo->evt_C;
+      break;
+    case 22:
+      pEventNumber = pCurrentNPCInfo->evt_D;
+      break;
+    case 23:
+      pEventNumber = pCurrentNPCInfo->evt_E;
+      break;
+    case 24:
+      pEventNumber = pCurrentNPCInfo->evt_F;
+      break;
+    default:
         goto _return;
-      }
-      switch ( a1 )
-      {
-        case 19:
-          v3 = v2->evt_A;
-          break;
-        case 20:
-          v3 = v2->evt_B;
-          break;
-        case 21:
-          v3 = v2->evt_C;
-          break;
-        default:
-          if ( a1 != 22 )
-            goto _return;
-          v3 = v2->evt_D;
-          break;
-      }
-    }
-    goto LABEL_84;
-  }
-  if ( a1 == 24 )
-  {
-    v3 = v2->evt_F;
-LABEL_84:
-    if ( v3 < 200 || v3 > 310 )
-    {
-      if ( v3 < 400 || v3 > 410 )
-      {
-        if ( v3 == 139 )
+  }
+  if ( pEventNumber < 200 || pEventNumber > 310 )
+    {
+      if ( pEventNumber < 400 || pEventNumber > 410 )
+      {
+        if ( pEventNumber == 139 )
         {
           sub_4B1ECE();
         }
         else
         {
-          if ( v3 == 311 )
+          if ( pEventNumber == 311 )
           {
             sub_4BBA85_bounties();
           }
@@ -9464,32 +9453,32 @@
           {
             ptr_F8B1E8 = 0;
             _5C3420_pDecoration = (LevelDecoration *)1;
-            EventProcessor(v3, 0, 1);
+            EventProcessor(pEventNumber, 0, 1);
             _5C3420_pDecoration = 0;
           }
         }
       }
       else
       {
-        dword_F8B1D8 = v1;
-        sub_4B3EF0(v3 - 400);
+        dword_F8B1D8 = uMessageParam;
+        DrawJoinGuildWindow(pEventNumber - 400);
       }
     }
     else
     {
-      sub_4B3FE5(v3);
+      sub_4B3FE5(pEventNumber);
     }
     goto _return;
-  }
-  if ( a1 != 76 )
-  {
-    if ( a1 == 77 )
-    {
-      v16 = v2->uProfession;
+  
+  if ( uMessageParam != 76 )
+  {
+    if ( uMessageParam == 77 )
+    {
+      v16 = pCurrentNPCInfo->uProfession;
       if (dialogue_show_profession_details)
-        v17 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText;
+        v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
       else
-        v17 = pNPCStats->pProfessions[v2->uProfession - 1].pBenefits;
+        v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits;
       ptr_F8B1E8 = v17;
       v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0);
       dialogue_show_profession_details = ~dialogue_show_profession_details;
@@ -9497,7 +9486,7 @@
     }
     else
     {
-      if ( a1 == 79 )
+      if ( uMessageParam == 79 )
       {
         if ( dword_F8B1A8 )
         {
@@ -9535,7 +9524,7 @@
       }
       else
       {
-        if ( a1 == 82 && dword_F8B1A8 )
+        if ( uMessageParam == 82 && dword_F8B1A8 )
         {
           Party::TakeGold(gold_transaction_amount);
           v4 = pParty->pPlayers;
@@ -9548,36 +9537,36 @@
           switch ( dword_F8B1D8 )
           {
             case 19:
-              v10 = v2->evt_A;
+              v10 = pCurrentNPCInfo->evt_A;
               if ( (signed int)v10 >= 400 && (signed int)v10 <= 416 )
-                v2->evt_A = 0;
+                pCurrentNPCInfo->evt_A = 0;
               break;
             case 20:
-              v9 = v2->evt_B;
+              v9 = pCurrentNPCInfo->evt_B;
               if ( v9 >= 400 && v9 <= 416 )
-                v2->evt_B = 0;
+                pCurrentNPCInfo->evt_B = 0;
               break;
             case 21:
-              v8 = v2->evt_C;
+              v8 = pCurrentNPCInfo->evt_C;
               if ( v8 >= 400 && v8 <= 416 )
-                v2->evt_C = 0;
+                pCurrentNPCInfo->evt_C = 0;
               break;
             case 22:
-              v7 = v2->evt_D;
+              v7 = pCurrentNPCInfo->evt_D;
               if ( v7 >= 400 && v7 <= 416 )
-                v2->evt_D = 0;
+                pCurrentNPCInfo->evt_D = 0;
               break;
             case 23:
-              v6 = v2->evt_E;
+              v6 = pCurrentNPCInfo->evt_E;
               if ( v6 >= 400 && v6 <= 416 )
-                v2->evt_E = 0;
+                pCurrentNPCInfo->evt_E = 0;
               break;
             case 24:
-              v5 = v2->evt_F;
+              v5 = pCurrentNPCInfo->evt_F;
               if ( v5 >= 400 )
               {
                 if ( v5 <= 416 )
-                  v2->evt_F = 0;
+                  pCurrentNPCInfo->evt_F = 0;
               }
               break;
           }
@@ -9611,15 +9600,15 @@
     goto _return;
   }
   //v20 = v2->uProfession;
-  if ( v2->uProfession != 51 )
-  {
-    v21 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice;
+  if ( pCurrentNPCInfo->uProfession != 51 )
+  {
+    v21 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].uHirePrice;
     if ( pParty->uNumGold < v21 )
     {
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
       dialogue_show_profession_details = false;
       uDialogueType = 13;
-      ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText;
+      ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
       ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
       if ( uActiveCharacter )
         pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
@@ -9629,19 +9618,19 @@
     Party::TakeGold(v21);
   }
   //LOBYTE(v2->uFlags) |= 0x80u;
-  v2->uFlags = 128;
+  pCurrentNPCInfo->uFlags = 128;
   pParty->field_709 = 0;
   sub_44A56A();
   if ( pParty->pHirelings[0].pName )
   {
-    memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1]));
-    v24 = v2->pName;
+    memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1]));
+    v24 = pCurrentNPCInfo->pName;
     v22 = pParty->pHireling2Name;
   }
   else
   {
-    memcpy(pParty->pHirelings, v2, 0x4Cu);
-    v24 = v2->pName;
+    memcpy(pParty->pHirelings, pCurrentNPCInfo, 0x4Cu);
+    v24 = pCurrentNPCInfo->pName;
     v22 = pParty->pHireling1Name;
   }
   strcpy(v22, v24);
@@ -10001,23 +9990,14 @@
 
 
 //----- (004B29F2) --------------------------------------------------------
-const char *__fastcall sub_4B29F2(int a1)
-{
-  int v1; // esi@1
-  Player *v2; // edi@1
-  int v3; // eax@1
-  Player *v4; // ecx@1
-
-  v1 = a1;
+const char *__fastcall ContractSelectText(int pEventNumber)
+{
   dword_F8B1A8 = 0;
-  v2 = pPlayers[uActiveCharacter];
-  v3 = a1 + 50;
-  v4 = pPlayers[uActiveCharacter];
-  dword_F8B1AC_something_todo_with_awards = v3;
-  gold_transaction_amount = dword_4F08EC[v1];
-  if ( v4->CanAct() )
-  {
-    if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v2->field_152, dword_F8B1AC_something_todo_with_awards) )
+  dword_F8B1AC_something_todo_with_awards = pEventNumber + 50;
+  gold_transaction_amount = dword_4F08EC[pEventNumber];
+  if ( pPlayers[uActiveCharacter]->CanAct() )
+  {
+    if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->field_152, dword_F8B1AC_something_todo_with_awards) )
     {
       return pNPCTopics[123].pText;
     }
@@ -10026,7 +10006,7 @@
       if ( gold_transaction_amount <= pParty->uNumGold )
       {
         dword_F8B1A8 = 1;
-        return pNPCTopics[v1 + 110].pText;
+        return pNPCTopics[pEventNumber + 110].pText;
       }
       else
       {
@@ -10104,7 +10084,7 @@
   NPCData *v58; // [sp+118h] [bp-4h]@6
 
   memcpy(&a1, pDialogueWindow, sizeof(a1));
-  if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic )
+  if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     v0 = pMapStats->pInfos[uHouse_ExitPic].pName;
     v1 = pMapStats->pInfos[uHouse_ExitPic].pName;
@@ -10128,7 +10108,7 @@
   }
   a1.uFrameWidth -= 10;
   a1.uFrameZ -= 10;
-  v58 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
+  v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
   v6 = v58;
   v55 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
@@ -10203,7 +10183,7 @@
         v27 = v26 - 3;
         if ( !v27 )
         {
-          v33 = (char *)sub_4B29F2((int)v52.ptr_1C);
+          v33 = (char *)ContractSelectText((int)v52.ptr_1C);
           goto LABEL_44;
         }
         v28 = v27 - 1;
@@ -11060,42 +11040,20 @@
 }
 
 //----- (004B3EF0) --------------------------------------------------------
-void __fastcall sub_4B3EF0(int a4)
-{
-  int v1; // edi@1
-
-  v1 = a4;
+void __fastcall DrawJoinGuildWindow(int pEventNumber)
+{
+  //int v1; // edi@1
+
+  //v1 = a4;
   uDialogueType = 81;
-  ptr_F8B1E8 = (char *)pNPCTopics[a4 + 99].pText;
-  sub_4B29F2(a4);
+  ptr_F8B1E8 = (char *)pNPCTopics[pEventNumber + 99].pText;
+  ContractSelectText(pEventNumber);
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, v1, 0);
-  pBtn_ExitCancel = pDialogueWindow->CreateButton(
-                 0x1D7,
-                 0x1BD,
-                 0xA9,
-                 0x23,
-                 1,
-                 0,
-                 0x71,
-                 0,
-                 0,
-                 pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
-                 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventNumber, 0);
+  pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, 0x71, 0, 0, pGlobalTXT_LocalizationStrings[34],
+                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
-  pDialogueWindow->CreateButton(
-    0x1E0u,
-    0xA0u,
-    0x8Cu,
-    0x1Eu,
-    1,
-    0,
-    0xAFu,
-    0x52u,
-    0,
-    pGlobalTXT_LocalizationStrings[122],
-    0);
+  pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
   dword_F8B19C = -1;
 }
@@ -11144,7 +11102,7 @@
   NPCData *v1; // edi@1
 
   v0 = 0;
-  v1 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
+  v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(
@@ -11209,7 +11167,7 @@
   NPCData *v17; // [sp+10h] [bp-4h]@4
 
   num_menu_buttons = 0;
-  array_5913D8[6] = (NPCData *)(_this + 1);
+  pDialogueNPCCount = (_this + 1);
   if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     pDialogueWindow->Release();
@@ -11226,7 +11184,7 @@
   }
   else
   {
-    v17 = array_5913D8[_this + 1 - ((dword_591080 != 0) + 1)];
+    v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) + 1)];
     if ( dword_F8B19C == -1 )
     {
       pDialogueWindow->Release();
@@ -11234,14 +11192,14 @@
     else
     {
       for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
-        GUIButton::_41D0D8((GUIButton *)array_5913D8[i + 7]);
+        GUIButton::_41D0D8((GUIButton *)HouseNPCData[i + 7]);
     }
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 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);
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
-    if ( array_5913D8[6] == (NPCData *)1 && dword_591080 )
+    if ( pDialogueNPCCount == 1 && dword_591080 )
     {
       sub_4B3B42(dword_F8B198);
     }
@@ -12419,7 +12377,7 @@
   //unsigned int v1; // esi@1
   NPCData *v2; // ebp@1
   //unsigned int v3; // eax@1
-  int v4; // ecx@10
+  int pEventNumber; // ecx@10
   signed int v5; // edi@14
   char *v6; // esi@15
   const char *v7; // ecx@22
@@ -12445,12 +12403,12 @@
   {
     if ( newDialogueType == DIALOGUE_23 )
     {
-      v4 = v2->evt_E;
+      pEventNumber = v2->evt_E;
       goto LABEL_74;
     }
     if (newDialogueType == DIALOGUE_24)
     {
-      v4 = v2->evt_F;
+      pEventNumber = v2->evt_F;
       goto LABEL_74;
     }
     if (newDialogueType != DIALOGUE_76)
@@ -12572,7 +12530,7 @@
   }
   if (newDialogueType == DIALOGUE_22)
   {
-    v4 = v2->evt_D;
+    pEventNumber = v2->evt_D;
     goto LABEL_74;
   }
   if (newDialogueType == DIALOGUE_9)
@@ -12621,23 +12579,23 @@
   }
   if (newDialogueType == DIALOGUE_19)
   {
-    v4 = v2->evt_A;
+    pEventNumber = v2->evt_A;
     goto LABEL_74;
   }
   if (newDialogueType == DIALOGUE_20)
   {
-    v4 = v2->evt_B;
+    pEventNumber = v2->evt_B;
     goto LABEL_74;
   }
   if (newDialogueType == DIALOGUE_21)
   {
-    v4 = v2->evt_C;
+    pEventNumber = v2->evt_C;
 LABEL_74:
-    if ( v4 < 200 || v4 > 310 )
-    {
-      if ( v4 < 400 || v4 > 410 )
-      {
-        switch ( v4 )
+    if ( pEventNumber < 200 || pEventNumber > 310 )
+    {
+      if ( pEventNumber < 400 || pEventNumber > 410 )
+      {
+        switch ( pEventNumber )
         {
           case 139:
             sub_4B1ECE();
@@ -12651,7 +12609,7 @@
           default:
             _5C3420_pDecoration = (LevelDecoration *)1;
             ptr_F8B1E8 = 0;
-            EventProcessor(v4, 0, 1);
+            EventProcessor(pEventNumber, 0, 1);
             _5C3420_pDecoration = 0;
             break;
         }
@@ -12659,12 +12617,12 @@
       else
       {
         dword_F8B1D8 = newDialogueType;
-        sub_4B3EF0(v4 - 400);
+        DrawJoinGuildWindow(pEventNumber - 400);
       }
     }
     else
     {
-      sub_4B3FE5(v4);
+      sub_4B3FE5(pEventNumber);
     }
   }
 LABEL_87:
@@ -14827,7 +14785,7 @@
         //if ( !(*(char *)v6 & 0x80) )
       {
         v7 = uNumDialogueNPCPortraits++ - dword_591080 ? 1 : 0;
-        array_5913D8[v7] = npc;
+        HouseNPCData[v7] = npc;
         //v6 = v17;
         //*(&v13 + v2) = *(v17 - 1);
         Dst[uNumDialogueNPCPortraits - 1] = npc->uPortraitID;
@@ -15041,14 +14999,14 @@
     }
 
     v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    array_5913D8[6] = 0;
+    pDialogueNPCCount = 0;
     pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
     uTextureID_507B04 = uTextureID_right_panel;
     PrepareHouse(uHouseID);
     v18 = 1;
     uTextureID_507B04 = uTextureID_right_panel;
     if ( uNumDialogueNPCPortraits == 1 )
-      array_5913D8[6] = (NPCData *)1;
+      pDialogueNPCCount = 1;
     pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
     if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 )
     {
--- a/mm7_5.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/mm7_5.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -393,8 +393,8 @@
         case UIMSG_51:
           sub_4BDB56_buy_skill____();
           continue;
-        case UIMSG_AF:
-          sub_4B2001(uMessageParam);
+        case UIMSG_AF://Click topic
+          ClickNPCTopic(uMessageParam);//CheckNPCTopic
           continue;
         case UIMSG_195:
           sub_4BCACC_bounties(uMessageParam);
@@ -3338,9 +3338,7 @@
             pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0);
             /*v115 = v0;
             pMessageQueue_50CBD0->uNumMessages = v0;
-//LABEL_769:
             pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14;
-//LABEL_770:
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
             //goto LABEL_771;
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
@@ -3349,7 +3347,6 @@
           }
           v115 = 0;
           pMessageQueue_50CBD0->uNumMessages = 0;
-//LABEL_768:
           pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0);
           /*if ( (signed int)v115 < 40 )
             //goto LABEL_769;
@@ -3362,7 +3359,6 @@
           }*/
           continue;
         case UIMSG_E:
-//LABEL_772:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           OnGameViewportClick();
@@ -3378,28 +3374,12 @@
             pPoint3 = pMouse->GetCursorPos(&v204);
             v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]];
           }
-          v163 = 0;
           pButton2 = (GUIButton *)(unsigned __int16)v116;
-          pWindowType1 = (WindowType)15;
-          //goto LABEL_779;
-          v8 = 0;
-          v9 = 0;
-          v137 = 0;
-          v133 = 0;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(0, 0, 0, 0, (WindowType)15, (int)pButton2, 0);
           continue;
         case UIMSG_54:
-          v163 = 0;
           pButton2 = (GUIButton *)uMessageParam;
-          pWindowType1 = (WindowType)22;
-//LABEL_779:
-          v8 = 0;
-          v9 = 0;
-//LABEL_732:
-          v137 = 0;
-          v133 = 0;
-//LABEL_733:
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(0, 0, 0, 0, (WindowType)22, (int)pButton2, 0);
           continue;
         case UIMSG_Game_Action:
           if ( pMessageQueue_50CBD0->uNumMessages )
--- a/mm7_data.cpp	Sun Feb 24 13:53:18 2013 +0600
+++ b/mm7_data.cpp	Sun Feb 24 20:39:03 2013 +0600
@@ -1998,7 +1998,8 @@
 int dword_591178_teleporty; // weak
 int dword_59117C_teleportx; // weak
 char byte_591180[600]; // idb
-struct NPCData *array_5913D8[12];
+struct NPCData *HouseNPCData[6];//array_5913D8
+int pDialogueNPCCount;
 struct Texture *pDialogueNPCPortraits[6];
 int uNumDialogueNPCPortraits; // weak
 struct Texture *pTexture_591428;
--- a/mm7_data.h	Sun Feb 24 13:53:18 2013 +0600
+++ b/mm7_data.h	Sun Feb 24 20:39:03 2013 +0600
@@ -1333,7 +1333,8 @@
 extern int dword_591178_teleporty; // weak
 extern int dword_59117C_teleportx; // weak
 extern char byte_591180[600]; // idb
-extern struct NPCData *array_5913D8[12];
+extern struct NPCData *HouseNPCData[6];
+extern int pDialogueNPCCount;
 extern struct Texture *pDialogueNPCPortraits[6];
 extern int uNumDialogueNPCPortraits; // weak
 extern struct Texture *pTexture_591428;
@@ -2302,9 +2303,9 @@
 void __cdecl sub_4B1D27();
 void __fastcall HousePlaySomeSound(unsigned int uHouseID, int a2); // idb
 void __cdecl sub_4B1ECE();
-void __fastcall sub_4B2001(signed int a1);
+void __fastcall ClickNPCTopic(signed int uMessageParam);
 char *__thiscall _4B254D_SkillMasteryTeacher(int _this);
-const char *__fastcall sub_4B29F2(int a1);
+const char *__fastcall ContractSelectText(int pEventNumber);
 char __cdecl SimpleHouseAndBoatsDialog();
 struct GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2);
 int __thiscall sub_4B3703(void *_this);
@@ -2312,7 +2313,7 @@
 int __fastcall sub_4B3AD4(signed int a1);
 int __fastcall sub_4B3B42(signed int a1);
 void __cdecl sub_4B3E1E();
-void __fastcall sub_4B3EF0(int a4);
+void __fastcall DrawJoinGuildWindow(int pEventNumber);
 void __fastcall sub_4B3FE5(int a4);
 void __cdecl sub_4B40E6();
 void  _4B4224_UpdateNPCTopics(int _this);