changeset 245:f070b49d40dd

goto cleaning
author zipi
date Mon, 18 Feb 2013 00:39:18 +0000
parents bb9e946cbcbf
children fb8a876f41e1
files Actor.cpp Items.cpp
diffstat 2 files changed, 334 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sun Feb 17 23:59:30 2013 +0000
+++ b/Actor.cpp	Mon Feb 18 00:39:18 2013 +0000
@@ -184,16 +184,13 @@
   if ( !pParty->uAlignment )
   {
     v14 = "-b";
-LABEL_7:
     strcat(pContainer, v14);
-    goto LABEL_8;
   }
-  if ( pParty->uAlignment == 2 )
+  else if ( pParty->uAlignment == 2 )
   {
     v14 = "-c";
-    goto LABEL_7;
+    strcat(pContainer, v14);
   }
-LABEL_8:
   v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   array_5913D8[6] = 0;
   uNumDialogueNPCPortraits = 1;
@@ -208,33 +205,38 @@
     if ( (signed int)pParty->GetPartyFame() <= v5->fame
       || (v10 = v5->uFlags & 0xFFFFFF7F, (v5->uFlags & 0xFFFFFF7F & 0x80000000u) != 0) )
     {
-LABEL_16:
       v9 = 1;
-      goto LABEL_17;
     }
-    if ( v10 > 1 )
-    {
-      if ( v10 == 2 )
-      {
-        v16 = 3;
-        goto LABEL_36;
-      }
-      if ( v10 != 3 )
-      {
-        if ( v10 == 4 )
-          goto LABEL_17;
-        goto LABEL_16;
-      }
-LABEL_35:
-      v16 = 2;
-LABEL_36:
-      v9 = v16;
-      goto LABEL_17;
-    }
-    if ( v5->rep )
-      goto LABEL_35;
+	else
+	{
+		if ( v10 > 1 )
+		{
+		  if ( v10 == 2 )
+		  {
+			v16 = 3;
+			v9 = v16;
+		  }
+		  else
+		  {
+			  if ( v10 != 3 )
+			  {
+				if ( v10 != 4 )
+				  v9 = 1;
+			  }
+			  else
+			  {
+				v16 = 2;
+				v9 = v16;
+			  }
+		  }
+		}
+		else if ( v5->rep )
+		{
+		  v16 = 2;
+		  v9 = v16;
+		}
+	}
   }
-LABEL_17:
   if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
   v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
@@ -2977,7 +2979,6 @@
   {
     v13 = &v14;
     v12 = 256;
-LABEL_16:
     Actor::_403EB6(uActorID, v16, v12, v13);
     return;
   }
@@ -2994,7 +2995,8 @@
   {
     v13 = &v14;
     v12 = 256;
-    goto LABEL_16;
+    Actor::_403EB6(uActorID, v16, v12, v13);
+    return;
   }
   v11 = v5->uMovementSpeed;
   v5->uYawAngle = v10;
@@ -3245,18 +3247,83 @@
   if ( v8 > MONSTER_HARPY_3 )
   {
     if ( v8 < MONSTER_OOZE_1 )
-      goto LABEL_21;
+	{
+      if ( !_this.uItemID )
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
+	}
     if ( v8 <= MONSTER_OOZE_3 )
     {
       _this.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
-      goto LABEL_21;
+      if ( !_this.uItemID )
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
     }
     if ( v8 <= MONSTER_PEASANT_GOBLIN_MALE_3_3 || v8 > MONSTER_TROLL_3 )
     {
-LABEL_21:
       if ( !_this.uItemID )
-        goto LABEL_24;
-      goto LABEL_22;
+	  {
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
+	  }
+      if ( rand() % 100 < 20 )
+	  {
+		v9 = rand();
+		sub_42F7EB_DropItemAt(
+		  pItemsTable->pItems[_this.uItemID].uSpriteID,
+		  v1->vPosition.x,
+		  v1->vPosition.y,
+		  v1->vPosition.z + 16,
+		  v9 % 200 + 200,
+		  1,
+		  1,
+		  0,
+		  &_this);
+	  }
+	  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		Actor::Explode(v11);
+	  return;
     }
     _this.uItemID = ITEM_TROLL_BLOOD;
   }
@@ -3269,20 +3336,81 @@
     else
     {
       if ( v8 < MONSTER_DEVIL_1 )
-        goto LABEL_21;
+	  {
+		  if ( !_this.uItemID )
+		  {
+			if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+				Actor::Explode(v11);
+			return;
+		  }
+		  if ( rand() % 100 < 20 )
+		  {
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+			  pItemsTable->pItems[_this.uItemID].uSpriteID,
+			  v1->vPosition.x,
+			  v1->vPosition.y,
+			  v1->vPosition.z + 16,
+			  v9 % 200 + 200,
+			  1,
+			  1,
+			  0,
+			  &_this);
+		  }
+		  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		  return;
+	  }
       if ( v8 > MONSTER_DEVIL_3 )
       {
         if ( v8 <= MONSTER_DRAGON_3 )
         {
           _this.uItemID = ITEM_DRAGON_EYE;
-          goto LABEL_22;
+          if ( rand() % 100 < 20 )
+		  {
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+				pItemsTable->pItems[_this.uItemID].uSpriteID,
+				v1->vPosition.x,
+				v1->vPosition.y,
+				v1->vPosition.z + 16,
+				v9 % 200 + 200,
+				1,
+				1,
+				0,
+				&_this);
+		  }
+		  if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+		    Actor::Explode(v11);
+		  return;
         }
-        goto LABEL_21;
+		if ( !_this.uItemID )
+		{
+			if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+				Actor::Explode(v11);
+			return;
+		}
+		if ( rand() % 100 < 20 )
+		{
+			v9 = rand();
+			sub_42F7EB_DropItemAt(
+			  pItemsTable->pItems[_this.uItemID].uSpriteID,
+			  v1->vPosition.x,
+			  v1->vPosition.y,
+			  v1->vPosition.z + 16,
+			  v9 % 200 + 200,
+			  1,
+			  1,
+			  0,
+			  &_this);
+		}
+		if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
+			Actor::Explode(v11);
+		return;
       }
       _this.uItemID = ITEM_DEVIL_ICHOR;
     }
   }
-LABEL_22:
   if ( rand() % 100 < 20 )
   {
     v9 = rand();
@@ -3297,7 +3425,6 @@
       0,
       &_this);
   }
-LABEL_24:
   if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
     Actor::Explode(v11);
 }
@@ -3719,60 +3846,79 @@
   v21 = 0;
   v24 = v6;
   v26 = 0;
-  if ( (signed int)uNumActors <= 0 )
-    goto LABEL_26;
-  v7 = pActors;
-  do
+  if ( (signed int)uNumActors > 0 )
   {
-	v8 = v7->uAIState;
-	if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
-      goto LABEL_23;
-    if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
-      goto LABEL_13;
-    if ( v7->IsAlive() == 1 )
-    {
-      v24 = v4;
-      v3->uLastCharacterIDToHit = v4;
-LABEL_13:
-      v10 = v3->GetActorsRelation(v7);
-      if ( v10 == v4 )
-        goto LABEL_23;
-      goto LABEL_14;
-    }
-	v18 = v7->uGroup;
-    if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
-      goto LABEL_23;
-    v10 = 4;
-LABEL_14:
-    if ( v3->pMonsterInfo.uHostilityType )
-      v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
-    v11 = dword_4DF380[v10];
-	v23 = abs(v3->vPosition.x - v7->vPosition.x);
-	v27 = abs(v3->vPosition.y - v7->vPosition.y);
-	v12 = abs(v3->vPosition.z - v7->vPosition.z);
-    v19 = v12;
-    if ( v23 <= v11
-      && v27 <= v11
-      && v12 <= v11
-      && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
-      && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
-    {
-      v25 = v23 * v23 + v27 * v27 + v19 * v19;
-      v21 = v26;
-    }
-    v4 = 0;
-LABEL_23:
-    ++v7;
-    v5 = v26++ + 1;
+	  v7 = pActors;
+	  do
+	  {
+		v8 = v7->uAIState;
+		if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
+		{
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		}
+		if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
+		{
+		  v10 = v3->GetActorsRelation(v7);
+		  if ( v10 == v4 )
+		  {
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		  }
+		}
+		else if ( v7->IsAlive() == 1 )
+		{
+		  v24 = v4;
+		  v3->uLastCharacterIDToHit = v4;
+		  v10 = v3->GetActorsRelation(v7);
+		  if ( v10 == v4 )
+		  {
+			++v7;
+			v5 = v26++ + 1;
+			continue;
+		  }
+		}
+		else
+		{
+			v18 = v7->uGroup;
+			if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
+			{
+				++v7;
+				v5 = v26++ + 1;
+				continue;
+			}
+			v10 = 4;
+		}
+		if ( v3->pMonsterInfo.uHostilityType )
+		  v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
+		v11 = dword_4DF380[v10];
+		v23 = abs(v3->vPosition.x - v7->vPosition.x);
+		v27 = abs(v3->vPosition.y - v7->vPosition.y);
+		v12 = abs(v3->vPosition.z - v7->vPosition.z);
+		v19 = v12;
+		if ( v23 <= v11
+		  && v27 <= v11
+		  && v12 <= v11
+		  && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
+		  && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
+		{
+		  v25 = v23 * v23 + v27 * v27 + v19 * v19;
+		  v21 = v26;
+		}
+		v4 = 0;
+		++v7;
+		v5 = v26++ + 1;
+	  }
+	  while ( v26 < (signed int)uNumActors );
+	  if ( v25 != -1 )
+	  {
+		v13 = 8 * v21;
+		LOBYTE(v13) = 8 * v21 | 3;
+		*v20 = v13;
+	  }
   }
-  while ( v26 < (signed int)uNumActors );
-  if ( v25 != -1 )
-  {
-    v13 = 8 * v21;
-    LOBYTE(v13) = 8 * v21 | 3;
-    *v20 = v13;
-  }
-LABEL_26:
   if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4
     && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) )
     a3 = v4;
@@ -3870,45 +4016,33 @@
   if ( a1 )
   {
     v9 = a1->uAlly;
-    if ( (signed int)v9 <= 0 )
-    {
-      if ( v9 != 9999 )
-        goto LABEL_30;
-    }
-    else
+    if ( (signed int)v9 > 0 )
     {
       if ( v9 != 9999 )
       {
         v7 = a1->uAlly;
-        goto LABEL_30;
       }
     }
-    v7 = 0;
-LABEL_30:
+	if(v9==9999)
+      v7 = 0;
     if ( (signed __int64)a1->pActorBuffs[12].uExpireTime > 0 )
       v7 = 0;
   }
-  if ( !v2 )
-    goto LABEL_40;
-  v10 = v2->uAlly;
-  if ( (signed int)v10 <= 0 )
-  {
-    if ( v10 != 9999 )
-      goto LABEL_38;
-  }
-  else
+  if ( v2 )
   {
-    if ( v10 != 9999 )
-    {
-      v8 = v2->uAlly;
-      goto LABEL_38;
-    }
+	  v10 = v2->uAlly;
+	  if ( (signed int)v10 > 0 )
+	  {
+		if ( v10 != 9999 )
+		{
+		  v8 = v2->uAlly;
+		}
+	  }
+	  if(v10==9999)
+	    v8 = 0;
+	  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
+		v8 = 0;
   }
-  v8 = 0;
-LABEL_38:
-  if ( (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 )
-    v8 = 0;
-LABEL_40:
   if ( a1 && (signed __int64)a1->pActorBuffs[1].uExpireTime > 0 && !v8
     || v2 && (signed __int64)v2->pActorBuffs[1].uExpireTime > 0 && !v7 )
     return 0;
@@ -3917,7 +4051,15 @@
   if ( v2 && a1 && (signed __int64)a1->pActorBuffs[12].uExpireTime <= 0 && v2->uAttributes & 0x80000 )
   {
     if ( v7 )
-      goto LABEL_55;
+	{
+		if ( (signed int)v7 < 89 )
+		{
+		  if ( v8 < 89 )
+			return pFactionTable->relations[v7][v8];
+		  return 0;
+		}
+		return 0;
+	}
     return 4;
   }
   if ( !v7 )
@@ -3925,16 +4067,18 @@
     if ( (!v2 || (signed __int64)v2->pActorBuffs[12].uExpireTime > 0 || !(v2->uAttributes & 0x80000))
       && !pFactionTable->relations[v8][0]) 
     {
-LABEL_56:
       if ( v8 < 89 )
         return pFactionTable->relations[v7][v8];
       return 0;
     }
     return 4;
   }
-LABEL_55:
   if ( (signed int)v7 < 89 )
-    goto LABEL_56;
+  {
+    if ( v8 < 89 )
+      return pFactionTable->relations[v7][v8];
+    return 0;
+  }
   return 0;
 }
 
--- a/Items.cpp	Sun Feb 17 23:59:30 2013 +0000
+++ b/Items.cpp	Mon Feb 18 00:39:18 2013 +0000
@@ -53,7 +53,6 @@
   UpdateTempBonus(pParty->uTimePlayed);
   if ( v4->uItemID == 501 )
   {
-LABEL_45:
     *v3 = 1;
     v10 = rand();
     v17 = 10;
@@ -73,13 +72,17 @@
     return v9 + 9;
   }
   if ( v4->uItemID == 517 )
-    goto LABEL_36;
+  {
+    v5 = 8;
+    *v3 = v5;
+    return v5;
+  }
   v8 = v4->uAdditionalValue;
   if ( v8 > 46 )
   {
-LABEL_42:
     v5 = 0;
-    goto LABEL_37;
+    *v3 = v5;
+    return v5;
   }
   if ( v8 == 46 )
   {
@@ -113,14 +116,14 @@
           *a3 = 1;
           return v5;
         }
-        goto LABEL_42;
+		v5 = 0;
+		*v3 = v5;
+		return v5;
       }
       *v3 = 2;
       return 12;
     }
-LABEL_36:
     v5 = 8;
-LABEL_37:
     *v3 = v5;
     return v5;
   }
@@ -160,9 +163,18 @@
     return rand() % 7 + 4;
   }
   if ( v8 == 9 )
-    goto LABEL_45;
+  {
+    *v3 = 1;
+    v10 = rand();
+    v17 = 10;
+    return v10 % v17 + 6;
+  }
   if ( v8 != 10 )
-    goto LABEL_42;
+  {
+        v5 = 0;
+    *v3 = v5;
+    return v5;
+  }
   *v3 = 0;
   v7 = 1;
   return GetDiceResult(v7, 6u);
@@ -1673,9 +1685,7 @@
         --v14;
       }
       while ( v14 );
-LABEL_72:
       v4->_bonus_type = v15 * treasure_level;
-      goto LABEL_73;
     }
   }
   else
@@ -1718,10 +1728,9 @@
         --v19;
       }
       while ( v19 );
-      goto LABEL_72;
+      v4->_bonus_type = v15 * treasure_level;
     }
   }
-LABEL_73:
   if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
     && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) )
     v4->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST;
@@ -1762,13 +1771,10 @@
     v23 = rand();
     v24 = *(unsigned int *)v22;
     v25 = v23 % 100;
-    if ( v23 % 100 < v24 )
-      goto LABEL_127;
-    if ( !uBonusChanceSpecial[v6] )
+    if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24))
         return;
-    if ( v25 < v24 )
+    if ( v25 < v24 || v23 % 100 < v24)
     {
-LABEL_127:
       v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
       v27 = v4->uItemID;
       v4->_bonus_type = 0;
@@ -1811,14 +1817,24 @@
       {
         case 2:
           if ( !*(unsigned char *)v40 )
-            goto LABEL_117;
+          {
+            v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+            if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+            {
+              v44 = v58;
+              ++v58;
+              *v44 = a2b;
+            }
+            ++a2b;
+			v40 += 28;
+			continue;
+          }
           v41 = *(unsigned char *)v40 == 1;
           break;
         case 3:
           v43 = *(unsigned char *)v40;
           if ( !*(unsigned char *)v40 || v43 == 1 )
           {
-LABEL_117:
             v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
             if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
             {
@@ -1826,24 +1842,49 @@
               ++v58;
               *v44 = a2b;
             }
-            goto LABEL_119;
+            ++a2b;
+			v40 += 28;
+			continue;
           }
           v41 = v43 == 2;
           break;
         case 4:
           v42 = *(unsigned char *)v40;
           if ( *(unsigned char *)v40 == 1 || v42 == 2 )
-            goto LABEL_117;
+          {
+            v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+            if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+            {
+              v44 = v58;
+              ++v58;
+              *v44 = a2b;
+            }
+            ++a2b;
+			v40 += 28;
+			continue;
+          }
           v41 = v42 == 3;
           break;
         default:
           if ( v6 != 5 )
-            goto LABEL_119;
+		  {
+            ++a2b;
+			v40 += 28;
+			continue;
+		  }
           v41 = *(unsigned char *)v40 == 3;
           break;
       }
       if ( v41 )
-        goto LABEL_117;
+      {
+		v39 += *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType);
+		if ( *((unsigned char *)&uAllItemsCount + v40 + v52 + pItems[v4->uItemID].uEquipType) )
+		{
+			v44 = v58;
+			++v58;
+			*v44 = a2b;
+		}
+	  }
 LABEL_119:
       ++a2b;
       v40 += 28;