diff Actor.cpp @ 848:ceef50611567

* AI fixed (temporary) * PID_ID, PID_TYPE replaces * >> 7 error in AudioPlayer
author zipi
date Sun, 31 Mar 2013 10:44:43 +0100
parents dfd683c4f538
children 8fafe3645f36
line wrap: on
line diff
--- a/Actor.cpp	Sat Mar 30 19:36:05 2013 +0400
+++ b/Actor.cpp	Sun Mar 31 10:44:43 2013 +0100
@@ -1757,8 +1757,8 @@
   int outx; // [sp+48h] [bp-4h]@6
   float a4a; // [sp+58h] [bp+Ch]@45
 
-  v4 = (signed int)uObj1ID >> 3;
-  v5 = (uObj1ID & 7) - 2;
+  v4 = PID_ID(uObj1ID);
+  v5 = PID_TYPE(uObj1ID) - 2;
   v6 = uObj2ID;
   if ( !v5 )
   {
@@ -1868,8 +1868,8 @@
   }
 LABEL_28:
   v20 = v6;
-  v21 = v6 & 7;
-  v22 = v20 >> 3;
+  v21 = PID_TYPE(v6);
+  v22 = PID_ID(v20);
   if ( v21 == 2 )
   {
     v30 = v22;
@@ -2050,7 +2050,7 @@
 }
 
 //----- (00403C6C) --------------------------------------------------------
-void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0)
+void Actor::_403C6C(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0)
 {
   Actor *v3; // ebx@1
   char v4; // zf@1
@@ -2071,31 +2071,31 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@12
   AIDirection v20; // [sp+28h] [bp-2Ch]@12
   unsigned int v21; // [sp+44h] [bp-10h]@9
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   int v23; // [sp+4Ch] [bp-8h]@6
   unsigned int v24; // [sp+50h] [bp-4h]@1
   unsigned int v25; // [sp+5Ch] [bp+8h]@13
 
   v3 = &pActors[uActorID];
-  a2 = edx0;
+  //a2 = edx0;
   v4 = v3->pMonsterInfo.uMovementType == 5;
   v24 = uActorID;
   if ( v4 && v3->pMonsterInfo.uAIType == 1 )
   {
-    Actor::AI_Stand(uActorID, edx0, 0, arg0);
+    Actor::AI_Stand(uActorID, sTargetPid, 0, arg0);
     return;
   }
 
-  if ( (edx0 & 7) == OBJECT_Actor)
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
     {
-      v8 = edx0 >> 3;
+      v8 = PID_ID(sTargetPid);
       v6 = (AIDirection *)pActors[v8].vPosition.x;
       v7 = (AIDirection *)pActors[v8].vPosition.y;
       v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z);
     }
     else
     {
-      if ( (edx0 & 7) == OBJECT_Player)
+      if ( PID_TYPE(sTargetPid) == OBJECT_Player)
       {
         v6 = (AIDirection *)pParty->vPosition.x;
         v7 = (AIDirection *)pParty->vPosition.y;
@@ -2119,7 +2119,7 @@
       v13 = 0;
       if ( !arg0 )
       {
-        v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0);
+        v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0);
         v12 = &v20;
         memcpy(&v20, v14, sizeof(v20));
         v13 = 0;
@@ -2149,7 +2149,7 @@
       v3->UpdateAnimation();
     }
     else
-      Actor::_402AD7(v24, a2, rand() % 2, 64, arg0);
+      Actor::_402AD7(v24, sTargetPid, rand() % 2, 64, arg0);
 }
 
 //----- (00438CF3) --------------------------------------------------------
@@ -2482,16 +2482,16 @@
   v22 = uActorID;
   v3 = &pActors[uActorID];
   a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  if ( PID_TYPE(edx0) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(edx0);
     v4 = (AIDirection *)pActors[v6].vPosition.x;
     v5 = (AIDirection *)pActors[v6].vPosition.y;
     v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(edx0) == OBJECT_Player)
     {
       v4 = (AIDirection *)pParty->vPosition.x;
       v5 = (AIDirection *)pParty->vPosition.y;
@@ -2561,7 +2561,7 @@
 }
 
 //----- (00403854) --------------------------------------------------------
-void Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_403854(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2580,24 +2580,24 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@9
   AIDirection v18; // [sp+28h] [bp-2Ch]@9
   int v19; // [sp+44h] [bp-10h]@6
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   int v21; // [sp+4Ch] [bp-8h]@3
   unsigned int v22; // [sp+50h] [bp-4h]@1
   unsigned int pDira; // [sp+5Ch] [bp+8h]@10
 
   v22 = uActorID;
   v3 = &pActors[uActorID];
-  a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  //a2 = edx0;
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(sTargetPid);
     v4 = (AIDirection *)pActors[v6].vPosition.x;
     v5 = (AIDirection *)pActors[v6].vPosition.y;
     v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
     {
       v4 = (AIDirection *)pParty->vPosition.x;
       v5 = (AIDirection *)pParty->vPosition.y;
@@ -2619,7 +2619,7 @@
     v10 = 0;
     if ( !pDir )
     {
-      v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0);
+      v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, sTargetPid, &a3, 0);
       v9 = &v18;
       memcpy(&v18, v11, sizeof(v18));
       v10 = 0;
@@ -2663,11 +2663,11 @@
       v3->UpdateAnimation();
   }
   else
-    Actor::_402AD7(v22, a2, v22, 64, pDir);
+    Actor::_402AD7(v22, sTargetPid, v22, 64, pDir);
 }
 
 //----- (0040368B) --------------------------------------------------------
-void Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_40368B(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   AIDirection *v4; // esi@3
@@ -2685,24 +2685,24 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@9
   AIDirection v17; // [sp+28h] [bp-2Ch]@9
   int v18; // [sp+44h] [bp-10h]@6
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   int v20; // [sp+4Ch] [bp-8h]@3
   unsigned int v21; // [sp+50h] [bp-4h]@1
   unsigned int pDira; // [sp+5Ch] [bp+8h]@10
 
   v21 = uActorID;
   v3 = &pActors[uActorID];
-  a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  //a2 = edx0;
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(sTargetPid);
     v4 = (AIDirection *)pActors[v6].vPosition.x;
     v5 = (AIDirection *)pActors[v6].vPosition.y;
     v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
     {
       v4 = (AIDirection *)pParty->vPosition.x;
       v5 = (AIDirection *)pParty->vPosition.y;
@@ -2724,7 +2724,7 @@
     v10 = 0;
     if ( !pDir )
     {
-      v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0);
+      v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0);
       v9 = &v17;
       memcpy(&v17, v11, sizeof(v17));
       v10 = 0;
@@ -2754,11 +2754,11 @@
     v3->UpdateAnimation();
   }
   else
-    Actor::_402AD7(v21, a2, v21, 64, pDir);
+    Actor::_402AD7(v21, sTargetPid, v21, 64, pDir);
 }
 
 //----- (00403476) --------------------------------------------------------
-void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir)
+void Actor::_403476(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir)
 {
   Actor *v3; // ebx@1
   int v4; // esi@3
@@ -2777,24 +2777,24 @@
   AIDirection a3; // [sp+Ch] [bp-48h]@10
   AIDirection v18; // [sp+28h] [bp-2Ch]@10
   int v19; // [sp+44h] [bp-10h]@6
-  signed int a2; // [sp+48h] [bp-Ch]@1
+  //signed int a2; // [sp+48h] [bp-Ch]@1
   unsigned int v21; // [sp+4Ch] [bp-8h]@1
   int v22; // [sp+50h] [bp-4h]@3
   unsigned int pDira; // [sp+5Ch] [bp+8h]@11
 
   v21 = uActorID;
   v3 = &pActors[uActorID];
-  a2 = edx0;
-  if ( (edx0 & 7) == OBJECT_Actor)
+  //a2 = edx0;
+  if ( PID_TYPE(sTargetPid) == OBJECT_Actor)
   {
-    v6 = edx0 >> 3;
+    v6 = PID_ID(sTargetPid);
     v4 = pActors[v6].vPosition.x;
     v5 = pActors[v6].vPosition.y;
     v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z);
   }
   else
   {
-    if ( (edx0 & 7) == OBJECT_Player)
+    if ( PID_TYPE(sTargetPid) == OBJECT_Player)
     {
       v4 = pParty->vPosition.x;
       v5 = pParty->vPosition.y;
@@ -2824,7 +2824,7 @@
     v11 = 0;
     if ( !pDir )
     {
-      v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0);
+      v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0);
       v10 = &v18;
       memcpy(&v18, v12, sizeof(v18));
       v11 = 0;
@@ -2858,7 +2858,7 @@
     v3->UpdateAnimation();
   }
   else
-    Actor::_402AD7(v21, a2, v21, 64, pDir);
+    Actor::_402AD7(v21, sTargetPid, v21, 64, pDir);
 }
 
 //----- (004032B2) --------------------------------------------------------
@@ -3304,7 +3304,7 @@
 }
 
 //----- (00402968) --------------------------------------------------------
-void Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4)
+void Actor::_402968(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4)
 {
   unsigned int v4; // esi@1
   Actor *v5; // ebx@1
@@ -3318,10 +3318,10 @@
   AIDirection v13; // [sp+5Ch] [bp-28h]@4
   signed int a1; // [sp+78h] [bp-Ch]@2
   unsigned int v15; // [sp+7Ch] [bp-8h]@1
-  signed int a2; // [sp+80h] [bp-4h]@1
+  //signed int a2; // [sp+80h] [bp-4h]@1
 
   v4 = uActorID;
-  a2 = edx0;
+  //a2 = edx0;
   v15 = uActorID;
   v5 = &pActors[uActorID];
   //result = pActors[uActorID].CanAct();
@@ -3332,13 +3332,13 @@
     if ( !a4 )
     {
       a4 = &v12;
-      memcpy(&v12, Actor::GetDirectionInfo(v7, a2, &a3, v5->pMonsterInfo.uFlying), sizeof(v12));
+      memcpy(&v12, Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying), sizeof(v12));
       v7 = a1;
     }
     memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3));
     memcpy(&v13, &a3, sizeof(v13));
     if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)
-      || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 )
+      || PID_TYPE(sTargetPid) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 )
     {
       if ( !uActionLength )
         uActionLength = 256;
@@ -3660,7 +3660,7 @@
       v14 = 4;
     if ( v14 != 0 )
     {
-      v15 = dword_4DF390;
+      v15 = dword_4DF380[4];
       if ( !_this->pMonsterInfo.uHostilityType )
         v15 = dword_4DF380[v14];
       v16 = abs(_this->vPosition.x - pParty->vPosition.x);