changeset 1418:483b1b453986

more label cleaning
author zipi
date Sun, 28 Jul 2013 17:45:21 +0100
parents 1dd0c79e1502
children 9a1adf08f4ed
files mm7_1.cpp mm7_3.cpp
diffstat 2 files changed, 275 insertions(+), 222 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_1.cpp	Sun Jul 28 17:12:25 2013 +0100
+++ b/mm7_1.cpp	Sun Jul 28 17:45:21 2013 +0100
@@ -488,7 +488,19 @@
         {
           v10 = 0;
           v11 = *(float *)v3 == *((float *)v6 - 5);
-          goto LABEL_19;
+          if ( ! (v11 | v10 ) )
+		  {
+			  ++v21;
+			  v22 += 48;
+			  v24 += 48;
+			  v25 += 48;
+			  v4 += 48;
+			  v3 += 48;
+			  ++out_num_vertices;
+			  v23 += 48;
+			  v19 = v4;
+			  v18 = v3;
+		  }
         }
       }
       else
@@ -497,25 +509,22 @@
         {
           v10 = 0;
           v11 = *(float *)v3 == *((float *)v6 + 7);
-LABEL_19:
-          if ( v11 | v10 )
-            goto LABEL_21;
-          goto LABEL_20;
+          if ( ! (v11 | v10 ) )
+		  {
+			  ++v21;
+			  v22 += 48;
+			  v24 += 48;
+			  v25 += 48;
+			  v4 += 48;
+			  v3 += 48;
+			  ++out_num_vertices;
+			  v23 += 48;
+			  v19 = v4;
+			  v18 = v3;
+		  }
         }
       }
-LABEL_20:
-      ++v21;
-      v22 += 48;
-      v24 += 48;
-      v25 += 48;
-      v4 += 48;
-      v3 += 48;
-      ++out_num_vertices;
-      v23 += 48;
-      v19 = v4;
-      v18 = v3;
     }
-LABEL_21:
     if ( v17 )
     {
       v12 = v21;
--- a/mm7_3.cpp	Sun Jul 28 17:12:25 2013 +0100
+++ b/mm7_3.cpp	Sun Jul 28 17:45:21 2013 +0100
@@ -1816,37 +1816,38 @@
   pParty->sRotationX = _view_angle;
   if ( bJumping )
   {
-    pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
+	pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
+	if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
+	{
+		if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
+		{
+			v41 = &pPlayers[1];
+			do
+			{
+				if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
+					(*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
+				++v41;
+			}
+			while ( (signed int)v41 <= (signed int)&pPlayers[4] );
+		}
+	}
+	else
+		pParty->uFallStartY = party_z;
   }
   else
   {
     if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 )
     {
       pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength();
-      goto LABEL_92;
+      pParty->uFallStartY = party_z;
     }
-    if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
-      goto LABEL_92;
-    pParty->uFallSpeed = 0;
-  }
-  if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
-  {
-    if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
-    {
-      v41 = &pPlayers[1];
-      do
-      {
-        if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
-          (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
-        ++v41;
-      }
-      while ( (signed int)v41 <= (signed int)&pPlayers[4] );
-    }
-    goto LABEL_93;
-  }
-LABEL_92:
-  pParty->uFallStartY = party_z;
-LABEL_93:
+	else
+	{
+		if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) )
+		  pParty->uFallSpeed = 0;
+		pParty->uFallStartY = party_z;
+	}
+  }
   if ( v2 * v2 + v1 * v1 < 400 )
   {
     v1 = 0;
@@ -1923,9 +1924,8 @@
         && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) )
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
       viewparams->bRedrawGameUI = 1;
-      goto LABEL_152;
     }
-    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
+	else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
       v53 = integer_sqrt(v2 * v2 + v1 * v1);
       v80 = v53;
@@ -1955,64 +1955,69 @@
           }
           if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
             uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-          goto LABEL_152;
         }
-        v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
-        v47 = v45 == 4;
-        v48 = v44->pFacePlane_old.vNormal.x;
-        if ( !v47 )
-        {
-          v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-          if ( stru_721530.field_64 >> 3 > v80 )
-            v80 = stru_721530.field_64 >> 3;
-          v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-          v81 = v44->pFacePlane_old.vNormal.y;
-          v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-          v82 = v44->pFacePlane_old.vNormal.z;
-          v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-          v2 += v50;
-          pParty->uFallSpeed += v82;
-          v74 = v44->pFacePlane_old.vNormal.z;
-          v51 = v44->pFacePlane_old.vNormal.y;
-          v69 = v44->pFacePlane_old.vNormal.x;
-          v80 = v51;
-          v1 += v81;
-          v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
-          if ( v52 > 0 )
-          {
-            new_party_x += v52 * v69 >> 16;
-            new_party_y += v52 * v80 >> 16;
-            v87 += v52 * v74 >> 16;
-          }
-          v43 = stru_721530.uFaceID;
-          if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-          goto LABEL_152;
-        }
-        v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-        if ( stru_721530.field_64 >> 3 > v80 )
-          v80 = stru_721530.field_64 >> 3;
-        v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-        v81 = v44->pFacePlane_old.vNormal.y;
-        v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-        v82 = v44->pFacePlane_old.vNormal.z;
-        v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-        v2 += v49;
-        v1 += v81;
-        pParty->uFallSpeed += v82;
-        if ( v2 * v2 + v1 * v1 >= 400 )
-        {
-          v43 = stru_721530.uFaceID;
-          if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-          goto LABEL_152;
-        }
-        v2 = 0;
-        v1 = 0;
-        pParty->uFallSpeed = 0;
+		else
+		{
+			v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
+			v47 = v45 == 4;
+			v48 = v44->pFacePlane_old.vNormal.x;
+			if ( !v47 )
+			{
+			  v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
+			  if ( stru_721530.field_64 >> 3 > v80 )
+				v80 = stru_721530.field_64 >> 3;
+			  v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
+			  v81 = v44->pFacePlane_old.vNormal.y;
+			  v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
+			  v82 = v44->pFacePlane_old.vNormal.z;
+			  v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
+			  v2 += v50;
+			  pParty->uFallSpeed += v82;
+			  v74 = v44->pFacePlane_old.vNormal.z;
+			  v51 = v44->pFacePlane_old.vNormal.y;
+			  v69 = v44->pFacePlane_old.vNormal.x;
+			  v80 = v51;
+			  v1 += v81;
+			  v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
+			  if ( v52 > 0 )
+			  {
+				new_party_x += v52 * v69 >> 16;
+				new_party_y += v52 * v80 >> 16;
+				v87 += v52 * v74 >> 16;
+			  }
+			  v43 = stru_721530.uFaceID;
+			  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
+				uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
+			}
+			else
+			{
+				v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
+				if ( stru_721530.field_64 >> 3 > v80 )
+				  v80 = stru_721530.field_64 >> 3;
+				v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
+				v81 = v44->pFacePlane_old.vNormal.y;
+				v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
+				v82 = v44->pFacePlane_old.vNormal.z;
+				v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
+				v2 += v49;
+				v1 += v81;
+				pParty->uFallSpeed += v82;
+				if ( v2 * v2 + v1 * v1 >= 400 )
+				{
+				  v43 = stru_721530.uFaceID;
+				  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
+					uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
+				}
+				else
+				{
+					v2 = 0;
+					v1 = 0;
+					pParty->uFallSpeed = 0;
+				}
+			}
+		}
       }
     }
-LABEL_152:
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
     v1 = (unsigned __int64)(58500i64 * v1) >> 16;
     ++v83;
@@ -2028,8 +2033,11 @@
     if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y)
          * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z)
          * (pParty->vPosition.z - new_party_z)) <= 16 )
-      goto LABEL_188;
-    if ( v72 && (!bJumping || jumping_up) )
+	{
+      pAudioPlayer->_4AA258(804);
+      pParty->walk_sound_timer = 64;
+	}
+    else if ( v72 && (!bJumping || jumping_up) )
     {
       v66 = 0;
       v64 = 0;
@@ -2045,13 +2053,16 @@
           v57 = (SoundID)50;
         else
           v57 = (SoundID)64;
-        goto LABEL_175;
+        pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
       }
-      v57 = (SoundID)63;
-      v56 = pAudioPlayer;
-      goto LABEL_175;
+	  else
+	  {
+		  v57 = (SoundID)63;
+		  v56 = pAudioPlayer;
+		  pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
+	  }
     }
-    if ( v78 && (!bJumping || jumping_up) )
+    else if ( v78 && (!bJumping || jumping_up) )
     {
       v66 = 0;
       v64 = 0;
@@ -2064,19 +2075,19 @@
       {
         v57 = (SoundID)102;
         v56 = pAudioPlayer;
-        goto LABEL_175;
       }
-      v56 = pAudioPlayer;
-      if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
-        v57 = (SoundID)89;
-      else
-        v57 = (SoundID)103;
-LABEL_175:
+	  else
+	  {
+		  v56 = pAudioPlayer;
+		  if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
+			v57 = (SoundID)89;
+		  else
+			v57 = (SoundID)103;
+	  }
       pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
     }
     else
     {
-LABEL_188:
       pAudioPlayer->_4AA258(804);
       pParty->walk_sound_timer = 64;
     }
@@ -3510,7 +3521,7 @@
   v25 = 0;
   v16 = word_720B40_intercepts_zs[0] >= v27;
   if ( v15 <= 0 )
-    goto LABEL_29;
+    return 0;
   do
   {
     if ( v31 >= 2 )
@@ -3545,7 +3556,6 @@
   while ( v25 < v15 );
   result = 1;
   if ( v31 != 1 )
-LABEL_29:
     result = 0;
   return result;
 }
@@ -3648,7 +3658,7 @@
   v21 = 0;
   v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
   if ( v11 <= 0 )
-    goto LABEL_29;
+    return 0;
   do
   {
     if ( a4d >= 2 )
@@ -3683,7 +3693,6 @@
   while ( v21 < v11 );
   result = 1;
   if ( a4d != 1 )
-LABEL_29:
     result = 0;
   return result;
 }
@@ -3882,10 +3891,37 @@
     {
       v5 = v4 - 15;
       if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 )
-        goto LABEL_11;
+	  {
+        v4 += 16;
+		--v34;
+		if ( !v34 )
+		  return this->uNumVertices = v38;
+		continue;
+	  }
       if ( *(float *)v5 <= (double)a2 )
-        break;
-      if ( *(float *)(v4 + 1) <= (double)a2 )
+	  {
+		v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
+		v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
+		v36 = v6;
+		v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
+		v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
+		*(float *)&v37 = (double)v7 * v6;
+		v8 = *(float *)&v37 + 6.7553994e15;
+		v9 = (unsigned __int8)*v4;
+		*(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
+		v10 = *(float *)&v37 + 6.7553994e15;
+		v11 = (unsigned __int8)*(v4 - 2);
+		v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
+		v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
+		v12 = v39 + 6.7553994e15;
+		v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
+		v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
+		v14 = v39 + 6.7553994e15;
+		v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
+		//this = v35;
+		v5 = (char *)&v30 + 4;
+	  }
+      else if ( *(float *)(v4 + 1) <= (double)a2 )
       {
         v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
         v16 = (unsigned __int8)*v4;
@@ -3918,9 +3954,8 @@
         v40 += 4;
         *v25 = *(int *)v26;
         v25[1] = *(int *)(v26 + 4);
-        goto LABEL_9;
+		v5 = (char *)&v30 + 4;
       }
-LABEL_10:
       v27 = v40;
       ++v38;
       *v40 = *(int *)v5;
@@ -3932,36 +3967,12 @@
       v40 += 4;
       *v27 = *(int *)v28;
       v27[1] = *(int *)(v28 + 4);
-LABEL_11:
       v4 += 16;
       --v34;
       if ( !v34 )
-        goto LABEL_12;
+          return this->uNumVertices = v38;
     }
-    v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
-    v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
-    v36 = v6;
-    v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
-    v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
-    *(float *)&v37 = (double)v7 * v6;
-    v8 = *(float *)&v37 + 6.7553994e15;
-    v9 = (unsigned __int8)*v4;
-    *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
-    v10 = *(float *)&v37 + 6.7553994e15;
-    v11 = (unsigned __int8)*(v4 - 2);
-    v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
-    v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
-    v12 = v39 + 6.7553994e15;
-    v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
-    v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
-    v14 = v39 + 6.7553994e15;
-    v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
-LABEL_9:
-    //this = v35;
-    v5 = (char *)&v30 + 4;
-    goto LABEL_10;
-  }
-LABEL_12:
+  }
   return this->uNumVertices = v38;
 }
 
@@ -4027,10 +4038,37 @@
     {
       v5 = v4 - 15;
       if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 )
-        goto LABEL_11;
+	  {
+        v4 += 16;
+		--v34;
+		if ( !v34 )
+          return this->uNumVertices = v38;
+		continue;
+	  }
       if ( *(float *)v5 >= (double)a2 )
-        break;
-      if ( *(float *)(v4 + 1) >= (double)a2 )
+	  {
+		v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
+		v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
+		v36 = v6;
+		v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
+		v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
+		*(float *)&v37 = (double)v7 * v6;
+		v8 = *(float *)&v37 + 6.7553994e15;
+		v9 = (unsigned __int8)*v4;
+		*(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
+		v10 = *(float *)&v37 + 6.7553994e15;
+		v11 = (unsigned __int8)*(v4 - 2);
+		v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
+		v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
+		v12 = v39 + 6.7553994e15;
+		v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
+		v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
+		v14 = v39 + 6.7553994e15;
+		v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
+		//this = v35;
+		v5 = (char *)&v30 + 4;
+	  }
+      else if ( *(float *)(v4 + 1) >= (double)a2 )
       {
         v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
         v16 = (unsigned __int8)*v4;
@@ -4063,9 +4101,8 @@
         v40 += 4;
         *v25 = *(int *)v26;
         v25[1] = *(int *)(v26 + 4);
-        goto LABEL_9;
+	    v5 = (char *)&v30 + 4;
       }
-LABEL_10:
       v27 = v40;
       ++v38;
       *v40 = *(int *)v5;
@@ -4077,36 +4114,12 @@
       v40 += 4;
       *v27 = *(int *)v28;
       v27[1] = *(int *)(v28 + 4);
-LABEL_11:
       v4 += 16;
       --v34;
       if ( !v34 )
-        goto LABEL_12;
+          return this->uNumVertices = v38;
     }
-    v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
-    v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
-    v36 = v6;
-    v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
-    v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
-    *(float *)&v37 = (double)v7 * v6;
-    v8 = *(float *)&v37 + 6.7553994e15;
-    v9 = (unsigned __int8)*v4;
-    *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
-    v10 = *(float *)&v37 + 6.7553994e15;
-    v11 = (unsigned __int8)*(v4 - 2);
-    v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
-    v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
-    v12 = v39 + 6.7553994e15;
-    v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
-    v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
-    v14 = v39 + 6.7553994e15;
-    v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
-LABEL_9:
-    //this = v35;
-    v5 = (char *)&v30 + 4;
-    goto LABEL_10;
-  }
-LABEL_12:
+  }
   return this->uNumVertices = v38;
 }
 
@@ -4292,7 +4305,10 @@
   }
   v4 = a1->uNumVertices;
   if ( v4 <= 0 )
-    goto LABEL_16;
+  {
+    memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
+    return v2->uNumVertices != 0;
+  }
   v5 = (char *)&a1->field_14[20];
   v6 = v4;
   do
@@ -4315,7 +4331,6 @@
       v2->_477927(v10);
       return v2->uNumVertices != 0;
     }
-LABEL_16:
     memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
     return v2->uNumVertices != 0;
   }
@@ -4899,12 +4914,10 @@
   {
     v3 = v2->pFacePlane.vNormal.x;
     v4 = -v2->pFacePlane.vNormal.y;
-LABEL_9:
     v5 = 0;
     v11 = 65536;
-    goto LABEL_5;
-  }
-  if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
+  }
+  else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
   {
     thisa.x = -v2->pFacePlane.vNormal.y;
     thisa.y = v2->pFacePlane.vNormal.x;
@@ -4912,13 +4925,16 @@
     thisa.Normalize_float();
     v4 = thisa.x;
     v3 = thisa.y;
-    goto LABEL_9;
-  }
-  v3 = 0;
-  v4 = 65536;
-  v11 = 0;
-  v5 = -65536;
-LABEL_5:
+    v5 = 0;
+    v11 = 65536;
+  }
+  else
+  {
+	  v3 = 0;
+	  v4 = 65536;
+	  v11 = 0;
+	  v5 = -65536;
+  }
   v6 = v11;
   sTextureDeltaU = v2->sTextureDeltaU;
   v7 = v3;
@@ -5765,7 +5781,6 @@
 {
   int v3; // ecx@1
   double v5; // st7@10
-  signed int v6; // esi@10
   signed int v7; // ecx@11
   double v8; // st6@12
   double v9; // st7@15
@@ -5781,44 +5796,73 @@
   if ( v3 )
   {
     v5 = (double)day_fogrange_1;
-    v6 = 216;
     if ( a3 < v5 )
-      goto LABEL_11;
-    v8 = (double)day_fogrange_2;
-    if ( a3 > v8 )
-    {
-LABEL_13:
-      v7 = v6;
-      goto LABEL_19;
-    }
-    v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
+	{
+      v7 = 0;
+      if ( a3 == 0.0 )
+	  {
+		v7 = 216;
+	  }
+	  goto LABEL_21;
+	}
+	else
+	{
+		v8 = (double)day_fogrange_2;
+		if ( a3 > v8 )
+		{
+		  v7 = 216;
+ 		  if ( a3 == 0.0 )
+		  {
+			v7 = 216;
+		  }
+		  goto LABEL_21;
+		}
+		v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
+	}
   }
   else
   {
     v9 = (double)day_fogrange_1;
-    v6 = 216;
     if ( a3 < v9 )
     {
-LABEL_11:
       v7 = 0;
-      goto LABEL_19;
+	  if ( a3 == 0.0 )
+	  {
+		v7 = 216;
+	  }
+      goto LABEL_21;
     }
-    v10 = (double)day_fogrange_2;
-    if ( a3 > v10 )
-      goto LABEL_13;
-    v11 = (a3 - v9) * 216.0 / (v10 - v9);
-    v12 = v11 + 6.7553994e15;
-    v7 = LODWORD(v12);
-  }
-  if ( v7 > v6 )
-  {
-LABEL_20:
-    v7 = v6;
-    goto LABEL_21;
-  }
-LABEL_19:
-  if ( a3 == 0.0 )
-    goto LABEL_20;
+	else
+	{
+		v10 = (double)day_fogrange_2;
+		if ( a3 > v10 )
+		{  
+		  v7 = 216;
+		  if ( a3 == 0.0 )
+		  {
+			v7 = 216;
+		  }
+		  goto LABEL_21;
+		}
+		else
+		{
+			v11 = (a3 - v9) * 216.0 / (v10 - v9);
+			v12 = v11 + 6.7553994e15;
+			v7 = LODWORD(v12);
+		}
+	}
+  }
+  if ( v7 > 216 )
+  {
+    v7 = 216;
+  }
+  else
+  {
+	  if ( a3 == 0.0 )
+	  {
+		v7 = 216;
+	  }
+  }
 LABEL_21:
   if ( a2 )
     v7 = 248;