diff mm7_3.cpp @ 252:e22e2357c8b3

Merge
author Gloval
date Mon, 18 Feb 2013 08:59:34 +0400
parents 48f21f569328 37dcbe8f3cca
children f1218b9d67f1
line wrap: on
line diff
--- a/mm7_3.cpp	Mon Feb 18 08:47:21 2013 +0400
+++ b/mm7_3.cpp	Mon Feb 18 08:59:34 2013 +0400
@@ -4703,6 +4703,11 @@
   return result;
 }
 
+//----- (00476387) --------------------------------------------------------
+bool PartyHasDragon()
+{
+  return pNPCStats->pNewNPCData[57].Hired();
+}
 
 
 // 47730C: using guessed type int __stdcall const_1(int);
@@ -15041,7 +15046,7 @@
   unsigned __int16 v2; // di@2
   //unsigned int v3; // eax@2
   char *v4; // esi@3
-  int v5; // eax@11
+  //int v5; // eax@11
   char *v6; // ecx@13
   char *v7; // eax@16
   unsigned int v8; // edi@19
@@ -15099,16 +15104,86 @@
   pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[0]);
-  if ( pNPC->uProfession )
-  {
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s
-  }
-  else
-  {
+
+  if (pNPC->uProfession)
+  {
+    assert(pNPC->uProfession < sizeof(aNPCProfessionNames) / sizeof(*aNPCProfessionNames)); // sometimes buffer overflows; errors emerge both here and in dialogue text
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s
+  }
+  else
     strcpy(pTmpBuf, pNPC->pName);
-  }
+
   v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf, 3);
   pParty->GetPartyFame();
+
+  switch (uDialogueType)
+  {
+    case DIALOGUE_PROFESSION_DETAILS:
+    {
+          if (dialogue_show_profession_details)
+          {
+            v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pBenefits;
+            v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
+            pInString = v7;
+            pWindow.uFrameWidth = 460;
+            pWindow.uFrameZ = 452;
+            pOutString = pFontArrus;
+            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+            if ( 352 - v12 < 8 )
+            {
+              pOutString = pFontCreate;
+              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+            }
+            if (uTextureID_Leather != -1)
+              pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12);
+            pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+          }
+          else if (pNPC->Hired())
+          {
+            v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pDismissText;
+            v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
+            pInString = v7;
+            pWindow.uFrameWidth = 460;
+            pWindow.uFrameZ = 452;
+            pOutString = pFontArrus;
+            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+            if ( 352 - v12 < 8 )
+            {
+              pOutString = pFontCreate;
+              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+            }
+            if (uTextureID_Leather != -1)
+              pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12);
+            pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
+            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+          }
+		  else
+		  {
+            v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText;
+			v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
+			pInString = v7;
+			pWindow.uFrameWidth = 460;
+			pWindow.uFrameZ = 452;
+			pOutString = pFontArrus;
+			v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+			if ( 352 - v12 < 8 )
+			{
+			pOutString = pFontCreate;
+			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
+			}
+            if (uTextureID_Leather != -1)
+              pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12);
+			pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
+			v13 = FitTextInAWindow(pInString, pOutString,  &pWindow, 0xDu, 0);
+			pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
+		  }
+    }
+    break;
+  }
+
   if ( (signed int)uDialogueType > DIALOGUE_ARENA_WELCOME )
   {
     if ( uDialogueType == DIALOGUE_ARENA_FIGHT_NOT_OVER_YET )
@@ -15189,8 +15264,7 @@
     }
     else if ( uDialogueType == DIALOGUE_13 )
     {
-      v5 = 5 * pNPC->uProfession;
-      v6 = (char *)*(&pNPCStats->field_13A64 + v5);
+      v6 = pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText;
       v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
       pInString = v7;
       pWindow.uFrameWidth = 460;
@@ -15202,79 +15276,15 @@
         pOutString = pFontCreate;
         v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
       }
-      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+      pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0),
         (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
       pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
       v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
       pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
     }
-    else if ( (signed int)uDialogueType > DIALOGUE_18 && !((signed int)uDialogueType > DIALOGUE_24 && uDialogueType != DIALOGUE_77 || byte_5B0938[0]) )
-    {
-      if ( (signed int)uDialogueType > DIALOGUE_24 && uDialogueType == DIALOGUE_77 )
-      {
-          v5 = 5 * pNPC->uProfession;
-          if ( byte_F8B1EC )
-          {
-            v6 = (char *)*(&pNPCStats->field_13A5C + 5 * pNPC->uProfession);
-            v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
-            pInString = v7;
-            pWindow.uFrameWidth = 460;
-            pWindow.uFrameZ = 452;
-            pOutString = pFontArrus;
-            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
-            if ( 352 - v12 < 8 )
-            {
-              pOutString = pFontCreate;
-              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
-            }
-            pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-                              (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-            pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
-            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
-          }
-          else if ( pNPC->uFlags & 0x80 )
-          {
-            v6 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession);
-            v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
-            pInString = v7;
-            pWindow.uFrameWidth = 460;
-            pWindow.uFrameZ = 452;
-            pOutString = pFontArrus;
-            v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
-            if ( 352 - v12 < 8 )
-            {
-              pOutString = pFontCreate;
-              v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
-            }
-            pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-                               (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-            pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-            v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
-            pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
-          }
-		  else
-		  {
-			v6 = (char *)*(&pNPCStats->field_13A64 + v5);
-			v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
-			pInString = v7;
-			pWindow.uFrameWidth = 460;
-			pWindow.uFrameZ = 452;
-			pOutString = pFontArrus;
-			v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
-			if ( 352 - v12 < 8 )
-			{
-			pOutString = pFontCreate;
-			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
-			}
-			pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-										(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
-			pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
-			v13 = FitTextInAWindow(pInString, pOutString,  &pWindow, 0xDu, 0);
-			pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
-		  }
-      }
-	  else
+    else if ( (signed int)uDialogueType > DIALOGUE_18 && !((signed int)uDialogueType > DIALOGUE_24 && uDialogueType != DIALOGUE_PROFESSION_DETAILS || byte_5B0938[0]) )
+    {
+	  if ((signed int)uDialogueType <= DIALOGUE_23)
 	  {
 		  v7 = (char *)ptr_F8B1E8;
 		  pInString = v7;
@@ -15287,7 +15297,7 @@
 			pOutString = pFontCreate;
 			v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
 		  }
-		  pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
+		  pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0),
 			(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
 		  pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
 		  v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
@@ -15326,10 +15336,10 @@
 		{
 			if ( *(int *)v54 == 2 )
 			{
-				if ( pNPC->uFlags & 0x80 )
-					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
+				if (pNPC->Hired())
+					v9 = pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
 				else
-					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
+					v9 = pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
 				pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
 				if (  pInString != NULL )
 				{
@@ -15342,8 +15352,8 @@
 						pOutString = pFontCreate;
 						v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7;
 					}
-					pRenderer->_4A6A68(8, 352 - v12, (Texture *)(uTextureID_Leather != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-					(uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - v12);
+                    if (uTextureID_Leather != -1)
+                      pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12);
 					pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428);
 					v13 = FitTextInAWindow(pInString, pOutString, &pWindow, 0xDu, 0);
 					pDialogueWindow->DrawText(pOutString, 13, 354 - v12, 0, v13, 0, 0, 0);
@@ -15371,24 +15381,24 @@
         v24 = "";
     }
 	else if ( v16 == 88 )
-		v24 = pGlobalTXT_LocalizationStrings[581];
+		v24 = pGlobalTXT_LocalizationStrings[581]; // Lord
     else if ( v16 == 87 )
-	    v24 = pGlobalTXT_LocalizationStrings[580];
+	    v24 = pGlobalTXT_LocalizationStrings[580]; // Knight
     else if ( v16 == 86 )
-	    v24 = pGlobalTXT_LocalizationStrings[579];
+	    v24 = pGlobalTXT_LocalizationStrings[579]; // Squire
     else if ( v16 == 85 )
-		v24 = pGlobalTXT_LocalizationStrings[578];
+		v24 = pGlobalTXT_LocalizationStrings[578]; // Page
     else if ( v16 == 77 )
-        v24 = pGlobalTXT_LocalizationStrings[407];
+        v24 = pGlobalTXT_LocalizationStrings[407]; // Details
     else if ( v16 == 76 )
     {
-		if ( pNPC->uFlags & 0x80 )
+		if (pNPC->Hired())
 		{
-			sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s
 			v24 = pTmpBuf;
 		}
 		else
-			v24 = pGlobalTXT_LocalizationStrings[406];
+			v24 = pGlobalTXT_LocalizationStrings[406]; // Hire
     }
 	else if ( v16 == 24 )
     {
@@ -15454,13 +15464,13 @@
 	}
 	else if ( v16 == 13 )
 	{
-		if ( pNPC->uFlags & 0x80 )
+		if (pNPC->Hired())
 		{
-			sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s
 			v24 = pTmpBuf;
 		}
 		else
-			v24 = pGlobalTXT_LocalizationStrings[122];
+			v24 = pGlobalTXT_LocalizationStrings[122]; // Join
 	}
 	else
 		v24 = "";
@@ -15661,7 +15671,7 @@
     {
       for (i = 0; i < pNPCStats->uNumNewNPCs; ++i)
       {
-        if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+        if (pNPCStats->pNewNPCData[i].Hired())
         {
           if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName))
           {
@@ -15747,7 +15757,7 @@
       v16 = &pTmpBuf[v6];
       do
       {
-        if ( v9->uFlags & 0x80
+        if ( v9->Hired()
           && (!pParty->pHirelings[0].pName || strcmp(v9->pName, pParty->pHirelings[0].pName))
           && (!pParty->pHirelings[1].pName || strcmp(v9->pName, pParty->pHirelings[1].pName)) )
         {
@@ -15813,7 +15823,7 @@
     v8 = pNPCStats->pNewNPCData;
     do
     {
-      if ( v8->uFlags & 0x80 && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) )
+      if (v8->Hired() && (!pParty->pHirelings[0].pName || strcmp(v8->pName, pParty->pHirelings[0].pName)) )
       {
         if ( !pParty->pHirelings[1].pName || strcmp(v8->pName, pParty->pHirelings[1].pName) )
           *v7++ = v1 + 2;
@@ -18931,7 +18941,7 @@
   for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i)
   {
     auto npc = pNPCStats->pNewNPCData + i;
-    if (npc->uFlags & 0x80 &&
+    if (npc->Hired() &&
         (!pParty->pHirelings[0].pName || strcmp(npc->pName, pParty->pHirelings[0].pName)))
     {
       if (!pParty->pHirelings[1].pName || strcmp(npc->pName, pParty->pHirelings[1].pName))