changeset 448:ee47cc585e1b

Слияние
author Ritor1
date Sat, 23 Feb 2013 23:46:20 +0600
parents 7c6e68307484 (current diff) 913675aac25b (diff)
children 510fb376ef2f
files lib/legacy_dx/lib/.svn/all-wcprops lib/legacy_dx/lib/.svn/entries lib/legacy_dx/lib/.svn/prop-base/d3dxof.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/ddraw.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/dinput.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/dinput8.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/dxguid.lib.svn-base lib/legacy_dx/lib/.svn/text-base/d3dxof.lib.svn-base lib/legacy_dx/lib/.svn/text-base/ddraw.lib.svn-base lib/legacy_dx/lib/.svn/text-base/dinput.lib.svn-base lib/legacy_dx/lib/.svn/text-base/dinput8.lib.svn-base lib/legacy_dx/lib/.svn/text-base/dxguid.lib.svn-base mm7_4.cpp mm7_data.h
diffstat 20 files changed, 136 insertions(+), 443 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Sat Feb 23 23:45:50 2013 +0600
+++ b/Actor.cpp	Sat Feb 23 23:46:20 2013 +0600
@@ -3055,42 +3055,19 @@
 //----- (00402F87) --------------------------------------------------------
 void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4)
 {
-  //int v3; // edi@1
-  //AIDirection *v4; // esi@1
-  //Actor *v5; // ebx@1
-  //SpriteFrame *v6; // ecx@3
   unsigned int v7; // eax@3
-  //int v8; // edx@3
   unsigned int v9; // eax@3
-  //int result; // eax@4
-  AIDirection a3; // [sp+Ch] [bp-5Ch]@2
-  //AIDirection v12; // [sp+28h] [bp-40h]@2
-  //AIDirection v13; // [sp+44h] [bp-24h]@2
-  //unsigned int v14; // [sp+60h] [bp-8h]@1
-  //unsigned int v15; // [sp+64h] [bp-4h]@1
 
   assert(uActorID < uNumActors);
   auto actor = pActors + uActorID;
-
-  //v3 = uActorID;
-  //v4 = a4;
-  //v5 = &pActors[uActorID];
-  //v14 = uObjID;
-  //v15 = uActorID;
+  
+  AIDirection a3; // [sp+Ch] [bp-5Ch]@2
   if (!a4)
     a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0);
-  /*{
-    memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, (int)a4), sizeof(v13));
-    memcpy(&v12, &v13, sizeof(v12));
-    v3 = v15;
-    v4 = &v12;
-  }*/
 
-  //v6 = pSpriteFrameTable->pSpriteSFrames;
   actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength;
 
   v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y);
-  //LOWORD(v8) = actor->uYawAngle;
   v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7;
 
   if ( BYTE1(v9) & 7 )      // turned away - just stand
@@ -3572,146 +3549,137 @@
   v6->UpdateAnimation();
 }
 
-//----- (00401221) --------------------------------------------------------
-void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3)
+//----- (00SelectTarget) --------------------------------------------------------
+void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party)
 {
-  Actor *v3; // esi@1
-  unsigned int v4; // ebx@1
+  //Actor *v3; // esi@1
+  //unsigned int v4; // ebx@1
   int v5; // ecx@1
-  unsigned int v6; // eax@1
-  Actor *v7; // edi@2
-  __int16 v8; // ax@3
+  //unsigned int v6; // eax@1
+  //Actor *v7; // edi@2
+  //__int16 v8; // ax@3
   int v9; // eax@10
   signed int v10; // eax@13
   int v11; // ebx@16
   int v12; // eax@16
-  int v13; // eax@25
+  //int v13; // eax@25
   signed int v14; // eax@31
   int v15; // edi@43
   int v16; // ebx@45
   int v17; // eax@45
-  int v18; // eax@51
+  //int v18; // eax@51
   int v19; // [sp+Ch] [bp-24h]@16
-  int *v20; // [sp+10h] [bp-20h]@1
+  //int *v20; // [sp+10h] [bp-20h]@1
   signed int v21; // [sp+14h] [bp-1Ch]@1
-  unsigned int v22; // [sp+18h] [bp-18h]@1
+  //unsigned int v22; // [sp+18h] [bp-18h]@1
   int v23; // [sp+1Ch] [bp-14h]@16
-  unsigned int v24; // [sp+20h] [bp-10h]@1
+  //unsigned int v24; // [sp+20h] [bp-10h]@1
   int v25; // [sp+24h] [bp-Ch]@1
-  signed int v26; // [sp+28h] [bp-8h]@1
+  //signed int v26; // [sp+28h] [bp-8h]@1
   int v27; // [sp+2Ch] [bp-4h]@16
   int v28; // [sp+2Ch] [bp-4h]@45
 
   v25 = -1;
-  v22 = uActorID;
-  v3 = &pActors[uActorID];
-  v4 = 0;
+  //v22 = uActorID;
+  //v3 = &pActors[uActorID];
+  //v4 = 0;
   v5 = 0;
-  v6 = v3->uLastCharacterIDToHit;
+  //v6 = v3->uLastCharacterIDToHit;
   *a2 = 0;
-  v20 = a2;
+  //v20 = a2;
   v21 = 0;
-  v24 = v6;
-  v26 = 0;
-  if ( (signed int)uNumActors > 0 )
+  //v24 = v3->uLastCharacterIDToHit;
+  //v26 = 0;
+  assert(uActorID < uNumActors);
+  auto _this = pActors + uActorID;
+
+  for (uint i = 0; i < uNumActors; ++i)
   {
-	  v7 = pActors;
-	  do
-	  {
-		v8 = v7->uAIState;
-		if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 )
+    auto actor = pActors + i;
+	  //v7 = pActors;
+	  //do
+	  //{
+		//v8 = v7->uAIState;
+    if (actor->uAIState == Dead || actor->uAIState == Dying ||
+        actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i )
+      continue;
+
+		if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, _this->uLastCharacterIDToHit != v9) )
 		{
-			++v7;
-			v5 = v26++ + 1;
+		  v10 = _this->GetActorsRelation(actor);
+		  if ( v10 == 0 )
 			continue;
 		}
-		if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) )
+		else if (_this->IsNotAlive())
 		{
-		  v10 = v3->GetActorsRelation(v7);
-		  if ( v10 == v4 )
-		  {
-			++v7;
-			v5 = v26++ + 1;
+		  _this->uLastCharacterIDToHit = 0;
+		  v10 = _this->GetActorsRelation(actor);
+		  if ( v10 == 0 )
 			continue;
-		  }
-		}
-		else if (v7->IsNotAlive())
-		{
-		  v24 = v4;
-		  v3->uLastCharacterIDToHit = v4;
-		  v10 = v3->GetActorsRelation(v7);
-		  if ( v10 == v4 )
-		  {
-			++v7;
-			v5 = v26++ + 1;
-			continue;
-		  }
 		}
 		else
 		{
-			v18 = v7->uGroup;
-			if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup )
-			{
-				++v7;
-				v5 = v26++ + 1;
+			//v18 = actor->uGroup;
+			if ( (actor->uGroup != 0 || _this->uGroup != 0) && actor->uGroup == _this->uGroup )
 				continue;
-			}
 			v10 = 4;
 		}
-		if ( v3->pMonsterInfo.uHostilityType )
-		  v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType;
+		if ( _this->pMonsterInfo.uHostilityType )
+		  v10 = pMonsterStats->pInfos[_this->pMonsterInfo.uID].uHostilityType;
 		v11 = dword_4DF380[v10];
-		v23 = abs(v3->vPosition.x - v7->vPosition.x);
-		v27 = abs(v3->vPosition.y - v7->vPosition.y);
-		v12 = abs(v3->vPosition.z - v7->vPosition.z);
+		v23 = abs(_this->vPosition.x - actor->vPosition.x);
+		v27 = abs(_this->vPosition.y - actor->vPosition.y);
+		v12 = abs(_this->vPosition.z - actor->vPosition.z);
 		v19 = v12;
 		if ( v23 <= v11
 		  && v27 <= v11
 		  && v12 <= v11
-		  && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3)
+		  && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor)
 		  && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 )
 		{
 		  v25 = v23 * v23 + v27 * v27 + v19 * v19;
-		  v21 = v26;
+		  v21 = i;
 		}
-		v4 = 0;
-		++v7;
-		v5 = v26++ + 1;
-	  }
-	  while ( v26 < (signed int)uNumActors );
-	  if ( v25 != -1 )
-	  {
-		v13 = 8 * v21;
-		LOBYTE(v13) = 8 * v21 | 3;
-		*v20 = v13;
-	  }
+		//v4 = 0;
+		//++v7;
+		//v5 = v26++ + 1;
+	  //}
+	  //while ( v26 < (signed int)uNumActors );
+
   }
-  if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4
-    && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) )
-    a3 = v4;
-  if ( a3 != v4 )
+  	  if ( v25 != -1 )
+	  {
+		//v13 = 8 * v21;
+		//LOBYTE(v13) = 8 * v21 | OBJECT_Actor;
+		*a2 = 8 * v21 | OBJECT_Actor;
+	  }
+
+  if (pParty->Invisible())
+    can_target_party = false;
+
+  if (can_target_party)
   {
-    v14 = v3->GetActorsRelation(0);
-    if ( BYTE2(v3->uAttributes) & 8
-      && SHIDWORD(v3->pActorBuffs[12].uExpireTime) <= (signed int)v4
-      && (SHIDWORD(v3->pActorBuffs[12].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[12].uExpireTime) <= v4)
-      && SHIDWORD(v3->pActorBuffs[1].uExpireTime) <= (signed int)v4
-      && (SHIDWORD(v3->pActorBuffs[1].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[1].uExpireTime) <= v4)
-      && SHIDWORD(v3->pActorBuffs[2].uExpireTime) <= (signed int)v4
-      && (SHIDWORD(v3->pActorBuffs[2].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[2].uExpireTime) <= v4) )
+    v14 = _this->GetActorsRelation(0);
+    if ( BYTE2(_this->uAttributes) & 8
+      && SHIDWORD(_this->pActorBuffs[12].uExpireTime) <= (signed int)0
+      && (SHIDWORD(_this->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[12].uExpireTime) <= 0)
+      && SHIDWORD(_this->pActorBuffs[1].uExpireTime) <= (signed int)0
+      && (SHIDWORD(_this->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[1].uExpireTime) <= 0)
+      && SHIDWORD(_this->pActorBuffs[2].uExpireTime) <= (signed int)0
+      && (SHIDWORD(_this->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[2].uExpireTime) <= 0) )
       v14 = 4;
-    if ( v14 != v4 )
+    if ( v14 != 0 )
     {
       v15 = dword_4DF390;
-      if ( !v3->pMonsterInfo.uHostilityType )
+      if ( !_this->pMonsterInfo.uHostilityType )
         v15 = dword_4DF380[v14];
-      v16 = abs(v3->vPosition.x - pParty->vPosition.x);
-      v28 = abs(v3->vPosition.y - pParty->vPosition.y);
-      v17 = abs(v3->vPosition.z - pParty->vPosition.z);
+      v16 = abs(_this->vPosition.x - pParty->vPosition.x);
+      v28 = abs(_this->vPosition.y - pParty->vPosition.y);
+      v17 = abs(_this->vPosition.z - pParty->vPosition.z);
       if ( v16 <= v15 && v28 <= v15 && v17 <= v15 )
       {
         if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 )
-          *v20 = 4;
+          *a2 = OBJECT_Player;
       }
     }
   }
--- a/Actor.h	Sat Feb 23 23:45:50 2013 +0600
+++ b/Actor.h	Sat Feb 23 23:46:20 2013 +0600
@@ -201,7 +201,7 @@
   bool IsPeasant();
 
   
-  static void _401221(unsigned int uActorID, int *a2, unsigned int a3);
+  static void _SelectTarget(unsigned int uActorID, int *a2, bool can_target_party);
   static void _402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4);
   static void _40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5);
   static void _402968(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4);
@@ -265,7 +265,7 @@
   char field_B7;
   unsigned int uCurrentActionTime;
   unsigned __int16 pSpriteIDs[8];
-  unsigned __int16 pSoundSampleIDs[4];
+  unsigned __int16 pSoundSampleIDs[4]; // 1 die     3 bored
   struct SpellBuff pActorBuffs[22];
   struct ItemGen array_000234[4];
   unsigned int uGroup;
--- a/LOD.cpp	Sat Feb 23 23:45:50 2013 +0600
+++ b/LOD.cpp	Sat Feb 23 23:46:20 2013 +0600
@@ -1947,53 +1947,36 @@
 //----- (0046188A) --------------------------------------------------------
 int LOD::File::LoadSubIndices(const char *pContainer)
 {
-  LOD::File *v2; // esi@1
+
   unsigned int uDir; // edi@1
-  int uDir_dup; // ebx@2
-  int result; // eax@5
-  LOD::Directory *v6; // eax@7
-  LOD::Directory *v7; // eax@7
-  __int32 v8; // edx@7
-  FILE *v9; // ST00_4@7
-  LOD::Directory *pSubIndices_dup; // eax@7
+  LOD::Directory *curr_index; // eax@7
 
-  v2 = this;
+
   ResetSubIndices();
   uDir = 0;
-  if ( (signed int)v2->header.uNumIndices <= 0 )
-  {
-LABEL_5:
-    result = 3;
-  }
+
+  if ( header.uNumIndices <= 0)
+	  return 3;
   else
-  {
-    uDir_dup = 0;
-    while ( _strcmpi(pContainer, (const char *)&v2->pRoot[uDir_dup]) )
-    {
-      ++uDir;
-      ++uDir_dup;
-      if ( (signed int)uDir >= (signed int)v2->header.uNumIndices )
-        goto LABEL_5;
-    }
-    strcpy((char *)v2->pContainerName, pContainer);
-    v6 = v2->pRoot;
-    v2->uCurrentIndexDir = uDir;
-    v7 = &v6[uDir];
-    v8 = v7->uOfsetFromSubindicesStart;
-    v2->uOffsetToSubIndex = v8;
-    v9 = v2->pFile;
-    v2->uNumSubIndices = v7->uNumSubIndices;
-    fseek(v9, v8, 0);
-    pSubIndices_dup = (LOD::Directory *)pAllocator->AllocNamedChunk(
-                                        v2->pSubIndices,
-                                        32 * (v2->uNumSubIndices + 5),
-                                        "LOD Index");
-    v2->pSubIndices = pSubIndices_dup;
-    if ( pSubIndices_dup )
-      fread(pSubIndices_dup, 0x20u, v2->uNumSubIndices, v2->pFile);
-    result = 0;
-  }
-  return result;
+	  {
+	  while (stricmp(pContainer, pRoot[uDir].pFilename))
+		  {
+		  ++uDir;  
+		  if (uDir >=  header.uNumIndices )
+			  return 3;
+		  }
+	  strcpy( pContainerName, pContainer);
+	  uCurrentIndexDir = uDir;
+	  curr_index=(LOD::Directory *)&pRoot[uDir];
+	  uOffsetToSubIndex =curr_index->uOfsetFromSubindicesStart ;
+	  uNumSubIndices =curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28);
+	  fseek( pFile, uOffsetToSubIndex, 0);
+	  pSubIndices = (LOD::Directory *)pAllocator->AllocNamedChunk(pSubIndices, sizeof(LOD::Directory)*(uNumSubIndices + 5), "LOD Index");
+
+	  if ( pSubIndices)
+		  fread( pSubIndices, sizeof(LOD::Directory),  uNumSubIndices,  pFile);
+	  return 0;
+	  }
 }
 
 //----- (004617D5) --------------------------------------------------------
--- a/lib/legacy_dx/lib/.svn/all-wcprops	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 40
-/svn/bb7/!svn/ver/289/libs/legacy_dx/lib
-END
-dinput8.lib
-K 25
-svn:wc:ra_dav:version-url
-V 52
-/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/dinput8.lib
-END
-ddraw.lib
-K 25
-svn:wc:ra_dav:version-url
-V 50
-/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/ddraw.lib
-END
-dinput.lib
-K 25
-svn:wc:ra_dav:version-url
-V 51
-/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/dinput.lib
-END
-dxguid.lib
-K 25
-svn:wc:ra_dav:version-url
-V 51
-/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/dxguid.lib
-END
-d3dxof.lib
-K 25
-svn:wc:ra_dav:version-url
-V 51
-/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/d3dxof.lib
-END
--- a/lib/legacy_dx/lib/.svn/entries	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-10
-
-dir
-316
-http://svn2.assembla.com/svn/bb7/libs/legacy_dx/lib
-http://svn2.assembla.com/svn/bb7
-
-
-
-2010-12-18T21:09:41.003199Z
-289
-Feaerenil
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b0191bc-8333-4b8d-b53c-6b3aa212730c
-
-dinput8.lib
-file
-
-
-
-
-2004-09-03T13:18:30.000000Z
-a9300cdf7a34c7da7be2117e099e15a7
-2010-12-18T21:09:41.003199Z
-289
-Feaerenil
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-173542
-
-ddraw.lib
-file
-
-
-
-
-2004-09-06T18:58:26.000000Z
-77752b153225ae97f64688aa5c16db31
-2010-12-18T21:09:41.003199Z
-289
-Feaerenil
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4540
-
-dinput.lib
-file
-
-
-
-
-2004-09-03T13:18:30.000000Z
-21f11641cd6d0b29f2979fcad555a81e
-2010-12-18T21:09:41.003199Z
-289
-Feaerenil
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-161464
-
-dxguid.lib
-file
-
-
-
-
-2005-05-26T12:11:04.000000Z
-b5d00b6a24df5706d25ae59b9ff77658
-2010-12-18T21:09:41.003199Z
-289
-Feaerenil
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-408632
-
-d3dxof.lib
-file
-
-
-
-
-2004-09-29T14:47:54.000000Z
-f17de8653cb71aa503a45d7908a6c296
-2010-12-18T21:09:41.003199Z
-289
-Feaerenil
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1746
-
--- a/lib/legacy_dx/lib/.svn/prop-base/d3dxof.lib.svn-base	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 24
-application/octet-stream
-END
--- a/lib/legacy_dx/lib/.svn/prop-base/ddraw.lib.svn-base	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 24
-application/octet-stream
-END
--- a/lib/legacy_dx/lib/.svn/prop-base/dinput.lib.svn-base	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 24
-application/octet-stream
-END
--- a/lib/legacy_dx/lib/.svn/prop-base/dinput8.lib.svn-base	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 24
-application/octet-stream
-END
--- a/lib/legacy_dx/lib/.svn/prop-base/dxguid.lib.svn-base	Sat Feb 23 23:45:50 2013 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 24
-application/octet-stream
-END
Binary file lib/legacy_dx/lib/.svn/text-base/d3dxof.lib.svn-base has changed
Binary file lib/legacy_dx/lib/.svn/text-base/ddraw.lib.svn-base has changed
Binary file lib/legacy_dx/lib/.svn/text-base/dinput.lib.svn-base has changed
Binary file lib/legacy_dx/lib/.svn/text-base/dinput8.lib.svn-base has changed
Binary file lib/legacy_dx/lib/.svn/text-base/dxguid.lib.svn-base has changed
--- a/mm7_3.cpp	Sat Feb 23 23:45:50 2013 +0600
+++ b/mm7_3.cpp	Sat Feb 23 23:46:20 2013 +0600
@@ -17691,7 +17691,7 @@
   //unsigned int v17; // edx@67
   //unsigned int v18; // ecx@67
   //unsigned __int16 v19; // ax@72
-  int *v20; // esi@80
+  //int *v20; // esi@80
   Actor *v21; // ebx@80
   unsigned __int16 v22; // ax@86
   signed int v23; // eax@94
@@ -17848,7 +17848,7 @@
       //pActor = (Actor *)(LODWORD(v80) - 176);
       //v11 = *(unsigned int *)LODWORD(v80);
       //v49 = *(unsigned int *)LODWORD(v80) == 5;
-    dword_4F6E08[i] = 4;
+    ai_near_actors_targets_pid[i] = OBJECT_Player;
     if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400)
       continue;
 
@@ -17937,12 +17937,12 @@
       actor_id = ai_near_actors_ids[v78];
       assert(actor_id < uNumActors);
 
-      v20 = &dword_4F6E08[actor_id];
+      //v20 = &ai_near_actors_targets_pid[actor_id];
       v21 = &pActors[actor_id];
-      Actor::_401221(actor_id, &dword_4F6E08[actor_id], 1u);
-      if ( v21->pMonsterInfo.uHostilityType && !*v20 )
+      Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true);
+      if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id])
         v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-      a2 = *v20;
+      a2 = ai_near_actors_targets_pid[actor_id];
       v76 = a2 & 7;
       if ( (a2 & 7) == OBJECT_Actor)
         v80 = 0.5;
@@ -18696,7 +18696,7 @@
           v7 = v6->uAttributes;
           if ( v7 & 0x8000 < 0 )
           {
-            v8 = dword_4F6E08[v5];
+            v8 = ai_near_actors_targets_pid[v5];
             LOBYTE(v7) = v7 | 0x80;
             v6->uAttributes = v7;
             v33 = 8 * v5 | OBJECT_Actor;
--- a/mm7_4.cpp	Sat Feb 23 23:45:50 2013 +0600
+++ b/mm7_4.cpp	Sat Feb 23 23:46:20 2013 +0600
@@ -14374,8 +14374,8 @@
             v4->uCurrentActionTime += pMiscTimer->uTimeElapsed;
             if ( (signed int)v4->uCurrentActionTime >= v5 )
             {
-              v17 = dword_4F6E08[v20];
-              v6 = Actor::GetDirectionInfo(8 * v20 | 3, v17, &a3, v2);
+              v17 = ai_near_actors_targets_pid[v20];
+              v6 = Actor::GetDirectionInfo(8 * v20 | OBJECT_Actor, v17, &a3, v2);
               v7 = v4->uAIState;
               memcpy(&v15, v6, sizeof(v15));
               v8 = v7 - 4;
--- a/mm7_5.cpp	Sat Feb 23 23:45:50 2013 +0600
+++ b/mm7_5.cpp	Sat Feb 23 23:46:20 2013 +0600
@@ -4749,7 +4749,7 @@
       v37 = v3;
       if ( stru_50FE08.field_3EC[v0] & 1 )
       {
-        v6 = dword_4F6E08[v3];
+        v6 = ai_near_actors_targets_pid[v3];
         v7 = v6 >> 3;
         v8 = (v6 & 7) - 3;
         uActorID = v7;
@@ -9721,7 +9721,7 @@
           if ( v6 != 8 )
             goto LABEL_19;
           v3 = 0;
-          Actor::AI_StandOrBored(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0);
+          Actor::AI_StandOrBored(v2->uPackedID >> 3, ai_near_actors_targets_pid[v2->uPackedID >> 3], 32, 0);
         }
       }
     }
@@ -9753,7 +9753,7 @@
           {
             if ( v11 != 17 )
             {
-              v12 = dword_4F6E08[v10];
+              v12 = ai_near_actors_targets_pid[v10];
               v9->uActionLength = v3;
               Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3);
             }
@@ -10044,8 +10044,8 @@
   if ( (v1->uPackedID & 7) != OBJECT_Player)
   {
     v4 = v3 >> 3;                               // turn based only stuff
-    a2a = dword_4F6E08[v3 >> 3];
-    memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, dword_4F6E08[v3 >> 3], &a3, 0), sizeof(a3));
+    a2a = ai_near_actors_targets_pid[v3 >> 3];
+    memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[v3 >> 3], &a3, 0), sizeof(a3));
     memcpy(&a4, &a3, sizeof(a4));
     v5 = &pActors[v3 >> 3];
     LOWORD(v3) = v5->uAIState;
@@ -10189,8 +10189,8 @@
     {
       if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 )
       {
-        v6 = (unsigned int *)&dword_4F6E08[(int)v4];
-        Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u);
+        v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4];
+        Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true);
         if ( v5->pMonsterInfo.uHostilityType && !*v6 )
           v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
         v22 = *v6;
@@ -10340,7 +10340,7 @@
       v5 = v10->uPackedID;
       if ( (v10->uPackedID & 7) == OBJECT_Actor)
       {
-        v8 = dword_4F6E08[v5 >> 3];
+        v8 = ai_near_actors_targets_pid[v5 >> 3];
         memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7));
         if ( !v1->_406D10(a2) )
           Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7);
@@ -10384,7 +10384,7 @@
         if ( pActors[v3].CanAct() )
         {
           v4 = v2->uPackedID;
-          v9 = dword_4F6E08[v3];
+          v9 = ai_near_actors_targets_pid[v3];
           memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6));
           Actor::AI_Stand(v8, v9, 0x20u, &v6);
           v2->field_C = 0;
@@ -10447,7 +10447,7 @@
           result = 1;
         if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) )
         {
-          v13 = dword_4F6E08[v5];
+          v13 = ai_near_actors_targets_pid[v5];
           memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9));
           v7 = v6->uAIState;
           if ( v7 == 6 || v7 == 1 )
@@ -10524,12 +10524,12 @@
   v5 = v4->uAIState;
   if ( v5 == 5 || v5 == 4 || v5 == 11 || v5 == 19 || v5 == 17 )
     return 1;
-  v6 = &dword_4F6E08[v3];
+  v6 = &ai_near_actors_targets_pid[v3];
   v7 = &pTurnEngine->pQueue[a2];
   v8 = *v6;
   v29 = &pTurnEngine->pQueue[a2];
   a2a = v8;
-  Actor::_401221(v3, &dword_4F6E08[v3], 1u);
+  Actor::_SelectTarget(v3, &ai_near_actors_targets_pid[v3], true);
   if ( v4->pMonsterInfo.uHostilityType && !*v6 )
     v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
   v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
@@ -10724,10 +10724,10 @@
             {
               if ( v6 != 17 )
               {
-                v7 = (unsigned int *)&dword_4F6E08[v4];
+                v7 = (unsigned int *)&ai_near_actors_targets_pid[v4];
                 a2 = *v7;
                 v8 = a2;
-                Actor::_401221(v4, (int *)v7, 1u);
+                Actor::_SelectTarget(v4, (int *)v7, true);
                 memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11));
                 memcpy(&a4, &v11, sizeof(a4));
                 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
@@ -12099,7 +12099,7 @@
   if (_449B57_test_bit(pParty->_award_bits, 100))
     v5 = 1;
 
-  Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // dword_4F6E08[i] for AI_Stand seems always 0;  original code behaviour is identical
+  Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0;  original code behaviour is identical
   for (uint i = 0; i < uNumActors; ++i)
   {
     auto actor = pActors + i;
@@ -12112,7 +12112,7 @@
       actor->sCurrentHP = actor->pMonsterInfo.uHP;
       if (actor->uAIState != Disabled)
       {
-        Actor::AI_Stand(i, dword_4F6E08[i], actor->pMonsterInfo.uRecoveryTime, 0);
+        Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0);
       }
     }
 
--- a/mm7_data.cpp	Sat Feb 23 23:45:50 2013 +0600
+++ b/mm7_data.cpp	Sat Feb 23 23:46:20 2013 +0600
@@ -1711,7 +1711,7 @@
 int dword_4F5D98_xs[777]; // idb
 int ai_array_4F5E68[500];
 int ai_array_4F6638_actor_ids[500];
-int dword_4F6E08[500];
+int ai_near_actors_targets_pid[500];
 int ai_arrays_size; // weak
 int ai_near_actors_distances[500];
 unsigned int ai_near_actors_ids[500];
--- a/mm7_data.h	Sat Feb 23 23:45:50 2013 +0600
+++ b/mm7_data.h	Sat Feb 23 23:46:20 2013 +0600
@@ -1071,7 +1071,7 @@
 extern int dword_4F5D98_xs[]; // idb
 extern int ai_array_4F5E68[500];
 extern int ai_array_4F6638_actor_ids[500];
-extern int dword_4F6E08[500];
+extern int ai_near_actors_targets_pid[500];
 extern int ai_arrays_size; // weak
 extern int ai_near_actors_distances[500];
 extern unsigned int ai_near_actors_ids[500];