diff Actor.cpp @ 1897:436553b0603c

_46DF1A_collide_against_actor cleaned up, moved to Actor.h
author Grumpy7
date Sun, 20 Oct 2013 22:58:27 -0700
parents b6a7410ff0ef
children 768590235c2c
line wrap: on
line diff
--- a/Actor.cpp	Sun Oct 20 02:52:48 2013 -0700
+++ b/Actor.cpp	Sun Oct 20 22:58:27 2013 -0700
@@ -2787,71 +2787,58 @@
 }
 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
 //----- (0046DF1A) --------------------------------------------------------
-signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2)
+bool Actor::_46DF1A_collide_against_actor( int a1, int a2 )
 {
   Actor *v2; // edi@1
   unsigned __int16 v3; // ax@1
   int v4; // esi@6
-  int v5; // ecx@8
-  int v6; // eax@10
-  int v7; // edx@12
   int v8; // ecx@14
   int v9; // eax@14
   int v10; // ebx@14
   int v11; // esi@14
   int v12; // ebx@15
   int v13; // ebx@17
-  unsigned int v14; // eax@20
-  signed int result; // eax@21
-  int v16; // [sp+Ch] [bp-10h]@1
-  int v17; // [sp+10h] [bp-Ch]@14
-  int v18; // [sp+14h] [bp-8h]@14
-  int v19; // [sp+18h] [bp-4h]@14
 
-  v16 = a1;
   v2 = &pActors[a1];
   v3 = v2->uAIState;
-  if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 )
-    goto LABEL_25;
+  if ( v3 == Removed || v3 == Dying || v3 == Disabled || v3 == Dead || v3 == Summoned )
+    return 0;
   v4 = v2->uActorRadius;
   if ( a2 )
     v4 = a2;
-  v5 = v2->vPosition.x;
-  if ( stru_721530.sMaxX > v5 + v4
-    || stru_721530.sMinX < v5 - v4
-    || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4)
-    || stru_721530.sMinY < v6 - v4
-    || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight)
-    || stru_721530.sMinZ < v7
-    || (v8 = v5 - stru_721530.normal.x,
-        v9 = v6 - stru_721530.normal.y,
-        v10 = stru_721530.prolly_normal_d + v4,
-        v17 = stru_721530.prolly_normal_d + v4,
-        v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16,
-        v18 = v8,
-        v19 = v9,
-        abs((v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16) > v10)
-    || (v12 = (v18 * stru_721530.direction.x + v19 * stru_721530.direction.y) >> 16, v12 <= 0)
-    || (signed int)(((unsigned __int64)(stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z )
+
+  if (stru_721530.sMaxX > v2->vPosition.x + v4 || 
+      stru_721530.sMinX < v2->vPosition.x - v4 || 
+      stru_721530.sMaxY > v2->vPosition.y + v4 || 
+      stru_721530.sMinY < v2->vPosition.y - v4 ||
+      stru_721530.sMaxZ > v2->vPosition.z + v2->uActorHeight ||
+      stru_721530.sMinZ < v2->vPosition.z)
+  {
+    return false;
+  }
+  v8 = v2->vPosition.x - stru_721530.normal.x;
+  v9 = v2->vPosition.y - stru_721530.normal.y;
+  v10 = stru_721530.prolly_normal_d + v4;
+  v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16;
+  v12 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16;
+  if ( abs(v11) > v10 || v12 <= 0)
   {
-LABEL_25:
-    result = 0;
+    return false;
   }
-  else
+  if (((stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z < v2->vPosition.z)
   {
-    v13 = v12 - integer_sqrt(v17 * v17 - v11 * v11);
-    if ( v13 < 0 )
-      v13 = 0;
-    if ( v13 < stru_721530.field_7C )
-    {
-      stru_721530.field_7C = v13;
-      v14 = 8 * v16;
-      LOBYTE(v14) = PID(OBJECT_Actor,v16);
-      stru_721530.uFaceID = v14;
-    }
-    result = 1;
+    return false;
   }
-  return result;
+
+  v13 = v12 - integer_sqrt(v10 * v10 - v11 * v11);
+  if ( v13 < 0 )
+    v13 = 0;
+  if ( v13 < stru_721530.field_7C )
+  {
+    stru_721530.field_7C = v13;
+    stru_721530.uFaceID = PID(OBJECT_Actor,a1);
+  }
+  return true;
 }
 //----- (00401A91) --------------------------------------------------------
 void  UpdateActorAI()