diff Actor.cpp @ 1864:b6258f64e313

Actor::GetDirectionInfo some minor changes
author Grumpy7
date Mon, 14 Oct 2013 08:00:30 +0200
parents 97b75e6100ff
children e622546c8f0c
line wrap: on
line diff
--- a/Actor.cpp	Mon Oct 14 07:40:44 2013 +0200
+++ b/Actor.cpp	Mon Oct 14 08:00:30 2013 +0200
@@ -947,48 +947,17 @@
 // // originally this function had following prototype:
 // // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4)
 // // but compiler converts functions returning structures by value in the such way
-AIDirection *__fastcall Actor::GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, AIDirection *pOut, int a4)
+struct AIDirection * Actor::GetDirectionInfo( unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4 )
 {
   signed int v4; // eax@1
   signed int v5; // ecx@1
-  //unsigned int v6; // ebx@1
-  int v7; // ecx@2
-  int v8; // ecx@3
-  int v9; // ecx@4
-  //BLVFace *v10; // eax@8
-  //unsigned int v11; // ecx@8
-  //signed int v12; // eax@9
-  //int v13; // ecx@9
-  //int v14; // eax@9
-  int v15; // eax@11
-  int v16; // eax@12
-  int v17; // eax@13
   int v18; // edx@15
-  //signed int v19; // eax@25
-  //signed int v20; // eax@28
-  //int v21; // ebx@28
-  //signed int v22; // eax@28
-  //BLVFace *v23; // eax@35
-  //int v24; // edx@35
-  //unsigned int v25; // ecx@35
-  //signed int v26; // eax@36
-  //int v27; // ecx@36
-  //int v28; // eax@36
-  //int v29; // eax@37
-  //signed int v30; // eax@42
-  double v31; // st7@45
-  double v32; // st6@45
-  double v33; // st7@45
+  float v31; // st7@45
+  float v32; // st6@45
+  float v33; // st7@45
   AIDirection *result; // eax@48
-  //int v35; // [sp-18h] [bp-64h]@17
-  //int v36; // [sp-14h] [bp-60h]@17
   Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15
-  //int *v38; // [sp-4h] [bp-50h]@15
-  //int *v39; // [sp+0h] [bp-4Ch]@15
-  //int *v40; // [sp+4h] [bp-48h]@15
   AIDirection v41; // [sp+14h] [bp-38h]@46
-  float v42; // [sp+30h] [bp-1Ch]@23
-  float v43; // [sp+34h] [bp-18h]@45
   float outy2; // [sp+38h] [bp-14h]@33
   float outx2; // [sp+3Ch] [bp-10h]@33
   int outz; // [sp+40h] [bp-Ch]@6
@@ -1028,7 +997,8 @@
       {
         v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
         v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-        *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
+        v37.x = pParty->vPosition.x;
+        v37.y = pParty->vPosition.y;
         Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz);
         break;
       }
@@ -1036,7 +1006,8 @@
       {
         v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
         v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
-        *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
+        v37.x = pParty->vPosition.x;
+        v37.y = pParty->vPosition.y;
         Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz);
         break;
       }
@@ -1044,7 +1015,8 @@
       {
         v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
-        *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
+        v37.x = pParty->vPosition.x;
+        v37.y = pParty->vPosition.y;
         Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz);
         break;
       }
@@ -1052,7 +1024,8 @@
       {
         v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
-        *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
+        v37.x = pParty->vPosition.x;
+        v37.y = pParty->vPosition.y;
         Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz);
         break;
       }
@@ -1087,22 +1060,22 @@
   {
     case OBJECT_Item:
     {
-      outx2 = pSpriteObjects[v5].vPosition.x;
-      outy2 = pSpriteObjects[v5].vPosition.y;
+      outx2 = (float)pSpriteObjects[v5].vPosition.x;
+      outy2 =(float) pSpriteObjects[v5].vPosition.y;
       a4 = pSpriteObjects[v5].vPosition.z;
       break;
     }
     case OBJECT_Actor:
     {
-      outx2 = pActors[v5].vPosition.x;
-      outy2 = pActors[v5].vPosition.y;
+      outx2 = (float)pActors[v5].vPosition.x;
+      outy2 = (float)pActors[v5].vPosition.y;
       a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75);
       break;
     }
     case OBJECT_Player:
     {
-      outx2 = pParty->vPosition.x;
-      outy2 = pParty->vPosition.y;
+      outx2 = (float)pParty->vPosition.x;
+      outy2 = (float)pParty->vPosition.y;
       if ( !a4 )
         a4 = pParty->sEyelevel;
       a4 = pParty->vPosition.z + a4;
@@ -1110,8 +1083,8 @@
     }
     case OBJECT_Decoration:
     {
-      outx2 = pLevelDecorations[v5].vPosition.x;
-      outy2 = pLevelDecorations[v5].vPosition.y;
+      outx2 = (float)pLevelDecorations[v5].vPosition.x;
+      outy2 = (float)pLevelDecorations[v5].vPosition.y;
       a4 = pLevelDecorations[v5].vPosition.z;
       break;
     }
@@ -1126,19 +1099,17 @@
     {
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
       {
-        outx2 = (pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1;
-        outy2 = (pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1;
+        outx2 = (float)((pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1);
+        outy2 = (float)((pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1);
         a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1;
       }
       break;
     }
   }
   
-  v31 = (double)outx2 - (double)outx;
-  v42 = v31;
-  v32 = (double)outy2 - (double)outy;
-  v43 = v32;
-  a4a = (double)a4 - (double)outz;
+  v31 = (float)outx2 - (float)outx;
+  v32 = (float)outy2 - (float)outy;
+  a4a = (float)a4 - (float)outz;
   outx2 = v32 * v32;
   outy2 = v31 * v31;
   v33 = sqrt(a4a * a4a + outy2 + outx2);
@@ -1154,12 +1125,12 @@
   }
   else
   {
-    v41.vDirection.x = (signed __int64)(1.0 / v33 * v42 * 65536.0);
-    v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0);
-    v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0);
-    v41.uDistance = (signed __int64)v33;
-    v41.uDistanceXZ = sqrt(outy2 + outx2);
-    v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43);
+    v41.vDirection.x = (int32_t)(1.0 / v33 * v31 * 65536.0);
+    v41.vDirection.y = (int32_t)(1.0 / v33 * v32 * 65536.0);
+    v41.vDirection.z = (int32_t)(1.0 / v33 * a4a * 65536.0);
+    v41.uDistance = (uint)v33;
+    v41.uDistanceXZ = (uint)sqrt(outy2 + outx2);
+    v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v31, (signed __int64)v32);
     v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a);
   }
   result = pOut;