diff mm7_4.cpp @ 652:1ff57450f090

* Some fixes to TravelByTransport * Minor bug with npc profession names * Fixed not loading npc profession decriptions * NPC professions enum
author Nomad
date Tue, 12 Mar 2013 04:45:38 +0200
parents 2bf48d11d742
children 6a2d29c21d09
line wrap: on
line diff
--- a/mm7_4.cpp	Tue Mar 12 03:10:35 2013 +0200
+++ b/mm7_4.cpp	Tue Mar 12 04:45:38 2013 +0200
@@ -10812,7 +10812,7 @@
 
 //----- (004BC49B) --------------------------------------------------------
 void OnSelectNPCDialogueOption(DIALOGUE_TYPE newDialogueType)
-    {
+{
     //unsigned int v1; // esi@1
     NPCData *speakingNPC; // ebp@1
     //unsigned int v3; // eax@1
@@ -10830,17 +10830,16 @@
     const char *v15; // [sp-4h] [bp-14h]@60
 
     //v1 = _this;
-    speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
+  speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID);
     //v3 = v1;
-    uDialogueType = newDialogueType;
-    if ( !speakingNPC->uFlags )
-        {
-        speakingNPC->uFlags = 1;
+  uDialogueType = newDialogueType;
+  if (!speakingNPC->uFlags)
+  {
+    speakingNPC->uFlags = 1;
         //v3 = uDialogueType;
-        }
-    if ((newDialogueType>DIALOGUE_24)||(newDialogueType<DIALOGUE_19))
-        {
-
+  }
+  if ((newDialogueType > DIALOGUE_24) || (newDialogueType < DIALOGUE_19))
+  {
         if (newDialogueType != DIALOGUE_76)
             {
             if (newDialogueType == DIALOGUE_PROFESSION_DETAILS)
@@ -11350,8 +11349,8 @@
   int v29; // eax@62
   unsigned int v30; // ecx@62
   char *v31; // eax@63
-  char v32; // [sp-3Ch] [bp-2CCh]@62
-  int v33; // [sp-38h] [bp-2C8h]@62
+  MapInfo v32; // [sp-3Ch] [bp-2CCh]@62
+  /*int v33; // [sp-38h] [bp-2C8h]@62
   int v34; // [sp-34h] [bp-2C4h]@62
   int v35; // [sp-30h] [bp-2C0h]@62
   int v36; // [sp-2Ch] [bp-2BCh]@62
@@ -11365,17 +11364,17 @@
   char *v44; // [sp-Ch] [bp-29Ch]@62
   unsigned int v45; // [sp-8h] [bp-298h]@62
   char *v46; // [sp-4h] [bp-294h]@62
-  const char *v47[5]; // [sp+0h] [bp-290h]@7
-  char v48; // [sp+14h] [bp-27Ch]@37
-  char v49; // [sp+78h] [bp-218h]@68
-  char v50; // [sp+DCh] [bp-1B4h]@68
-  char v51; // [sp+140h] [bp-150h]@68
-  char Dest; // [sp+1A4h] [bp-ECh]@36
+  const char *v47[5]; // [sp+0h] [bp-290h]@7*/
+  char v48[100]; // [sp+14h] [bp-27Ch]@37
+  char v49[100]; // [sp+78h] [bp-218h]@68
+  char v50[100]; // [sp+DCh] [bp-1B4h]@68
+  char v51[100]; // [sp+140h] [bp-150h]@68
+  char Dest[100]; // [sp+1A4h] [bp-ECh]@36
   GUIWindow v53; // [sp+208h] [bp-88h]@1
   int v54; // [sp+25Ch] [bp-34h]@36
   int v55; // [sp+260h] [bp-30h]@36
   unsigned int v56; // [sp+264h] [bp-2Ch]@1
-  __int16 v57[2]; // [sp+268h] [bp-28h]@1
+  int v57; // [sp+268h] [bp-28h]@1
   Player *v58; // [sp+26Ch] [bp-24h]@36
   GUIWindow *v59; // [sp+270h] [bp-20h]@1
   unsigned int v60; // [sp+274h] [bp-1Ch]@36
@@ -11394,7 +11393,7 @@
   v53.uFrameX = 483;
   v53.uFrameWidth = 148;
   v53.uFrameZ = 334;
-  *(int *)v57 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  v57 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v56 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   v3 = 52 * (unsigned int)v0->ptr_1C;
   //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50);
@@ -11414,8 +11413,8 @@
       v17 = LOBYTE(pFontArrus->uFontHeight) - 3;
       v59 = pDialogueWindow;
       v54 = v17;
-      strcpy(&Dest, "");
-      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1);
+      strcpy(Dest, "");
+      sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1); // Price: %lu gold
       v18 = pFontArrus->CalcTextHeight(pTmpBuf2, &v53, 0, 0);
       v19 = v16->pNumPresenceButton;
       v20 = v18 + v17 + 146;
@@ -11426,13 +11425,13 @@
       if ( v21 >= v21 + v19 )
         goto LABEL_71;
       s1 = 2;
-      a1 = &v48;
+      a1 = v48;
       while ( 1 )
       {
-        v47[1] = (const char *)v60;
+        int v47 = v60;
         v22 = window_SpeakInHouse->ptr_1C;
-        v23 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (signed int)v22] + v62);
-        v61 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (signed int)v22] + v62);
+        v23 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (unsigned int)v22] + v62); // negindex. actual address is around + 0x36
+        v61 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (unsigned int)v22] + v62); // + 0x3F for sea travels, less for land
         v24 = v16->GetControl(v60);
         if ( v23 != v58
           && ((signed int)s1 >= 6 ? (v25 = 1) : (v25 = (unsigned __int8)*(&byte_4F09B1[32 * (int)v23]
@@ -11444,49 +11443,35 @@
           v58 = v61;
           v27 = (const char *)v56;
           if ( pDialogueWindow->pCurrentPosActiveItem != s1 )
-            v27 = *(const char **)v57;
-          v47[1] = v27;
+            v27 = (const char *)v57;
+          //v32.uRedbookTrackID = v27;
           sprintf(a1, "\xC" "%05d", v27);
           v66 = (unsigned __int8)byte_4F09B8[v26 * 4];
           if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 )
           {
-            if ( CheckHiredNPCSpeciality(8u) )
+            if ( CheckHiredNPCSpeciality(Sailor) )
               v66 -= 2;
-            if ( CheckHiredNPCSpeciality(9u) )
+            if ( CheckHiredNPCSpeciality(Navigator) )
               v66 -= 3;
-            v47[1] = (const char *)45;
+            //v47 = Pirate;
+            if ( CheckHiredNPCSpeciality(Pirate) )
+              v66 -= 2;
           }
           else
           {
-            v47[1] = (const char *)35;
-          }
-          if ( CheckHiredNPCSpeciality((unsigned int)v47[1]) )
-            v66 -= 2;
-          if ( CheckHiredNPCSpeciality(0x2Cu) )
+            //v47 = Horseman;
+            if ( CheckHiredNPCSpeciality(Horseman) )
+              v66 -= 2;
+          }
+          if ( CheckHiredNPCSpeciality(Explorer) )
             --v66;
           if ( v66 < 1 )
             v66 = 1;
           if ( v61 != (Player *)v2 )
           {
-            memcpy(&v32, (char *)&pMapStats + 68 * (unsigned __int8)byte_4F09B0[v26 * 4], 0x44u);
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[404],
-              v66,
-              *(int *)&v32,
-              v33,
-              v34,
-              v35,
-              v36,
-              v37,
-              v38,
-              v39,
-              v40,
-              v41,
-              v42,
-              v43,
-              v44,
-              v45,
-              v46,
-              *(_QWORD *)v47);
+            memcpy(&v32, &pMapStats->pInfos[(unsigned __int8)byte_4F09B0[v26 * 4]], 0x44u);
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[404], // Time - %d days, destination %s
+              v66, v32.pName);
             strcat(a1, pTmpBuf);
             v28 = a1;
             a1 += 100;
@@ -11523,23 +11508,20 @@
       }
       if ( v63 != v55 )
       {
-        v47[1] = &Dest;
+        /*v47[1] = &Dest;
         v47[0] = &v51;
         v46 = &v50;
         v45 = (unsigned int)&v49;
         v44 = &v48;
-        v43 = pTmpBuf2;
-        sprintf(pTmpBuf, "%s\n \n%s%s%s%s%s", pTmpBuf2, &v48, &v49, &v50, &v51, &Dest);
+        v43 = pTmpBuf2;*/
+        sprintf(pTmpBuf, "%s\n \n%s%s%s%s%s", pTmpBuf2, v48, v49, v50, v51, Dest);
         v53.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
       }
       else
       {
 LABEL_71:
-        v47[1] = (const char *)3;
-        v47[0] = pGlobalTXT_LocalizationStrings[561];
-        v46 = *(char **)v57;
-        v45 = (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &v53, 0, 0)) / 2 + 138;
-        v53.DrawTitleText(pFontArrus, 0, v45, (unsigned __int16)v46, v47[0], (unsigned int)v47[1]);
+        v53.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &v53, 0, 0)) / 2 + 138,
+                          v57, pGlobalTXT_LocalizationStrings[561], 3);
         pAudioPlayer->StopChannels(-1, -1);
       }
     }
@@ -11560,8 +11542,8 @@
         pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
       }
       Party::TakeGold(s1);
-      v47[1] = (const char *)7;
-      v5 = &byte_4F09B0[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + dialog_menu_id)];
+      //v47[1] = (const char *)7;
+      v5 = &byte_4F09B0[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + dialog_menu_id)];  // negindex with ptr_1C around +0x36
       if ( v5[pParty->uDaysPlayed % 7 + 1] )
       {
         if ( _strcmpi(pCurrentMapName, pMapStats->pInfos[(unsigned __int8)*v5].pFilename) )
@@ -11597,25 +11579,28 @@
         }
         HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
         v12 = (unsigned __int8)v5[8];
+        int _v47;
         if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 )
         {
-          v63 = SPEECH_72;
+          v63 = SPEECH_SetSail;
           v13 = 2500;
-          if ( CheckHiredNPCSpeciality(8u) )
+          if ( CheckHiredNPCSpeciality(Sailor) )
             v12 -= 2;
-          if ( CheckHiredNPCSpeciality(9u) )
+          if ( CheckHiredNPCSpeciality(Navigator) )
             v12 -= 3;
-          v47[1] = (const char *)45;
+          //_v47 = 45;
+          if ( CheckHiredNPCSpeciality(Pirate) )
+            v12 -= 2;
         }
         else
         {
-          v63 = SPEECH_71;
+          v63 = SPEECH_CarriageReady;
           v13 = 1500;
-          v47[1] = (const char *)35;
-        }
-        if ( CheckHiredNPCSpeciality((unsigned int)v47[1]) )
-          v12 -= 2;
-        if ( CheckHiredNPCSpeciality(0x2Cu) )
+          //_v47 = 35;
+          if ( CheckHiredNPCSpeciality(Horseman) )
+            v12 -= 2;
+        }
+        if ( CheckHiredNPCSpeciality(Explorer) )
           --v12;
         if ( v12 < 1 )
           v12 = 1;