changeset 242:578b4a1e58ba

MonsterPopup remove goto
author zipi
date Sun, 17 Feb 2013 23:04:07 +0000
parents f305a0ece6ab
children a6a8fa73b4ec
files mm7_1.cpp
diffstat 1 files changed, 190 insertions(+), 171 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_1.cpp	Sun Feb 17 22:49:12 2013 +0000
+++ b/mm7_1.cpp	Sun Feb 17 23:04:07 2013 +0000
@@ -3043,99 +3043,101 @@
     {
       memset(&pDesc, 0, 0x7Cu);
       pDesc.dwSize = 124;
-      if ( !pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT))
-        goto LABEL_51;
-      v20 = (char *)v124;
-      v110 = pDesc.lpSurface;
-      a2 = (Player *)v124;
-      if ( v124 < v119 )
-      {
-        v111 = 2 * pRenderer->uTargetSurfacePitch;
-        v21 = (int)a4;
-        v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v23 = i - v124;
-        v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v115 = i - v124;
-        while ( 1 )
-        {
-          v124 = v21;
-          if ( v21 < (signed int)v116 )
-          {
-            v24 = (int)&v20[v23];
-            v25 = v107 - v21;
-            v109 = v24;
-            for ( i = v107 - v21; ; v25 = i )
-            {
-              v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight);
-              v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth;
-              *v22 = *((short *)v110 + (int)v26);
-              ++v22;
-              if ( v124 >= (signed int)v116 )
-                break;
-            }
-            v23 = v115;
-          }
-          v22 = (unsigned __int16 *)((char *)v120 + v111);
-          v20 = (char *)&a2->pConditions[0] + 1;
-          v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119);
-          v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0;
-          a2 = (Player *)((char *)a2 + 1);
-          v120 = (SpellBuff *)((char *)v120 + v111);
-          if ( !(v27 ^ v28) )
-            break;
-          v21 = (int)a4;
-        }
-      }
-      goto LABEL_37;
-    }
-    memset(&pDesc, 0, 0x7Cu);
-    pDesc.dwSize = 124;
-    if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) )
-    {
-      v108 = (unsigned __int16 *)pDesc.lpSurface;
-      a2 = (Player *)v124;
-      if ( v124 < v119 )
-      {
-        v109 = 2 * pRenderer->uTargetSurfacePitch;
-        v29 = (int)a4;
-        v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v31 = i - v124;
-        v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
-        v115 = i - v124;
-        while ( 1 )
-        {
-          v124 = v29;
-          if ( v29 < (signed int)v116 )
-          {
-            v32 = v107 - (int)a4;
-            v111 = (unsigned int)((char *)a2 + v31);
-            for ( i = v107 - (int)a4; ; v32 = i )
-            {
-              v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight);
-              v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)];
-              v34 = v33 & 0x1F | 2
-                               * (unsigned __int16)(v108[(int)((char *)v110
-                                                                + pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
-              v35 = v124;
-              *(short *)v30 = v34;
-              v30 += 2;
-              if ( v35 >= (signed int)v116 )
-                break;
-            }
-            v31 = v115;
-          }
-          a2 = (Player *)((char *)a2 + 1);
-          v30 = (char *)v120 + v109;
-          v120 = (SpellBuff *)((char *)v120 + v109);
-          if ( (signed int)a2 >= v119 )
-            break;
-          v29 = (int)a4;
-        }
-      }
-LABEL_37:
-      v222->Unlock(0);
-      goto LABEL_51;
-    }
+      if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT))
+	  {
+		  v20 = (char *)v124;
+		  v110 = pDesc.lpSurface;
+		  a2 = (Player *)v124;
+		  if ( v124 < v119 )
+		  {
+			v111 = 2 * pRenderer->uTargetSurfacePitch;
+			v21 = (int)a4;
+			v22 = &pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v23 = i - v124;
+			v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v115 = i - v124;
+			while ( 1 )
+			{
+			  v124 = v21;
+			  if ( v21 < (signed int)v116 )
+			  {
+				v24 = (int)&v20[v23];
+				v25 = v107 - v21;
+				v109 = v24;
+				for ( i = v107 - v21; ; v25 = i )
+				{
+				  v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight);
+				  v26 = (char *)v108 + pDesc.dwWidth * (v25 + v124++) / v13->uAreaWidth;
+				  *v22 = *((short *)v110 + (int)v26);
+				  ++v22;
+				  if ( v124 >= (signed int)v116 )
+					break;
+				}
+				v23 = v115;
+			  }
+			  v22 = (unsigned __int16 *)((char *)v120 + v111);
+			  v20 = (char *)&a2->pConditions[0] + 1;
+			  v28 = __OFSUB__((int)&a2->pConditions[0] + 1, v119);
+			  v27 = (signed int)((char *)&a2->pConditions[0] + -v119 + 1) < 0;
+			  a2 = (Player *)((char *)a2 + 1);
+			  v120 = (SpellBuff *)((char *)v120 + v111);
+			  if ( !(v27 ^ v28) )
+				break;
+			  v21 = (int)a4;
+			}
+		  }
+		  v222->Unlock(0);
+	  }
+    }
+	else
+	{
+		memset(&pDesc, 0, 0x7Cu);
+		pDesc.dwSize = 124;
+		if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) )
+		{
+		  v108 = (unsigned __int16 *)pDesc.lpSurface;
+		  a2 = (Player *)v124;
+		  if ( v124 < v119 )
+		  {
+			v109 = 2 * pRenderer->uTargetSurfacePitch;
+			v29 = (int)a4;
+			v30 = (char *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v31 = i - v124;
+			v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]];
+			v115 = i - v124;
+			while ( 1 )
+			{
+			  v124 = v29;
+			  if ( v29 < (signed int)v116 )
+			  {
+				v32 = v107 - (int)a4;
+				v111 = (unsigned int)((char *)a2 + v31);
+				for ( i = v107 - (int)a4; ; v32 = i )
+				{
+				  v110 = (LPVOID)((pDesc.lPitch >> 1) * pDesc.dwHeight * v111 / v13->uAreaHeight);
+				  v33 = v108[(int)((char *)v110 + pDesc.dwWidth * (v32 + v124) / v13->uAreaWidth)];
+				  v34 = v33 & 0x1F | 2
+								   * (unsigned __int16)(v108[(int)((char *)v110
+																	+ pDesc.dwWidth * (v32 + v124++) / v13->uAreaWidth)] & 0xFFE0);
+				  v35 = v124;
+				  *(short *)v30 = v34;
+				  v30 += 2;
+				  if ( v35 >= (signed int)v116 )
+					break;
+				}
+				v31 = v115;
+			  }
+			  a2 = (Player *)((char *)a2 + 1);
+			  v30 = (char *)v120 + v109;
+			  v120 = (SpellBuff *)((char *)v120 + v109);
+			  if ( (signed int)a2 >= v119 )
+				break;
+			  v29 = (int)a4;
+			}
+		  }
+		  v222->Unlock(0);
+		}
+	}
   }
   else
   {
@@ -3149,17 +3151,18 @@
     if ( v36 >= 0 )
       pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0);
   }
-LABEL_51:
   if ( v121->uNPC_ID )
   {
     v37 = v112[6];
     if ( v37 )
     {
       sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]);
-      goto LABEL_59;
-    }
-    v77 = 2000;
-    v72 = *v112;
+    }
+	else
+	{
+	  v77 = 2000;
+	  v72 = *v112;
+	}
   }
   else
   {
@@ -3170,8 +3173,8 @@
     else
       v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName;
   }
-  strncpy(pTmpBuf, v72, v77);
-LABEL_59:
+  if(!v121->uNPC_ID || (v121->uNPC_ID && !v37))
+    strncpy(pTmpBuf, v72, v77);
   v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u);
   Actor::DrawHealthBar(v121, a1);
@@ -3184,77 +3187,93 @@
   if ( !uActiveCharacter )
   {
     v45 = 1;
-    goto LABEL_84;
-  }
-  LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
-  v120 = v40;
-  if ( !v40 )
-    goto LABEL_72;
-  v41 = (unsigned __int8)v40 & 0x3F;
-  v42 = SkillToMastery((unsigned __int16)v40) - 1;
-  if ( !v42 )
-  {
-    if ( v41 + 10 >= v121->pMonsterInfo.uLevel )
-    {
-      v45 = 1;
-      v119 = 1;
-      goto LABEL_73;
-    }
-    goto LABEL_72;
-  }
-  v43 = v42 - 1;
-  if ( !v43 )
-  {
-    if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel )
-    {
-      v45 = 1;
-      v119 = 1;
-      v116 = 1;
-      goto LABEL_73;
-    }
-    goto LABEL_72;
-  }
-  v44 = v43 - 1;
-  if ( !v44 )
-  {
-    if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel )
-    {
-      v45 = 1;
-      v119 = 1;
-      v116 = 1;
-      i = 1;
-      goto LABEL_73;
-    }
-LABEL_72:
-    v45 = 1;
-    goto LABEL_73;
-  }
-  if ( v44 != 1 )
-    goto LABEL_72;
-  v45 = 1;
-  v119 = 1;
-  v116 = 1;
-  i = 1;
-  v112 = (char **)1;
-LABEL_73:
-  v46 = v121->uAIState;
-  if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 )
-  {
-    v47 = pPlayers[uActiveCharacter];
-    if ( v119 | v116 | i | (unsigned int)v112 )
-    {
-      if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 )
-        v73 = SPEECH_105;
-      else
-        v73 = SPEECH_104;
-    }
-    else
-    {
-      v73 = SPEECH_106;
-    }
-    v47->PlaySound((PlayerSpeech)v73, 0);
-  }
-LABEL_84:
+  }
+  else
+  {
+	  LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID);
+	  v120 = v40;
+	  if ( !v40 )
+					v45 = 1;
+	  else
+	  {
+		  v41 = (unsigned __int8)v40 & 0x3F;
+		  v42 = SkillToMastery((unsigned __int16)v40) - 1;
+		  if ( !v42 )
+		  {
+			if ( v41 + 10 >= v121->pMonsterInfo.uLevel )
+			{
+			  v45 = 1;
+			  v119 = 1;
+			}
+			else
+						v45 = 1;
+		  }
+		  else
+		  {
+			  v43 = v42 - 1;
+			  if ( !v43 )
+			  {
+				if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel )
+				{
+				  v45 = 1;
+				  v119 = 1;
+				  v116 = 1;
+				}
+				else
+						v45 = 1;
+			  }
+			  else
+			  {
+				  v44 = v43 - 1;
+				  if ( !v44 )
+				  {
+					if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel )
+					{
+					  v45 = 1;
+					  v119 = 1;
+					  v116 = 1;
+					  i = 1;
+					}
+					else
+					{
+						v45 = 1;
+					}
+				  }
+				  else
+				  {
+					  if ( v44 != 1 )
+						v45 = 1;
+					  else
+					  {
+						  v45 = 1;
+						  v119 = 1;
+						  v116 = 1;
+						  i = 1;
+						  v112 = (char **)1;
+					  }
+				  }
+			  }
+		  }
+	  }
+	  //	LABEL_73:
+	  v46 = v121->uAIState;
+	  if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 )
+	  {
+		v47 = pPlayers[uActiveCharacter];
+		if ( v119 | v116 | i | (unsigned int)v112 )
+		{
+		  if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 )
+			v73 = SPEECH_105;
+		  else
+			v73 = SPEECH_104;
+		}
+		else
+		{
+		  v73 = SPEECH_106;
+		}
+		v47->PlaySound((PlayerSpeech)v73, 0);
+	  }
+  }
   a2 = pParty->pPlayers;
   do
   {