diff mm7_3.cpp @ 1061:89422dd58318

ODM_ProcessPartyActions cleaned of labels
author zipi
date Thu, 23 May 2013 22:07:17 +0100
parents b79139c3b5c8
children e23a79658fc5
line wrap: on
line diff
--- a/mm7_3.cpp	Thu May 23 20:51:27 2013 +0100
+++ b/mm7_3.cpp	Thu May 23 22:07:17 2013 +0100
@@ -2230,7 +2230,9 @@
   v1 = 0;
   v103 = 0;
   v2 = 0;
-  *(float *)&v128 = 0.0;
+  //*(float *)&v128 = 0.0;
+  v128 = 0;
+  v129 = 0;
   pX = pParty->vPosition.x;
   pY = pParty->vPosition.y;
   v113 = pParty->field_6F0;
@@ -2648,14 +2650,14 @@
     }
   }
 
-LABEL_123:
+//LABEL_123:
   pParty->sRotationY = _angle_y;
   pParty->sRotationX = _angle_x;
-  if ( pZ < v111 )
+  if ( pZ < v111 || pParty->bFlying)
   {
     if ( pParty->bFlying )
     {
-LABEL_130:
+//LABEL_130:
       v31 = GetTickCount();
       v126 = stru_5C6E00->Cos(v31);
       v129 = (unsigned __int64)(4i64 * v126) >> 16;
@@ -2665,60 +2667,61 @@
       if (pParty->FlyActive())
         stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu;
       pParty->uFallStartY = pZ;
-      goto LABEL_141;
-    }
-    if ( v130 && v121 )
-      sub_42F960_create_object(pX, pY, v111);
-    v121 = 0;
-    pZ = v111;
-    pParty->uFallStartY = v111;
-  }
-  if ( pParty->bFlying )
-    goto LABEL_130;
-  v113 = pZ;
-  if (pParty->FlyActive())
-    stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
-
-LABEL_141:
+      //goto LABEL_141;
+    }
+	else
+	{
+		if ( v130 && v121 )
+		  sub_42F960_create_object(pX, pY, v111);
+		v121 = 0;
+		pZ = v111;
+		pParty->uFallStartY = v111;
+	    v113 = pZ;
+	    if (pParty->FlyActive())
+		  stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
+
+	}
+  }
+  else
+  {
+	  v113 = pZ;
+	  if (pParty->FlyActive())
+		stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;
+  }
+//LABEL_141:
   if (bJumping && !pParty->bFlying)
   {
     v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
     v34 = v121 + 2 * v33;
     v121 += 2 * v33;
-    goto LABEL_164;
-  }
-  if (!partyAtHighSlope)
+  }
+  else if (!partyAtHighSlope)
   {
     v34 = v121;
-    if (!bJumping)
-      goto LABEL_150;
-    goto LABEL_164;
-  }
-  if (!bJumping)
-  {
-    if ( v108 )
-      goto LABEL_150;
-
-    // rolling down the hill
-    // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air
-    // and falling to the gravity, gradually sliding downwards. nice trick
-    pZ = v111;
-    ODM_GetTerrainNormalAt(pX, pY, &v98);
-    v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
-    v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16;
-    v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16;
-    v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16;
-    v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16);
-    v128 = v1;
-    v121 = v34;
-    if (!bJumping)
-      goto LABEL_150;
-    goto LABEL_164;
-  }
-  v34 = v121;
-
-LABEL_164:
-  if ( !bUnderwater && v34 <= 0)
+  }
+  else if (!bJumping)
+  {
+    if ( !v108 )
+	{
+		// rolling down the hill
+		// how it's done: you get a little bit pushed in the air along terrain normal, getting in the air
+		// and falling to the gravity, gradually sliding downwards. nice trick
+		pZ = v111;
+		ODM_GetTerrainNormalAt(pX, pY, &v98);
+		v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
+		v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16;
+		v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16;
+		v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16;
+		v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16);
+		v128 = v1;
+		v121 = v34;
+	}
+  }
+  else
+	  v34 = v121;
+
+//LABEL_164:
+  if ( !bUnderwater && v34 <= 0 && bJumping)
   {
     if ( v34 < -500
       && !pParty->bFlying
@@ -2735,7 +2738,7 @@
   }
   else
   {
-LABEL_150:
+//LABEL_150:
   pParty->uFallStartY = pZ;
   }
 
@@ -2801,27 +2804,37 @@
     v43 = 1;
     v44 = 1;
     if ( bUnderwater || !v107 )
-      goto LABEL_197;
-    if ( v127 && v129 > pZ )
-      v44 = 0;
-    if ( v118 && v119 > pZ )
-      v43 = 0;
-    if ( v44 )
-      goto LABEL_197;
-    if ( v43 )
-      goto LABEL_198;
-    v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
-    if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
-    {
-      v43 = 1;
-LABEL_197:
-      pX = _angle_x;
-      if ( !v43 )
-        goto LABEL_199;
-LABEL_198:
-      pY = _angle_y;
-    }
-LABEL_199:
+	{
+		  pX = _angle_x;
+		  if ( v43 )
+			  pY = _angle_y;
+	}
+	else
+	{
+		if ( v127 && v129 > pZ )
+		  v44 = 0;
+		if ( v118 && v119 > pZ )
+		  v43 = 0;
+		if ( v44 )
+		{
+			  pX = _angle_x;
+			  if ( v43 )
+				  pY = _angle_y;
+		}
+		else if ( v43 )
+		  pY = _angle_y;
+		else
+		{
+			v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
+			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
+			{
+			  v43 = 1;
+			  pX = _angle_x;
+			  if ( v43 )
+				  pY = _angle_y;
+			}
+		}
+	}
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       if ( !v107 )
@@ -2843,8 +2856,14 @@
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
 
       viewparams->bRedrawGameUI = 1;
-      goto LABEL_234;
-    }
+		v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+		v127 = (BSPModel *)58500;
+		v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+		v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+		++v126;
+		v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+		continue;
+	}
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
       v56 = integer_sqrt(v2 * v2 + v128 * v128);
@@ -2884,15 +2903,26 @@
         v53 = v47->uPolygonType;
         if ( v53 == 3 )
         {
-          if ( v121 < 0 )
-            v121 = 0;
-          pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
-          if ( v2 * v2 + v128 * v128 < 400 )
-          {
-            v2 = 0;
-            *(float *)&v128 = 0.0;
-          }
-          goto LABEL_221;
+			if ( v121 < 0 )
+				v121 = 0;
+			pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
+			if ( v2 * v2 + v128 * v128 < 400 )
+			{
+				v2 = 0;
+				*(float *)&v128 = 0.0;
+			}
+			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			{
+				pParty->floor_face_pid = v45;
+				v103 = v47->sCogTriggeredID;
+			}
+			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+			v127 = (BSPModel *)58500;
+			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			++v126;
+			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			continue;
         }
         if ( !v129 && (v53 != 4 || v119) )
         {
@@ -2925,15 +2955,20 @@
             if ( !v119 )
               pZ = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16);
           }
-LABEL_220:
-          v45 = stru_721530.uFaceID;
-LABEL_221:
-          if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
-          {
-            pParty->floor_face_pid = v45;
-            v103 = v47->sCogTriggeredID;
-          }
-          goto LABEL_234;
+//LABEL_220:
+			v45 = stru_721530.uFaceID;
+			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			{
+				pParty->floor_face_pid = v45;
+				v103 = v47->sCogTriggeredID;
+			}
+			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+			v127 = (BSPModel *)58500;
+			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			++v126;
+			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			continue;
         }
         v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
         if ( stru_721530.field_64 >> 3 > v118 )
@@ -2948,13 +2983,27 @@
         v2 += v122;
         v128 += (int)v127;
         if ( v2 * v2 + v128 * v128 >= 400 )
-          goto LABEL_220;
+		{
+			v45 = stru_721530.uFaceID;
+			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			{
+				pParty->floor_face_pid = v45;
+				v103 = v47->sCogTriggeredID;
+			}
+			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+			v127 = (BSPModel *)58500;
+			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			++v126;
+			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			continue;
+		}
         v2 = 0;
         v121 = 0;
         *(float *)&v128 = 0.0;
       }
     }
-LABEL_234:
+//LABEL_234:
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
     v127 = (BSPModel *)58500;
     v128 = (unsigned __int64)(58500i64 * v128) >> 16;
@@ -2969,54 +3018,71 @@
     v126 = abs(pParty->vPosition.y - pY);
     v62 = abs(pParty->vPosition.z - pZ);
     if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) < 8 )
-      goto LABEL_344;
-    if ( v114 && (!bJumping || v101) )
-    {
-      if ( !v107
-        && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
-      {
+	{
+		  pAudioPlayer->_4AA258(804);
+		  pParty->walk_sound_timer = 64;
+	}
+	else
+	{
+		if ( v114 && (!bJumping || v101) )
+		{
+		  if ( !v107
+			&& !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
+		  {
         
-        v90 = -1;
-        v89 = 1;
-        v88 = 804;
-        v87 = 64;
-        goto LABEL_257;
-      }
-     
-      v90 = -1;
-      v89 = 1;
-      v88 = 804;
-      v86 = 1;
-LABEL_255:
-      v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
-      v64 = WorldPosToGridCellX(pParty->vPosition.x);
-      v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
-      goto LABEL_257;
-    }
-    if ( v124 && (!bJumping || v101) )
-    {
-      if ( v107
-        || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
-      {
+			v90 = -1;
+			v89 = 1;
+			v88 = 804;
+			v87 = 64;
+			pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+		  }
+		  else
+		  {
+			v90 = -1;
+			v89 = 1;
+			v88 = 804;
+			v86 = 1;
+		//LABEL_255:
+			v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+			v64 = WorldPosToGridCellX(pParty->vPosition.x);
+			v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
+			pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+		  }
+		}
+		else
+		{
+			if ( v124 && (!bJumping || v101) )
+			{
+			  if ( v107
+				|| BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
+			  {
         
-        v90 = -1;
-        v89 = 1;
-        v88 = 804;
-        v86 = 0;
-        goto LABEL_255;
-      }
-      v90 = -1;
-      v89 = 1;
-      v88 = 804;
-      v87 = 103;
-LABEL_257:
-      pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
-    }
-    else
-    {
-LABEL_344:
-      pAudioPlayer->_4AA258(804);
-      pParty->walk_sound_timer = 64;
+				v90 = -1;
+				v89 = 1;
+				v88 = 804;
+				v86 = 0;
+				v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+				v64 = WorldPosToGridCellX(pParty->vPosition.x);
+				v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
+				pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+			  }
+			  else
+			  {
+				  v90 = -1;
+				  v89 = 1;
+				  v88 = 804;
+				  v87 = 103;
+			//LABEL_257:
+				  pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
+			  }
+			}
+			else
+			{
+		//LABEL_344:
+			  pAudioPlayer->_4AA258(804);
+			  pParty->walk_sound_timer = 64;
+			}
+		}
     }
   }
   if ( !bJumping || v101 )
@@ -3113,24 +3179,26 @@
     if ( v127 )
     {
       v78 = v69 != 0;
-      goto LABEL_306;
-    }
-    v114 = 1;
-  }
-  v78 = 1;
-LABEL_306:
+    }
+	else
+	{
+		v114 = 1;
+		v78 = 1;
+	}
+  }
+  else
+	v78 = 1;
+//LABEL_306:
   if ( v77 )
   {
     pParty->vPosition.x = pX;
-    if ( !v78 )
-      goto LABEL_313;
-    goto LABEL_312;
   }
   if ( v78 )
   {
-LABEL_312:
     pParty->vPosition.y = pY;
-LABEL_313:
+  }
+  if ( v78 || v77)
+  {
     if ( bWaterWalk )
     {
       pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER;
@@ -3148,14 +3216,13 @@
         }
       }
     }
-    goto LABEL_318;
-  }
-  if ( bWalkSound && pParty->walk_sound_timer <= 0 )
+  }
+  else if ( bWalkSound && pParty->walk_sound_timer <= 0 )
   {
     pAudioPlayer->_4AA258(804);
     pParty->walk_sound_timer = 64;
   }
-LABEL_318:
+//LABEL_318:
   v81 = pZ;
   v82 = pZ;
   pParty->vPosition.z = pZ;