changeset 2163:9aa0a5d90454

fall_speed
author Ritor1
date Wed, 15 Jan 2014 17:35:41 +0600
parents 5e1f535bad58
children f5e9ac04dd25
files Outdoor.cpp Player.cpp mm7_4.cpp
diffstat 3 files changed, 48 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor.cpp	Tue Jan 14 17:29:20 2014 +0600
+++ b/Outdoor.cpp	Wed Jan 15 17:35:41 2014 +0600
@@ -3640,7 +3640,7 @@
   BSPModel *pModel; // eax@203
   ODMFace *pODMFace; // esi@203
   int v48; // eax@203
-  BSPModel *v54; // eax@215
+  int v54; // eax@215
   int v55; // eax@217
   BSPModel *v58; // eax@228
   //unsigned __int64 v59; // qax@228
@@ -3698,6 +3698,7 @@
   trigger_id = 0;
   v2 = 0;
   //*(float *)&v128 = 0.0;
+  int fall_speed = pParty->uFallSpeed;
   v128 = 0;
   v129 = 0;
   pX = pParty->vPosition.x;
@@ -3852,7 +3853,7 @@
               }
               v1 = 0;
               v2 = 0;
-              pParty->uFallSpeed = 0;
+              fall_speed = 0;
               *(float *)&v128 = 0.0;
               if ( v102 && pZ < ceiling_height && (signed int)(pParty->uPartyHeight + pZ) >= ceiling_height )//столкновение с потолком(ошибка)
               {
@@ -3884,6 +3885,7 @@
             pZ -= 30;
             v113 -= 30;
             pParty->uFallSpeed = 0;
+            fall_speed = 0;
             pParty->bFlying = true;
             pModel = (BSPModel *)1;
             if ( pZ <= v111 )
@@ -4103,7 +4105,7 @@
         {
           //v126 = pParty->field_24 << 6;
           hovering = true;
-          pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
+          fall_speed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)fall_speed);
         }
       break;
 
@@ -4141,9 +4143,9 @@
     }
     else
     {
-      if ( is_on_water && pParty->uFallSpeed )
+      if ( is_on_water && fall_speed )
         sub_42F960_create_object(pX, pY, v111);
-      pParty->uFallSpeed = 0;
+      fall_speed = 0;
       pZ = v111;
       pParty->uFallStartY = v111;
       v113 = pZ;
@@ -4161,11 +4163,11 @@
   if (hovering && !pParty->bFlying)//расчёт скорости падения
   {
     v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
-    v34 = pParty->uFallSpeed + 2 * v33;
-    pParty->uFallSpeed += 2 * v33;
+    v34 = fall_speed + 2 * v33;
+    fall_speed += 2 * v33;
   }
   else if (!partyAtHighSlope)
-    v34 = pParty->uFallSpeed;
+    v34 = fall_speed;
   else if (!hovering)
   {
     if ( !bmodel_standing_on_pid )
@@ -4175,17 +4177,17 @@
 		// and falling to the gravity, gradually sliding downwards. nice trick
 		pZ = v111;
 		ODM_GetTerrainNormalAt(pX, pY, &v98);
-		v35 = pParty->uFallSpeed + (8 * -(pEventTimer->uTimeElapsed * GetGravityStrength()));
+		v35 = fall_speed + (8 * -(pEventTimer->uTimeElapsed * GetGravityStrength()));
 		v129 = abs(v2 * v98.x + v1 * v98.y + 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;
-		pParty->uFallSpeed = v34;
+		fall_speed = v34;
     }
   }
   else
-    v34 = pParty->uFallSpeed;
+    v34 = fall_speed;
 
   if ( hovering )
   {
@@ -4228,7 +4230,7 @@
 
     stru_721530.velocity.x = v2;
     stru_721530.velocity.y = v128;
-    stru_721530.velocity.z = pParty->uFallSpeed;
+    stru_721530.velocity.z = fall_speed;
 
     stru_721530.uSectorID = 0;
     v36 = 0;
@@ -4241,8 +4243,8 @@
     //v38 = WorldPosToGridCellX(pParty->vPosition.x);
     _46E26D_collide_against_sprites(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y));
     _46ED8A_collide_against_sprite_objects(4);
-    for ( i = 0; i < (signed int)uNumActors; ++i )
-      Actor::_46DF1A_collide_against_actor(i, 0);
+    for ( uint actor_id = 0; actor_id < (signed int)uNumActors; ++actor_id )
+      Actor::_46DF1A_collide_against_actor(actor_id, 0);
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       _angle_x = stru_721530.normal2.x;
@@ -4321,11 +4323,13 @@
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
 
       viewparams->bRedrawGameUI = true;
-      v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+	  unsigned __int64 ps = 58500i64 * v2;
+	  float pr = (float)v2;
+      v2 = ps >> 16;
       pModel = (BSPModel *)58500;
       v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-      v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-      pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+      v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16;
+      fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16;
       continue;
     }
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
@@ -4354,8 +4358,8 @@
           v119 = 0;
         if ( pODMFace->uPolygonType == POLYGON_Floor )
         {
-          if ( pParty->uFallSpeed < 0 )
-            pParty->uFallSpeed = 0;
+          if ( fall_speed < 0 )
+            fall_speed = 0;
           pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1;
           if ( v2 * v2 + v128 * v128 < 400 )
           {
@@ -4370,14 +4374,13 @@
           v2 = (unsigned __int64)(58500i64 * v2) >> 16;
           pModel = (BSPModel *)58500;
           v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-          v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-          pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16;
+          fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16;
           continue;
         }
         if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб
         {
-          v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y
-               + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z
+          v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + fall_speed * pODMFace->pFacePlane.vNormal.z
                + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
           if ((stru_721530.speed >> 3) > v118 )
             v118 = stru_721530.speed >> 3;
@@ -4385,10 +4388,9 @@
           v128 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
           v54 = 0;
           if ( !v119 )
-            pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16;
-          v55 = stru_721530.prolly_normal_d
-              - ((signed int)(pODMFace->pFacePlane.dist
-                            + v122 * pODMFace->pFacePlane.vNormal.z
+            v54 = (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16;
+          pParty->uFallSpeed += v54;
+          v55 = stru_721530.prolly_normal_d - ((signed int)(pODMFace->pFacePlane.dist + v122 * pODMFace->pFacePlane.vNormal.z
                             + _angle_y * pODMFace->pFacePlane.vNormal.y
                             + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16);
           if ( v55 > 0 )
@@ -4406,17 +4408,17 @@
           v2 = (unsigned __int64)(58500i64 * v2) >> 16;
           pModel = (BSPModel *)58500;
           v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-          v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-          pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16;
+          fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16;
           continue;
         }
         v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y
-             + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
+             + fall_speed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
         if ((stru_721530.speed >> 3) > v118 )
           v118 = stru_721530.speed >> 3;
         v2 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.x) >> 16;
         v128 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.y) >> 16;
-        pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16;
+        fall_speed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16;
         if ( v2 * v2 + v128 * v128 >= 400 )
         {
           if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() )
@@ -4427,21 +4429,21 @@
           v2 = (unsigned __int64)(58500i64 * v2) >> 16;
           pModel = (BSPModel *)58500;
           v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-          v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16;
           //++v126;
-          pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16;
           continue;
         }
         v2 = 0;
-        pParty->uFallSpeed = 0;
+        fall_speed = 0;
         *(float *)&v128 = 0.0;
       }
     //}
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
     pModel = (BSPModel *)58500;
     v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-    v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-    pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+    v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16;
+    fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16;
   }
 
   //Воспроизведение звуков ходьбы/бега------------------------
@@ -4507,6 +4509,7 @@
     pParty->vPosition.y = pY;
     pParty->vPosition.z = pZ;
     pParty->field_6F0 = v113;
+    pParty->uFallSpeed = fall_speed;
     if ( pZ > 8160 )
     {
       pZ = 8160;
@@ -4617,7 +4620,7 @@
     pParty->vPosition.z = 8160;
   }
   LOWORD(pParty->uFlags) &= 0xFDFBu;
-  //pParty->uFallSpeed = v121;
+  pParty->uFallSpeed = fall_speed;
   pParty->field_6F0 = v113;
   if ( party_drowning_flag )
   {
--- a/Player.cpp	Tue Jan 14 17:29:20 2014 +0600
+++ b/Player.cpp	Wed Jan 15 17:35:41 2014 +0600
@@ -4272,10 +4272,10 @@
   char v72; // [sp+20h] [bp-Ch]@68
   signed int v73; // [sp+24h] [bp-8h]@1
   const char*  v74; // [sp+24h] [bp-8h]@23
-  Player *thisb; // [sp+28h] [bp-4h]@1
+  //Player *thisb; // [sp+28h] [bp-4h]@1
   unsigned int thisa; // [sp+28h] [bp-4h]@22
 
-  thisb = this;
+  //thisb = this;
   playerAffected = &pParty->pPlayers[player_num-1];
   v73 = 1;
   if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 1 || pTurnEngine->turn_stage == 3) )
@@ -4318,12 +4318,12 @@
       if ( pParty->bTurnBasedModeOn )
       {
         pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
-        thisb->SetRecoveryTime(100);
+        this->SetRecoveryTime(100);
         pTurnEngine->ApplyPlayerAction();
       }
       else
       {
-        thisb->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
+        this->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
       }
     }
     pMouse->RemoveHoldingItem();
@@ -4614,12 +4614,12 @@
         if ( pParty->bTurnBasedModeOn )
         {
           pParty->pTurnBasedPlayerRecoveryTimes[player_num-1] = 100;
-          thisb->SetRecoveryTime(100);
+          this->SetRecoveryTime(100);
           pTurnEngine->ApplyPlayerAction();
         }
         else
         {
-          thisb->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
+          this->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * 213.3333333333333));
         }
       }
       pMouse->RemoveHoldingItem();
--- a/mm7_4.cpp	Tue Jan 14 17:29:20 2014 +0600
+++ b/mm7_4.cpp	Wed Jan 15 17:35:41 2014 +0600
@@ -197,7 +197,7 @@
   int v6; // edi@17
   int v12; // eax@26
 
-  __debugbreak();//Ritor1
+  //__debugbreak();//Ritor1
   for ( uint pl = 0; pl < 4; pl++ )
   {
     if (SoundSetAction[24][0])
@@ -205,6 +205,7 @@
       v3 = 0;
       for ( v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1 )
       {
+        int ps = 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998;//6728
         if ( pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998 )
           v3 = v1;
       }