changeset 202:037726ac5999

DrawDialogueUI cleaned from goto
author zipi@zipi-PC
date Sat, 16 Feb 2013 22:52:39 +0100
parents 30aa44013f7a
children 335db7429f7c
files mm7_3.cpp
diffstat 1 files changed, 215 insertions(+), 238 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_3.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/mm7_3.cpp	Sat Feb 16 22:52:39 2013 +0100
@@ -16424,19 +16424,8 @@
   GUIButton *v14; // eax@43
   GUIButton *v15; // edi@43
   signed int v16; // eax@44
-  int v17; // eax@46
-  int v18; // eax@47
-  int v19; // eax@48
-  int v20; // eax@49
-  int v21; // eax@50
-  int v22; // eax@51
   unsigned int v23; // eax@53
   const char *v24; // eax@59
-  int v25; // eax@65
-  int v26; // eax@66
-  int v27; // eax@67
-  int v28; // eax@68
-  int v29; // eax@69
   unsigned __int16 v30; // cx@83
   int v31; // ecx@86
   int v32; // ebx@93
@@ -16478,8 +16467,8 @@
   GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0));
-  pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
+  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 )
   {
@@ -16509,9 +16498,8 @@
       pRenderer->DrawTextureIndexed(8, 347 - v12, pTexture_591428);
       v13 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[577], pFontArrus, &pWindow, 0xDu, 0);
       pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == DIALOGUE_ARENA_REWARD )
+    }
+    else if ( uDialogueType == DIALOGUE_ARENA_REWARD )
     {
       sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
       pInString = v4;
@@ -16529,9 +16517,8 @@
       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);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == DIALOGUE_ARENA_ALREADY_WON )
+    }
+    else if ( uDialogueType == DIALOGUE_ARENA_ALREADY_WON )
     {
       pInString = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:"
       pWindow.uFrameWidth = 460;
@@ -16548,7 +16535,6 @@
       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);
-      goto LABEL_42;
     }
   }
   else
@@ -16571,9 +16557,8 @@
       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);
-      goto LABEL_42;
-    }
-    if ( uDialogueType == DIALOGUE_13 )
+    }
+    else if ( uDialogueType == DIALOGUE_13 )
     {
       v5 = 5 * pNPC->uProfession;
       v6 = (char *)*(&pNPCStats->field_13A64 + v5);
@@ -16593,14 +16578,11 @@
       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);
-      goto LABEL_42;
-    }
-    if ( (signed int)uDialogueType > DIALOGUE_18 )
-    {
-      if ( (signed int)uDialogueType > DIALOGUE_24 )
-      {
-        if ( uDialogueType == DIALOGUE_77 )
-        {
+    }
+    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 )
           {
@@ -16621,9 +16603,8 @@
             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);
-            goto LABEL_42;
-          }
-          if ( pNPC->uFlags & 0x80 )
+          }
+          else if ( pNPC->uFlags & 0x80 )
           {
             v6 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession);
             v7 = sub_495461(v6, uActiveCharacter - 1, 0, 0, 0, 0);
@@ -16642,92 +16623,106 @@
             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);
-            goto LABEL_42;
-          }
-          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);
-          goto LABEL_42;
-        }
-        goto LABEL_24;
-      }
-      if ( byte_5B0938[0] )
-        goto LABEL_24;
-      v7 = (char *)ptr_F8B1E8;
-      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);
-      goto LABEL_42;
-    }
-  }
-LABEL_24:
-  if ( *(int *)v54 == 1 )
-  {
-    v11 = pNPC->greet;
-    v8 = 0;
-    if ( v11 )
-    {
-      v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11);
-      goto LABEL_32;
-    }
-  }
-  else
-  {
-    if ( *(int *)v54 == 2 )
-    {
-      if ( pNPC->uFlags & 0x80 )
-        v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
-      else
-        v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
-       pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
-LABEL_32:
-
-      if (  pInString == NULL )
-        goto LABEL_42;
-      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);
-      goto LABEL_42;
-    }
-  }
-LABEL_42:
+          }
+		  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
+	  {
+		  v7 = (char *)ptr_F8B1E8;
+		  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 ( *(int *)v54 == 1 )
+		{
+			v11 = pNPC->greet;
+			v8 = 0;
+			if ( v11 )
+			{
+				v10 = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * v11);
+				if (  pInString != NULL )
+				{
+					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 ( *(int *)v54 == 2 )
+			{
+				if ( pNPC->uFlags & 0x80 )
+					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText;
+				else
+					v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed"
+				pInString = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0);
+				if (  pInString != NULL )
+				{
+					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);
+				}
+			}
+		}
+	}
+  }
   memcpy(&v52, pDialogueWindow, sizeof(v52));
   v52.uFrameX = 483;
   v52.uFrameWidth = 148;
@@ -16741,125 +16736,107 @@
     if ( !v14 )
       break;
     v16 = v14->uControlParam;
-    if ( v16 > 24 )
-    {
-      v25 = v16 - 76;
-      if ( v25 )
-      {
-        v26 = v25 - 1;
-        if ( v26 )
-        {
-          v27 = v26 - 8;
-          if ( v27 )
-          {
-            v28 = v27 - 1;
-            if ( v28 )
-            {
-              v29 = v28 - 1;
-              if ( v29 )
-              {
-                if ( v29 != 1 )
-                {
-                  v24 = "";
-                  goto LABEL_79;
-                }
-                v24 = pGlobalTXT_LocalizationStrings[581];
-              }
-              else
-              {
-                v24 = pGlobalTXT_LocalizationStrings[580];
-              }
-            }
-            else
-            {
-              v24 = pGlobalTXT_LocalizationStrings[579];
-            }
-          }
-          else
-          {
-            v24 = pGlobalTXT_LocalizationStrings[578];
-          }
-        }
-        else
-        {
-          v24 = pGlobalTXT_LocalizationStrings[407];
-        }
-      }
-      else
-      {
-        if ( pNPC->uFlags & 0x80 )
-        {
-          sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName);
-          v24 = pTmpBuf;
-          goto LABEL_79;
-        }
-        v24 = pGlobalTXT_LocalizationStrings[406];
-      }
-    }
-    else
-    {
-      if ( v16 == 24 )
-      {
-        v23 = pNPC->evtf;
-LABEL_63:
-        v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
-        if ( !v24 )
-        {
-          v24 = "";
-          v15->uControlParam = 0;
-        }
-        goto LABEL_79;
-      }
-      v17 = v16 - 9;
-      if ( !v17 )
-      {
-        v24 = (const char *)sub_445308(pNPC->uProfession);
-        goto LABEL_79;
-      }
-      v18 = v17 - 4;
-      if ( v18 )
-      {
-        v19 = v18 - 6;
-        if ( !v19 )
-        {
-          v23 = pNPC->bDrawSomeAnim;
-          goto LABEL_63;
-        }
-        v20 = v19 - 1;
-        if ( !v20 )
-        {
-          v23 = pNPC->_anim_current_time;
-          goto LABEL_63;
-        }
-        v21 = v20 - 1;
-        if ( !v21 )
-        {
-          v23 = pNPC->_anim_end_time;
-          goto LABEL_63;
-        }
-        v22 = v21 - 1;
-        if ( !v22 )
-        {
-          v23 = pNPC->evtd;
-          goto LABEL_63;
-        }
-        if ( v22 == 1 )
-        {
-          v23 = pNPC->evte;
-          goto LABEL_63;
-        }
+
+    if ( v16 > 88 )
+    {
         v24 = "";
-        goto LABEL_79;
-      }
-      if ( pNPC->uFlags & 0x80 )
-      {
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
-        v24 = pTmpBuf;
-        goto LABEL_79;
-      }
-      v24 = pGlobalTXT_LocalizationStrings[122];
-    }
-LABEL_79:
+    }
+	else if ( v16 == 88 )
+		v24 = pGlobalTXT_LocalizationStrings[581];
+    else if ( v16 == 87 )
+	    v24 = pGlobalTXT_LocalizationStrings[580];
+    else if ( v16 == 86 )
+	    v24 = pGlobalTXT_LocalizationStrings[579];
+    else if ( v16 == 85 )
+		v24 = pGlobalTXT_LocalizationStrings[578];
+    else if ( v16 == 77 )
+        v24 = pGlobalTXT_LocalizationStrings[407];
+    else if ( v16 == 76 )
+    {
+		if ( pNPC->uFlags & 0x80 )
+		{
+			sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			v24 = pTmpBuf;
+		}
+		else
+			v24 = pGlobalTXT_LocalizationStrings[406];
+    }
+	else if ( v16 == 24 )
+    {
+		v23 = pNPC->evtf;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+    }
+	else if ( v16 == 9 )
+		v24 = (const char *)sub_445308(pNPC->uProfession);
+	else if ( v16 == 19 )
+	{
+		v23 = pNPC->bDrawSomeAnim;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 20 )
+	{
+		v23 = pNPC->_anim_current_time;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 21 )
+	{
+		v23 = pNPC->_anim_end_time;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 22 )
+	{
+		v23 = pNPC->evtd;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 23 )
+	{
+		v23 = pNPC->evte;
+		v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23];
+		if ( !v24 )
+		{
+			v24 = "";
+			v15->uControlParam = 0;
+		}
+	}
+	else if ( v16 == 13 )
+	{
+		if ( pNPC->uFlags & 0x80 )
+		{
+			sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName);
+			v24 = pTmpBuf;
+		}
+		else
+			v24 = pGlobalTXT_LocalizationStrings[122];
+	}
+	else
+		v24 = "";
+	
+
     if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 )
     {
       pInString = 0;