diff mm7_4.cpp @ 462:37090bd974f9

Merge
author Gloval
date Sun, 24 Feb 2013 20:47:46 +0400
parents 197461e5acec a7869569e912
children f7b91ef98ab2
line wrap: on
line diff
--- a/mm7_4.cpp	Sun Feb 24 20:47:01 2013 +0400
+++ b/mm7_4.cpp	Sun Feb 24 20:47:46 2013 +0400
@@ -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);
@@ -9376,11 +9376,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
@@ -9404,60 +9404,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();
           }
@@ -9465,32 +9454,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;
@@ -9498,7 +9487,7 @@
     }
     else
     {
-      if ( a1 == 79 )
+      if ( uMessageParam == 79 )
       {
         if ( dword_F8B1A8 )
         {
@@ -9536,7 +9525,7 @@
       }
       else
       {
-        if ( a1 == 82 && dword_F8B1A8 )
+        if ( uMessageParam == 82 && dword_F8B1A8 )
         {
           Party::TakeGold(gold_transaction_amount);
           v4 = pParty->pPlayers;
@@ -9549,36 +9538,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;
           }
@@ -9612,15 +9601,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);
@@ -9630,19 +9619,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);
@@ -10002,23 +9991,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;
     }
@@ -10027,7 +10007,7 @@
       if ( gold_transaction_amount <= pParty->uNumGold )
       {
         dword_F8B1A8 = 1;
-        return pNPCTopics[v1 + 110].pText;
+        return pNPCTopics[pEventNumber + 110].pText;
       }
       else
       {
@@ -10043,7 +10023,7 @@
 
 
 //----- (004B2A74) --------------------------------------------------------
-char __cdecl SimpleHouseDialog()
+char __cdecl SimpleHouseAndBoatsDialog()
 {
   char *v0; // esi@3
   char *v1; // ST1C_4@3
@@ -10105,7 +10085,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;
@@ -10129,7 +10109,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);
@@ -10204,7 +10184,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;
@@ -11061,42 +11041,17 @@
 }
 
 //----- (004B3EF0) --------------------------------------------------------
-void __fastcall sub_4B3EF0(int a4)
-{
-  int v1; // edi@1
-
-  v1 = a4;
+void __fastcall DrawJoinGuildWindow(int pEventNumber)
+{
   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;
 }
@@ -11145,7 +11100,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(
@@ -11210,7 +11165,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();
@@ -11227,7 +11182,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();
@@ -11235,14 +11190,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);
     }
@@ -12666,7 +12621,7 @@
       else
       {
         dword_F8B1D8 = newDialogueType;
-        sub_4B3EF0(v4 - 400);
+        DrawJoinGuildWindow(v4 - 400);
       }
     }
     else
@@ -14750,7 +14705,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;
@@ -14964,14 +14919,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 )
     {