changeset 2172:56aa61b54785

indoor cleaning continue
author Ritor1
date Mon, 20 Jan 2014 17:25:01 +0600
parents 41bb73de29fb
children daa61976637d
files Actor.cpp Indoor.cpp Outdoor.cpp example.h
diffstat 4 files changed, 526 insertions(+), 743 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Jan 20 09:22:16 2014 +0600
+++ b/Actor.cpp	Mon Jan 20 17:25:01 2014 +0600
@@ -2767,8 +2767,8 @@
   }
   v27 = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? 128 : 64;
   v13 = rand() % 2048;
-  v15 = ((stru_5C6E00->Cos(v13) * (signed __int64)v27) >> 16) + this->vPosition.x;
-  v17 = ((stru_5C6E00->Sin(v13) * (signed __int64)v27) >> 16) + this->vPosition.y;
+  v15 = fixpoint_mul(stru_5C6E00->Cos(v13), v27) + this->vPosition.x;
+  v17 = fixpoint_mul(stru_5C6E00->Sin(v13), v27) + this->vPosition.y;
 
   if (uCurrentlyLoadedLevelType != LEVEL_Outdoor)
   {
@@ -2875,13 +2875,9 @@
   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)
-  {
     return false;
-  }
-  if (((stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z < v2->vPosition.z)
-  {
+  if (fixpoint_mul(stru_721530.direction.z, v12) + stru_721530.normal.z < v2->vPosition.z)
     return false;
-  }
 
   v13 = v12 - integer_sqrt(v10 * v10 - v11 * v11);
   if ( v13 < 0 )
@@ -3909,9 +3905,9 @@
     knockbackValue = 10;
   if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) )
   {
-    pVelocity->x = (unsigned __int64)(knockbackValue * (signed __int64)pVelocity->x) >> 16;
-    pVelocity->y = (unsigned __int64)(knockbackValue * (signed __int64)pVelocity->y) >> 16;
-    pVelocity->z = (unsigned __int64)(knockbackValue * (signed __int64)pVelocity->z) >> 16;
+    pVelocity->x = fixpoint_mul(knockbackValue, pVelocity->x);
+    pVelocity->y = fixpoint_mul(knockbackValue, pVelocity->y);
+    pVelocity->z = fixpoint_mul(knockbackValue, pVelocity->z);
     pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x);
     pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
     pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
--- a/Indoor.cpp	Mon Jan 20 09:22:16 2014 +0600
+++ b/Indoor.cpp	Mon Jan 20 17:25:01 2014 +0600
@@ -2405,10 +2405,10 @@
       if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall )
       {
         //v51 = pFace->zCalc1;
-        v57 = (unsigned __int64)(pFace->zCalc1 * (signed __int64)(sX << 16)) >> 16;
+        v57 = fixpoint_mul(pFace->zCalc1, (sX << 16));
         //v56 = sY << 16;
         //v51 = pFace->zCalc2;
-        v56 = (unsigned __int64)(pFace->zCalc2 * (signed __int64)(sY << 16)) >> 16;
+        v56 = fixpoint_mul(pFace->zCalc2, (sY << 16));
         v42 = (v56 + pFace->zCalc3 + v57 + 32768) >> 16;
         v39 = sZ - v42;
       }
@@ -2615,9 +2615,9 @@
 LABEL_18:
     for (uint j = 0; j < door->uNumVertices; ++j)
     {
-      pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j];
-      pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j];
-      pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j];
+      pIndoor->pVertices[door->pVertexIDs[j]].x = fixpoint_mul(door->vDirection.x, v89) + door->pXOffsets[j];
+      pIndoor->pVertices[door->pVertexIDs[j]].y = fixpoint_mul(door->vDirection.y, v89) + door->pYOffsets[j];
+      pIndoor->pVertices[door->pVertexIDs[j]].z = fixpoint_mul(door->vDirection.z, v89) + door->pZOffsets[j];
     }
     for ( v88 = 0; v88 < door->uNumFaces; ++v88 )
     {
@@ -2713,16 +2713,16 @@
       }
       if ( face->uAttributes & FACE_TEXTURE_FLOW )
       {
-        v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16;
-        v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16;
-        v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16;
+        v84 = fixpoint_mul(door->vDirection.x, v70.x);
+        v82 = fixpoint_mul(door->vDirection.y, v70.y);
+        v83 = fixpoint_mul(door->vDirection.z, v70.z);
         v75 = v84 + v82 + v83;
         v53 = v89;
-        v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16;
+        v82 = fixpoint_mul(v75, v89);
         v28->sTextureDeltaU = -v82;
-        v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16;
-        v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16;
-        v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16;
+        v84 = fixpoint_mul(door->vDirection.x, v67.x);
+        v82 = fixpoint_mul(door->vDirection.y, v67.y);
+        v83 = fixpoint_mul(door->vDirection.z, v67.z);
         v75 = v84 + v82 + v83;
         v55 = v75 * (signed __int64)v53;
         v32 = v55 >> 16;
@@ -2740,28 +2740,21 @@
 //----- (0046F90C) --------------------------------------------------------
 void  UpdateActors_BLV()
 {
-  Actor *v0; // esi@2
-  unsigned __int16 v1; // ax@2
   int v2; // edi@6
   int v3; // eax@6
   int v4; // eax@8
   __int16 v5; // ax@11
   signed int v6; // ebx@14
-  unsigned __int8 v7; // zf@14
-  unsigned __int8 v8; // sf@14
   signed __int16 v9; // ax@17
   signed __int64 v10; // qax@18
-  unsigned __int16 v11; // ax@21
   int v12; // eax@29
   unsigned __int64 v13; // qax@29
   int v14; // eax@30
   unsigned __int64 v15; // qax@30
-  int v16; // ecx@33
   BLVFace *v17; // edx@33
   int v18; // ecx@33
   BLVFace *v19; // eax@34
   int v20; // ecx@46
-  //int v21; // eax@46
   int v22; // edi@46
   int v23; // eax@48
   unsigned int v24; // eax@51
@@ -2776,9 +2769,7 @@
   int v33; // eax@64
   unsigned int v34; // ecx@64
   int v35; // ecx@64
-  signed int v36; // edx@85
   signed int v37; // ebx@85
-  BLVFace *v38; // edi@89
   int v39; // ecx@90
   int v40; // ebx@90
   PolygonType v41; // al@94
@@ -2786,12 +2777,8 @@
   __int16 v43; // dx@96
   int v44; // ecx@96
   int v45; // edi@101
-  //int v46; // edi@101
-  //int v47; // eax@101
-  //unsigned __int64 v48; // qax@101
   unsigned __int8 v49; // zf@103
   unsigned __int8 v50; // sf@103
-  unsigned __int8 v51; // of@103
   AIDirection v52; // [sp+0h] [bp-60h]@75
   AIDirection v53; // [sp+1Ch] [bp-44h]@116
   int v54; // [sp+38h] [bp-28h]@53
@@ -2803,381 +2790,343 @@
   unsigned int uFaceID; // [sp+50h] [bp-10h]@6
   int v61; // [sp+54h] [bp-Ch]@14
   int v62; // [sp+58h] [bp-8h]@6
-  unsigned int v63; // [sp+5Ch] [bp-4h]@1
-
-  v63 = 0;
-  if ( (signed int)uNumActors > 0 )
-  {
-    while ( 1 )
+  unsigned int actor_id; // [sp+5Ch] [bp-4h]@1
+
+  for ( actor_id = 0; actor_id < uNumActors; actor_id++ )
+  {
+    if ( pActors[actor_id].uAIState == 11 || pActors[actor_id].uAIState == 19 || pActors[actor_id].uAIState == 17 || !pActors[actor_id].uMovementSpeed )
+      continue;
+    uSectorID = pActors[actor_id].uSectorID;
+    v2 = collide_against_floor(pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y, pActors[actor_id].vPosition.z, &uSectorID, &uFaceID);
+    pActors[actor_id].uSectorID = uSectorID;
+    v3 = pActors[actor_id].pMonsterInfo.uFlying;
+    v56 = v2;
+    v62 = v3;
+    if ( !pActors[actor_id].CanAct() )
+      v62 = 0;
+    v4 = pActors[actor_id].vPosition.z;
+    v59 = 0;
+    if ( pActors[actor_id].vPosition.z > v2 + 1 )
+      v59 = 1;
+    if ( v2 <= -30000 )
     {
-      v0 = &pActors[v63];
-      v1 = v0->uAIState;
-      if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
+      v5 = pIndoor->GetSector(pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y, v4);
+      pActors[actor_id].uSectorID = v5;
+      v56 = BLV_GetFloorLevel(pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y, pActors[actor_id].vPosition.z, v5, &uFaceID);
+      if ( !v5 || v56 == -30000 )
         goto LABEL_123;
-      uSectorID = v0->uSectorID;
-      v2 = collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, &uSectorID, &uFaceID);
-      v0->uSectorID = uSectorID;
-      v3 = v0->pMonsterInfo.uFlying;
-      v56 = v2;
-      v62 = v3;
-      if ( !v0->CanAct() )
-        v62 = 0;
-      v4 = v0->vPosition.z;
-      v59 = 0;
-      if ( v4 > v2 + 1 )
-        v59 = 1;
-      if ( v2 <= -30000 )
-      {
-        v5 = pIndoor->GetSector(v0->vPosition.x, v0->vPosition.y, v4);
-        v0->uSectorID = v5;
-        if ( !v5
-          || (v56 = BLV_GetFloorLevel(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &uFaceID), v56 == -30000) )
-          goto LABEL_123;
-      }
-      if ( v0->uCurrentActionAnimation == ANIM_Walking)
+    }
+    if ( pActors[actor_id].uCurrentActionAnimation == ANIM_Walking)
+    {
+      v6 = pActors[actor_id].uMovementSpeed;
+      if ( pActors[actor_id].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 )
       {
-        v6 = v0->uMovementSpeed;
-        v7 = HIDWORD(v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime) == 0;
-        v8 = SHIDWORD(v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime) < 0;
-        v61 = v0->uMovementSpeed;
-        if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime)) )
-        {
-          v9 = v0->pActorBuffs[ACTOR_BUFF_SLOWED].uPower;
-          if ( v9 )
-            LODWORD(v10) = v6 / (unsigned __int16)v9;
-          else
-            v10 = (signed __int64)((double)v61 * 0.5);
-          v6 = v10;
-          v61 = v10;
-        }
-        v11 = v0->uAIState;
-        if ( v11 == 6 || v11 == 7 )
-        {
-          v6 *= 2;
-          v61 = v6;
-        }
-        if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 )
-          v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6);
-        if ( v6 > 1000 )
-          v6 = 1000;
-        v12 = stru_5C6E00->Cos(v0->uYawAngle);
-        uSectorID = v12;
-        v13 = v12 * (signed __int64)v6;
-        v61 = v13 >> 16;
-        v0->vVelocity.x = WORD1(v13);
-        uSectorID = stru_5C6E00->Sin(v0->uYawAngle);
-        v61 = (unsigned __int64)(uSectorID * (signed __int64)v6) >> 16;
-        v7 = v62 == 0;
-        v0->vVelocity.y = (unsigned int)(uSectorID * v6) >> 16;
-        if ( !v7 )
-        {
-          v14 = stru_5C6E00->Sin(v0->uPitchAngle);
-          uSectorID = v14;
-          v15 = v14 * (signed __int64)v6;
-          v61 = v15 >> 16;
-          v0->vVelocity.z = WORD1(v15);
-        }
+        if ( pActors[actor_id].pActorBuffs[ACTOR_BUFF_SLOWED].uPower )
+          LODWORD(v10) = pActors[actor_id].uMovementSpeed / (unsigned __int16)pActors[actor_id].pActorBuffs[ACTOR_BUFF_SLOWED].uPower;
+        else
+          v10 = (signed __int64)((double)pActors[actor_id].uMovementSpeed * 0.5);
+        v6 = v10;
       }
-      else
+      if ( pActors[actor_id].uAIState == Pursuing || pActors[actor_id].uAIState == Fleeing )
+        v6 *= 2;
+      if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 )
+        v6 = (signed __int64)((double)v6 * flt_6BE3AC_debug_recmod1_x_1_6);
+      if ( v6 > 1000 )
+        v6 = 1000;
+      pActors[actor_id].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[actor_id].uYawAngle), v6);
+      pActors[actor_id].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[actor_id].uYawAngle), v6);
+      if ( v62 )
+        pActors[actor_id].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[actor_id].uPitchAngle), v6);
+    }
+    else
+    {
+      pActors[actor_id].vVelocity.x = fixpoint_mul(55000, pActors[actor_id].vVelocity.x);
+      pActors[actor_id].vVelocity.y = fixpoint_mul(55000, pActors[actor_id].vVelocity.y);
+      if ( v62 )
+        pActors[actor_id].vVelocity.z = fixpoint_mul(55000, pActors[actor_id].vVelocity.z);
+    }
+    if ( pActors[actor_id].vPosition.z <= v56 )
+    {
+      pActors[actor_id].vPosition.z = v56 + 1;
+      if ( pIndoor->pFaces[uFaceID].uPolygonType == 3 )
       {
-        v61 = v0->vVelocity.x;
-        uSectorID = 55000;
-        v61 = (unsigned __int64)(55000i64 * v61) >> 16;
-        v0->vVelocity.x = v61;
-        v61 = v0->vVelocity.y;
-        v61 = (unsigned __int64)(uSectorID * (signed __int64)v61) >> 16;
-        v7 = v62 == 0;
-        v0->vVelocity.y = v61;
-        if ( !v7 )
-        {
-          uSectorID = 55000;
-          v61 = v0->vVelocity.z;
-          v61 = (unsigned __int64)(55000i64 * v61) >> 16;
-          v0->vVelocity.z = v61;
-        }
-      }
-      v16 = v0->vPosition.z;
-      v17 = pIndoor->pFaces;
-      v51 = __OFSUB__(v16, v56);
-      v8 = v16 - v56 < 0;
-      v18 = uFaceID;
-      if ( v8 ^ v51 )
-      {
-        v0->vPosition.z = v56 + 1;
-        v19 = &v17[v18];
-        if ( v19->uPolygonType == 3 )
-        {
-          if ( v0->vVelocity.z < 0 )
-            v0->vVelocity.z = 0;
-        }
-        else
-        {
-          if ( v19->pFacePlane_old.vNormal.z < 45000 )
-            v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
-        }
+        if ( pActors[actor_id].vVelocity.z < 0 )
+          pActors[actor_id].vVelocity.z = 0;
       }
       else
       {
-        if ( v59 && !v62 )
-          v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
+        if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 45000 )
+          pActors[actor_id].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
       }
-      if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y + v0->vVelocity.z * v0->vVelocity.z >= 400 )
-        break;
-      v0->vVelocity.z = 0;
-      v0->vVelocity.y = 0;
-      v0->vVelocity.x = 0;
-      if ( BYTE2(v17[v18].uAttributes) & 0x40 )
-      {
-        if (v0->uAIState == Dead)
-          v0->uAIState = Removed;
-      }
-LABEL_123:
-      ++v63;
-      if ( (signed int)v63 >= (signed int)uNumActors )
-        return;
+    }
+    else
+    {
+      if ( v59 && !v62 )
+        pActors[actor_id].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
     }
-    v20 = v0->uActorRadius;
-    stru_721530.field_84 = -1;
-    stru_721530.field_70 = 0;
-    uSectorID = 0;
-    stru_721530.field_0 = 1;
-    stru_721530.field_8_radius = v20;
-    stru_721530.prolly_normal_d = v20;
-    stru_721530.height = v0->uActorHeight;
-    v22 = 0;
-    while ( 1 )
+    if ( pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y
+       + pActors[actor_id].vVelocity.z * pActors[actor_id].vVelocity.z >= 400 )
     {
-      stru_721530.position.x = v0->vPosition.x;
-      stru_721530.normal.x = stru_721530.position.x;
-      stru_721530.position.y = v0->vPosition.y;
-      stru_721530.normal.y = stru_721530.position.y;
-      v23 = v0->vPosition.z;
-      stru_721530.normal.z = v23 + v20 + 1;
-      stru_721530.position.z = v23 - v20 + stru_721530.height - 1;
-      if ( stru_721530.position.z < stru_721530.normal.z )
-        stru_721530.position.z = v23 + v20 + 1;
-      stru_721530.velocity.x = v0->vVelocity.x;
-      stru_721530.velocity.y = v0->vVelocity.y;
-      stru_721530.velocity.z = v0->vVelocity.z;
-      stru_721530.uSectorID = v0->uSectorID;
-      if ( !stru_721530._47050A(v22) )
+      stru_721530.field_84 = -1;
+      stru_721530.field_70 = 0;
+      stru_721530.field_0 = 1;
+      stru_721530.field_8_radius = pActors[actor_id].uActorRadius;
+      stru_721530.prolly_normal_d = pActors[actor_id].uActorRadius;
+      stru_721530.height = pActors[actor_id].uActorHeight;
+      v22 = 0;
+      for ( uSectorID = 0; uSectorID < 100; uSectorID++ )
       {
-        v58 = v22;
-        v24 = 8 * v63;
-        LOBYTE(v24) = PID(OBJECT_Actor,v63);
-        v61 = v22;
-        _this = v24;
-        do
+        stru_721530.position.x = pActors[actor_id].vPosition.x;
+        stru_721530.normal.x = stru_721530.position.x;
+        stru_721530.position.y = pActors[actor_id].vPosition.y;
+        stru_721530.normal.y = stru_721530.position.y;
+        stru_721530.normal.z = pActors[actor_id].vPosition.z + pActors[actor_id].uActorRadius + 1;
+        stru_721530.position.z = pActors[actor_id].vPosition.z - pActors[actor_id].uActorRadius + stru_721530.height - 1;
+        if ( stru_721530.position.z < stru_721530.normal.z )
+        stru_721530.position.z = pActors[actor_id].vPosition.z + pActors[actor_id].uActorRadius + 1;
+        stru_721530.velocity.x = pActors[actor_id].vVelocity.x;
+        stru_721530.velocity.y = pActors[actor_id].vVelocity.y;
+        stru_721530.velocity.z = pActors[actor_id].vVelocity.z;
+        stru_721530.uSectorID = pActors[actor_id].uSectorID;
+        if ( !stru_721530._47050A(v22) )
         {
-          _46E44E_collide_against_faces_and_portals(1u);
-          _46E0B2_collide_against_decorations();
-          _46EF01_collision_chech_player(0);
-          _46ED8A_collide_against_sprite_objects(_this);
-          v25 = 0;
-          v56 = 0;
-          if ( ai_arrays_size > v22 )
+          v58 = 0;
+          v24 = 8 * actor_id;
+          LOBYTE(v24) = PID(OBJECT_Actor,actor_id);
+          for ( v61 = 0; v61 < 100; ++v61 )
           {
-            do
+            _46E44E_collide_against_faces_and_portals(1);
+            _46E0B2_collide_against_decorations();
+            _46EF01_collision_chech_player(0);
+            _46ED8A_collide_against_sprite_objects(v24);
+            for ( uint j = 0; j < ai_arrays_size; j++ )
             {
-              v54 = ai_near_actors_ids[v25];
-              if ( v54 != v63 )
+              if ( ai_near_actors_ids[j] != actor_id )
               {
-                v26 = v54;
-                v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z);
-                v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y);
-                v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x);
-                if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius
-                  && Actor::_46DF1A_collide_against_actor(v54, 40) )
+                v27 = abs(pActors[ai_near_actors_ids[j]].vPosition.z - pActors[actor_id].vPosition.z);
+                v28 = abs(pActors[ai_near_actors_ids[j]].vPosition.y - pActors[actor_id].vPosition.y);
+                v29 = abs(pActors[ai_near_actors_ids[j]].vPosition.x - pActors[actor_id].vPosition.x);
+                if ( int_get_vector_length(v29, v28, v27) >= pActors[actor_id].uActorRadius + (signed int)pActors[ai_near_actors_ids[j]].uActorRadius
+                  && Actor::_46DF1A_collide_against_actor(ai_near_actors_ids[j], 40) )
                   ++v58;
-                v22 = 0;
               }
-              v25 = v56++ + 1;
             }
-            while ( v56 < ai_arrays_size );
+            if ( _46F04E_collide_against_portals() )
+              break;
+          }
+          v56 = v58 > 1;
+          if ( stru_721530.field_7C >= stru_721530.field_6C )
+          {
+            v30 = stru_721530.normal2.x;
+            v31 = stru_721530.normal2.y;
+            v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
+          }
+          else
+          {
+            v30 = pActors[actor_id].vPosition.x + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
+            v31 = pActors[actor_id].vPosition.y + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
+            v32 = pActors[actor_id].vPosition.z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
+          }
+          v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID);
+          if (pIndoor->pFaces[uFaceID].uAttributes & FACE_INDOOR_SKY && pActors[actor_id].uAIState == Dead)
+          {
+            pActors[actor_id].uAIState = Removed;
+            continue;
           }
-          if ( _46F04E_collide_against_portals() )
-            break;
-          ++v61;
-        }
-        while ( v61 < 100 );
-        v56 = v58 > 1;
-        if ( stru_721530.field_7C >= stru_721530.field_6C )
-        {
-          v30 = stru_721530.normal2.x;
-          v31 = stru_721530.normal2.y;
-          v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
-        }
-        else
-        {
-          v30 = v0->vPosition.x + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
-          v31 = v0->vPosition.y + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
-          v32 = v0->vPosition.z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
-        }
-        v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID);
-        v34 = pIndoor->pFaces[uFaceID].uAttributes;
-        v35 = v34 & 0x400000;
-        if (v35 && v0->uAIState == Dead)
-        {
-          v0->uAIState = Removed;
-          goto LABEL_120;
-        }
-        if ( v59 != v22 || v62 != v22 || v35 == v22 )
-        {
-          if ( v33 == -30000 )
-            goto LABEL_120;
-          if ( v0->uCurrentActionAnimation != 1 || v33 >= v0->vPosition.z - 100 || v59 != v22 || v62 != v22 )
+          if ( v59 || v62 || !(pIndoor->pFaces[uFaceID].uAttributes & FACE_INDOOR_SKY) )
           {
-            if ( stru_721530.field_7C >= stru_721530.field_6C )
+            if ( v33 == -30000 )
+              continue;
+            if ( pActors[actor_id].uCurrentActionAnimation != 1 || v33 >= pActors[actor_id].vPosition.z - 100 || v59 || v62 )
             {
-              v0->vPosition.x = LOWORD(stru_721530.normal2.x);
-              v0->vPosition.y = LOWORD(stru_721530.normal2.y);
-              v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
-              v0->uSectorID = LOWORD(stru_721530.uSectorID);
+              if ( stru_721530.field_7C >= stru_721530.field_6C )
+              {
+                pActors[actor_id].vPosition.x = LOWORD(stru_721530.normal2.x);
+                pActors[actor_id].vPosition.y = LOWORD(stru_721530.normal2.y);
+                pActors[actor_id].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
+                pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID);
+                goto LABEL_123;
+              }
+              pActors[actor_id].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
+              pActors[actor_id].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
+              pActors[actor_id].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
+              pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID);
+              stru_721530.field_70 += stru_721530.field_7C;
+              v37 = PID_ID(stru_721530.uFaceID);
+              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
+              {
+                if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) )
+                {
+                  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                  v22 = 0;
+                  continue;
+                }
+                if ( pActors[actor_id].pMonsterInfo.uHostilityType )
+                {
+                  if ( !v56 )
+                  {
+                    Actor::AI_Flee(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+                    pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                    pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                    pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                    v22 = 0;
+                    continue;
+                  }
+                }
+                else
+                {
+                  if ( !v56 )
+                  {
+                    if ( !pActors[v37].pMonsterInfo.uHostilityType )
+                    {
+                      Actor::AI_FaceObject(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+                      pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                      pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                      pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                      v22 = 0;
+                      continue;
+                    }
+                    Actor::AI_Flee(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+                    pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                    pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                    pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                    v22 = 0;
+                    continue;
+                  }
+                }
+                Actor::AI_StandOrBored(actor_id, 4, v22, &v53);
+                pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                v22 = 0;
+                continue;
+              }
+              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Player)
+              {
+                if ( pActors[actor_id].GetActorsRelation(0) )
+                {
+                  //v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22);
+                  //v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22;
+                  //v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0;
+                  pActors[actor_id].vVelocity.y = v22;
+                  pActors[actor_id].vVelocity.x = v22;
+                  if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > v22 )
+                    pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
+                  viewparams->bRedrawGameUI = 1;
+                  pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                  pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                  pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                  v22 = 0;
+                  continue;
+                }
+                Actor::AI_FaceObject(actor_id, stru_721530.uFaceID, v22, (AIDirection *)v22);
+                pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                v22 = 0;
+                continue;
+              }
+              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
+              {
+                _this = integer_sqrt(pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y);
+                v45 = stru_5C6E00->Atan2(pActors[actor_id].vPosition.x - pLevelDecorations[v37].vPosition.x,
+                        pActors[actor_id].vPosition.y - pLevelDecorations[v37].vPosition.y);
+                pActors[actor_id].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v45), _this);
+                pActors[actor_id].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v45), _this);
+                pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                v22 = 0;
+                continue;
+              }
+              if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
+              {
+                stru_721530.field_84 = stru_721530.uFaceID >> 3;
+                if ( pIndoor->pFaces[v37].uPolygonType == 3 )
+                {
+                  pActors[actor_id].vVelocity.z = 0;
+                  pActors[actor_id].vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v37].pVertexIDs].z + 1;
+                  if ( pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x
+                     + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y < 400 )
+                  {
+                    pActors[actor_id].vVelocity.y = 0;
+                    pActors[actor_id].vVelocity.x = 0;
+                    pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+                    pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+                    pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+                    v22 = 0;
+                    continue;
+                  }
+                }
+                else
+                {
+                  v61 = abs(pIndoor->pFaces[v37].pFacePlane_old.vNormal.x * pActors[actor_id].vVelocity.x + pIndoor->pFaces[v37].pFacePlane_old.vNormal.y
+                                                                            * pActors[actor_id].vVelocity.y
+                                                                            + pIndoor->pFaces[v37].pFacePlane_old.vNormal.z
+                                                                            * pActors[actor_id].vVelocity.z) >> 16;
+                  if ( (stru_721530.speed >> 3) > v61 )
+                    v61 = stru_721530.speed >> 3;
+                  pActors[actor_id].vVelocity.x += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.x);
+                  pActors[actor_id].vVelocity.y += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.y);
+                  pActors[actor_id].vVelocity.z += fixpoint_mul(v61, pIndoor->pFaces[v37].pFacePlane_old.vNormal.z);
+                  if ( pIndoor->pFaces[v37].uPolygonType != 4 && pIndoor->pFaces[v37].uPolygonType != 3 )
+                  {
+                    v44 = stru_721530.prolly_normal_d
+                        - ((pIndoor->pFaces[v37].pFacePlane_old.dist
+                          + pIndoor->pFaces[v37].pFacePlane_old.vNormal.z * pActors[actor_id].vPosition.z
+                          + pIndoor->pFaces[v37].pFacePlane_old.vNormal.y * pActors[actor_id].vPosition.y
+                          + pIndoor->pFaces[v37].pFacePlane_old.vNormal.x * pActors[actor_id].vPosition.x) >> 16);
+                    if ( v44 > 0 )
+                    {
+                      pActors[actor_id].vPosition.x += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.x);
+                      pActors[actor_id].vPosition.y += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.y);
+                      pActors[actor_id].vPosition.z += fixpoint_mul(v44, pIndoor->pFaces[v37].pFacePlane_old.vNormal.z);
+                    }
+                    pActors[actor_id].uYawAngle = stru_5C6E00->Atan2(pActors[actor_id].vVelocity.x, pActors[actor_id].vVelocity.y);
+                  }
+                }
+                if ( pIndoor->pFaces[v37].uAttributes & 8000000 )
+                  EventProcessor(pIndoor->pFaceExtras[ pIndoor->pFaces[v37].uFaceExtraID].uEventID, 0, 1);
+              }
+              pActors[actor_id].vVelocity.x = fixpoint_mul(58500, pActors[actor_id].vVelocity.x);
+              pActors[actor_id].vVelocity.y = fixpoint_mul(58500, pActors[actor_id].vVelocity.y);
+              pActors[actor_id].vVelocity.z = fixpoint_mul(58500, pActors[actor_id].vVelocity.z);
+              v22 = 0;
+              continue;
+            }
+            if ( pActors[actor_id].vPosition.x & 1 )
+              pActors[actor_id].uYawAngle += 100;
+            else
+              pActors[actor_id].uYawAngle -= 100;
+          }
+          else
+          {
+            if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) )
+              goto LABEL_123;
+            if ( !pActors[actor_id].pMonsterInfo.uHostilityType || v56 != v22 )
+            {
+              Actor::AI_StandOrBored(actor_id, 4, v22, &v52);
               goto LABEL_123;
             }
-            //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
-            v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
-            //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
-            v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
-            //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16;
-            v36 = stru_721530.uFaceID;
-            v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
-            v0->uSectorID = LOWORD(stru_721530.uSectorID);
-            stru_721530.field_70 += stru_721530.field_7C;
-            v37 = PID_ID(v36);
-            if ( PID_TYPE(v36) != OBJECT_Actor)
-            {
-              if ( PID_TYPE(v36) != OBJECT_Player)
-              {
-                if ( PID_TYPE(v36) == OBJECT_Decoration)
-                {
-                  _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
-                  v45 = stru_5C6E00->Atan2(
-                          v0->vPosition.x - pLevelDecorations[v37].vPosition.x,
-                          v0->vPosition.y - pLevelDecorations[v37].vPosition.y);
-                  v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v45), _this);
-                  v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v45), _this);
-                  goto LABEL_119;
-                }
-                if ( PID_TYPE(v36) == OBJECT_BModel)
-                {
-                  stru_721530.field_84 = v36 >> 3;
-                  v38 = &pIndoor->pFaces[v37];
-                  if ( v38->uPolygonType == 3 )
-                  {
-                    v39 = v0->vVelocity.x;
-                    v40 = v0->vVelocity.y * v0->vVelocity.y;
-                    v0->vVelocity.z = 0;
-                    v0->vPosition.z = pIndoor->pVertices[*v38->pVertexIDs].z + 1;
-                    if ( v39 * v39 + v40 < 400 )
-                    {
-                      v0->vVelocity.y = 0;
-                      v0->vVelocity.x = 0;
-                      goto LABEL_119;
-                    }
-                  }
-                  else
-                  {
-                    v61 = abs(v38->pFacePlane_old.vNormal.x * v0->vVelocity.x + v38->pFacePlane_old.vNormal.y
-                                                                              * v0->vVelocity.y
-                                                                              + v38->pFacePlane_old.vNormal.z
-                                                                              * v0->vVelocity.z) >> 16;
-                    if ( (stru_721530.speed >> 3) > v61 )
-                      v61 = stru_721530.speed >> 3;
-
-                    v0->vVelocity.x += fixpoint_mul(v61, v38->pFacePlane_old.vNormal.x);
-                    v0->vVelocity.y += fixpoint_mul(v61, v38->pFacePlane_old.vNormal.y);
-                    v0->vVelocity.z += fixpoint_mul(v61, v38->pFacePlane_old.vNormal.z);
-                    v41 = v38->uPolygonType;
-                    if ( v41 != 4 && v41 != 3 )
-                    {
-                      v42 = v38->pFacePlane_old.vNormal.x;
-                      v43 = v0->vPosition.z;
-                      v44 = stru_721530.prolly_normal_d
-                          - ((v38->pFacePlane_old.dist
-                            + v38->pFacePlane_old.vNormal.z * v0->vPosition.z
-                            + v38->pFacePlane_old.vNormal.y * v0->vPosition.y
-                            + v42 * v0->vPosition.x) >> 16);
-                      if ( v44 > 0 )
-                      {
-                        v0->vPosition.x += (unsigned int)(v44 * v42) >> 16;
-                        v0->vPosition.y += (unsigned int)(v44 * v38->pFacePlane_old.vNormal.y) >> 16;
-                        v0->vPosition.z = v43 + ((unsigned int)(v44 * v38->pFacePlane_old.vNormal.z) >> 16);
-                      }
-                      v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y);
-                    }
-                  }
-                  if ( BYTE3(v38->uAttributes) & 8 )
-                    EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1);
-                }
-LABEL_119:
-                v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x);
-                v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y);
-                v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z);
-                v22 = 0;
-                goto LABEL_120;
-              }
-              if ( v0->GetActorsRelation(0) )
-              {
-                v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22);
-                v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22;
-                v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0;
-                v0->vVelocity.y = v22;
-                v0->vVelocity.x = v22;
-                if ( !(v50 ^ v51)
-                  && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > v22) )
-                  pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
-                viewparams->bRedrawGameUI = 1;
-                goto LABEL_119;
-              }
-              v36 = stru_721530.uFaceID;
-LABEL_118:
-              Actor::AI_FaceObject(v63, v36, v22, (AIDirection *)v22);
-              goto LABEL_119;
-            }
-            if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) )
-              goto LABEL_119;
-            if ( v0->pMonsterInfo.uHostilityType )
-            {
-              if ( v56 == v22 )
-                goto LABEL_114;
-            }
-            else
-            {
-              if ( v56 == v22 )
-              {
-                if ( !pActors[v37].pMonsterInfo.uHostilityType )
-                  goto LABEL_118;
-LABEL_114:
-                Actor::AI_Flee(v63, v36, v22, (AIDirection *)v22);
-                goto LABEL_119;
-              }
-            }
-            Actor::AI_StandOrBored(v63, 4, v22, &v53);
-            goto LABEL_119;
-          }
-          if ( v0->vPosition.x & 1 )
-            v0->uYawAngle += 100;
-          else
-            v0->uYawAngle -= 100;
-        }
-        else
-        {
-          if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) )
-            goto LABEL_123;
-          if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 )
-          {
-            Actor::AI_StandOrBored(v63, 4, v22, &v52);
-            goto LABEL_123;
           }
         }
       }
-LABEL_120:
-      ++uSectorID;
-      if ( uSectorID >= 100 )
-        goto LABEL_123;
-      v20 = stru_721530.prolly_normal_d;
     }
+    else
+    {
+      pActors[actor_id].vVelocity.z = 0;
+      pActors[actor_id].vVelocity.y = 0;
+      pActors[actor_id].vVelocity.x = 0;
+      if ( pIndoor->pFaces[uFaceID].uAttributes & FACE_INDOOR_SKY )
+      {
+        if (pActors[actor_id].uAIState == Dead)
+          pActors[actor_id].uAIState = Removed;
+      }
+    }
+LABEL_123:
+    ;
   }
 }
 
@@ -3185,101 +3134,63 @@
 //----- (00460A78) --------------------------------------------------------
 void PrepareToLoadBLV(unsigned int bLoading)
 {
-  unsigned int v1; // ebx@1
-  unsigned int v2; // eax@8
-  MapInfo *v3; // edi@9
+  unsigned int respawn; // ebx@1
+  unsigned int map_id; // eax@8
+  MapInfo *map_info; // edi@9
   int v4; // eax@11
-  int v5; // eax@12
-  int v6; // eax@13
-  int v7; // esi@27
-  SpawnPointMM7 *v8; // edx@28
-  //char v9; // bl@33
-  //int v10; // eax@34
-  //char *v11; // ecx@37
-  //int v12; // edi@44
-  //unsigned int v13; // edi@48
   char *v14; // esi@49
-  __int16 v15; // ax@50
-  int v16; // ecx@52
-  DecorationDesc *v17; // eax@54
-  int v18; // ecx@55
-  //int *v19; // edi@58
-  //unsigned char v20; // dl@58
-  int v21; // eax@64
+  DecorationDesc *decoration; // eax@54
   char v22; // cl@64
-  //signed int v23; // ebx@67
-  //char *v24; // esi@68
-  //int v25; // eax@70
-  //char *v26; // esi@78
-  //int v27; // eax@79
   char v28; // zf@81
   __int16 v29; // ax@85
   signed int v30; // edi@94
-  int v31; // esi@94
-  //char Args; // [sp+350h] [bp-C4h]@16
   int v34[4]; // [sp+3E8h] [bp-2Ch]@96
   int v35; // [sp+3F8h] [bp-1Ch]@1
-  //char b[4]; // [sp+3FCh] [bp-18h]@58
-  MapInfo *v37; // [sp+400h] [bp-14h]@1
   int v38; // [sp+404h] [bp-10h]@1
-  unsigned int v39; // [sp+408h] [bp-Ch]@8
   int pDest; // [sp+40Ch] [bp-8h]@1
-  //int i; // [sp+410h] [bp-4h]@27
-
-  v37 = (MapInfo *)bLoading;
-  v1 = 0;
-  v35 = 0;
+
+  respawn = 0;
   pGameLoadingUI_ProgressBar->Reset(0x20u);
-  bUnderwater = 0;
-  bNoNPCHiring = 0;
-  v38 = 0;
+  bUnderwater = false;
+  bNoNPCHiring = false;
   pDest = 1;
   uCurrentlyLoadedLevelType = LEVEL_Indoor;
   pGame->uFlags2 &= 0xFFFFFFF7u;
   if ( Is_out15odm_underwater() )
   {
-    bUnderwater = 1;
-    pGame->uFlags2 |= 8u;
+    bUnderwater = true;
+    pGame->uFlags2 |= 8;
   }
   if ( !_stricmp(pCurrentMapName, "out15.odm") || !_stricmp(pCurrentMapName, "d23.blv") )
-    bNoNPCHiring = 1;
+    bNoNPCHiring = true;
   pPaletteManager->pPalette_tintColor[0] = 0;
   pPaletteManager->pPalette_tintColor[1] = 0;
   pPaletteManager->pPalette_tintColor[2] = 0;
   pPaletteManager->RecalculateAll();
   if ( qword_A750D8 )
     qword_A750D8 = 0i64;
-  v2 = pMapStats->GetMapInfo(pCurrentMapName);
-  v39 = v2;
-  if ( v2 )
-  {
-    v3 = &pMapStats->pInfos[v2];
-    v1 = v3->uRespawnIntervalDays;
+  map_id = pMapStats->GetMapInfo(pCurrentMapName);
+  if ( map_id )
+  {
+    map_info = &pMapStats->pInfos[map_id];
+    respawn = pMapStats->pInfos[map_id].uRespawnIntervalDays;
     v38 = GetAlertStatus();
   }
   else
-  {
-    v3 = v37;
-  }
-  dword_6BE13C_uCurrentlyLoadedLocationID = v39;
+    map_info = (MapInfo *)bLoading;
+  dword_6BE13C_uCurrentlyLoadedLocationID = map_id;
 
   pStationaryLightsStack->uNumLightsActive = 0;
-  v4 = pIndoor->Load(pCurrentMapName,
-         (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1,
-         v1,
-         (char *)&pDest)
-     - 1;
+  v4 = pIndoor->Load(pCurrentMapName, (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1, respawn, (char *)&pDest) - 1;
   if ( !v4 )
     Error("Unable to open %s", pCurrentMapName);
 
-  v5 = v4 - 1;
-  if ( !v5 )
+  if ( v4 == 1 )
     Error("File %s is not a BLV File", pCurrentMapName);
 
-  v6 = v5 - 1;
-  if ( !v6 )
+  if ( v4 == 2 )
     Error("Attempt to open new level before clearing old");
-  if ( v6 == 1 )
+  if ( v4 == 3 )
     Error("Out of memory loading indoor level");
   if ( !(dword_6BE364_game_settings_1 & GAME_SETTINGS_2000) )
   {
@@ -3287,225 +3198,160 @@
     InitializeSpriteObjects();
   }
   dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_2000;
-  if ( !v39 )
+  if ( !map_id )
     pDest = 0;
   if ( pDest == 1 )
   {
-    v7 = 0;
-    for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++v7 )
+    for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++i )
     {
-      v8 = &pIndoor->pSpawnPoints[v7];
-      if ( pIndoor->pSpawnPoints[v7].uKind == 3 )
-        SpawnEncounter(v3, v8, 0, 0, 0);
+      if ( pIndoor->pSpawnPoints[i].uKind == 3 )
+        SpawnEncounter(map_info, &pIndoor->pSpawnPoints[i], 0, 0, 0);
       else
-        v3->SpawnRandomTreasure(v8);
-      ++i;
+        map_info->SpawnRandomTreasure(&pIndoor->pSpawnPoints[i]);
     }
     RespawnGlobalDecorations();
   }
 
-  pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39], 0);
-  pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39] + 1, 0);
+  pSoundList->LoadSound(pDoorSoundIDsByLocationID[map_id], 0);
+  pSoundList->LoadSound(pDoorSoundIDsByLocationID[map_id] + 1, 0);
 
   for (uint i = 0; i < pIndoor->uNumDoors; ++i)
   {
-    BLVDoor* pDoor = &pIndoor->pDoors[i];
-
-    if (pDoor->uAttributes & 0x01)
+    if (pIndoor->pDoors[i].uAttributes & 0x01)
     {
-      pDoor->uState = BLVDoor::Opening;
-      pDoor->uTimeSinceTriggered = 15360;
-      pDoor->uAttributes = 2;
-    }
-
-    if (pDoor->uState == BLVDoor::Closed)
-    {
-      pDoor->uState = BLVDoor::Closing;
-      pDoor->uTimeSinceTriggered = 15360;
-      pDoor->uAttributes = 2;
-    }
-    else if (pDoor->uState == BLVDoor::Open)
-    {
-      pDoor->uState = BLVDoor::Opening;
-      pDoor->uTimeSinceTriggered = 15360;
-      pDoor->uAttributes = 2;
+      pIndoor->pDoors[i].uState = BLVDoor::Opening;
+      pIndoor->pDoors[i].uTimeSinceTriggered = 15360;
+      pIndoor->pDoors[i].uAttributes = 2;
     }
-  }
-
-/*
-  i = 0;
-  v9 = 2;
-  if ( pIndoor->uNumDoors > 0 )
-  {
-    v10 = 0;
-    while ( 1 )
+
+    if (pIndoor->pDoors[i].uState == BLVDoor::Closed)
     {
-      if ( pIndoor->pDoors[v10].uAttributes & 1 )
-      {
-        pIndoor->pDoors[v10].uState = 1;
-        pIndoor->pDoors[v10].uTimeSinceTriggered = 15360;
-        pIndoor->pDoors[v10].uAttributes = 2;
-      }
-      v11 = (char *)&pIndoor->pDoors[v10].uState;
-      if ( !*(short *)v11 )
-        break;
-      if ( *(short *)v11 == 2 )
-      {
-        *(short *)v11 = 1;
-        goto LABEL_41;
-      }
-LABEL_42:
-      ++i;
-      ++v10;
-      if ( i >= pIndoor->uNumDoors )
-        goto LABEL_43;
+      pIndoor->pDoors[i].uState = BLVDoor::Closing;
+      pIndoor->pDoors[i].uTimeSinceTriggered = 15360;
+      pIndoor->pDoors[i].uAttributes = 2;
     }
-    *(short *)v11 = 3;
-LABEL_41:
-    pIndoor->pDoors[v10].uTimeSinceTriggered = 15360;
-    pIndoor->pDoors[v10].uAttributes = 2;
-    goto LABEL_42;
-  }
-LABEL_43:
-*/
+    else if (pIndoor->pDoors[i].uState == BLVDoor::Open)
+    {
+      pIndoor->pDoors[i].uState = BLVDoor::Opening;
+      pIndoor->pDoors[i].uTimeSinceTriggered = 15360;
+      pIndoor->pDoors[i].uAttributes = 2;
+    }
+  }
 
   for (uint i = 0; i < pIndoor->uNumFaces; ++i)
   {
-    BLVFace* pFace = &pIndoor->pFaces[i];
-    if (!pFace->uBitmapID != -1)
-      pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1);
- }
-  
+    if (!pIndoor->pFaces[i].uBitmapID != -1)
+      pBitmaps_LOD->pTextures[pIndoor->pFaces[i].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[i].uBitmapID].palette_id1);
+  }
+
   pGameLoadingUI_ProgressBar->Progress();
-  
+
+  v35 = 0;
   for (uint i = 0; i < uNumLevelDecorations; ++i)
   {
-    LevelDecoration* pDecortaion = &pLevelDecorations[i];
-    
-    pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID);
-
-    v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID;
-    if (v15 && _6807E0_num_decorations_with_sounds_6807B8 < 9)
-    {
-        pSoundList->LoadSound(v15, 0);
-        v16 = _6807E0_num_decorations_with_sounds_6807B8++;
-        _6807B8_level_decorations_ids[v16] = i;
-    }
-
-    if (!(pDecortaion->uFlags & LEVEL_DECORATION_INVISIBLE))
+    pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID);
+
+    if (pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID].uSoundID && _6807E0_num_decorations_with_sounds_6807B8 < 9)
     {
-      v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID];
-      if (!v17->DontDraw())
+        pSoundList->LoadSound(pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID].uSoundID, 0);
+        _6807B8_level_decorations_ids[_6807E0_num_decorations_with_sounds_6807B8++] = i;
+    }
+
+    if (!(pLevelDecorations[i].uFlags & LEVEL_DECORATION_INVISIBLE))
+    {
+      decoration = &pDecorationList->pDecorations[pLevelDecorations[i].uDecorationDescID];
+      if (!decoration->DontDraw())
+      {
+        if ( decoration->uLightRadius )
         {
-          v18 = v17->uLightRadius;
-          if ( v18 )
+          unsigned char r = 255,
+                        g = 255,
+                        b = 255;
+          if (/*pRenderer->pRenderD3D*/true && pRenderer->bUseColoredLights)
           {
-            unsigned char r = 255,
-                          g = 255,
-                          b = 255;
-            if (/*pRenderer->pRenderD3D*/true && pRenderer->bUseColoredLights)
-            {
-              r = v17->uColoredLightRed;
-              g = v17->uColoredLightGreen;
-              b = v17->uColoredLightBlue;
-            }
-            pStationaryLightsStack->AddLight(pDecortaion->vPosition.x,
-                                             pDecortaion->vPosition.y,
-                                             pDecortaion->vPosition.z + v17->uDecorationHeight,
-              v18,
-              r,
-              g,
-              b,
-              _4E94D0_light_type);
+            r = decoration->uColoredLightRed;
+            g = decoration->uColoredLightGreen;
+            b = decoration->uColoredLightBlue;
           }
+          pStationaryLightsStack->AddLight(pLevelDecorations[i].vPosition.x,
+                                           pLevelDecorations[i].vPosition.y,
+                                           pLevelDecorations[i].vPosition.z + decoration->uDecorationHeight, decoration->uLightRadius, r, g, b, _4E94D0_light_type);
         }
       }
-
-      if (!pDecortaion->uEventID)
+    }
+
+    if (!pLevelDecorations[i].uEventID)
+    {
+      if (pLevelDecorations[i].IsInteractive())
       {
-        if (pDecortaion->IsInteractive())
+        if ( v35 < 124 )
         {
-          if ( v35 < 124 )
-          {
-            v21 = v35 + 1;
-            pDecortaion->_idx_in_stru123 = v35 + 75;
-            v22 = stru_5E4C90_MapPersistVars._decor_events[v21 + 74 - 75];
-            v35 = v21;
-            if ( !v22 )
-              pDecortaion->uFlags |= LEVEL_DECORATION_INVISIBLE;
-          }
+          pLevelDecorations[i]._idx_in_stru123 = v35 + 75;
+          if ( !stru_5E4C90_MapPersistVars._decor_events[v35] )
+            pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE;
+          v35++;
         }
       }
+    }
   }
 
   pGameLoadingUI_ProgressBar->Progress();
 
   for (uint i = 0; i < uNumSpriteObjects; ++i)
   {
-    SpriteObject* p = &pSpriteObjects[i];
-    if (p->uObjectDescID)
+    if (pSpriteObjects[i].uObjectDescID)
     {
-      int uItemID = p->stru_24.uItemID;
-      if (uItemID)
+      if ( pSpriteObjects[i].stru_24.uItemID )
       {
-        if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION &&
-            !p->stru_24.uEnchantmentType)
-          p->stru_24.uEnchantmentType = rand() % 15 + 5;
-        pItemsTable->SetSpecialBonus(&p->stru_24);
+        if ( pSpriteObjects[i].stru_24.uItemID != 220 && pItemsTable->pItems[ pSpriteObjects[i].stru_24.uItemID].uEquipType == EQUIP_POTION &&
+            !pSpriteObjects[i].stru_24.uEnchantmentType)
+          pSpriteObjects[i].stru_24.uEnchantmentType = rand() % 15 + 5;
+        pItemsTable->SetSpecialBonus(&pSpriteObjects[i].stru_24);
       }
     }
   }
 
   // INDOOR initialize actors
+  v38 = 0;
   for (uint i = 0; i < uNumActors; ++i)
-  //if ( (signed int)uNumActors > (signed int)v13 )
-  {
-    Actor *pActor = &pActors[i];
-    //v26 = (char *)&pActors[0].uAttributes;
-    //do
-    //{
-      //v27 = *(int *)v26;
-      if (pActor->uAttributes & 0x100000)
-      {
-        if ( !v39 )
-        {
-          pActor->pMonsterInfo.field_3E = 19;
-          pActor->uAttributes |= 0x10000;
-          continue;
-        }
-        v28 = v38 == 0;
-      }
-      else
+  {
+    if (pActors[i].uAttributes & 0x100000)
+    {
+      if ( !map_id )
       {
-        v28 = v38 == 1;
+        pActors[i].pMonsterInfo.field_3E = 19;
+        pActors[i].uAttributes |= 0x10000;
+        continue;
       }
-
-      if ( !v28 )
+      v28 = v38 == 0;
+    }
+    else
+      v28 = v38 == 1;
+
+    if ( !v28 )
+    {
+      pActors[i].PrepareSprites(0);
+      pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+      if ( pActors[i].pMonsterInfo.field_3E != 11 && pActors[i].pMonsterInfo.field_3E != 19 && (!pActors[i].sCurrentHP || !pActors[i].pMonsterInfo.uHP) )
       {
-        pActor->PrepareSprites(0);
-        v29 = pActor->pMonsterInfo.field_3E;
-        pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-        if ( v29 != 11 && v29 != 19 && (!pActor->sCurrentHP || !pActor->pMonsterInfo.uHP) )
-        {
-          pActor->pMonsterInfo.field_3E = 5;
-          pActor->UpdateAnimation();
-        }
+        pActors[i].pMonsterInfo.field_3E = 5;
+        pActors[i].UpdateAnimation();
       }
-      else
-      {
-          pActor->pMonsterInfo.field_3E = 19;
-          pActor->uAttributes |= 0x10000;
-      }
-    //}
-    //while ( i < (signed int)uNumActors );
+    }
+    else
+    {
+      pActors[i].pMonsterInfo.field_3E = 19;
+      pActors[i].uAttributes |= 0x10000;
+    }
   }
 
   pGameLoadingUI_ProgressBar->Progress();
 
+  //Party to start position
   Actor this_;
   this_.pMonsterInfo.uID = 45;
   this_.PrepareSprites(0);
-  if ( !v37 )
+  if ( !bLoading )
   {
     pParty->sRotationX = 0;
     pParty->sRotationY = 0;
@@ -3518,24 +3364,21 @@
   }
   viewparams->_443365();
   PlayLevelMusic();
-  if ( !v37 )
+  if ( !bLoading )
   {
     v30 = 0;
-    v31 = 1;
-    do
+    for ( uint pl_id = 1; pl_id <= 4; ++pl_id )
     {
-      if ( pPlayers[v31]->CanAct() )
-        v34[v30++] = v31;
-      ++v31;
+      if ( pPlayers[pl_id]->CanAct() )
+        v34[v30++] = pl_id;
     }
-    while ( v31 <= 4 );
     if ( v30 )
     {
       if ( pDest )
       {
         qword_A750D8 = 256i64;
         PlayerSpeechID = SPEECH_46;
-        uSpeakingCharacter = LOWORD(v34[rand() % v30]);
+        uSpeakingCharacter = v34[rand() % v30];
       }
     }
   }
@@ -4195,7 +4038,7 @@
             v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
             pBillboardRenderList[uNumBillboardsToDraw].uHwSpriteID = v4->pHwSpriteIDs[v9];
             if ( v4->uFlags & 0x20 )
-              pSpriteObjects[i].vPosition.z -= (signed int)(fixpoint_mul(v4->scale, pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) / 2);
+              pSpriteObjects[i].vPosition.z -= (signed int)(fixpoint_mul(v4->scale, pSprites_LOD->pSpriteHeaders[pBillboardRenderList[uNumBillboardsToDraw].uHwSpriteID].uHeight) / 2);
 
             v34 = 0;
             if ( v4->uFlags & 2 )
--- a/Outdoor.cpp	Mon Jan 20 09:22:16 2014 +0600
+++ b/Outdoor.cpp	Mon Jan 20 17:25:01 2014 +0600
@@ -2375,61 +2375,35 @@
   int v4; // ecx@1
   int v5; // edx@2
   int v6; // edi@2
-  int v7; // esi@2
-  int v8; // eax@4
   int v9; // ebx@4
   int v10; // eax@5
-  int v11; // eax@7
   int v12; // esi@12
   char v13; // al@12
   int v15; // [sp+4h] [bp-14h]@7
-  int v16; // [sp+8h] [bp-10h]@5
-  int v17; // [sp+Ch] [bp-Ch]@2
-  OutdoorLocation *v18; // [sp+10h] [bp-8h]@1
-  int v19; // [sp+14h] [bp-4h]@2
-  int i; // [sp+24h] [bp+Ch]@5
-
-  v18 = this;
+
   v4 = Y_grid_poa - 10;
-  if ( Y_grid_poa - 10 < Y_grid_poa + 10 )
+  if ( v4 < Y_grid_poa + 10 )
   {
     v5 = v4 - Y_grid_poa;
     v6 = (Y_grid_poa - 30);
-    v7 = X_grid_pos;
-    v19 = v4 - Y_grid_poa;
-    v17 = Y_grid_poa + 10 - v4;
-    while ( 1 )
+    for ( int i = 0; i < Y_grid_poa + 10 - v4; i++)
     {
-      v8 = abs(v5);
-      v9 = v7 - 10;
-      if ( v7 - 10 < v7 + 10 )
+      v9 = X_grid_pos - 10;
+      v10 = v9 - X_grid_pos;
+      for ( v9; v9 < X_grid_pos + 10; ++v9 )
       {
-        v16 = v8 * v8;
-        v10 = v9 - v7;
-        for ( i = v9 - v7; ; v10 = i )
+        v15 = abs(v10) * abs(v10) + abs(v5) * abs(v5);
+        if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 87 )
         {
-          v11 = abs(v10);
-          v15 = v11 * v11 + v16;
-          if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 87 )
-          {
-            v13 = 1 << (7 - (v9 - 20) % 8);
-            v18->uDicovered_area[v6][(v9 - 20)/8] |= v13;
-            if ( v15 <= 49 )
-              v18->uUndiscoveredArea[v6][(v9 - 20)/8] |= v13;
-            v7 = X_grid_pos;
-          }
-          ++v9;
-          ++i;
-          if ( v9 >= v7 + 10 )
-            break;
+          v13 = 1 << (7 - (v9 - 20) % 8);
+          this->uDicovered_area[v6][(v9 - 20)/8] |= v13;
+          if ( v15 <= 49 )
+            this->uUndiscoveredArea[v6][(v9 - 20)/8] |= v13;
         }
+        ++v10;
       }
-      ++v6 ;
-      ++v19;
-      --v17;
-      if ( !v17 )
-        break;
-      v5 = v19;
+      ++v6;
+      ++v5;
     }
   }
   return 1;
@@ -2462,25 +2436,12 @@
 //----- (0047F0E2) --------------------------------------------------------
 bool OutdoorLocation::_47F0E2()
 {
-  signed int v1; // edi@1
-  OutdoorLocation *v2; // ebx@1
-  Texture *v3; // ebp@2
-
-  v1 = 0;
-  v2 = this;
-  if ( (signed int)pBitmaps_LOD->uNumLoadedFiles > 0 )
+  for ( uint i = 0; i < (signed int)pBitmaps_LOD->uNumLoadedFiles; ++i )
   {
-    v3 = pBitmaps_LOD->pTextures;
-    do
-    {
-      if ( v1 != -1 ? (int)v3 : 0 )
-        v3->uDecompressedSize = v2->pTerrain._47CB57((int)v3->pLevelOfDetail0_prolly_alpha_mask,
-                                                      v3->palette_id2,
-                                                      v3->uTextureWidth * v3->uTextureHeight);
-      ++v1;
-      ++v3;
-    }
-    while ( v1 < (signed int)pBitmaps_LOD->uNumLoadedFiles );
+    //if ( i != -1 ? (int)&pBitmaps_LOD->pTextures[i] : 0 )
+      pBitmaps_LOD->pTextures[i].uDecompressedSize = this->pTerrain._47CB57((int)pBitmaps_LOD->pTextures[i].pLevelOfDetail0_prolly_alpha_mask,
+                                                    pBitmaps_LOD->pTextures[i].palette_id2,
+                                                    pBitmaps_LOD->pTextures[i].uTextureWidth * pBitmaps_LOD->pTextures[i].uTextureHeight);
   }
   return 1;
 }
@@ -2536,21 +2497,17 @@
 //----- (0047F223) --------------------------------------------------------
 void OutdoorLocation::ArrangeSpriteObjects()
 {
-  char *v2; // esi@2
   OutdoorLocation *v5; // [sp+0h] [bp-4h]@1
 
   v5 = this;
-  
   if ( (signed int)uNumSpriteObjects > 0 )
   {
-    v2 = (char *)&pSpriteObjects[0].uObjectDescID;
     for ( int i = 0; i < (signed int)uNumSpriteObjects; ++i )
     {
       if ( pSpriteObjects[i].uObjectDescID )
       {
-        if ( !(v2[24] & 8) && !(pObjectList->pObjects[pSpriteObjects[i].uObjectDescID].uFlags & 0x10) )
-          pSpriteObjects[i].vPosition.z = GetTerrainHeightsAroundParty2(pSpriteObjects[i].vPosition.x,
-                              pSpriteObjects[i].vPosition.y, (int *)&v5, 0);
+        if ( !(pSpriteObjects[i].uAttributes & 8) && !(pObjectList->pObjects[pSpriteObjects[i].uObjectDescID].uFlags & 0x10) )
+          pSpriteObjects[i].vPosition.z = GetTerrainHeightsAroundParty2(pSpriteObjects[i].vPosition.x, pSpriteObjects[i].vPosition.y, (int *)&v5, 0);
         if ( pSpriteObjects[i].stru_24.uItemID )
         {
           if ( pSpriteObjects[i].stru_24.uItemID != 220
@@ -2560,7 +2517,6 @@
           pItemsTable->SetSpecialBonus(&pSpriteObjects[i].stru_24);
         }
       }
-      v2 += 112;
     }
   }
   pGameLoadingUI_ProgressBar->Progress();
@@ -2569,69 +2525,64 @@
 //----- (0047F2D3) --------------------------------------------------------
 bool OutdoorLocation::InitalizeActors(int a1)
 {
-  Actor *v3; // esi@2
-  int v4; // eax@3
-  __int16 v5; // ax@11
   int alert_status; // [sp+348h] [bp-8h]@1
   int v9; // [sp+34Ch] [bp-4h]@1
 
   alert_status = 0;
-  for(int i=0; i<uNumActors; ++i) 
+  for( int i = 0; i < uNumActors; ++i ) 
+  {
+    if ( !(pActors[i].uAttributes & 0x100000) )
+    {
+      if ( alert_status != 1 )
+      {
+        pActors[i].uCurrentActionTime = 0;
+        pActors[i].uCurrentActionLength = 0;
+        if ( pActors[i].uAttributes & 0x10000 )
+          pActors[i].uAIState = AIState::Disabled;
+        if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled &&
+           (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) )
+          pActors[i].uAIState = AIState::Dead;
+        pActors[i].vVelocity.x = 0;
+        pActors[i].vVelocity.y = 0;
+        pActors[i].vVelocity.z = 0;
+        pActors[i].UpdateAnimation();
+        pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+        pActors[i].PrepareSprites(0);
+      }
+      else
       {
-      v4 = pActors[i].uAttributes;
-      if ( !(v4 & 0x100000) )
-          {
-          if ( alert_status != 1 )
-              {
-              pActors[i].uCurrentActionTime = 0;
-              pActors[i].uCurrentActionLength = 0;
-              if ( v4 & 0x10000 )
-                  pActors[i].uAIState = AIState::Disabled;
-              if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled &&
-                    (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) )
-                  pActors[i].uAIState = AIState::Dead;
-              pActors[i].vVelocity.x = 0;
-              pActors[i].vVelocity.y = 0;
-              pActors[i].vVelocity.z = 0;
-              pActors[i].UpdateAnimation();
-			  pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-              pActors[i].PrepareSprites(0);
-              }
-          else
-              {
-              pActors[i].uAIState = AIState::Disabled;
-              pActors[i].uAttributes = v4 | 0x10000;
-              }
-          }
-      else if ( a1 == 0 )
-          {
-          pActors[i].uAIState = AIState::Disabled;
-          pActors[i].uAttributes = v4 | 0x10000;
-          }
-      else if ( alert_status != 0 )
-          {
-          pActors[i].uCurrentActionTime = 0;
-          pActors[i].uCurrentActionLength = 0;
-          if ( v4 & 0x10000 )
-              pActors[i].uAIState = AIState::Disabled;
-          v5 = pActors[i].uAIState;
-          if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled && 
-              (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) )
-              pActors[i].uAIState = AIState::Dead;
-          pActors[i].vVelocity.x = 0;
-          pActors[i].vVelocity.y = 0;
-          pActors[i].vVelocity.z = 0;
-          pActors[i].UpdateAnimation();
-		  pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
-          pActors[i].PrepareSprites(0);
-          }
-      else 
-          {
-          pActors[i].uAIState = AIState::Disabled;
-          pActors[i].uAttributes = v4 | 0x10000;
-          alert_status = GetAlertStatus();
-          }
+        pActors[i].uAIState = AIState::Disabled;
+        pActors[i].uAttributes = pActors[i].uAttributes | 0x10000;
       }
+    }
+    else if ( a1 == 0 )
+    {
+      pActors[i].uAIState = AIState::Disabled;
+      pActors[i].uAttributes = pActors[i].uAttributes | 0x10000;
+    }
+    else if ( alert_status != 0 )
+    {
+      pActors[i].uCurrentActionTime = 0;
+      pActors[i].uCurrentActionLength = 0;
+      if ( pActors[i].uAttributes & 0x10000 )
+        pActors[i].uAIState = AIState::Disabled;
+      if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled && 
+         (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) )
+        pActors[i].uAIState = AIState::Dead;
+      pActors[i].vVelocity.x = 0;
+      pActors[i].vVelocity.y = 0;
+      pActors[i].vVelocity.z = 0;
+      pActors[i].UpdateAnimation();
+      pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
+      pActors[i].PrepareSprites(0);
+    }
+    else 
+    {
+      pActors[i].uAIState = AIState::Disabled;
+      pActors[i].uAttributes = pActors[i].uAttributes | 0x10000;
+      alert_status = GetAlertStatus();
+    }
+  }
 
   pGameLoadingUI_ProgressBar->Progress();
   //no use for this
@@ -2662,13 +2613,8 @@
 void OutdoorLocation::PrepareActorsDrawList()
 {
   unsigned int result; // eax@1
-  //Actor *v1; // edi@2
-  //__int16 v2; // ax@3
   int z; // esi@5
   float v4; // ST48_4@8
-  //double v5; // ST38_8@8
-  //float v6; // ST48_4@10
-  //double v7; // ST30_8@10
   unsigned int v8; // eax@11
   int v9; // edx@11
   //__int16 v10; // dx@11
--- a/example.h	Mon Jan 20 09:22:16 2014 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-int gcd(int x, int y);
-extern double Foo;
\ No newline at end of file