changeset 39:e19e48280ca0

Слияние
author Ritor1
date Thu, 18 Oct 2012 09:12:00 +0600
parents 431e26f265a0 (current diff) e62134245ab0 (diff)
children 001b45e84aaa
files Render.cpp mm7_5.cpp
diffstat 15 files changed, 1358 insertions(+), 1286 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/Actor.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -3099,7 +3099,7 @@
   if ( v4->pMonsterInfo.uHostilityType != 4 )
   {
     v4->uAttributes &= 0xFFFFFFFBu;
-    v4->pMonsterInfo.uHostilityType = 4;
+    v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
   }
   if ( (signed __int64)v4->pActorBuffs[1].uExpireTime > 0 )
     v4->pActorBuffs[1].Reset();
@@ -4046,41 +4046,42 @@
 //----- (0045959A) --------------------------------------------------------
 void Actor::PrepareSprites(char load_sounds_if_bit1_set)
 {
-  Actor *v2; // edi@1
+  //Actor *v2; // edi@1
   MonsterDesc *v3; // esi@1
-  __int16 v4; // ax@2
+  //__int16 v4; // ax@2
   unsigned __int16 *v5; // ecx@4
   unsigned __int16 *v6; // eax@4
   signed int v7; // edx@4
-  char pSpriteName; // [sp+Ch] [bp-88h]@2
+  //char pSpriteName[120]; // [sp+Ch] [bp-88h]@2
   MonsterInfo *v9; // [sp+84h] [bp-10h]@1
-  int v10; // [sp+88h] [bp-Ch]@1
-  char *Source; // [sp+8Ch] [bp-8h]@1
-  unsigned __int16 *v12; // [sp+90h] [bp-4h]@1
+  //int v10; // [sp+88h] [bp-Ch]@1
+  //char *Source; // [sp+8Ch] [bp-8h]@1
+  //unsigned __int16 *v12; // [sp+90h] [bp-4h]@1
 
-  v2 = this;
-  v10 = 8;
-  v3 = &pMonsterList->pMonsters[this->pMonsterInfo.uID - 1];
-  v9 = &pMonsterStats->pInfos[this->pMonsterInfo.uID - 1 + 1];
-  v12 = this->pSpriteIDs;
-  Source = (char *)v3->pSpriteNames;
-  do
+  //v2 = this;
+  //v10 = 8;
+  v3 = &pMonsterList->pMonsters[pMonsterInfo.uID - 1];
+  v9 = &pMonsterStats->pInfos[pMonsterInfo.uID - 1 + 1];
+  //v12 = pSpriteIDs;
+  //Source = (char *)v3->pSpriteNames;
+  //do
+  for (uint i = 0; i < 8; ++i)
   {
-    strcpy(&pSpriteName, Source);
-    v4 = pSpriteFrameTable->FastFindSprite(&pSpriteName);
-    *v12 = v4;
-    pSpriteFrameTable->InitializeSprite(v4);
-    ++v12;
-    Source += 10;
-    --v10;
+    //strcpy(pSpriteName, v3->pSpriteNames[i]);
+    pSpriteIDs[i] = pSpriteFrameTable->FastFindSprite(v3->pSpriteNames[i]);
+    //*v12 = v4;
+    pSpriteFrameTable->InitializeSprite(pSpriteIDs[i]);
+    //++v12;
+    //Source += 10;
+    //--v10;
   }
-  while ( v10 );
-  v2->uActorHeight = v3->uMonsterHeight;
-  v2->uActorRadius = v3->uMonsterRadius;
-  v2->uMovementSpeed = LOWORD(v9->uBaseSpeed);
+  //while ( v10 );
+  uActorHeight = v3->uMonsterHeight;
+  uActorRadius = v3->uMonsterRadius;
+  uMovementSpeed = LOWORD(v9->uBaseSpeed);
   if ( !(load_sounds_if_bit1_set & 1) )
   {
-    v5 = v2->pSoundSampleIDs;
+    v5 = pSoundSampleIDs;
     v6 = v3->pSoundSampleIDs;
     v7 = 4;
     do
@@ -4199,7 +4200,7 @@
   v8->uSectorID = v16;
   v8->PrepareSprites(0);
   v18 = v30;
-  v8->pMonsterInfo.uHostilityType = 0;
+  v8->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
   LODWORD(v19) = v18->uAlly;
   if ( !(uint)v19 )
   {
--- a/Game.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/Game.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -542,7 +542,7 @@
         (signed __int64)*((float *)v4 - 3),
         (signed __int64)*((float *)v4 - 2),
         (signed __int64)*((float *)v4 + 2),
-        (int *)(signed __int64)*((float *)v4 - 1),
+        (signed __int64)*((float *)v4 - 1),
         (signed __int64)*(float *)v4,
         (signed __int64)*((float *)v4 + 1),
         byte_4E94D0);
--- a/Indoor.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/Indoor.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -19,6 +19,9 @@
 #include "stru123.h"
 #include "AudioPlayer.h"
 #include "Log.h"
+#include "TurnEngine.h"
+#include "PaletteManager.h"
+#include "MapInfo.h"
 
 #include "mm7_data.h"
 
@@ -51,6 +54,17 @@
 
 
 
+unsigned __int16 pDoorSoundIDsByLocationID[78] =
+{
+  300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
+  300, 300, 300, 404, 302, 306, 308, 304, 308, 302, 400, 302, 300,
+  308, 308, 306, 308, 308, 304, 300, 404, 406, 300, 400, 406, 404,
+  306, 302, 408, 304, 300, 300, 300, 300, 300, 300, 300, 300, 300,
+  300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 404, 304,
+  400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300
+};
+
+
 
 //----- (0043F39E) --------------------------------------------------------
 void __fastcall sub_43F39E(IndoorLocation_drawstru *_this)
@@ -3542,3 +3556,1278 @@
     result = 1;
   return result;
 }
+
+
+
+
+//----- (0046F228) --------------------------------------------------------
+void __cdecl BLV_UpdateDoors()
+{
+  int v0; // ebx@1
+  int v1; // edi@1
+  BLVDoor *v2; // esi@3
+  unsigned __int16 v3; // ax@3
+  unsigned int v4; // ecx@5
+  int v5; // eax@8
+  int v6; // ecx@8
+  int v7; // eax@12
+  int v8; // eax@16
+  unsigned __int8 v9; // zf@18
+  char v10; // sf@18
+  unsigned __int8 v11; // of@18
+  int v12; // edi@19
+  int v13; // ecx@19
+  __int16 v14; // ax@19
+  BLVFace *v15; // ebx@24
+  unsigned __int16 *v16; // ecx@24
+  Vec3_short_ *v17; // esi@24
+  int v18; // eax@24
+  int v19; // edx@24
+  signed int v20; // eax@24
+  Vec3_short_ *v21; // ecx@24
+  double v22; // st7@24
+  double v23; // st6@24
+  int v24; // esi@25
+  int v25; // eax@25
+  BLVDoor *v26; // edi@25
+  signed __int64 v27; // qtt@27
+  BLVFaceExtra *v28; // esi@32
+  int v29; // ecx@34
+  int v30; // edx@34
+  unsigned __int64 v31; // qax@34
+  int v32; // eax@34
+  unsigned __int16 *v33; // eax@35
+  Vec3_short_ *v34; // eax@35
+  int v35; // ecx@35
+  int v36; // edx@35
+  signed int v37; // eax@35
+  signed int v38; // edx@35
+  int v39; // eax@35
+  int v40; // edx@35
+  unsigned __int8 v41; // cf@35
+  unsigned __int16 *v42; // edi@36
+  Vec3_short_ *v43; // edi@36
+  int v44; // ecx@36
+  int v45; // edi@36
+  int v46; // ecx@36
+  unsigned __int16 *v47; // edx@44
+  int v48; // ecx@44
+  unsigned int v49; // ecx@46
+  unsigned __int16 v50; // ax@48
+  unsigned int v51; // eax@51
+  unsigned __int16 v52; // ax@54
+  int v53; // ecx@57
+  int v54; // edx@57
+  unsigned __int64 v55; // qax@57
+  int v56; // ecx@58
+  int v57; // eax@58
+  int v58; // eax@59
+  SoundID v59; // [sp-24h] [bp-88h]@12
+  signed int v60; // [sp-20h] [bp-84h]@12
+  unsigned int v61; // [sp-1Ch] [bp-80h]@12
+  signed int v62; // [sp-18h] [bp-7Ch]@12
+  signed int v63; // [sp-14h] [bp-78h]@12
+  int v64; // [sp-10h] [bp-74h]@12
+  unsigned int v65; // [sp-Ch] [bp-70h]@12
+  int v66; // [sp-8h] [bp-6Ch]@12
+  int v67; // [sp+8h] [bp-5Ch]@31
+  int v68; // [sp+Ch] [bp-58h]@34
+  int v69; // [sp+10h] [bp-54h]@34
+  int v70; // [sp+14h] [bp-50h]@31
+  int v71; // [sp+18h] [bp-4Ch]@34
+  int v72; // [sp+1Ch] [bp-48h]@34
+  int v73; // [sp+20h] [bp-44h]@24
+  __int16 v74; // [sp+24h] [bp-40h]@24
+  int v75; // [sp+28h] [bp-3Ch]@36
+  int v76; // [sp+2Ch] [bp-38h]@36
+  int v77; // [sp+30h] [bp-34h]@36
+  int v78; // [sp+34h] [bp-30h]@36
+  int v79; // [sp+38h] [bp-2Ch]@19
+  unsigned int v80; // [sp+3Ch] [bp-28h]@2
+  int v81; // [sp+40h] [bp-24h]@1
+  int v82; // [sp+44h] [bp-20h]@35
+  int v83; // [sp+48h] [bp-1Ch]@34
+  int v84; // [sp+4Ch] [bp-18h]@34
+  int v85; // [sp+50h] [bp-14h]@19
+  SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1
+  BLVDoor *v87; // [sp+58h] [bp-Ch]@3
+  int v88; // [sp+5Ch] [bp-8h]@18
+  int v89; // [sp+60h] [bp-4h]@6
+
+  v0 = 0;
+  v1 = 0;
+  eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID];
+  v81 = 0;
+  if ( pIndoor->uNumDoors > 0 )
+  {
+    v80 = 0;
+    do
+    {
+      v2 = &pIndoor->pDoors[v80 / 0x50];
+      v87 = &pIndoor->pDoors[v80 / 0x50];
+      v3 = pIndoor->pDoors[v80 / 0x50].uState;
+      if ( v3 == (short)v0 || v3 == 2 )
+      {
+        v2->uAttributes &= 0xFFFFFFFDu;
+        goto LABEL_62;
+      }
+      v2->uTimeSinceTriggered += pEventTimer->uTimeElapsed;
+      v4 = v2->uTimeSinceTriggered;
+      if ( v2->uState == 1 )
+      {
+        v89 = (signed int)(v4 * v2->uCloseSpeed) / 128;
+        if ( v89 >= v2->uMoveLength )
+        {
+          v89 = v2->uMoveLength;
+          v2->uState = BLVDoor::Open;
+LABEL_10:
+          if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 )
+          {
+            v66 = v0;
+            v65 = v0;
+            v64 = v0;
+            v7 = 8 * v1;
+            v63 = v0;
+            v62 = -1;
+            LOBYTE(v7) = 8 * v1 | 1;
+            v61 = v0;
+            v60 = v7;
+            v59 = (SoundID)((int)eDoorSoundID + 1);
+LABEL_17:
+            pAudioPlayer->PlaySound(v59, v60, v61, v62, v63, v64, v65, v66);
+            goto LABEL_18;
+          }
+          goto LABEL_18;
+        }
+      }
+      else
+      {
+        v5 = (signed int)(v4 * v2->uOpenSpeed) / 128;
+        v6 = v2->uMoveLength;
+        if ( v5 >= v6 )
+        {
+          v89 = v0;
+          v2->uState = (BLVDoor::State)v0;
+          goto LABEL_10;
+        }
+        v89 = v6 - v5;
+      }
+      if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 )
+      {
+        v66 = v0;
+        v65 = v0;
+        v64 = v0;
+        v8 = 8 * v1;
+        v63 = v0;
+        v62 = -1;
+        LOBYTE(v8) = 8 * v1 | 1;
+        v61 = 1;
+        v60 = v8;
+        v59 = eDoorSoundID;
+        goto LABEL_17;
+      }
+LABEL_18:
+      v11 = __OFSUB__(v2->uNumVertices, (short)v0);
+      v9 = v2->uNumVertices == (short)v0;
+      v10 = (signed __int16)(v2->uNumVertices - v0) < 0;
+      v88 = v0;
+      if ( !((unsigned __int8)(v10 ^ v11) | v9) )
+      {
+        do
+        {
+          v12 = v88;
+          v13 = v2->pVertexIDs[v88];
+          v85 = v89;
+          v79 = v2->vDirection.x;
+          v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
+          v13 *= 6;
+          *(__int16 *)((char *)&pIndoor->pVertices->x + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pXOffsets[v88];
+          v85 = v89;
+          v79 = v2->vDirection.y;
+          v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
+          *(__int16 *)((char *)&pIndoor->pVertices->y + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pYOffsets[v12];
+          v85 = v89;
+          v79 = v2->vDirection.z;
+          v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
+          v14 = ((unsigned int)(v79 * v89) >> 16) + v2->pZOffsets[v12];
+          ++v88;
+          *(__int16 *)((char *)&pIndoor->pVertices->z + v13) = v14;
+        }
+        while ( v88 < v2->uNumVertices );
+        v1 = v81;
+      }
+      v11 = __OFSUB__(v2->uNumFaces, (short)v0);
+      v9 = v2->uNumFaces == (short)v0;
+      v10 = (signed __int16)(v2->uNumFaces - v0) < 0;
+      v88 = v0;
+      if ( !((unsigned __int8)(v10 ^ v11) | v9) )
+      {
+        while ( 1 )
+        {
+          v15 = &pIndoor->pFaces[v2->pFaceIDs[v88]];
+          v16 = v15->pVertexIDs;
+          v17 = &pIndoor->pVertices[*v16];
+          v18 = v15->pFacePlane_old.vNormal.y;
+          v73 = *(int *)&v17->x;
+          v74 = v17->z;
+          v19 = v15->pFacePlane_old.vNormal.z;
+          v20 = -(v19 * v74 + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18);
+          v15->pFacePlane_old.dist = v20;
+          v21 = &pIndoor->pVertices[*v16];
+          v79 = v21->x;
+          v22 = (double)v79;
+          v23 = (double)v21->y;
+          v79 = v21->z;
+          v15->pFacePlane.dist = -((double)v79 * v15->pFacePlane.vNormal.z
+                                 + v23 * v15->pFacePlane.vNormal.y
+                                 + v22 * v15->pFacePlane.vNormal.x);
+          if ( v19 )
+          {
+            v24 = abs(v20 >> 15);
+            v25 = abs(v15->pFacePlane_old.vNormal.z);
+            v26 = v87;
+            if ( v24 > v25 )
+              Abortf(
+                "Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
+                v87->uDoorID,
+                v87->pFaceIDs[v88],
+                v15->pFacePlane_old.dist,
+                v15->pFacePlane_old.vNormal.z);
+            v79 = v15->pFacePlane_old.vNormal.z;
+            v85 = v15->pFacePlane_old.dist;
+            LODWORD(v27) = v85 << 16;
+            HIDWORD(v27) = v85 >> 16;
+            v85 = v27 / v79;
+            v15->zCalc3 = -(v27 / v79);
+          }
+          else
+          {
+            v26 = v87;
+          }
+          if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D )
+            v15->_get_normals((Vec3_int_ *)&v70, (Vec3_int_ *)&v67);
+          v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID];
+          if ( !pRenderer->pRenderD3D )
+          {
+            if ( !(BYTE2(v15->uAttributes) & 4) )
+              goto LABEL_59;
+            v79 = v26->vDirection.x;
+            v83 = (unsigned __int64)(v79 * (signed __int64)v70) >> 16;
+            v85 = v71;
+            v79 = v26->vDirection.y;
+            v85 = (unsigned __int64)(v79 * (signed __int64)v71) >> 16;
+            v84 = v72;
+            v79 = v26->vDirection.z;
+            v84 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
+            v79 = v83 + v85 + ((unsigned __int64)(v79 * (signed __int64)v72) >> 16);
+            v29 = v89;
+            v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
+            v28->sTextureDeltaU = -((unsigned int)(v79 * v89) >> 16);
+            v79 = v26->vDirection.x;
+            v85 = (unsigned __int64)(v79 * (signed __int64)v67) >> 16;
+            v83 = v68;
+            v79 = v26->vDirection.y;
+            v83 = (unsigned __int64)(v79 * (signed __int64)v68) >> 16;
+            v84 = v69;
+            v79 = v26->vDirection.z;
+            v84 = (unsigned __int64)(v79 * (signed __int64)v69) >> 16;
+            v30 = v83 + ((unsigned __int64)(v79 * (signed __int64)v69) >> 16);
+            v79 = v85 + v30;
+            v31 = (v85 + v30) * (signed __int64)v29;
+            v83 = v31 >> 16;
+            v32 = v31 >> 16;
+            goto LABEL_58;
+          }
+          v28->sTextureDeltaU = 0;
+          v28->sTextureDeltaV = 0;
+          v33 = v15->pVertexIDs;
+          v85 = 1;
+          v34 = &pIndoor->pVertices[*v33];
+          v35 = v34->z;
+          v36 = v34->y;
+          v82 = v34->x;
+          v79 = v36;
+          v37 = v70 * v82 + v71 * v36 + v72 * v35;
+          v38 = v67 * v82 + v68 * v36 + v35 * v69;
+          v39 = v37 >> 16;
+          *v15->pVertexUIDs = v39;
+          v40 = v38 >> 16;
+          *v15->pVertexVIDs = v40;
+          v41 = v15->uNumVertices < 1u;
+          v9 = v15->uNumVertices == 1;
+          v83 = v40;
+          v84 = v39;
+          v82 = v40;
+          if ( !(v41 | v9) )
+          {
+            do
+            {
+              v42 = v15->pVertexIDs;
+              v75 = 2 * v85;
+              v43 = &pIndoor->pVertices[v42[v85]];
+              v79 = v43->z;
+              v44 = v43->y;
+              v45 = v43->x;
+              v78 = v44;
+              v76 = (v72 * v79 + v70 * v45 + v71 * v44) >> 16;
+              v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16;
+              v77 = v46;
+              if ( v76 < v39 )
+                v39 = v76;
+              if ( v46 < v40 )
+                v83 = v46;
+              if ( v76 > v84 )
+                v84 = v76;
+              if ( v46 > v82 )
+                v82 = v46;
+              v47 = v15->pVertexUIDs;
+              v48 = v75;
+              ++v85;
+              *(unsigned __int16 *)((char *)v47 + v75) = v76;
+              *(unsigned __int16 *)((char *)v15->pVertexVIDs + v48) = v77;
+              v40 = v83;
+            }
+            while ( v85 < v15->uNumVertices );
+            v26 = v87;
+          }
+          v49 = v15->uAttributes;
+          if ( BYTE1(v49) & 0x10 )
+            goto LABEL_50;
+          if ( SBYTE1(v49) < 0 )
+          {
+            v50 = v15->uBitmapID;
+            if ( v50 != -1 )
+              break;
+          }
+LABEL_51:
+          v51 = v15->uAttributes;
+          if ( v51 & 8 )
+          {
+            v28->sTextureDeltaV -= v40;
+          }
+          else
+          {
+            if ( v51 & 0x20000 )
+            {
+              v52 = v15->uBitmapID;
+              if ( v52 != -1 )
+                v28->sTextureDeltaV -= v82
+                                     + *(short *)((signed __int16)v52 != -1 ? 72 * (signed __int16)v52 + 7278780 + 0x1A : 26);
+            }
+          }
+          if ( BYTE2(v15->uAttributes) & 4 )
+          {
+            v75 = v26->vDirection.x;
+            v84 = (unsigned __int64)(v75 * (signed __int64)v70) >> 16;
+            v82 = v71;
+            v75 = v26->vDirection.y;
+            v82 = (unsigned __int64)(v75 * (signed __int64)v71) >> 16;
+            v83 = v72;
+            v75 = v26->vDirection.z;
+            v83 = (unsigned __int64)(v75 * (signed __int64)v72) >> 16;
+            v75 = v84 + v82 + ((unsigned __int64)(v75 * (signed __int64)v72) >> 16);
+            v53 = v89;
+            v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16;
+            v28->sTextureDeltaU = -((unsigned int)(v75 * v89) >> 16);
+            v75 = v26->vDirection.x;
+            v84 = (unsigned __int64)(v75 * (signed __int64)v67) >> 16;
+            v82 = v68;
+            v75 = v26->vDirection.y;
+            v82 = (unsigned __int64)(v75 * (signed __int64)v68) >> 16;
+            v83 = v69;
+            v75 = v26->vDirection.z;
+            v83 = (unsigned __int64)(v75 * (signed __int64)v69) >> 16;
+            v54 = v82 + ((unsigned __int64)(v75 * (signed __int64)v69) >> 16);
+            v75 = v84 + v54;
+            v55 = (v84 + v54) * (signed __int64)v53;
+            v82 = v55 >> 16;
+            v32 = v55 >> 16;
+LABEL_58:
+            v56 = v88;
+            v57 = -v32;
+            v28->sTextureDeltaV = v57;
+            v28->sTextureDeltaU += v26->pDeltaUs[v56];
+            v28->sTextureDeltaV = v57 + v26->pDeltaVs[v56];
+          }
+LABEL_59:
+          v58 = v26->uNumFaces;
+          ++v88;
+          if ( v88 >= v58 )
+          {
+            v1 = v81;
+            v0 = 0;
+            goto LABEL_62;
+          }
+          v2 = v87;
+        }
+        LOWORD(v39) = v84
+                    + ((signed __int16)v39 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v39].uTextureWidth : 24);
+LABEL_50:
+        v28->sTextureDeltaU -= v39;
+        goto LABEL_51;
+      }
+LABEL_62:
+      v80 += 80;
+      ++v1;
+      v81 = v1;
+    }
+    while ( v1 < pIndoor->uNumDoors );
+  }
+}
+// 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID;
+
+//----- (0046F90C) --------------------------------------------------------
+void __cdecl 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
+  int v25; // eax@52
+  int v26; // ebx@54
+  int v27; // ST08_4@54
+  int v28; // edi@54
+  int v29; // eax@54
+  int v30; // ecx@62
+  int v31; // ebx@62
+  int v32; // eax@62
+  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
+  int v42; // eax@96
+  __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
+  int v55; // [sp+3Ch] [bp-24h]@6
+  int v56; // [sp+40h] [bp-20h]@6
+  unsigned int _this; // [sp+44h] [bp-1Ch]@51
+  int v58; // [sp+48h] [bp-18h]@51
+  int v59; // [sp+4Ch] [bp-14h]@8
+  int v60; // [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 )
+    {
+      v0 = &pActors[v63];
+      v1 = v0->uAIState;
+      if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
+        goto LABEL_123;
+      v55 = v0->uSectorID;
+      v2 = _46ED1B_collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, (unsigned int *)&v55, &v60);
+      v0->uSectorID = v55;
+      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 = _46CEC3_get_floor_level(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &v60), v56 == -30000) )
+          goto LABEL_123;
+      }
+      if ( v0->uCurrentActionAnimation == 1 )
+      {
+        v6 = v0->uMovementSpeed;
+        v7 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0;
+        v8 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0;
+        v61 = v0->uMovementSpeed;
+        if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[7].uExpireTime)) )
+        {
+          v9 = v0->pActorBuffs[7].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->field_4 == 1 )
+          v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6);
+        if ( v6 > 1000 )
+          v6 = 1000;
+        v12 = stru_5C6E00->SinCos(v0->uYawAngle);
+        v55 = v12;
+        v13 = v12 * (signed __int64)v6;
+        v61 = v13 >> 16;
+        v0->vVelocity.x = WORD1(v13);
+        v55 = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
+        v61 = (unsigned __int64)(v55 * (signed __int64)v6) >> 16;
+        v7 = v62 == 0;
+        v0->vVelocity.y = (unsigned int)(v55 * v6) >> 16;
+        if ( !v7 )
+        {
+          v14 = stru_5C6E00->SinCos(v0->uPitchAngle - stru_5C6E00->uIntegerHalfPi);
+          v55 = v14;
+          v15 = v14 * (signed __int64)v6;
+          v61 = v15 >> 16;
+          v0->vVelocity.z = WORD1(v15);
+        }
+      }
+      else
+      {
+        v61 = v0->vVelocity.x;
+        v55 = 55000;
+        v61 = (unsigned __int64)(55000i64 * v61) >> 16;
+        v0->vVelocity.x = v61;
+        v61 = v0->vVelocity.y;
+        v61 = (unsigned __int64)(v55 * (signed __int64)v61) >> 16;
+        v7 = v62 == 0;
+        v0->vVelocity.y = v61;
+        if ( !v7 )
+        {
+          v55 = 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 = v60;
+      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();
+        }
+      }
+      else
+      {
+        if ( v59 && !v62 )
+          v0->vVelocity.z += -8 * 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 == 5 )
+          v0->uAIState = 11;
+      }
+LABEL_123:
+      ++v63;
+      if ( (signed int)v63 >= (signed int)uNumActors )
+        return;
+    }
+    v20 = v0->uActorRadius;
+    v21 = v0->uActorHeight;
+    stru_721530.field_84 = -1;
+    stru_721530.field_70 = 0;
+    v55 = 0;
+    stru_721530.field_0 = 1;
+    stru_721530.field_8 = v20;
+    stru_721530.prolly_normal_d = v20;
+    stru_721530.field_C = v21;
+    v22 = 0;
+    while ( 1 )
+    {
+      stru_721530.field_34.x = v0->vPosition.x;
+      stru_721530.normal.x = stru_721530.field_34.x;
+      stru_721530.field_34.y = v0->vPosition.y;
+      stru_721530.normal.y = stru_721530.field_34.y;
+      v23 = v0->vPosition.z;
+      stru_721530.normal.z = v23 + v20 + 1;
+      stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1;
+      if ( stru_721530.field_34.z < stru_721530.normal.z )
+        stru_721530.field_34.z = v23 + v20 + 1;
+      stru_721530.field_1C = v0->vVelocity.x;
+      stru_721530.field_20 = v0->vVelocity.y;
+      stru_721530.field_24 = v0->vVelocity.z;
+      stru_721530.uSectorID = v0->uSectorID;
+      if ( !stru_721530._47050A(v22) )
+      {
+        v58 = v22;
+        v24 = 8 * v63;
+        LOBYTE(v24) = 8 * v63 | 3;
+        v61 = v22;
+        _this = v24;
+        do
+        {
+          _46E44E_collide_against_faces_and_portals(1u);
+          _46E0B2_collide_against_decorations();
+          _46EF01_collision_chech_player(0);
+          _46ED8A_collide_against_layingItems(_this);
+          v25 = 0;
+          v56 = 0;
+          if ( ai_arrays_size > v22 )
+          {
+            do
+            {
+              v54 = ai_array_4F7DB0_actor_ids[v25];
+              if ( v54 != v63 )
+              {
+                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 ( sub_4621DA(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius
+                  && _46DF1A_collide_against_actor(v54, 40) )
+                  ++v58;
+                v22 = 0;
+              }
+              v25 = v56++ + 1;
+            }
+            while ( v56 < ai_arrays_size );
+          }
+          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
+        {
+          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
+          v30 = v58 + v0->vPosition.x;
+          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
+          v31 = v58 + v0->vPosition.y;
+          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+          v32 = v58 + v0->vPosition.z;
+        }
+        v33 = _46ED1B_collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &v60);
+        v34 = pIndoor->pFaces[v60].uAttributes;
+        v35 = v34 & 0x400000;
+        if ( v35 && v0->uAIState == 5 )
+        {
+          v0->uAIState = 11;
+          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 ( stru_721530.field_7C >= stru_721530.field_6C )
+            {
+              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);
+              goto LABEL_123;
+            }
+            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
+            v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
+            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
+            v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
+            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
+            v36 = stru_721530.uFaceID;
+            v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
+            v0->uSectorID = LOWORD(stru_721530.uSectorID);
+            stru_721530.field_70 += stru_721530.field_7C;
+            v37 = v36 >> 3;
+            if ( (v36 & 7) != 3 )
+            {
+              if ( (v36 & 7) != 4 )
+              {
+                if ( (v36 & 7) == 5 )
+                {
+                  _this = sub_452A9E(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);
+                  v54 = stru_5C6E00->SinCos(v45);
+                  v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16;
+                  v46 = v45 - stru_5C6E00->uIntegerHalfPi;
+                  v0->vVelocity.x = v54 * _this >> 16;
+                  v47 = stru_5C6E00->SinCos(v46);
+                  v54 = v47;
+                  v48 = v47 * (signed __int64)(signed int)_this;
+                  v56 = v48 >> 16;
+                  v0->vVelocity.y = WORD1(v48);
+                  goto LABEL_119;
+                }
+                if ( (v36 & 7) == 6 )
+                {
+                  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.field_64 >> 3 > v61 )
+                      v61 = stru_721530.field_64 >> 3;
+                    v58 = v38->pFacePlane_old.vNormal.x;
+                    v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16;
+                    _this = v38->pFacePlane_old.vNormal.y;
+                    _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16;
+                    v56 = v38->pFacePlane_old.vNormal.z;
+                    v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16;
+                    v0->vVelocity.x += v58;
+                    v0->vVelocity.y += _this;
+                    v0->vVelocity.z += v56;
+                    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:
+                v56 = v0->vVelocity.x;
+                v54 = 58500;
+                v56 = (unsigned __int64)(58500i64 * v56) >> 16;
+                v0->vVelocity.x = v56;
+                v56 = v0->vVelocity.y;
+                v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
+                v54 = 58500;
+                v0->vVelocity.y = v56;
+                v56 = v0->vVelocity.z;
+                v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
+                v22 = 0;
+                v0->vVelocity.z = v56;
+                goto LABEL_120;
+              }
+              if ( v0->GetActorsRelation(0) )
+              {
+                v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[11].uExpireTime), v22);
+                v49 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == v22;
+                v50 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) - v22 < 0;
+                v0->vVelocity.y = v22;
+                v0->vVelocity.x = v22;
+                if ( !(v50 ^ v51)
+                  && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v22) )
+                  pParty->pPartyBuffs[11].Reset();
+                viewparams->bRedrawGameUI = 1;
+                goto LABEL_119;
+              }
+              v36 = stru_721530.uFaceID;
+LABEL_118:
+              Actor::FaceObject(v63, v36, v22, (AIDirection *)v22);
+              goto LABEL_119;
+            }
+            if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 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::_402968(v63, v36, v22, (AIDirection *)v22);
+                goto LABEL_119;
+              }
+            }
+            Actor::_403F58(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->field_4 == 2 || pTurnEngine->field_4 == 3) )
+            goto LABEL_123;
+          if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 )
+          {
+            Actor::_403F58(v63, 4, v22, &v52);
+            goto LABEL_123;
+          }
+        }
+      }
+LABEL_120:
+      ++v55;
+      if ( v55 >= 100 )
+        goto LABEL_123;
+      v20 = stru_721530.prolly_normal_d;
+    }
+  }
+}
+// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
+// 4F75D8: using guessed type int ai_arrays_size;
+
+
+
+
+
+
+//----- (00460A78) --------------------------------------------------------
+void __thiscall PrepareToLoadBLV(unsigned int bLoading)
+{
+  unsigned int v1; // ebx@1
+  unsigned int v2; // eax@8
+  MapInfo *v3; // 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
+  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;
+  pGameLoadingUI_ProgressBar->Reset(0x20u);
+  bUnderwater = 0;
+  bNoNPCHiring = 0;
+  v38 = 0;
+  pDest = 1;
+  uCurrentlyLoadedLevelType = LEVEL_Indoor;
+  pGame->uFlags2 &= 0xFFFFFFF7u;
+  if ( Is_out15odm_underwater() )
+  {
+    bUnderwater = 1;
+    pGame->uFlags2 |= 8u;
+  }
+  if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d23.blv") )
+    bNoNPCHiring = 1;
+  pPaletteManager->field_267AD3 = 0;
+  pPaletteManager->field_267AD4 = 0;
+  pPaletteManager->field_267AD5 = 0;
+  pPaletteManager->RecalculateAll();
+  if ( qword_A750D8 )
+    qword_A750D8 = 0i64;
+  v2 = pMapStats->GetMapInfo(pCurrentMapName);
+  v39 = v2;
+  if ( v2 )
+  {
+    v3 = &pMapStats->pInfos[v2];
+    v1 = v3->uRespawnIntervalDays;
+    v38 = GetAlertStatus();
+  }
+  else
+  {
+    v3 = v37;
+  }
+  dword_6BE13C_uCurrentlyLoadedLocationID = v39;
+  pAllocator->FreeChunk(ptr_6A0D08);
+  ptr_6A0D08 = 0;
+  _6A0D0C_txt_lod_loading = 0;
+  TryLoadLevelFromLOD();
+  uNumStationaryLightsApplied = 0;
+  v4 = pIndoor->Load(
+         pCurrentMapName,
+         (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1,
+         v1,
+         (char *)&pDest)
+     - 1;
+  if ( !v4 )
+  {
+    sprintf(&Args, "Unable to open %s", pCurrentMapName);
+    Abortf(&Args);
+  }
+  v5 = v4 - 1;
+  if ( !v5 )
+  {
+    sprintf(&Args, "File %s is not a BLV File", pCurrentMapName);
+    Abortf(&Args);
+  }
+  v6 = v5 - 1;
+  if ( !v6 )
+    Abortf("Attempt to open new level before clearing old");
+  if ( v6 == 1 )
+    Abortf("Out of memory loading indoor level");
+  if ( !(dword_6BE364_game_settings_1 & 0x2000) )
+  {
+    UpdateActors();
+    UpdateLayingItems();
+  }
+  BYTE1(dword_6BE364_game_settings_1) &= 0xDFu;
+  if ( !v39 )
+    pDest = 0;
+  if ( pDest == 1 )
+  {
+    v7 = 0;
+    for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++v7 )
+    {
+      v8 = &pIndoor->pSpawnPoints[v7];
+      if ( pIndoor->pSpawnPoints[v7].uKind == 3 )
+        SpawnEncounter(v3, v8, 0, 0, 0);
+      else
+        v3->SpawnRandomTreasure(v8);
+      ++i;
+    }
+    RespawnGlobalDecorations();
+  }
+
+  pSoundList->_4A9A67(pDoorSoundIDsByLocationID[v39], 0);
+  pSoundList->_4A9A67(pDoorSoundIDsByLocationID[v39] + 1, 0);
+
+  for (uint i = 0; i < pIndoor->uNumDoors; ++i)
+  {
+    auto pDoor = pIndoor->pDoors + i;
+
+    if (pDoor->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;
+    }
+  }
+
+/*
+  i = 0;
+  v9 = 2;
+  if ( pIndoor->uNumDoors > 0 )
+  {
+    v10 = 0;
+    while ( 1 )
+    {
+      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;
+    }
+    *(short *)v11 = 3;
+LABEL_41:
+    pIndoor->pDoors[v10].uTimeSinceTriggered = 15360;
+    pIndoor->pDoors[v10].uAttributes = 2;
+    goto LABEL_42;
+  }
+LABEL_43:
+*/
+
+  for (uint i = 0; i < pIndoor->uNumFaces; ++i)
+  {
+    auto pFace = pIndoor->pFaces + i;
+    if (!pFace->uBitmapID != -1)
+      pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1);
+ }
+
+  /*i = 0;
+  if ( (signed int)pIndoor->uNumFaces > 0 )
+  {
+    v12 = 0;
+    do
+    {
+      if ( pIndoor->pFaces[v12].uBitmapID != -1 )
+        pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1);
+      ++i;
+      ++v12;
+    }
+    while ( i < (signed int)pIndoor->uNumFaces );
+  }*/
+
+  
+  pGameLoadingUI_ProgressBar->Progress();
+  
+  for (uint i = 0; i < uNumLevelDecorations; ++i)
+  {
+    auto pDecortaion = pLevelDecorations + i;
+    
+    pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID);
+
+    v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID;
+    if (v15 && _6807E0_num_decorations_6807B8 < 9)
+    {
+        pSoundList->_4A9A67(v15, 0);
+        v16 = _6807E0_num_decorations_6807B8++;
+        _6807B8_level_decorations_ids[v16] = i;
+    }
+
+    if ( !(pDecortaion->field_2 & 0x20) )
+    {
+      v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID];
+      if ( !((unsigned __int8)2 & v17->uFlags) )
+        {
+          v18 = v17->uLightRadius;
+          if ( v18 )
+          {
+            unsigned char r = 255,
+                          g = 255,
+                          b = 255;
+            if (pRenderer->pRenderD3D && 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,
+              byte_4E94D0);
+          }
+        }
+      }
+
+      if (!pDecortaion->field_16_event_id)
+      {
+        if (pDecortaion->IsInteractive())
+        {
+          if ( v35 < 124 )
+          {
+            v21 = v35 + 1;
+            pDecortaion->field_1C = v35 + 75;
+            v22 = stru_5E4C90.field_0[v21 + 74];
+            v35 = v21;
+            if ( !v22 )
+              pDecortaion->field_2 |= 0x20;
+          }
+        }
+      }
+  }
+
+  pGameLoadingUI_ProgressBar->Progress();
+
+  for (uint i = 0; i < uNumLayingItems; ++i)
+  {
+    auto p = pLayingItems + i;
+    if (p->uObjectDescID)
+    {
+      auto uItemID = p->stru_24.uItemID;
+      if (uItemID)
+      {
+        if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION &&
+            !p->stru_24._bonus_type)
+          p->stru_24._bonus_type = rand() % 15 + 5;
+        pItemsTable->SetSpecialBonus(&p->stru_24);
+      }
+    }
+  }
+
+  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
+      {
+        v28 = v38 == 1;
+      }
+
+      if ( !v28 )
+      {
+        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();
+        }
+      }
+      else
+      {
+          pActor->pMonsterInfo.field_3E = 19;
+          pActor->uAttributes |= 0x10000;
+      }
+    //}
+    //while ( i < (signed int)uNumActors );
+  }
+
+  pGameLoadingUI_ProgressBar->Progress();
+
+  Actor this_;
+  this_.pMonsterInfo.uID = 45;
+  this_.PrepareSprites(0);
+  if ( !v37 )
+  {
+    pParty->sRotationX = 0;
+    pParty->sRotationY = 0;
+    pParty->vPosition.y = 0;
+    pParty->vPosition.z = 0;
+    pParty->vPosition.x = 0;
+    pParty->uFallStartY = 0;
+    pParty->uFallSpeed = 0;
+    TeleportToStartingPoint(uLevel_StartingPointType);
+  }
+  viewparams->_443365();
+  PlayLevelMusic();
+  if ( !v37 )
+  {
+    v30 = 0;
+    v31 = 1;
+    do
+    {
+      if ( pPlayers[v31]->CanAct() )
+        v34[v30++] = v31;
+      ++v31;
+    }
+    while ( v31 <= 4 );
+    if ( v30 )
+    {
+      if ( pDest )
+      {
+        qword_A750D8 = 256i64;
+        word_A750E0 = 46;
+        word_A750E2 = LOWORD(v34[rand() % v30]);
+      }
+    }
+  }
+}
\ No newline at end of file
--- a/Indoor.h	Thu Oct 18 09:11:23 2012 +0600
+++ b/Indoor.h	Thu Oct 18 09:12:00 2012 +0600
@@ -198,10 +198,20 @@
 };
 #pragma pack(pop)
 
+
+
 /*  100 */
 #pragma pack(push, 1)
 struct BLVDoor
 {
+  enum State: unsigned __int16
+  {
+    Closed = 0,
+    Opening = 1,
+    Open = 2,
+    Closing = 3
+  };
+
   unsigned int uAttributes;
   unsigned int uDoorID;
   unsigned int uTimeSinceTriggered;
@@ -221,7 +231,7 @@
   unsigned __int16 uNumFaces;
   __int16 field_48;
   unsigned __int16 uNumOffsets;
-  unsigned __int16 uState;
+  State uState;
   __int16 field_4E;
 };
 #pragma pack(pop)
--- a/LightmapBuilder.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/LightmapBuilder.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -11,10 +11,10 @@
 
 
 
-LightsStack_StationaryLight_ *pStationaryLightsStack;
+LightsStack_StationaryLight_ *pStationaryLightsStack = new LightsStack_StationaryLight_;
 StationaryLight pStationaryLights[400];
 int uNumStationaryLightsApplied; // weak
-LightsStack_MobileLight_ *pMobileLightsStack;
+LightsStack_MobileLight_ *pMobileLightsStack = new LightsStack_MobileLight_;
 MobileLight pMobileLights[400];
 int uNumMobileLightsApplied;
 
--- a/Lights.h	Thu Oct 18 09:11:23 2012 +0600
+++ b/Lights.h	Thu Oct 18 09:12:00 2012 +0600
@@ -72,7 +72,7 @@
   }
 
   //----- (004AD3C8) --------------------------------------------------------
-  inline bool AddLight(__int16 x, __int16 y, __int16 z, __int16 a5, int *r, char g, char b, char a9)
+  inline bool AddLight(__int16 x, __int16 y, __int16 z, __int16 a5, unsigned char r, unsigned char g, unsigned char b, char a9)
   {
     unsigned int v9; // eax@1
     std::string v11; // [sp-18h] [bp-18h]@3
--- a/Monsters.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/Monsters.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -813,7 +813,7 @@
             v102->pInfos[v103].uAIType = v101;
             goto LABEL_325;
           case 0xC:
-            v102->pInfos[v103].uHostilityType = atoi((const char *)v2);
+            v102->pInfos[v103].uHostilityType = (MonsterInfo::HostilityRadius)atoi((const char *)v2);
             goto LABEL_325;
           case 0xD:
             v102->pInfos[v103].uBaseSpeed = atoi((const char *)v2);
--- a/Monsters.h	Thu Oct 18 09:11:23 2012 +0600
+++ b/Monsters.h	Thu Oct 18 09:12:00 2012 +0600
@@ -71,6 +71,15 @@
 #pragma pack(push, 1)
 struct MonsterInfo
 {
+  enum HostilityRadius: unsigned __int8
+  {
+    Hostility_Friendly = 0,
+    Hostility_Close = 1,
+    Hostility_Short = 2,
+    Hostility_Medium = 3,
+    Hostility_Long = 4
+  };
+
   char *pName;
   char *pTexture;
   unsigned __int8 uLevel;
@@ -82,7 +91,7 @@
   unsigned __int8 uFlying;
   unsigned __int8 uMovementType;
   unsigned __int8 uAIType;
-  unsigned __int8 uHostilityType;
+  HostilityRadius uHostilityType;
   char field_12;
   unsigned __int8 uSpecialAttack;
   unsigned __int8 uSpecialAttackType;
--- a/Render.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/Render.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -3506,7 +3506,7 @@
                 y,
                 v36 + v1->uDecorationHeight / 2,
                 a5,
-                (int *)v14,
+                v14,
                 v15,
                 v16,
                 byte_4E94D0);
--- a/mm7_2.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/mm7_2.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -3381,7 +3381,7 @@
     v7->uTetherDistance = 256;
     v7->uSectorID = v16;
     v7->uGroup = 1;
-    v7->pMonsterInfo.uHostilityType = 4;
+    v7->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
     v7->PrepareSprites(0);
     v11 = v10->pSoundSampleIDs;
     ya = 4;
@@ -7751,7 +7751,7 @@
       v22->uSectorID = v54;
       v22->uGroup = v6->uGroup;
       v22->PrepareSprites((char)v45);
-      v22->pMonsterInfo.uHostilityType = 0;
+      v22->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
       v32 = rand();
       v33 = v32 % 2048;
       v34 = stru_5C6E00->SinCos(v32 % 2048);
@@ -7890,7 +7890,7 @@
     v6->uTetherDistance = 256;
     v6->uSectorID = v12;
     v6->PrepareSprites(0);
-    v6->pMonsterInfo.uHostilityType = 0;
+    v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
     v6->uAlly = 9999;
     v6->uGroup = 0;
     v6->uCurrentActionTime = 0;
@@ -11823,354 +11823,6 @@
   return v0;
 }
 
-//----- (00460A78) --------------------------------------------------------
-void __thiscall PrepareToLoadBLV(unsigned int bLoading)
-{
-  unsigned int v1; // ebx@1
-  unsigned int v2; // eax@8
-  MapInfo *v3; // 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
-  char v20; // dl@58
-  int v21; // eax@64
-  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;
-  pGameLoadingUI_ProgressBar->Reset(0x20u);
-  bUnderwater = 0;
-  bNoNPCHiring = 0;
-  v38 = 0;
-  pDest = 1;
-  uCurrentlyLoadedLevelType = LEVEL_Indoor;
-  pGame->uFlags2 &= 0xFFFFFFF7u;
-  if ( Is_out15odm_underwater() )
-  {
-    bUnderwater = 1;
-    pGame->uFlags2 |= 8u;
-  }
-  if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d23.blv") )
-    bNoNPCHiring = 1;
-  pPaletteManager->field_267AD3 = 0;
-  pPaletteManager->field_267AD4 = 0;
-  pPaletteManager->field_267AD5 = 0;
-  pPaletteManager->RecalculateAll();
-  if ( qword_A750D8 )
-    qword_A750D8 = 0i64;
-  v2 = pMapStats->GetMapInfo(pCurrentMapName);
-  v39 = v2;
-  if ( v2 )
-  {
-    v3 = &pMapStats->pInfos[v2];
-    v1 = v3->uRespawnIntervalDays;
-    v38 = GetAlertStatus();
-  }
-  else
-  {
-    v3 = v37;
-  }
-  dword_6BE13C_uCurrentlyLoadedLocationID = v39;
-  pAllocator->FreeChunk(ptr_6A0D08);
-  ptr_6A0D08 = 0;
-  _6A0D0C_txt_lod_loading = 0;
-  TryLoadLevelFromLOD();
-  uNumStationaryLightsApplied = 0;
-  v4 = pIndoor->Load(
-         pCurrentMapName,
-         (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1,
-         v1,
-         (char *)&pDest)
-     - 1;
-  if ( !v4 )
-  {
-    sprintf(&Args, "Unable to open %s", pCurrentMapName);
-    Abortf(&Args);
-  }
-  v5 = v4 - 1;
-  if ( !v5 )
-  {
-    sprintf(&Args, "File %s is not a BLV File", pCurrentMapName);
-    Abortf(&Args);
-  }
-  v6 = v5 - 1;
-  if ( !v6 )
-    Abortf("Attempt to open new level before clearing old");
-  if ( v6 == 1 )
-    Abortf("Out of memory loading indoor level");
-  if ( !(dword_6BE364_game_settings_1 & 0x2000) )
-  {
-    UpdateActors();
-    UpdateLayingItems();
-  }
-  BYTE1(dword_6BE364_game_settings_1) &= 0xDFu;
-  if ( !v39 )
-    pDest = 0;
-  if ( pDest == 1 )
-  {
-    v7 = 0;
-    for ( i = 0; i < (signed int)pIndoor->uNumSpawnPoints; ++v7 )
-    {
-      v8 = &pIndoor->pSpawnPoints[v7];
-      if ( pIndoor->pSpawnPoints[v7].uKind == 3 )
-        SpawnEncounter(v3, v8, 0, 0, 0);
-      else
-        v3->SpawnRandomTreasure(v8);
-      ++i;
-    }
-    RespawnGlobalDecorations();
-  }
-  pSoundList->_4A9A67(pDoorSoundIDsByLocationID[v39], 0);
-  pSoundList->_4A9A67(pDoorSoundIDsByLocationID[v39] + 1, 0);
-  i = 0;
-  v9 = 2;
-  if ( pIndoor->uNumDoors > 0 )
-  {
-    v10 = 0;
-    while ( 1 )
-    {
-      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;
-    }
-    *(short *)v11 = 3;
-LABEL_41:
-    pIndoor->pDoors[v10].uTimeSinceTriggered = 15360;
-    pIndoor->pDoors[v10].uAttributes = 2;
-    goto LABEL_42;
-  }
-LABEL_43:
-  i = 0;
-  if ( (signed int)pIndoor->uNumFaces > 0 )
-  {
-    v12 = 0;
-    do
-    {
-      if ( pIndoor->pFaces[v12].uBitmapID != -1 )
-        pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1);
-      ++i;
-      ++v12;
-    }
-    while ( i < (signed int)pIndoor->uNumFaces );
-  }
-  v13 = 0;
-  pGameLoadingUI_ProgressBar->Progress();
-  i = 0;
-  if ( (signed int)uNumLevelDecorations > 0 )
-  {
-    v14 = (char *)&pLevelDecorations[0].vPosition.y;
-    do
-    {
-      pDecorationList->InitializeDecorationSprite(*((short *)v14 - 4));
-      v15 = pDecorationList->pDecorations[*((short *)v14 - 4)].uSoundID;
-      if ( v15 != (short)v13 && _6807E0_num_decorations_6807B8 < 9 )
-      {
-        pSoundList->_4A9A67(v15, v13);
-        v16 = _6807E0_num_decorations_6807B8++;
-        _6807B8_level_decorations_ids[v16] = i;
-      }
-      if ( !(*(v14 - 6) & 0x20) )
-      {
-        v17 = &pDecorationList->pDecorations[*((short *)v14 - 4)];
-        if ( !((unsigned __int8)v9 & v17->uFlags) )
-        {
-          v18 = v17->uLightRadius;
-          if ( v18 != v13 )
-          {
-            if ( pRenderer->pRenderD3D == (RenderD3D *)v13 || pRenderer->bUseColoredLights == v13 )
-            {
-              v20 = -1;
-              v19 = (int *)255;
-              *(int *)b = 255;
-            }
-            else
-            {
-              v19 = (int *)v17->uColoredLightRed;
-              v20 = v17->uColoredLightGreen;
-              *(int *)b = v17->uColoredLightBlue;
-            }
-            pStationaryLightsStack->AddLight(
-              *((int *)v14 - 1),
-              *(int *)v14,
-              *((short *)v14 + 2) + v17->uDecorationHeight / 2,
-              v18,
-              v19,
-              v20,
-              b[0],
-              byte_4E94D0);
-            v13 = 0;
-            v9 = 2;
-          }
-        }
-      }
-      if ( *((short *)v14 + 7) == (short)v13 )
-      {
-        if ( ((LevelDecoration *)(v14 - 8))->IsInteractive() )
-        {
-          if ( v35 < 124 )
-          {
-            v21 = v35 + 1;
-            *((short *)v14 + 10) = v35 + 75;
-            v22 = stru_5E4C90.field_0[v21 + 74];
-            v35 = v21;
-            if ( !v22 )
-              *(v14 - 6) |= 0x20u;
-          }
-        }
-      }
-      ++i;
-      v14 += 32;
-    }
-    while ( i < (signed int)uNumLevelDecorations );
-  }
-  pGameLoadingUI_ProgressBar->Progress();
-  v23 = 0;
-  if ( (signed int)uNumLayingItems > (signed int)v13 )
-  {
-    v24 = (char *)&pLayingItems[0].stru_24;
-    do
-    {
-      if ( *((short *)v24 - 17) != (short)v13 )
-      {
-        v25 = *(int *)v24;
-        if ( *(int *)v24 != v13 )
-        {
-          if ( v25 != 220 && pItemsTable->pItems[v25].uEquipType == 14 && *((int *)v24 + 1) == v13 )
-            *((int *)v24 + 1) = rand() % 15 + 5;
-          pItemsTable->SetSpecialBonus((ItemGen *)v24);
-        }
-      }
-      ++v23;
-      v24 += 112;
-    }
-    while ( v23 < (signed int)uNumLayingItems );
-  }
-  i = v13;
-  if ( (signed int)uNumActors > (signed int)v13 )
-  {
-    v26 = (char *)&pActors[0].uAttributes;
-    do
-    {
-      v27 = *(int *)v26;
-      if ( v27 & 0x100000 )
-      {
-        if ( !v39 )
-          goto LABEL_84;
-        v28 = v38 == 0;
-      }
-      else
-      {
-        v28 = v38 == 1;
-      }
-      if ( !v28 )
-      {
-        ((Actor *)(v26 - 36))->PrepareSprites(0);
-        v29 = *((short *)v26 + 70);
-        v26[25] = 0;
-        if ( v29 != 11 && v29 != 19 && (!*((short *)v26 + 2) || !*((int *)v26 + 18)) )
-        {
-          *((short *)v26 + 70) = 5;
-          ((Actor *)(v26 - 36))->UpdateAnimation();
-        }
-        goto LABEL_90;
-      }
-LABEL_84:
-      *((short *)v26 + 70) = 19;
-      *(int *)v26 = v27 | 0x10000;
-LABEL_90:
-      ++i;
-      v26 += 836;
-    }
-    while ( i < (signed int)uNumActors );
-  }
-  pGameLoadingUI_ProgressBar->Progress();
-
-  Actor this_;
-  this_.pMonsterInfo.uID = 45;
-  this_.PrepareSprites(0);
-  if ( !v37 )
-  {
-    pParty->sRotationX = 0;
-    pParty->sRotationY = 0;
-    pParty->vPosition.y = 0;
-    pParty->vPosition.z = 0;
-    pParty->vPosition.x = 0;
-    pParty->uFallStartY = 0;
-    pParty->uFallSpeed = 0;
-    TeleportToStartingPoint(uLevel_StartingPointType);
-  }
-  viewparams->_443365();
-  PlayLevelMusic();
-  if ( !v37 )
-  {
-    v30 = 0;
-    v31 = 1;
-    do
-    {
-      if ( pPlayers[v31]->CanAct() )
-        v34[v30++] = v31;
-      ++v31;
-    }
-    while ( v31 <= 4 );
-    if ( v30 )
-    {
-      if ( pDest )
-      {
-        qword_A750D8 = 256i64;
-        word_A750E0 = 46;
-        word_A750E2 = LOWORD(v34[rand() % v30]);
-      }
-    }
-  }
-}
 
 //----- (004610AA) --------------------------------------------------------
 void __fastcall PrepareToLoadODM(unsigned int bLoading, OutdoorCamera *a2)
--- a/mm7_3.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/mm7_3.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -784,893 +784,6 @@
   return result;
 }
 
-//----- (0046F228) --------------------------------------------------------
-void __cdecl BLV_UpdateDoors()
-{
-  int v0; // ebx@1
-  int v1; // edi@1
-  BLVDoor *v2; // esi@3
-  unsigned __int16 v3; // ax@3
-  unsigned int v4; // ecx@5
-  int v5; // eax@8
-  int v6; // ecx@8
-  int v7; // eax@12
-  int v8; // eax@16
-  unsigned __int8 v9; // zf@18
-  char v10; // sf@18
-  unsigned __int8 v11; // of@18
-  int v12; // edi@19
-  int v13; // ecx@19
-  __int16 v14; // ax@19
-  BLVFace *v15; // ebx@24
-  unsigned __int16 *v16; // ecx@24
-  Vec3_short_ *v17; // esi@24
-  int v18; // eax@24
-  int v19; // edx@24
-  signed int v20; // eax@24
-  Vec3_short_ *v21; // ecx@24
-  double v22; // st7@24
-  double v23; // st6@24
-  int v24; // esi@25
-  int v25; // eax@25
-  BLVDoor *v26; // edi@25
-  signed __int64 v27; // qtt@27
-  BLVFaceExtra *v28; // esi@32
-  int v29; // ecx@34
-  int v30; // edx@34
-  unsigned __int64 v31; // qax@34
-  int v32; // eax@34
-  unsigned __int16 *v33; // eax@35
-  Vec3_short_ *v34; // eax@35
-  int v35; // ecx@35
-  int v36; // edx@35
-  signed int v37; // eax@35
-  signed int v38; // edx@35
-  int v39; // eax@35
-  int v40; // edx@35
-  unsigned __int8 v41; // cf@35
-  unsigned __int16 *v42; // edi@36
-  Vec3_short_ *v43; // edi@36
-  int v44; // ecx@36
-  int v45; // edi@36
-  int v46; // ecx@36
-  unsigned __int16 *v47; // edx@44
-  int v48; // ecx@44
-  unsigned int v49; // ecx@46
-  unsigned __int16 v50; // ax@48
-  unsigned int v51; // eax@51
-  unsigned __int16 v52; // ax@54
-  int v53; // ecx@57
-  int v54; // edx@57
-  unsigned __int64 v55; // qax@57
-  int v56; // ecx@58
-  int v57; // eax@58
-  int v58; // eax@59
-  SoundID v59; // [sp-24h] [bp-88h]@12
-  signed int v60; // [sp-20h] [bp-84h]@12
-  unsigned int v61; // [sp-1Ch] [bp-80h]@12
-  signed int v62; // [sp-18h] [bp-7Ch]@12
-  signed int v63; // [sp-14h] [bp-78h]@12
-  int v64; // [sp-10h] [bp-74h]@12
-  unsigned int v65; // [sp-Ch] [bp-70h]@12
-  int v66; // [sp-8h] [bp-6Ch]@12
-  int v67; // [sp+8h] [bp-5Ch]@31
-  int v68; // [sp+Ch] [bp-58h]@34
-  int v69; // [sp+10h] [bp-54h]@34
-  int v70; // [sp+14h] [bp-50h]@31
-  int v71; // [sp+18h] [bp-4Ch]@34
-  int v72; // [sp+1Ch] [bp-48h]@34
-  int v73; // [sp+20h] [bp-44h]@24
-  __int16 v74; // [sp+24h] [bp-40h]@24
-  int v75; // [sp+28h] [bp-3Ch]@36
-  int v76; // [sp+2Ch] [bp-38h]@36
-  int v77; // [sp+30h] [bp-34h]@36
-  int v78; // [sp+34h] [bp-30h]@36
-  int v79; // [sp+38h] [bp-2Ch]@19
-  unsigned int v80; // [sp+3Ch] [bp-28h]@2
-  int v81; // [sp+40h] [bp-24h]@1
-  int v82; // [sp+44h] [bp-20h]@35
-  int v83; // [sp+48h] [bp-1Ch]@34
-  int v84; // [sp+4Ch] [bp-18h]@34
-  int v85; // [sp+50h] [bp-14h]@19
-  SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1
-  BLVDoor *v87; // [sp+58h] [bp-Ch]@3
-  int v88; // [sp+5Ch] [bp-8h]@18
-  int v89; // [sp+60h] [bp-4h]@6
-
-  v0 = 0;
-  v1 = 0;
-  eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID];
-  v81 = 0;
-  if ( pIndoor->uNumDoors > 0 )
-  {
-    v80 = 0;
-    do
-    {
-      v2 = &pIndoor->pDoors[v80 / 0x50];
-      v87 = &pIndoor->pDoors[v80 / 0x50];
-      v3 = pIndoor->pDoors[v80 / 0x50].uState;
-      if ( v3 == (short)v0 || v3 == 2 )
-      {
-        v2->uAttributes &= 0xFFFFFFFDu;
-        goto LABEL_62;
-      }
-      v2->uTimeSinceTriggered += pEventTimer->uTimeElapsed;
-      v4 = v2->uTimeSinceTriggered;
-      if ( v2->uState == 1 )
-      {
-        v89 = (signed int)(v4 * v2->uCloseSpeed) / 128;
-        if ( v89 >= v2->uMoveLength )
-        {
-          v89 = v2->uMoveLength;
-          v2->uState = 2;
-LABEL_10:
-          if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 )
-          {
-            v66 = v0;
-            v65 = v0;
-            v64 = v0;
-            v7 = 8 * v1;
-            v63 = v0;
-            v62 = -1;
-            LOBYTE(v7) = 8 * v1 | 1;
-            v61 = v0;
-            v60 = v7;
-            v59 = (SoundID)((int)eDoorSoundID + 1);
-LABEL_17:
-            pAudioPlayer->PlaySound(v59, v60, v61, v62, v63, v64, v65, v66);
-            goto LABEL_18;
-          }
-          goto LABEL_18;
-        }
-      }
-      else
-      {
-        v5 = (signed int)(v4 * v2->uOpenSpeed) / 128;
-        v6 = v2->uMoveLength;
-        if ( v5 >= v6 )
-        {
-          v89 = v0;
-          v2->uState = v0;
-          goto LABEL_10;
-        }
-        v89 = v6 - v5;
-      }
-      if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 )
-      {
-        v66 = v0;
-        v65 = v0;
-        v64 = v0;
-        v8 = 8 * v1;
-        v63 = v0;
-        v62 = -1;
-        LOBYTE(v8) = 8 * v1 | 1;
-        v61 = 1;
-        v60 = v8;
-        v59 = eDoorSoundID;
-        goto LABEL_17;
-      }
-LABEL_18:
-      v11 = __OFSUB__(v2->uNumVertices, (short)v0);
-      v9 = v2->uNumVertices == (short)v0;
-      v10 = (signed __int16)(v2->uNumVertices - v0) < 0;
-      v88 = v0;
-      if ( !((unsigned __int8)(v10 ^ v11) | v9) )
-      {
-        do
-        {
-          v12 = v88;
-          v13 = v2->pVertexIDs[v88];
-          v85 = v89;
-          v79 = v2->vDirection.x;
-          v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-          v13 *= 6;
-          *(__int16 *)((char *)&pIndoor->pVertices->x + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pXOffsets[v88];
-          v85 = v89;
-          v79 = v2->vDirection.y;
-          v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-          *(__int16 *)((char *)&pIndoor->pVertices->y + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pYOffsets[v12];
-          v85 = v89;
-          v79 = v2->vDirection.z;
-          v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-          v14 = ((unsigned int)(v79 * v89) >> 16) + v2->pZOffsets[v12];
-          ++v88;
-          *(__int16 *)((char *)&pIndoor->pVertices->z + v13) = v14;
-        }
-        while ( v88 < v2->uNumVertices );
-        v1 = v81;
-      }
-      v11 = __OFSUB__(v2->uNumFaces, (short)v0);
-      v9 = v2->uNumFaces == (short)v0;
-      v10 = (signed __int16)(v2->uNumFaces - v0) < 0;
-      v88 = v0;
-      if ( !((unsigned __int8)(v10 ^ v11) | v9) )
-      {
-        while ( 1 )
-        {
-          v15 = &pIndoor->pFaces[v2->pFaceIDs[v88]];
-          v16 = v15->pVertexIDs;
-          v17 = &pIndoor->pVertices[*v16];
-          v18 = v15->pFacePlane_old.vNormal.y;
-          v73 = *(int *)&v17->x;
-          v74 = v17->z;
-          v19 = v15->pFacePlane_old.vNormal.z;
-          v20 = -(v19 * v74 + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18);
-          v15->pFacePlane_old.dist = v20;
-          v21 = &pIndoor->pVertices[*v16];
-          v79 = v21->x;
-          v22 = (double)v79;
-          v23 = (double)v21->y;
-          v79 = v21->z;
-          v15->pFacePlane.dist = -((double)v79 * v15->pFacePlane.vNormal.z
-                                 + v23 * v15->pFacePlane.vNormal.y
-                                 + v22 * v15->pFacePlane.vNormal.x);
-          if ( v19 )
-          {
-            v24 = abs(v20 >> 15);
-            v25 = abs(v15->pFacePlane_old.vNormal.z);
-            v26 = v87;
-            if ( v24 > v25 )
-              Abortf(
-                "Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
-                v87->uDoorID,
-                v87->pFaceIDs[v88],
-                v15->pFacePlane_old.dist,
-                v15->pFacePlane_old.vNormal.z);
-            v79 = v15->pFacePlane_old.vNormal.z;
-            v85 = v15->pFacePlane_old.dist;
-            LODWORD(v27) = v85 << 16;
-            HIDWORD(v27) = v85 >> 16;
-            v85 = v27 / v79;
-            v15->zCalc3 = -(v27 / v79);
-          }
-          else
-          {
-            v26 = v87;
-          }
-          if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D )
-            v15->_get_normals((Vec3_int_ *)&v70, (Vec3_int_ *)&v67);
-          v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID];
-          if ( !pRenderer->pRenderD3D )
-          {
-            if ( !(BYTE2(v15->uAttributes) & 4) )
-              goto LABEL_59;
-            v79 = v26->vDirection.x;
-            v83 = (unsigned __int64)(v79 * (signed __int64)v70) >> 16;
-            v85 = v71;
-            v79 = v26->vDirection.y;
-            v85 = (unsigned __int64)(v79 * (signed __int64)v71) >> 16;
-            v84 = v72;
-            v79 = v26->vDirection.z;
-            v84 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
-            v79 = v83 + v85 + ((unsigned __int64)(v79 * (signed __int64)v72) >> 16);
-            v29 = v89;
-            v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-            v28->sTextureDeltaU = -((unsigned int)(v79 * v89) >> 16);
-            v79 = v26->vDirection.x;
-            v85 = (unsigned __int64)(v79 * (signed __int64)v67) >> 16;
-            v83 = v68;
-            v79 = v26->vDirection.y;
-            v83 = (unsigned __int64)(v79 * (signed __int64)v68) >> 16;
-            v84 = v69;
-            v79 = v26->vDirection.z;
-            v84 = (unsigned __int64)(v79 * (signed __int64)v69) >> 16;
-            v30 = v83 + ((unsigned __int64)(v79 * (signed __int64)v69) >> 16);
-            v79 = v85 + v30;
-            v31 = (v85 + v30) * (signed __int64)v29;
-            v83 = v31 >> 16;
-            v32 = v31 >> 16;
-            goto LABEL_58;
-          }
-          v28->sTextureDeltaU = 0;
-          v28->sTextureDeltaV = 0;
-          v33 = v15->pVertexIDs;
-          v85 = 1;
-          v34 = &pIndoor->pVertices[*v33];
-          v35 = v34->z;
-          v36 = v34->y;
-          v82 = v34->x;
-          v79 = v36;
-          v37 = v70 * v82 + v71 * v36 + v72 * v35;
-          v38 = v67 * v82 + v68 * v36 + v35 * v69;
-          v39 = v37 >> 16;
-          *v15->pVertexUIDs = v39;
-          v40 = v38 >> 16;
-          *v15->pVertexVIDs = v40;
-          v41 = v15->uNumVertices < 1u;
-          v9 = v15->uNumVertices == 1;
-          v83 = v40;
-          v84 = v39;
-          v82 = v40;
-          if ( !(v41 | v9) )
-          {
-            do
-            {
-              v42 = v15->pVertexIDs;
-              v75 = 2 * v85;
-              v43 = &pIndoor->pVertices[v42[v85]];
-              v79 = v43->z;
-              v44 = v43->y;
-              v45 = v43->x;
-              v78 = v44;
-              v76 = (v72 * v79 + v70 * v45 + v71 * v44) >> 16;
-              v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16;
-              v77 = v46;
-              if ( v76 < v39 )
-                v39 = v76;
-              if ( v46 < v40 )
-                v83 = v46;
-              if ( v76 > v84 )
-                v84 = v76;
-              if ( v46 > v82 )
-                v82 = v46;
-              v47 = v15->pVertexUIDs;
-              v48 = v75;
-              ++v85;
-              *(unsigned __int16 *)((char *)v47 + v75) = v76;
-              *(unsigned __int16 *)((char *)v15->pVertexVIDs + v48) = v77;
-              v40 = v83;
-            }
-            while ( v85 < v15->uNumVertices );
-            v26 = v87;
-          }
-          v49 = v15->uAttributes;
-          if ( BYTE1(v49) & 0x10 )
-            goto LABEL_50;
-          if ( SBYTE1(v49) < 0 )
-          {
-            v50 = v15->uBitmapID;
-            if ( v50 != -1 )
-              break;
-          }
-LABEL_51:
-          v51 = v15->uAttributes;
-          if ( v51 & 8 )
-          {
-            v28->sTextureDeltaV -= v40;
-          }
-          else
-          {
-            if ( v51 & 0x20000 )
-            {
-              v52 = v15->uBitmapID;
-              if ( v52 != -1 )
-                v28->sTextureDeltaV -= v82
-                                     + *(short *)((signed __int16)v52 != -1 ? 72 * (signed __int16)v52 + 7278780 + 0x1A : 26);
-            }
-          }
-          if ( BYTE2(v15->uAttributes) & 4 )
-          {
-            v75 = v26->vDirection.x;
-            v84 = (unsigned __int64)(v75 * (signed __int64)v70) >> 16;
-            v82 = v71;
-            v75 = v26->vDirection.y;
-            v82 = (unsigned __int64)(v75 * (signed __int64)v71) >> 16;
-            v83 = v72;
-            v75 = v26->vDirection.z;
-            v83 = (unsigned __int64)(v75 * (signed __int64)v72) >> 16;
-            v75 = v84 + v82 + ((unsigned __int64)(v75 * (signed __int64)v72) >> 16);
-            v53 = v89;
-            v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16;
-            v28->sTextureDeltaU = -((unsigned int)(v75 * v89) >> 16);
-            v75 = v26->vDirection.x;
-            v84 = (unsigned __int64)(v75 * (signed __int64)v67) >> 16;
-            v82 = v68;
-            v75 = v26->vDirection.y;
-            v82 = (unsigned __int64)(v75 * (signed __int64)v68) >> 16;
-            v83 = v69;
-            v75 = v26->vDirection.z;
-            v83 = (unsigned __int64)(v75 * (signed __int64)v69) >> 16;
-            v54 = v82 + ((unsigned __int64)(v75 * (signed __int64)v69) >> 16);
-            v75 = v84 + v54;
-            v55 = (v84 + v54) * (signed __int64)v53;
-            v82 = v55 >> 16;
-            v32 = v55 >> 16;
-LABEL_58:
-            v56 = v88;
-            v57 = -v32;
-            v28->sTextureDeltaV = v57;
-            v28->sTextureDeltaU += v26->pDeltaUs[v56];
-            v28->sTextureDeltaV = v57 + v26->pDeltaVs[v56];
-          }
-LABEL_59:
-          v58 = v26->uNumFaces;
-          ++v88;
-          if ( v88 >= v58 )
-          {
-            v1 = v81;
-            v0 = 0;
-            goto LABEL_62;
-          }
-          v2 = v87;
-        }
-        LOWORD(v39) = v84
-                    + ((signed __int16)v39 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v39].uTextureWidth : 24);
-LABEL_50:
-        v28->sTextureDeltaU -= v39;
-        goto LABEL_51;
-      }
-LABEL_62:
-      v80 += 80;
-      ++v1;
-      v81 = v1;
-    }
-    while ( v1 < pIndoor->uNumDoors );
-  }
-}
-// 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID;
-
-//----- (0046F90C) --------------------------------------------------------
-void __cdecl 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
-  int v25; // eax@52
-  int v26; // ebx@54
-  int v27; // ST08_4@54
-  int v28; // edi@54
-  int v29; // eax@54
-  int v30; // ecx@62
-  int v31; // ebx@62
-  int v32; // eax@62
-  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
-  int v42; // eax@96
-  __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
-  int v55; // [sp+3Ch] [bp-24h]@6
-  int v56; // [sp+40h] [bp-20h]@6
-  unsigned int _this; // [sp+44h] [bp-1Ch]@51
-  int v58; // [sp+48h] [bp-18h]@51
-  int v59; // [sp+4Ch] [bp-14h]@8
-  int v60; // [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 )
-    {
-      v0 = &pActors[v63];
-      v1 = v0->uAIState;
-      if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
-        goto LABEL_123;
-      v55 = v0->uSectorID;
-      v2 = _46ED1B_collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, (unsigned int *)&v55, &v60);
-      v0->uSectorID = v55;
-      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 = _46CEC3_get_floor_level(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &v60), v56 == -30000) )
-          goto LABEL_123;
-      }
-      if ( v0->uCurrentActionAnimation == 1 )
-      {
-        v6 = v0->uMovementSpeed;
-        v7 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0;
-        v8 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0;
-        v61 = v0->uMovementSpeed;
-        if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[7].uExpireTime)) )
-        {
-          v9 = v0->pActorBuffs[7].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->field_4 == 1 )
-          v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6);
-        if ( v6 > 1000 )
-          v6 = 1000;
-        v12 = stru_5C6E00->SinCos(v0->uYawAngle);
-        v55 = v12;
-        v13 = v12 * (signed __int64)v6;
-        v61 = v13 >> 16;
-        v0->vVelocity.x = WORD1(v13);
-        v55 = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
-        v61 = (unsigned __int64)(v55 * (signed __int64)v6) >> 16;
-        v7 = v62 == 0;
-        v0->vVelocity.y = (unsigned int)(v55 * v6) >> 16;
-        if ( !v7 )
-        {
-          v14 = stru_5C6E00->SinCos(v0->uPitchAngle - stru_5C6E00->uIntegerHalfPi);
-          v55 = v14;
-          v15 = v14 * (signed __int64)v6;
-          v61 = v15 >> 16;
-          v0->vVelocity.z = WORD1(v15);
-        }
-      }
-      else
-      {
-        v61 = v0->vVelocity.x;
-        v55 = 55000;
-        v61 = (unsigned __int64)(55000i64 * v61) >> 16;
-        v0->vVelocity.x = v61;
-        v61 = v0->vVelocity.y;
-        v61 = (unsigned __int64)(v55 * (signed __int64)v61) >> 16;
-        v7 = v62 == 0;
-        v0->vVelocity.y = v61;
-        if ( !v7 )
-        {
-          v55 = 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 = v60;
-      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();
-        }
-      }
-      else
-      {
-        if ( v59 && !v62 )
-          v0->vVelocity.z += -8 * 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 == 5 )
-          v0->uAIState = 11;
-      }
-LABEL_123:
-      ++v63;
-      if ( (signed int)v63 >= (signed int)uNumActors )
-        return;
-    }
-    v20 = v0->uActorRadius;
-    v21 = v0->uActorHeight;
-    stru_721530.field_84 = -1;
-    stru_721530.field_70 = 0;
-    v55 = 0;
-    stru_721530.field_0 = 1;
-    stru_721530.field_8 = v20;
-    stru_721530.prolly_normal_d = v20;
-    stru_721530.field_C = v21;
-    v22 = 0;
-    while ( 1 )
-    {
-      stru_721530.field_34.x = v0->vPosition.x;
-      stru_721530.normal.x = stru_721530.field_34.x;
-      stru_721530.field_34.y = v0->vPosition.y;
-      stru_721530.normal.y = stru_721530.field_34.y;
-      v23 = v0->vPosition.z;
-      stru_721530.normal.z = v23 + v20 + 1;
-      stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1;
-      if ( stru_721530.field_34.z < stru_721530.normal.z )
-        stru_721530.field_34.z = v23 + v20 + 1;
-      stru_721530.field_1C = v0->vVelocity.x;
-      stru_721530.field_20 = v0->vVelocity.y;
-      stru_721530.field_24 = v0->vVelocity.z;
-      stru_721530.uSectorID = v0->uSectorID;
-      if ( !stru_721530._47050A(v22) )
-      {
-        v58 = v22;
-        v24 = 8 * v63;
-        LOBYTE(v24) = 8 * v63 | 3;
-        v61 = v22;
-        _this = v24;
-        do
-        {
-          _46E44E_collide_against_faces_and_portals(1u);
-          _46E0B2_collide_against_decorations();
-          _46EF01_collision_chech_player(0);
-          _46ED8A_collide_against_layingItems(_this);
-          v25 = 0;
-          v56 = 0;
-          if ( ai_arrays_size > v22 )
-          {
-            do
-            {
-              v54 = ai_array_4F7DB0_actor_ids[v25];
-              if ( v54 != v63 )
-              {
-                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 ( sub_4621DA(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius
-                  && _46DF1A_collide_against_actor(v54, 40) )
-                  ++v58;
-                v22 = 0;
-              }
-              v25 = v56++ + 1;
-            }
-            while ( v56 < ai_arrays_size );
-          }
-          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
-        {
-          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-          v30 = v58 + v0->vPosition.x;
-          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-          v31 = v58 + v0->vPosition.y;
-          v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
-          v32 = v58 + v0->vPosition.z;
-        }
-        v33 = _46ED1B_collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &v60);
-        v34 = pIndoor->pFaces[v60].uAttributes;
-        v35 = v34 & 0x400000;
-        if ( v35 && v0->uAIState == 5 )
-        {
-          v0->uAIState = 11;
-          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 ( stru_721530.field_7C >= stru_721530.field_6C )
-            {
-              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);
-              goto LABEL_123;
-            }
-            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-            v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16;
-            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-            v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16;
-            v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
-            v36 = stru_721530.uFaceID;
-            v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16;
-            v0->uSectorID = LOWORD(stru_721530.uSectorID);
-            stru_721530.field_70 += stru_721530.field_7C;
-            v37 = v36 >> 3;
-            if ( (v36 & 7) != 3 )
-            {
-              if ( (v36 & 7) != 4 )
-              {
-                if ( (v36 & 7) == 5 )
-                {
-                  _this = sub_452A9E(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);
-                  v54 = stru_5C6E00->SinCos(v45);
-                  v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16;
-                  v46 = v45 - stru_5C6E00->uIntegerHalfPi;
-                  v0->vVelocity.x = v54 * _this >> 16;
-                  v47 = stru_5C6E00->SinCos(v46);
-                  v54 = v47;
-                  v48 = v47 * (signed __int64)(signed int)_this;
-                  v56 = v48 >> 16;
-                  v0->vVelocity.y = WORD1(v48);
-                  goto LABEL_119;
-                }
-                if ( (v36 & 7) == 6 )
-                {
-                  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.field_64 >> 3 > v61 )
-                      v61 = stru_721530.field_64 >> 3;
-                    v58 = v38->pFacePlane_old.vNormal.x;
-                    v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16;
-                    _this = v38->pFacePlane_old.vNormal.y;
-                    _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16;
-                    v56 = v38->pFacePlane_old.vNormal.z;
-                    v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16;
-                    v0->vVelocity.x += v58;
-                    v0->vVelocity.y += _this;
-                    v0->vVelocity.z += v56;
-                    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:
-                v56 = v0->vVelocity.x;
-                v54 = 58500;
-                v56 = (unsigned __int64)(58500i64 * v56) >> 16;
-                v0->vVelocity.x = v56;
-                v56 = v0->vVelocity.y;
-                v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
-                v54 = 58500;
-                v0->vVelocity.y = v56;
-                v56 = v0->vVelocity.z;
-                v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16;
-                v22 = 0;
-                v0->vVelocity.z = v56;
-                goto LABEL_120;
-              }
-              if ( v0->GetActorsRelation(0) )
-              {
-                v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[11].uExpireTime), v22);
-                v49 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == v22;
-                v50 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) - v22 < 0;
-                v0->vVelocity.y = v22;
-                v0->vVelocity.x = v22;
-                if ( !(v50 ^ v51)
-                  && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v22) )
-                  pParty->pPartyBuffs[11].Reset();
-                viewparams->bRedrawGameUI = 1;
-                goto LABEL_119;
-              }
-              v36 = stru_721530.uFaceID;
-LABEL_118:
-              Actor::FaceObject(v63, v36, v22, (AIDirection *)v22);
-              goto LABEL_119;
-            }
-            if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->field_4 == 2 || pTurnEngine->field_4 == 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::_402968(v63, v36, v22, (AIDirection *)v22);
-                goto LABEL_119;
-              }
-            }
-            Actor::_403F58(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->field_4 == 2 || pTurnEngine->field_4 == 3) )
-            goto LABEL_123;
-          if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 )
-          {
-            Actor::_403F58(v63, 4, v22, &v52);
-            goto LABEL_123;
-          }
-        }
-      }
-LABEL_120:
-      ++v55;
-      if ( v55 >= 100 )
-        goto LABEL_123;
-      v20 = stru_721530.prolly_normal_d;
-    }
-  }
-}
-// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
-// 4F75D8: using guessed type int ai_arrays_size;
-
-
 
 //----- (0047050A) --------------------------------------------------------
 int stru141::_47050A(int a2)
@@ -20428,7 +19541,7 @@
       LOWORD(v2) = v6->uState;
       if ( (short)v2 && (short)v2 != 3 )
       {
-        v6->uState = 3;
+        v6->uState = BLVDoor::Closing;
         if ( (short)v2 == 2 )
         {
 LABEL_17:
@@ -20455,7 +19568,7 @@
   LOWORD(v2) = v6->uState;
   if ( (short)v2 != 2 && (short)v2 != 1 )
   {
-    v6->uState = 1;
+    v6->uState = BLVDoor::Opening;
     if ( !(short)v2 )
       goto LABEL_17;
     v7 = v6->uTimeSinceTriggered;
@@ -21459,7 +20572,7 @@
         pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight;
       if ( v82 != v12 )
       {
-        pActor->pMonsterInfo.uHostilityType = 0;
+        pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
         if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) <= (signed int)v12 )
         {
           if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) < (signed int)v12
@@ -21517,7 +20630,7 @@
       v21 = &pActors[uActorID];
       Actor::_401221(uActorID, &dword_4F6E08[uActorID], 1u);
       if ( v21->pMonsterInfo.uHostilityType && !*v20 )
-        v21->pMonsterInfo.uHostilityType = 0;
+        v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
       a2 = *v20;
       v76 = a2 & 7;
       if ( (a2 & 7) == 3 )
@@ -21568,7 +20681,7 @@
         v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight;
       if ( v82 != v24 )
       {
-        v21->pMonsterInfo.uHostilityType = 0;
+        v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
         if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= (signed int)v24 )
         {
           if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < (signed int)v24
@@ -21691,7 +20804,7 @@
       }
       if ( v38 ^ v39 )
 LABEL_257:
-        v21->pMonsterInfo.uHostilityType = 4;
+      v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
 LABEL_165:
       if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 )
       {
--- a/mm7_5.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/mm7_5.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -9965,7 +9965,7 @@
         v6 = (unsigned int *)&dword_4F6E08[(int)v4];
         Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u);
         if ( v5->pMonsterInfo.uHostilityType && !*v6 )
-          v5->pMonsterInfo.uHostilityType = 0;
+          v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
         v22 = *v6;
         v7 = Actor::GetDirectionInfo(8 * (int)v4 | 3, *v6, &a3, 0);
         v8 = v5->uActorRadius;
@@ -10015,7 +10015,7 @@
           if ( v11 ^ v12 )
           {
 LABEL_25:
-            v5->pMonsterInfo.uHostilityType = 4;
+            v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
             goto LABEL_26;
           }
         }
@@ -10304,7 +10304,7 @@
   a2a = v8;
   Actor::_401221(v3, &dword_4F6E08[v3], 1u);
   if ( v4->pMonsterInfo.uHostilityType && !*v6 )
-    v4->pMonsterInfo.uHostilityType = 0;
+    v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
   v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0);
   v10 = v4->uActorRadius;
   memcpy(&a3, v9, sizeof(a3));
@@ -10322,7 +10322,7 @@
     if ( (double)(signed int)v28 >= 307.2 )
       goto LABEL_21;
 LABEL_20:
-    v4->pMonsterInfo.uHostilityType = 4;
+    v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long;
     goto LABEL_21;
   }
   if ( v12 == 2 )
--- a/mm7_6.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/mm7_6.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -6300,7 +6300,7 @@
             v1,
             v1,
             v1);
-          *(&pActors[0].pMonsterInfo.uHostilityType + v730) = 4;
+          *(&pActors[0].pMonsterInfo.uHostilityType + v730) = MonsterInfo::Hostility_Long;
         }
         a1.stru_24.Reset();
         a1.field_48 = v3->spellnum;
--- a/mm7_data.cpp	Thu Oct 18 09:11:23 2012 +0600
+++ b/mm7_data.cpp	Thu Oct 18 09:12:00 2012 +0600
@@ -2121,7 +2121,6 @@
 char a3dologo[8]; // weak
 char aNoMovie[777]; // idb
 char aEWorkMsdevM_26[777]; // idb
-unsigned __int16 pDoorSoundIDsByLocationID[78];
 char aCanTLoadSoundF[777]; // idb
 char aEWorkMsdevM_27[777]; // idb
 char aSoundSIsSizeIB[777]; // idb
--- a/mm7_data.h	Thu Oct 18 09:11:23 2012 +0600
+++ b/mm7_data.h	Thu Oct 18 09:12:00 2012 +0600
@@ -2101,7 +2101,6 @@
 extern char a3dologo[8]; // weak
 extern char aNoMovie[]; // idb
 extern char aEWorkMsdevM_26[]; // idb
-extern unsigned __int16 pDoorSoundIDsByLocationID[78];
 extern char aCanTLoadSoundF[]; // idb
 extern char aEWorkMsdevM_27[]; // idb
 extern char aSoundSIsSizeIB[]; // idb