diff mm7_2.cpp @ 1416:b69805ffeb4b

mm7_2.cpp cleaning
author zipi
date Sun, 28 Jul 2013 16:34:52 +0100
parents ff495bf260d9
children 1dd0c79e1502
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Jul 27 22:21:09 2013 +0200
+++ b/mm7_2.cpp	Sun Jul 28 16:34:52 2013 +0100
@@ -481,28 +481,28 @@
   if ( uDialogueType == 85 )
   {
     num_monsters = v4;
-    goto LABEL_22;
-  }
-  if ( uDialogueType == 86 )
+    v4 /= 2;
+  }
+  else if ( uDialogueType == 86 )
   {
     v5 = (signed __int64)((double)v26 * 1.5);
-    goto LABEL_20;
-  }
-  if ( uDialogueType == 87 )
+    num_monsters = v5;
+    v4 /= 2;
+  }
+  else if ( uDialogueType == 87 )
   {
     LODWORD(v5) = 2 * v4;
-LABEL_20:
     num_monsters = v5;
-LABEL_22:
     v4 /= 2;
-    goto LABEL_24;
-  }
-  __debugbreak(); // warning C4700: uninitialized local variable 'v27' used
-  if ( uDialogueType == 88 )
-    num_monsters = 2 * v4;
+  }
   else
-    v4 = v27;
-LABEL_24:
+  {
+    __debugbreak(); // warning C4700: uninitialized local variable 'v27' used
+    if ( uDialogueType == 88 )
+      num_monsters = 2 * v4;
+    else
+      v4 = v27;
+  }
   if ( v4 < 1 )
     v4 = 1;
   if ( v4 > 100 )
@@ -555,20 +555,20 @@
     v16 = rand();
     v17 = 3;
     v22 = 50;
-    goto LABEL_53;
-  }
-  if ( uDialogueType == 86 )
+    v18 = v16 % v17;
+    v13 = v22;
+    v14 = v18 + 6;
+  }
+  else if ( uDialogueType == 86 )
   {
     v16 = rand();
     v17 = 7;
     v22 = 100;
-LABEL_53:
     v18 = v16 % v17;
     v13 = v22;
     v14 = v18 + 6;
-    goto LABEL_55;
-  }
-  if ( uDialogueType == 87 )
+  }
+  else if ( uDialogueType == 87 )
   {
     v15 = rand() % 11;
     v13 = 200;
@@ -587,7 +587,6 @@
       v13 = gold_transaction_amount;
     }
   }
-LABEL_55:
   i = 0;
   for ( gold_transaction_amount = v26 * v13; i < v14; ++i )
   {
@@ -631,7 +630,6 @@
       if ( v0 == -1 )
       {
         _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1));
-//LABEL_33:
         pVideoPlayer->_4BF5B2();
         return 1;
       }
@@ -648,7 +646,6 @@
           if ( v0 != 102 && v0 != 103 && v0 != 104 )
           {
             pVideoPlayer->_4BF5B2();
-//LABEL_28:
             dialog_menu_id = HOUSE_DIALOGUE_MAIN;
             InitializaDialogueOptions(in_current_building_type);
             return 1;
@@ -870,27 +867,21 @@
     /*if ( (signed int)result < 40 )
     {
       pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit;
-      goto LABEL_42;
     }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0);
-    goto LABEL_43;
   }
   else
   {
     pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0);
-    goto LABEL_43;
     /*if ( (signed int)result < 40 )
     {
       pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5;
-LABEL_42:
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
       result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
       *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
-      goto LABEL_43;
     }*/
   }
-LABEL_43:
   bGameoverLoop = 0;
   return result;
 }
@@ -1105,19 +1096,25 @@
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v12 = v10 % (v11 - v9 + 1);
         v13 = pMapInfo->Dif_M1;
-        goto LABEL_20;
+        v57 = v13;
+        v56 = v9 + v12;
+        strcpy(Source, pTexture);
+        break;
     case 3u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s A";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 4u:
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s A";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 5u:
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s A";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 1u:
         v9 = pMapInfo->uEncounterMonster2AtLeast;
         v14 = rand();
@@ -1125,19 +1122,25 @@
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v12 = v14 % (v15 - v9 + 1);
         v13 = pMapInfo->Dif_M2;
-        goto LABEL_20;
+        v57 = v13;
+        v56 = v9 + v12;
+        strcpy(Source, pTexture);
+        break;
     case 6u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s B";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 7u:
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s B";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 8u:
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s B";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 2u:
         v9 = pMapInfo->uEncounterMonster3AtLeast;
         v16 = rand();
@@ -1145,50 +1148,49 @@
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v12 = v16 % (v17 - v9 + 1);
         v13 = pMapInfo->Dif_M3;
-LABEL_20:
         v57 = v13;
         v56 = v9 + v12;
         strcpy(Source, pTexture);
-        goto LABEL_26;
+        break;
     case 9u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s C";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 0xAu:
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s C";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 0xBu:
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s C";
-LABEL_25:
         sprintf(Source, v44, pTexture);
-LABEL_26:
-        if (Source[0] == '0')
-          return;
-        v57 += a3;
-        if ( v57 > 4 )
-          v57 = 4;
-        strcpy(Str2, Source);
-        if ( a4 )
-          v56 = a4;
-        v18 = v56;
-        if ( (signed int)(v56 + uNumActors) >= 500 )
-          return;
-        pSector = 0;
-        pPosX = spawn->vPosition.x;
-        a4 = spawn->vPosition.y;
-        a3 = spawn->vPosition.z;
-        if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-          pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
-        v53 = 0;
-        v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
-        if ( v18 <= 0 )
-          return;
         break;
       default:
         return;
   }
+    if (Source[0] == '0')
+        return;
+    v57 += a3;
+    if ( v57 > 4 )
+        v57 = 4;
+    strcpy(Str2, Source);
+    if ( a4 )
+        v56 = a4;
+    v18 = v56;
+    if ( (signed int)(v56 + uNumActors) >= 500 )
+        return;
+    pSector = 0;
+    pPosX = spawn->vPosition.x;
+    a4 = spawn->vPosition.y;
+    a3 = spawn->vPosition.z;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+        pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
+    v53 = 0;
+    v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
+    if ( v18 <= 0 )
+        return;
   for (uint i = v53; i < v56; ++i)
   {
       pMonster = &pActors[uNumActors];
@@ -1222,7 +1224,7 @@
           else
           {
             if ( v24 != 3 )
-              goto LABEL_58;
+              continue;
             pTexture = Source;
             v44 = "%s C";
           }
@@ -1275,7 +1277,12 @@
       v36 = spawn->vPosition.z;
       a3 = spawn->vPosition.z;
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
-        goto LABEL_55;
+	  {
+        if ( a5 )
+            pMonster->uAttributes |= 0x080000;
+        ++uNumActors;
+        continue;
+	  }
       v37 = pIndoor->GetSector(pPosX, a4, v36);
       if ( v37 == pSector )
       {
@@ -1286,15 +1293,13 @@
           if ( abs(v38 - a3) <= 1024 )
           {
             a3 = v39;
-LABEL_55:
             if ( a5 )
               pMonster->uAttributes |= 0x080000;
             ++uNumActors;
-            goto LABEL_58;
+            continue;
           }
         }
       }
-LABEL_58:
       ;
       //v53 = (char *)v53 + 1;
       //result = v53;
@@ -1537,19 +1542,20 @@
               v14 = rand() % 3001 + 2000;
             }
             a1a.stru_24.uItemID = 199;
-LABEL_19:
             v34 = v14;
             goto LABEL_20;
           }
           v14 = rand() % 501 + 500;
         }
         a1a.stru_24.uItemID = 198;
-        goto LABEL_19;
+        v34 = v14;
+        goto LABEL_20;
       }
       v14 = rand() % 101 + 100;
     }
     a1a.stru_24.uItemID = 197;
-    goto LABEL_19;
+    v34 = v14;
+    goto LABEL_20;
   }
   result = a1a.stru_24.GenerateArtifact();
   if ( !result )
@@ -1734,22 +1740,16 @@
                           &v27,
                           0);
       v23 = 0;
-      if ( (signed int)pOutdoor->uNumBModels > 0 )
-      {
-        while ( 1 )
-        {
-          v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y);
-          v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x);
-          if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 )
-            break;
-          ++v23;
-          ++v8;
-          if ( v23 >= (signed int)pOutdoor->uNumBModels )
-            goto LABEL_16;
-        }
-        v22 = 1;
-      }
-LABEL_16:
+	  for( int i = 0; i < pOutdoor->uNumBModels; i++ )
+	  {
+		v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y);
+		v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x);
+		if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 )
+		{
+		  v22 = 1;
+		  break;
+		}
+	  }
       v11 = uFaceID == 100;
       if ( uFaceID >= 100 )
         break;
@@ -1797,7 +1797,6 @@
   }
   if ( v11 )
   {
-LABEL_8:
     result = 0;
   }
   else
@@ -2947,34 +2946,43 @@
                 if ( a1 < 78 )
                 {
                   if ( a1 < 89 )
-                    goto LABEL_31;
-                  goto LABEL_28;
+				  {
+					v4 = 0;
+					v1 = 0;
+					v2 = 0;
+					return TargetColor(v2, v1, v4);
+				  }
                 }
+				else
+				{
 LABEL_25:
-                if ( a1 < 89 )
-                {
-                  v4 = 155;
-                  v2 = 255;
-                  goto LABEL_30;
-                }
-LABEL_28:
+					if ( a1 < 89 )
+					{
+					  v4 = 155;
+					  v2 = 255;
+					  v1 = v2;
+					  return TargetColor(v2, v1, v4);
+					}
+				}
                 if ( a1 < 100 )
                 {
                   v4 = 240;
                   v2 = 192;
-                  goto LABEL_30;
+				  v1 = v2;
+				  return TargetColor(v2, v1, v4);
                 }
-LABEL_31:
                 v4 = 0;
                 v1 = 0;
-                goto LABEL_32;
+				v2 = 0;
+				return TargetColor(v2, v1, v4);
               }
 LABEL_21:
               if ( a1 < 78 )
               {
                 v4 = 0;
                 v1 = 128;
-                goto LABEL_23;
+			    v2 = 255;
+			    return TargetColor(v2, v1, v4);
               }
               goto LABEL_25;
             }
@@ -2992,7 +3000,9 @@
           if ( a1 < 56 )
           {
             v2 = 225;
-            goto LABEL_13;
+            v4 = v2;
+            v1 = v2;
+            return TargetColor(v2, v1, v4);
           }
           goto LABEL_18;
         }
@@ -3000,9 +3010,7 @@
         if ( a1 < 45 )
         {
           v2 = 128;
-LABEL_13:
           v4 = v2;
-LABEL_30:
           v1 = v2;
           return TargetColor(v2, v1, v4);
         }
@@ -3013,7 +3021,6 @@
       {
         v4 = 255;
         v1 = 128;
-LABEL_32:
         v2 = 0;
         return TargetColor(v2, v1, v4);
       }
@@ -3026,7 +3033,6 @@
     {
       v4 = 0;
       v1 = 85;
-LABEL_23:
       v2 = 255;
       return TargetColor(v2, v1, v4);
     }
@@ -3117,9 +3123,9 @@
       {
         if ( v4 != 1 )
         {
-          if ( v4 != 0 || pActor->sNPC_ID )
-            continue;
-          goto LABEL_12;
+          if ( v4 == 0 && pActor->sNPC_ID == 0 )
+			pActor->sNPC_ID = 0;
+		  continue;
         }
       }
       if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 )
@@ -3132,9 +3138,7 @@
         pActor->sNPC_ID = v14;
         continue;
       }
-LABEL_12:
       pActor->sNPC_ID = 0;
-//LABEL_13:
       //++v15;
       //v2 += 836;
     //}
@@ -4032,14 +4036,12 @@
       else
       {
         if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() )
-          //goto LABEL_20;
         {
           EndPaint(hWnd, &Paint);
           return 0;
         }
       }
       pRenderer->Present();
-//LABEL_20:
       EndPaint(hWnd, &Paint);
       return 0;
     }
@@ -4324,25 +4326,27 @@
     || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
     || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
     || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
-    goto LABEL_7;
-  if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
+  {
+    result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
+  }
+  else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
   {
     RegCloseKey(v14);
     v14 = 0;
-LABEL_7:
     result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
-    goto LABEL_8;
-  }
-  v4 = RegCloseKey;
-  RegCloseKey(v14);
-  v14 = 0;
-  RegCloseKey(v13);
-  v13 = 0;
-  RegCloseKey(phkResult);
-  phkResult = 0;
-  result = RegCloseKey(hKey);
-  hKey = 0;
-LABEL_8:
+  }
+  else
+  {
+	v4 = RegCloseKey;
+	RegCloseKey(v14);
+	v14 = 0;
+	RegCloseKey(v13);
+	v13 = 0;
+	RegCloseKey(phkResult);
+	phkResult = 0;
+	result = RegCloseKey(hKey);
+	hKey = 0;
+  }
   if ( v14 )
     result = v4(v14);
   if ( v13 )
@@ -4503,7 +4507,6 @@
     if ( a3 == 2 )
     {
       v12 = 0;
-LABEL_9:
       EndDialog(hDlg, v12);
       return 1;
     }
@@ -4516,7 +4519,8 @@
   if ( v4 )
   {
     v12 = 1;
-    goto LABEL_9;
+    EndDialog(hDlg, v12);
+    return 1;
   }
   return 0;
 }
@@ -5424,7 +5428,6 @@
     {
       MainMenu_Loop();
       uGameState = GAME_STATE_PLAYING;
-//LABEL_21:
       while ( 1 )
       {
         if (uGameState == GAME_FINISHED ||
@@ -5480,30 +5483,29 @@
         if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
         {
           uGameState = GAME_STATE_PLAYING;
+		  pGame->Loop();
         }
         else
         {
-          if (GetCurrentMenuID() != MENU_10)
-            goto LABEL_49;
-          pMouse->Activate(0);
-
-          pParty->Reset();
-          pParty->CreateDefaultParty(1);
-          crt_init_globals_46271C();
-          extern OPENFILENAMEA ofn;
-          if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
-          {
-            pMouse->Activate(1);
-
-            break;
-          }
-          _chdir("..\\");
-          strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle);
-          pMouse->Activate(1);
+          if (GetCurrentMenuID() == MENU_10)
+		  {
+			  pMouse->Activate(0);
+
+			  pParty->Reset();
+			  pParty->CreateDefaultParty(1);
+			  crt_init_globals_46271C();
+			  extern OPENFILENAMEA ofn;
+			  if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
+			  {
+				pMouse->Activate(1);
+				break;
+			  }
+			  _chdir("..\\");
+			  strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle);
+			  pMouse->Activate(1);
+			  pGame->Loop();
+		  }
         }
-//LABEL_48:
-        pGame->Loop();
-LABEL_49:
         if ( uGameState == GAME_STATE_LOADING_GAME )
         {
           SetCurrentMenuID(MENU_5);
@@ -6091,13 +6093,13 @@
   v29 = 640 * v3;
   while ( 2 )
   {
-    v31 = 100;
-    v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2];
+    v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]-1;
     v7 = v0;
-    while ( 1 )
-    {
+    //while ( 1 )
+    for( int i = 0; i < 100; i++)
+	{
+	  ++v6;
       v8 = *v6;
-      --v31;
       if ( (unsigned int)*v6 <= 0x2000000 )
       {
         v9 = 0;
@@ -6130,17 +6132,13 @@
           }
         }
       }
-      if ( !v31 )
-        break;
-      ++v6;
-    }
+     }
     v4 = -1;
     ++v30;
     v5 = v29 + 640;
     v29 += 640;
-    if ( v30 < v28 )
-      continue;
-    break;
+    if ( v30 >= v28 )
+      break;
   }
   v12 = 0;
   v10 = v0 == 0;
@@ -6183,45 +6181,51 @@
       if ( !(pSpriteObjects[v20].uAttributes & 0x10) )
       {
         v23 = pSpriteObjects[v20].stru_24.GetDisplayName();
-LABEL_36:
         v24 = v23;
-        goto LABEL_51;
-      }
-      goto LABEL_41;
-    }
-    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor)
-    {
-      if ( v20 >= 0xBB8 )
-        return 0;
-      v24 = (const char *)&pActors[v20];
-      goto LABEL_51;
-    }
-    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration)
-      break;
-    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel)
-    {
-      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      {
-        v21 = &pIndoor->pFaces[v20];
-        if ( !(BYTE3(v21->uAttributes) & 2) )
-          goto LABEL_41;
-        v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID;
-      }
-      else
-      {
-        if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels )
-          goto LABEL_41;
-        v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID;
-      }
-      if ( v22 )
-      {
-        v23 = GetEventHintString(v22);
-        if ( v23 )
-          goto LABEL_36;
+	    GameUI_SetFooterString(v24);
+	    return v19;
       }
     }
-LABEL_41:
-    ++v18;
+    else
+	{
+		if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor)
+		{
+		  if ( v20 >= 0xBB8 )
+			return 0;
+		  v24 = (const char *)&pActors[v20];
+		  GameUI_SetFooterString(v24);
+		  return v19;
+		}
+		if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration)
+		  break;
+		if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel)
+		{
+		  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+		  {
+			v21 = &pIndoor->pFaces[v20];
+			if ( BYTE3(v21->uAttributes) & 2 )
+				v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID;
+		  }
+		  else
+		  {
+			if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 < pOutdoor->uNumBModels )
+			{
+				v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID;
+				if ( v22 )
+				{
+					v23 = GetEventHintString(v22);
+					if ( v23 )
+					{
+						v24 = v23;
+						GameUI_SetFooterString(v24);
+						return v19;
+					}
+				}
+			}
+		  }
+		}
+	}
+	++v18;
     if ( v18 >= v0 )
       return 0;
   }
@@ -6233,13 +6237,14 @@
     v23 = GetEventHintString(v27);
     if ( !v23 )
       return v19;
-    goto LABEL_36;
+	v24 = v23;
+	GameUI_SetFooterString(v24);
+	return v19;
   }
   if ( v25->IsInteractive() )
     v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic;
   else
     v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20;
-LABEL_51:
   GameUI_SetFooterString(v24);
   return v19;
 }
@@ -6515,8 +6520,11 @@
         if ( v151 != OBJECT_Actor)
         {
           if ( v6 != 9030 || v2->spell_skill != 4 )
-            goto LABEL_246;
-          v2->_46BEF1_apply_spells_aoe();
+		  {
+			  SpriteObject::OnInteraction(v153);
+			  return 0;
+		  }
+		  v2->_46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
           {
@@ -6562,9 +6570,10 @@
             v127 = 0;
             v126 = v115;
             v116 = v143;
-            goto LABEL_269;
+            v125 = v116 + 1;
+			pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+			return 0;
           }
-LABEL_246:
           SpriteObject::OnInteraction(v153);
           return 0;
         }
@@ -6659,7 +6668,24 @@
             if ( v52 >= (signed int)v93 )
               goto LABEL_181;
           }
-          goto LABEL_202;
+		  v95 = v52;
+			v2->uObjectDescID = v95;
+			if ( v95 == (short)v9 )
+				SpriteObject::OnInteraction(v153);
+			v96 = v2->uSoundID;
+			v2->vVelocity.z = v9;
+			v2->vVelocity.y = v9;
+			v2->vVelocity.x = v9;
+			v2->uSpriteFrameID = v9;
+			if ( v96 == (short)v9 )
+				v97 = 0;
+			else
+				v97 = (signed __int16)v96 + 4;
+			v133 = v9;
+			v131 = v9;
+			v130 = v97;
+			v92 = v153;
+			goto LABEL_267;
         }
         goto LABEL_181;
       }
@@ -6736,11 +6762,10 @@
             LOBYTE(v124) = v124 | 2;
             v127 = v9;
             v126 = v124;
-LABEL_268:
             v116 = word_4EE088_sound_ids[v2->spell_id - 1];
-LABEL_269:
             v125 = v116 + 1;
-            goto LABEL_29;
+			pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+			return 0;
           }
           v59 = v6 + 2;
           v60 = pObjectList->uNumObjects;
@@ -6847,7 +6872,10 @@
         v128 = -1;
         v127 = v66;
         v126 = v75;
-        goto LABEL_268;
+        v116 = word_4EE088_sound_ids[v2->spell_id - 1];
+        v125 = v116 + 1;
+		pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+		return 0;
       }
       if ( v7 == 4090 )
       {
@@ -7053,7 +7081,20 @@
       v2->vVelocity.x = 0;
       v2->uSpriteFrameID = 0;
       if ( !v44 )
-        goto LABEL_27;
+	  {
+		  v133 = v9;
+		  v131 = v9;
+		  v130 = v9;
+		  v13 = 8 * v153;
+		  v129 = v9;
+		  v128 = -1;
+		  LOBYTE(v13) = PID(OBJECT_Item,v153);
+		  v127 = v9;
+		  v126 = v13;
+		  v125 = 8;
+		  pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+		  return 0;
+	  }
     }
     return 0;
   }
@@ -7090,11 +7131,13 @@
         if ( v52 >= (signed int)v51 )
           goto LABEL_181;
       }
-      goto LABEL_202;
+      v95 = v52;
     }
+	else
+	{
 LABEL_181:
     v95 = 0;
-LABEL_182:
+	}
     v2->uObjectDescID = v95;
     if ( v95 == (short)v9 )
       SpriteObject::OnInteraction(v153);
@@ -7163,7 +7206,9 @@
     v128 = -1;
     v127 = 0;
     v126 = v147;
-    goto LABEL_28;
+	v125 = 8;
+	pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+	return 0;
   }
   v27 = v26 - 410;
   if ( !v27 )
@@ -7230,7 +7275,10 @@
         v128 = -1;
         v127 = v32;
         v126 = v149;
-        goto LABEL_268;
+        v116 = word_4EE088_sound_ids[v2->spell_id - 1];
+        v125 = v116 + 1;
+		pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+		return 0;
       }
       goto LABEL_195;
     }
@@ -7255,9 +7303,24 @@
         if ( v52 >= (signed int)v122 )
           goto LABEL_181;
       }
-LABEL_202:
       v95 = v52;
-      goto LABEL_182;
+		v2->uObjectDescID = v95;
+		if ( v95 == (short)v9 )
+			SpriteObject::OnInteraction(v153);
+		v96 = v2->uSoundID;
+		v2->vVelocity.z = v9;
+		v2->vVelocity.y = v9;
+		v2->vVelocity.x = v9;
+		v2->uSpriteFrameID = v9;
+		if ( v96 == (short)v9 )
+			v97 = 0;
+		else
+			v97 = (signed __int16)v96 + 4;
+		v133 = v9;
+		v131 = v9;
+		v130 = v97;
+		v92 = v153;
+		goto LABEL_267;
     }
     goto LABEL_181;
   }
@@ -7269,7 +7332,6 @@
   v2->uType = v117;
   if ( v20 | v44 )
   {
-LABEL_255:
     v121 = 0;
   }
   else
@@ -7280,7 +7342,28 @@
       ++v119;
       v120 += 56;
       if ( v119 >= (signed int)v118 )
-        goto LABEL_255;
+	  {
+		  v121 = 0;
+		  v2->uObjectDescID = v121;
+		  if ( !v121 )
+			SpriteObject::OnInteraction(v153);
+		  v2->vVelocity.z = 0;
+		  v2->vVelocity.y = 0;
+		  v2->vVelocity.x = 0;
+		  v2->uSpriteFrameID = 0;
+		  v133 = v9;
+		  v131 = v9;
+		  v130 = v9;
+		  v13 = 8 * v153;
+		  v129 = v9;
+		  v128 = -1;
+		  LOBYTE(v13) = PID(OBJECT_Item,v153);
+		  v127 = v9;
+		  v126 = v13;
+		  v125 = 8;
+		  pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+		  return 0;
+	  }
     }
     v121 = v119;
   }
@@ -7291,7 +7374,6 @@
   v2->vVelocity.y = 0;
   v2->vVelocity.x = 0;
   v2->uSpriteFrameID = 0;
-LABEL_27:
   v133 = v9;
   v131 = v9;
   v130 = v9;
@@ -7301,9 +7383,7 @@
   LOBYTE(v13) = PID(OBJECT_Item,v153);
   v127 = v9;
   v126 = v13;
-LABEL_28:
   v125 = 8;
-LABEL_29:
   pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
   return 0;
 }