changeset 149:2b0c652cc165

12.02.13
author Ritor1
date Tue, 12 Feb 2013 10:17:11 +0600
parents 77ad59c17864
children d92c78ab54fe
files Keyboard.cpp Render.cpp mm7_3.cpp
diffstat 3 files changed, 106 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/Keyboard.cpp	Tue Feb 12 09:11:19 2013 +0600
+++ b/Keyboard.cpp	Tue Feb 12 10:17:11 2013 +0600
@@ -953,28 +953,17 @@
 //----- (0045B06E) --------------------------------------------------------
 bool Keyboard::IsShiftHeld()
 {
-  bool result; // eax@2
-  char v2; // zf@3
 
   if (bUsingAsynKeyboard)
   {
     if ( pAsyncKeyboard->_45B4EC(0x2Au) )
     {
-LABEL_6:
-      LOBYTE(result) = 1;
-      return result;
+      return true;
     }
-    v2 = pAsyncKeyboard->_45B4EC(0x36u) == 0;
+    return pAsyncKeyboard->_45B4EC(0x36u) != 0;
   }
   else
-  {
-    LOWORD(result) = GetAsyncKeyState(VK_SHIFT);
-    v2 = result == 0;
-  }
-  if ( !v2 )
-    goto LABEL_6;
-  LOBYTE(result) = 0;
-  return result;
+    return GetAsyncKeyState(VK_SHIFT);
 }
 
 //----- (0045B0A9) --------------------------------------------------------
--- a/Render.cpp	Tue Feb 12 09:11:19 2013 +0600
+++ b/Render.cpp	Tue Feb 12 10:17:11 2013 +0600
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "Render.h"
 #include "OutdoorCamera.h"
 #include "IndoorCamera.h"
@@ -1824,6 +1826,8 @@
         memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
         array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
       }
+
+      assert(v6 < 1000); // many random crashes here
       pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]);
       --pOutdoorCamera->numStru148s;
       --pOutdoorCamera->field_44;
--- a/mm7_3.cpp	Tue Feb 12 09:11:19 2013 +0600
+++ b/mm7_3.cpp	Tue Feb 12 10:17:11 2013 +0600
@@ -3011,20 +3011,20 @@
   //double v14; // st7@84
   //int v15; // eax@87
   //double v16; // st7@87
-  int v17; // eax@88
-  double v18; // st7@88
-  int v19; // eax@89
-  double v20; // st7@89
-  int v21; // eax@92
-  double v22; // st7@92
-  int v23; // eax@96
-  double v24; // st7@96
-  int v25; // eax@97
-  double v26; // st7@97
-  int v27; // eax@98
-  double v28; // st7@98
-  signed __int64 v29; // qax@98
-  unsigned int v30; // eax@103
+  //int v17; // eax@88
+  //double v18; // st7@88
+  //int v19; // eax@89
+  //double v20; // st7@89
+  //int v21; // eax@92
+  //double v22; // st7@92
+  //int v23; // eax@96
+  //double v24; // st7@96
+  //int v25; // eax@97
+  //double v26; // st7@97
+  //int v27; // eax@98
+  //double v28; // st7@98
+  //signed __int64 v29; // qax@98
+  //unsigned int v30; // eax@103
   int v31; // eax@130
   int v32; // ecx@141
   signed int v33; // eax@143
@@ -3087,9 +3087,9 @@
   signed int v90; // [sp-14h] [bp-A8h]@246
   signed int v91; // [sp-10h] [bp-A4h]@246
   int v92; // [sp-Ch] [bp-A0h]@246
-  int v93; // [sp-8h] [bp-9Ch]@104
+  //int v93; // [sp-8h] [bp-9Ch]@104
   unsigned int v94; // [sp-8h] [bp-9Ch]@246
-  int v95; // [sp-4h] [bp-98h]@104
+  //int v95; // [sp-4h] [bp-98h]@104
   int v96; // [sp-4h] [bp-98h]@246
   int v97; // [sp+Ch] [bp-88h]@180
   Vec3_int_ v98;
@@ -3262,7 +3262,6 @@
                                                                     * stru_5C6E00->uIntegerPi)
                                                        / 180)) >> 16);*/
   __int64 dturn = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16;
-LABEL_118:
   while ( pPartyActionQueue->uNumActions )
   {
     switch ( pPartyActionQueue->Next() )
@@ -3371,8 +3370,6 @@
 
       case PARTY_StrafeLeft:
       {
-        //v13 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
-        //v14 = (double)_walk_speed;
         *(float *)&v128 = pParty->uWalkSpeed;
 
         float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0);
@@ -3390,14 +3387,7 @@
 
       case PARTY_StrafeRight:
       {
-        //v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
         *(float *)&v128 = pParty->uWalkSpeed;
-        /*v124 = (unsigned __int64)(v126 * (signed __int64)((signed int)(signed __int64)(pParty->uWalkSpeed * fWalkSpeedMultiplier) >> 1)) >> 16;
-        v2 += v124;
-        v126 = stru_5C6E00->SinCos(_angle_y);
-        v124 = (unsigned __int64)(v126
-                                * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16;
-        v1 -= v124;*/
         float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0);
         int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
         v2 += 3 * dx / 4;
@@ -3412,69 +3402,93 @@
       break;
 
       case PARTY_WalkForward:
-        v17 = stru_5C6E00->SinCos(_angle_y);
-        v18 = (double)_walk_speed;
-        v126 = v17;
-        *(float *)&v128 = v18;
-        v124 = (unsigned __int64)(v17 * (signed __int64)(signed int)(signed __int64)(v18 * fWalkSpeedMultiplier)) >> 16;
-        v2 += v124;
-        v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
-        v124 = (unsigned __int64)(v126
-                                * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16;
-        v1 += v124;
-        v128 = v1;
-        v124 = 1;
-      break;
-
-      case PARTY_WalkBackward:
-        v19 = stru_5C6E00->SinCos(_angle_y);
-        v20 = (double)_walk_speed;
-        v126 = v19;
-        *(float *)&v128 = v20;
-        v124 = (unsigned __int64)(v19
-                                * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardWalkSpeedMultiplier)) >> 16;
-        v2 -= v124;
-        v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
-        v124 = (unsigned __int64)(v126
-                                * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
-                                                                             * fBackwardWalkSpeedMultiplier)) >> 16;
-        v1 -= v124;
+        {
+        *(float *)&v128 = _walk_speed;
+
+        float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
+              cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
+
+        int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
+        v2 += dx;
+        
+        int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
+        v1 += dy;
         v128 = v1;
         v124 = 1;
       break;
-
       case PARTY_RunForward:
-        if ( pParty->bFlying )
-        {
-          v21 = stru_5C6E00->SinCos(_angle_y);
-          v22 = (double)_walk_speed;
-          v126 = v21;
-          *(float *)&v128 = v22;
-          v129 = (unsigned __int64)(v21
-                                  * (signed __int64)(signed int)(4
-                                                               * (unsigned __int64)(signed __int64)(v22
-                                                                                                  * fWalkSpeedMultiplier))) >> 16;
-          v2 += v129;
-          v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
-          v129 = (unsigned __int64)(v126
-                                  * (signed __int64)(signed int)(4
-                                                               * (unsigned __int64)(signed __int64)(*(float *)&v128
-                                                                                                  * fWalkSpeedMultiplier))) >> 16;
-          v1 += v129;
-          goto LABEL_93;
-        }
-        if ( partyAtHighSlope && !v108 )
-        {
-          v23 = stru_5C6E00->SinCos(_angle_y);
-          v24 = (double)_walk_speed;
-          v126 = v23;
-          *(float *)&v128 = v24;
-          v129 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
-          v2 += v129;
-          v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
-          v129 = (unsigned __int64)(v126
-                                  * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16;
-          v1 += v129;
+      {
+        *(float *)&v128 = _walk_speed;
+
+        float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
+              cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
+
+        int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;        
+        int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
+
+        if (pParty->bFlying)
+        {
+          v2 += 4 * dx;
+          v1 += 4 * dy;
+
+          v128 = v1;
+        }
+        else if (partyAtHighSlope && !v108)
+        {
+          v2 += dx;
+          v1 += dy;
+
+          v128 = v1;
+          v124 = 1;
+        }
+        else
+        {
+          v2 += 2 * dx;
+          v1 += 2 * dy;
+          
+          v128 = v1;
+          v114 = 1;
+        }
+      }
+      break;
+
+      case PARTY_WalkBackward:
+      {
+        *(float *)&v128 = _walk_speed;
+
+        float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
+              cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
+
+        int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
+        v2 -= dx;
+        
+        int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
+        v1 -= dy;
+
+        v128 = v1;
+        v124 = 1;
+      }
+      break;
+
+      case PARTY_RunBackward:
+      {
+        float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
+              cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
+
+        int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;        
+        int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
+
+        if (pParty->bFlying)
+        {
+          v2 -= 4 * dx;
+          v1 -= 4 * dy;
+          v128 = v1;
+        }
+        else
+        {
+          v2 -= dx;
+          v1 -= dy;
+
           v128 = v1;
           v124 = 1;
           break;