diff mm7_3.cpp @ 2085:52abdea20b9e

Door_switch_animation
author Ritor1
date Wed, 11 Dec 2013 23:12:54 +0600
parents 87be06553c76
children 3920278a2905
line wrap: on
line diff
--- a/mm7_3.cpp	Tue Dec 03 16:35:57 2013 +0600
+++ b/mm7_3.cpp	Wed Dec 11 23:12:54 2013 +0600
@@ -58,18 +58,12 @@
   unsigned __int8 v6; // sf@12
   unsigned __int8 v7; // of@12
   int result; // eax@14
-  //BLVSector *v9; // ebx@15
-  int v10; // ecx@15
+  //int v10; // ecx@15
   int pFloor; // eax@16
-  //BLVFace *v12; // ebp@16
-  int v13; // eax@24
-  int v14; // esi@24
   int v15; // eax@24
   int v16; // edx@25
   int v17; // eax@29
   unsigned int v18; // eax@33
-  int v19; // eax@35
-  int v20; // edx@35
   int v21; // eax@35
   int v22; // ecx@36
   int v23; // eax@40
@@ -79,24 +73,19 @@
   int i; // [sp+18h] [bp-40h]@1
   int a10; // [sp+1Ch] [bp-3Ch]@1
   int v29; // [sp+20h] [bp-38h]@14
-  int v30; // [sp+24h] [bp-34h]@35
-  int v31; // [sp+28h] [bp-30h]@24
   int v32; // [sp+2Ch] [bp-2Ch]@15
   int pSectorsArray[10]; // [sp+30h] [bp-28h]@1
 
   pSector = &pIndoor->pSectors[stru_721530.uSectorID];
-  v2 = 0;
+  i = 1;
   a10 = b1;
   pSectorsArray[0] = stru_721530.uSectorID;
-  for ( i = 1; v2 < pSector->uNumPortals; ++v2 )
+  for ( v2 = 0; v2 < pSector->uNumPortals; ++v2 )
   {
     pFace = &pIndoor->pFaces[pSector->pPortals[v2]];
-    if ( stru_721530.sMaxX <= pFace->pBounding.x2
-      && stru_721530.sMinX >= pFace->pBounding.x1
-      && stru_721530.sMaxY <= pFace->pBounding.y2
-      && stru_721530.sMinY >= pFace->pBounding.y1
-      && stru_721530.sMaxZ <= pFace->pBounding.z2
-      && stru_721530.sMinZ >= pFace->pBounding.z1
+    if ( stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
+      && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
+      && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
       && abs((pFace->pFacePlane_old.dist
             + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
             + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
@@ -112,51 +101,35 @@
     }
   }
   result = 0;
-  v29 = 0;
-  if ( i > 0 )
+  for ( v29 = 0; v29 < i; v29++ )
   {
-    while ( 1 )
+    pSector = &pIndoor->pSectors[pSectorsArray[v29]];
+    v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
+    for ( v26 = 0;  v26 < v32; v26++ )
     {
-      pSector = &pIndoor->pSectors[pSectorsArray[result]];
-      v10 = 0;
-      v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
-      v26 = 0;
-      if ( v32 > 0 )
-        break;
-LABEL_46:
-      result = v29++ + 1;
-      if ( v29 >= i )
-        return result;
-    }
-    while ( 1 )
-    {
-      pFloor = pSector->pFloors[v10];
-      pFace = &pIndoor->pFaces[pFloor];
-      if ( pFace->Portal()
-        || stru_721530.sMaxX > pFace->pBounding.x2
-        || stru_721530.sMinX < pFace->pBounding.x1
-        || stru_721530.sMaxY > pFace->pBounding.y2
-        || stru_721530.sMinY < pFace->pBounding.y1
-        || stru_721530.sMaxZ > pFace->pBounding.z2
-        || stru_721530.sMinZ < pFace->pBounding.z1
-        || pFloor == stru_721530.field_84 )
-        goto LABEL_45;
-      v13 = pFace->pFacePlane_old.vNormal.y;
-      v14 = pFace->pFacePlane_old.dist;
-      v31 = v13;
-      v15 = (stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + v14 + stru_721530.normal.y * v13
-           + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16;
+      pFloor = pSector->pFloors[v26];
+      pFace = &pIndoor->pFaces[pSector->pFloors[v26]];
+      if ( !pFace->Portal()
+        && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
+        && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
+        && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
+        && pFloor != stru_721530.field_84 )
+      {
+      v15 = ( pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
+                                         + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
+                                         + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z ) >> 16;
       if ( v15 > 0 )
       {
-        v16 = (stru_721530.normal2.y * v31 + pFace->pFacePlane_old.dist + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z
-             + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x) >> 16;
+        v16 = ( pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x
+                                           + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y
+                                           + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z ) >> 16;
         if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
         {
           if ( v16 <= v15 )
           {
             a3 = stru_721530.field_6C;
             if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
-                   stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
+                 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
             {
               v17 = a3;
             }
@@ -180,18 +153,14 @@
       }
 LABEL_34:
       if ( !(stru_721530.field_0 & 1)
-        || (v19 = pFace->pFacePlane_old.vNormal.x,
-            v20 = pFace->pFacePlane_old.vNormal.y,
-            v30 = v19,
-            v21 = (stru_721530.position.x * v19 + pFace->pFacePlane_old.dist + stru_721530.position.y * v20
-                 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16,
-            v21 <= 0)
-        || (v22 = (stru_721530.field_4C * v30 + pFace->pFacePlane_old.dist + stru_721530.field_50 * v20
-                 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16,
-            v21 > stru_721530.prolly_normal_d)
-        && v22 > stru_721530.prolly_normal_d
-        || v22 > v21 )
-        goto LABEL_45;
+        || (v21 = ( pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x
+                                               + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y
+                                               + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0)
+        || (v22 = ( pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x
+                                               + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y
+                                               + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d)
+        && v22 > stru_721530.prolly_normal_d || v22 > v21 )
+        continue;
       a3 = stru_721530.field_6C;
       if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
              stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
@@ -213,11 +182,9 @@
           stru_721530.uFaceID = v24;
         }
       }
-LABEL_45:
-      v10 = v26++ + 1;
-      if ( v26 >= v32 )
-        goto LABEL_46;
+      }
     }
+    result = v29 + 1;
   }
   return result;
 }
@@ -227,259 +194,150 @@
 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
 {
   int result; // eax@1
-  BSPModel *v2; // ecx@3
   int v3; // ebx@9
-  ODMFace *v4; // eax@11
-  int v5; // edi@17
-  int v6; // esi@17
-  unsigned int v7; // ecx@17
   int v8; // eax@19
   int v9; // ecx@20
   int v10; // eax@24
-  int v11; // ST18_4@25
-  int v12; // ST1C_4@25
-  int v13; // ST0C_4@25
   unsigned int v14; // eax@28
   int v15; // eax@30
   int v16; // ecx@31
   unsigned int v17; // eax@36
-  int v18; // ST18_4@41
-  int v19; // ST1C_4@41
-  int v20; // ST0C_4@41
   int v21; // eax@42
   unsigned int v22; // eax@43
-  //BLVFace f; // [sp+Ch] [bp-7Ch]@1
-  int v24; // [sp+6Ch] [bp-1Ch]@9
   int a11; // [sp+70h] [bp-18h]@1
-  unsigned int v26; // [sp+74h] [bp-14h]@2
-  unsigned int v27; // [sp+78h] [bp-10h]@10
-  BSPModel *v28; // [sp+7Ch] [bp-Ch]@3
   int a10; // [sp+80h] [bp-8h]@1
   int a2; // [sp+84h] [bp-4h]@23
 
   a11 = ecx0;
 
   BLVFace f; // [sp+Ch] [bp-7Ch]@1
-  //BLVFace::BLVFace(&f);
 
   result = 0;
-  a10 = 0;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
+  for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 )
   {
-    v26 = 0;
-    while ( 1 )
+    if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX 
+      && stru_721530.sMaxY <= pOutdoor->pBModels[a10].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[a10].sMinY
+      && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[a10].sMinZ )
     {
-      v2 = &pOutdoor->pBModels[v26 / 0xBC];
-      v28 = &pOutdoor->pBModels[v26 / 0xBC];
-      if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX )
+      for ( v3 = 0; v3 < pOutdoor->pBModels[a10].uNumFaces; ++v3 )
       {
-        if ( stru_721530.sMinX >= v2->sMinX )
+        if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1
+          && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1
+          && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 )
         {
-          if ( stru_721530.sMaxY <= v2->sMaxY )
+          f.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x;
+          f.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y;
+          f.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z;
+          f.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist;
+          f.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes;
+          f.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1;
+          f.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1;
+          f.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1;
+          f.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2;
+          f.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2;
+          f.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2;
+          f.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1;
+          f.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2;
+          f.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3;
+          f.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements;
+          f.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements;
+          f.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements;
+          f.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType;
+          f.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices;
+          f.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID;
+          f.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs;
+          if ( !f.Ethereal() && !f.Portal() )
           {
-            if ( stru_721530.sMinY >= v2->sMinY )
+            v8 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal.x
+                                        + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
+                                        + f.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16;
+            if ( v8 > 0 )
             {
-              if ( stru_721530.sMaxZ <= v2->sMaxZ )
+              v9 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x
+                                          + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
+                                          + f.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16;
+              if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
               {
-                if ( stru_721530.sMinZ >= v2->sMinZ )
+                if ( v9 <= v8 )
                 {
-                  v3 = 0;
-                  v24 = v2->uNumFaces;
-                  if ( v24 > 0 )
-                    break;
+                  a2 = stru_721530.field_6C;
+                  if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
+                            stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) )
+                  {
+                    v10 = a2;
+                  }
+                  else
+                  {
+                    a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
+                    if ( !sub_475F30( &a2, &f, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
+                             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
+                      goto LABEL_29;
+                    v10 = a2 - stru_721530.prolly_normal_d;
+                    a2 -= stru_721530.prolly_normal_d;
+                  }
+                  if ( v10 < stru_721530.field_7C )
+                  {
+                    stru_721530.field_7C = v10;
+                    v14 = 8 * (v3 | (a10 << 6));
+                    LOBYTE(v14) = v14 | 6;
+                    stru_721530.uFaceID = v14;
+                  }
+                }
+              }
+            }
+LABEL_29:
+            if ( stru_721530.field_0 & 1 )
+            {
+              v15 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.position.x
+                                           + f.pFacePlane_old.vNormal.y * stru_721530.position.y
+                                           + f.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16;
+              if ( v15 > 0 )
+              {
+                v16 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.field_4C
+                                             + f.pFacePlane_old.vNormal.y * stru_721530.field_50
+                                             + f.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16;
+                if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
+                {
+                  if ( v16 <= v15 )
+                  {
+                    a2 = stru_721530.field_6C;
+                    if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
+                             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) )
+                    {
+                      if ( a2 < stru_721530.field_7C )
+                      {
+                        stru_721530.field_7C = a2;
+                        v17 = 8 * (v3 | (a10 << 6));
+                        LOBYTE(v17) = v17 | 6;
+                        stru_721530.uFaceID = v17;
+                      }
+                    }
+                    else
+                    {
+                      a2 = stru_721530.field_6C + stru_721530.field_8_radius;
+                      if ( sub_475F30(&a2, &f, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
+                                     stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
+                      {
+                        v21 = a2 - stru_721530.prolly_normal_d;
+                        a2 -= stru_721530.prolly_normal_d;
+                        if ( a2 < stru_721530.field_7C )
+                        {
+                          stru_721530.field_7C = v21;
+                          v22 = 8 * (v3 | (a10 << 6));
+                          LOBYTE(v22) = v22 | 6;
+                          stru_721530.uFaceID = v22;
+                        }
+                      }
+                    }
+                  }
                 }
               }
             }
           }
         }
       }
-LABEL_39:
-      ++a10;
-      v26 += 188;
-      result = a10;
-      if ( a10 >= (signed int)pOutdoor->uNumBModels )
-        return result;
     }
-    v27 = 0;
-    while ( 1 )
-    {
-      v4 = &v2->pFaces[v27 / 0x134];
-      if ( stru_721530.sMaxX > v4->pBoundingBox.x2
-        || stru_721530.sMinX < v4->pBoundingBox.x1
-        || stru_721530.sMaxY > v4->pBoundingBox.y2
-        || stru_721530.sMinY < v4->pBoundingBox.y1
-        || stru_721530.sMaxZ > v4->pBoundingBox.z2
-        || stru_721530.sMinZ < v4->pBoundingBox.z1 )
-        goto LABEL_38;
-      f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x;
-      f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y;
-      v5 = v4->pFacePlane.vNormal.z;
-      f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
-      v6 = v4->pFacePlane.dist;
-      f.pFacePlane_old.dist = v4->pFacePlane.dist;
-      v7 = v4->uAttributes;
-      f.uAttributes = v7;
-      f.pBounding.x1 = v4->pBoundingBox.x1;
-      f.pBounding.y1 = v4->pBoundingBox.y1;
-      f.pBounding.z1 = v4->pBoundingBox.z1;
-      f.pBounding.x2 = v4->pBoundingBox.x2;
-      f.pBounding.y2 = v4->pBoundingBox.y2;
-      f.pBounding.z2 = v4->pBoundingBox.z2;
-      f.zCalc1 = v4->zCalc1;
-      f.zCalc2 = v4->zCalc2;
-      f.zCalc3 = v4->zCalc3;
-      f.pXInterceptDisplacements = v4->pXInterceptDisplacements;
-      f.pYInterceptDisplacements = v4->pYInterceptDisplacements;
-      f.pZInterceptDisplacements = v4->pZInterceptDisplacements;
-      f.uPolygonType = (PolygonType)v4->uPolygonType;
-      f.uNumVertices = v4->uNumVertices;
-      f.uBitmapID = v4->uTextureID;
-      f.pVertexIDs = v4->pVertexIDs;
-      if ( !(v7 & 0x20000000) )
-      {
-        if ( !(v7 & 1) )
-          break;
-      }
-LABEL_37:
-      v2 = v28;
-LABEL_38:
-      v27 += 308;
-      ++v3;
-      if ( v3 >= v24 )
-        goto LABEL_39;
-    }
-    v8 = (v5 * stru_721530.normal.z
-        + v6
-        + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
-        + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16;
-    if ( v8 > 0 )
-    {
-      v9 = (v5 * stru_721530.normal2.z
-          + v6
-          + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
-          + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16;
-      if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
-      {
-        if ( v9 <= v8 )
-        {
-          a2 = stru_721530.field_6C;
-          if ( sub_4754BF(
-                 stru_721530.prolly_normal_d,
-                 &a2,
-                 stru_721530.normal.x,
-                 stru_721530.normal.y,
-                 stru_721530.normal.z,
-                 stru_721530.direction.x,
-                 stru_721530.direction.y,
-                 stru_721530.direction.z,
-                 &f,
-                 a10,
-                 a11) )
-          {
-            v10 = a2;
-          }
-          else
-          {
-            v11 = stru_721530.direction.y;
-            v12 = stru_721530.direction.z;
-            v13 = stru_721530.normal.y;
-            a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
-            if ( !sub_475F30(
-                    &a2,
-                    &f,
-                    stru_721530.normal.x,
-                    v13,
-                    stru_721530.normal.z,
-                    stru_721530.direction.x,
-                    v11,
-                    v12,
-                    a10) )
-              goto LABEL_29;
-            v10 = a2 - stru_721530.prolly_normal_d;
-            a2 -= stru_721530.prolly_normal_d;
-          }
-          if ( v10 < stru_721530.field_7C )
-          {
-            stru_721530.field_7C = v10;
-            v14 = 8 * (v3 | (a10 << 6));
-            LOBYTE(v14) = v14 | 6;
-            stru_721530.uFaceID = v14;
-          }
-        }
-      }
-    }
-LABEL_29:
-    if ( stru_721530.field_0 & 1 )
-    {
-      v15 = (f.pFacePlane_old.vNormal.z * stru_721530.position.z
-           + f.pFacePlane_old.dist
-           + f.pFacePlane_old.vNormal.y * stru_721530.position.y
-           + f.pFacePlane_old.vNormal.x * stru_721530.position.x) >> 16;
-      if ( v15 > 0 )
-      {
-        v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54
-             + f.pFacePlane_old.dist
-             + f.pFacePlane_old.vNormal.y * stru_721530.field_50
-             + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16;
-        if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
-        {
-          if ( v16 <= v15 )
-          {
-            a2 = stru_721530.field_6C;
-            if ( sub_4754BF(stru_721530.field_8_radius,
-                   &a2,
-                   stru_721530.position.x,
-                   stru_721530.position.y,
-                   stru_721530.position.z,
-                   stru_721530.direction.x,
-                   stru_721530.direction.y,
-                   stru_721530.direction.z,
-                   &f,
-                   a10,
-                   a11) )
-            {
-              if ( a2 < stru_721530.field_7C )
-              {
-                stru_721530.field_7C = a2;
-                v17 = 8 * (v3 | (a10 << 6));
-                LOBYTE(v17) = v17 | 6;
-                stru_721530.uFaceID = v17;
-              }
-            }
-            else
-            {
-              v18 = stru_721530.direction.y;
-              v19 = stru_721530.direction.z;
-              v20 = stru_721530.position.y;
-              a2 = stru_721530.field_6C + stru_721530.field_8_radius;
-              if ( sub_475F30(&a2,
-                     &f,
-                     stru_721530.position.x,
-                     v20,
-                     stru_721530.position.z,
-                     stru_721530.direction.x,
-                     v18,
-                     v19,
-                     a10) )
-              {
-                v2 = v28;
-                v21 = a2 - stru_721530.prolly_normal_d;
-                a2 -= stru_721530.prolly_normal_d;
-                if ( a2 < stru_721530.field_7C )
-                {
-                  stru_721530.field_7C = v21;
-                  v22 = 8 * (v3 | (a10 << 6));
-                  LOBYTE(v22) = v22 | 6;
-                  stru_721530.uFaceID = v22;
-                }
-                goto LABEL_38;
-              }
-            }
-          }
-        }
-      }
-    }
-    goto LABEL_37;
+    result = a10;
   }
   return result;
 }
@@ -509,75 +367,41 @@
 //----- (0046ED8A) --------------------------------------------------------
 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this)
 {
-  int v1; // ebx@2
-  ObjectDesc *v2; // edx@4
-  int v3; // esi@5
-  int v4; // ecx@5
-  int v5; // eax@7
-  int v6; // edi@9
-  int v7; // edx@9
-  int v8; // edi@11
-  int v9; // ebx@11
+  ObjectDesc *object; // edx@4
   int v10; // ecx@12
   int v11; // esi@13
-  signed int v12; // [sp+0h] [bp-14h]@1
-  int v13; // [sp+4h] [bp-10h]@9
-  char *v14; // [sp+8h] [bp-Ch]@2
-  unsigned int v15; // [sp+10h] [bp-4h]@1
-
-  v15 = 0;
-  v12 = _this;
+
   if ( (signed int)uNumSpriteObjects > 0 )
   {
-    v1 = (int)&pSpriteObjects[0].uObjectDescID;
-    v14 = (char *)&pSpriteObjects[0].uObjectDescID;
-    do
+    for ( uint i = 0; i < uNumSpriteObjects; ++i )
     {
-      if ( *(short *)v1 )
+      if ( pSpriteObjects[i].uObjectDescID )
       {
-        v2 = &pObjectList->pObjects[*(short *)v1];
-        if ( !(v2->uFlags & 2) )
+        object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
+        if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
         {
-          v3 = v2->uRadius;
-          v4 = *(int *)(v1 + 2);
-          if ( stru_721530.sMaxX <= v4 + v3 )
+          if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius
+            && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius
+            && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius
+            && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
+            && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight
+            && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z )
           {
-            if ( stru_721530.sMinX >= v4 - v3 )
+            if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+                    - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= object->uHeight
+                                                                                    + stru_721530.prolly_normal_d )
             {
-              v5 = *(int *)(v1 + 6);
-              if ( stru_721530.sMaxY <= v5 + v3 )
+              v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x
+                   + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16;
+              if ( v10 > 0 )
               {
-                if ( stru_721530.sMinY >= v5 - v3 )
+                v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
+                if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d )
                 {
-                  v6 = v2->uHeight;
-                  v7 = *(int *)(v1 + 10);
-                  v13 = v6;
-                  if ( stru_721530.sMaxZ <= v7 + v6 )
+                  if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
                   {
-                    if ( stru_721530.sMinZ >= v7 )
-                    {
-                      v8 = v4 - stru_721530.normal.x;
-                      v9 = v5 - stru_721530.normal.y;
-                      if ( abs(((v4 - stru_721530.normal.x) * stru_721530.direction.y
-                              - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= v3
-                                                                                              + stru_721530.prolly_normal_d )
-                      {
-                        v10 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16;
-                        if ( v10 > 0 )
-                        {
-                          v11 = stru_721530.normal.z
-                              + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
-                          if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d )
-                          {
-                            if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) )
-                            {
-                              if ( v10 < stru_721530.field_7C )
-                                sub_46DEF2(v12, v15);
-                            }
-                          }
-                        }
-                      }
-                    }
+                    if ( v10 < stru_721530.field_7C )
+                      sub_46DEF2(_this, i);
                   }
                 }
               }
@@ -585,11 +409,7 @@
           }
         }
       }
-      ++v15;
-      v1 = (int)(v14 + 112);
-      v14 += 112;
     }
-    while ( (signed int)v15 < (signed int)uNumSpriteObjects );
   }
 }
 
@@ -612,51 +432,39 @@
   v1 = 2 * pParty->field_14_radius;
   result = pParty->vPosition.x;
   v9 = pParty->uPartyHeight;
-  if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14_radius )
+  if ( stru_721530.sMaxX <= pParty->vPosition.x + v1 && stru_721530.sMinX >= pParty->vPosition.x - v1
+    && stru_721530.sMaxY <= pParty->vPosition.y + v1 && stru_721530.sMinY >= pParty->vPosition.y - v1
+    && stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight)
+    && stru_721530.sMinZ >= pParty->vPosition.z )
   {
-    if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
+    v3 = stru_721530.prolly_normal_d + v1;
+    v11 = pParty->vPosition.x - stru_721530.normal.x;
+    v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+        - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
+    v10 = pParty->vPosition.y - stru_721530.normal.y;
+    result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+                - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
+    if ( result <= stru_721530.prolly_normal_d + v1 )
     {
-      if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 )
+      result = v10 * stru_721530.direction.y;
+      v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
+      if ( v5 > 0 )
       {
-        if ( stru_721530.sMinY >= pParty->vPosition.y - v1 )
+        v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
+        result = pParty->vPosition.z;
+        if ( v6 >= pParty->vPosition.z )
         {
-          if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) )
+          result = v9 + pParty->vPosition.z;
+          if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
           {
-            if ( stru_721530.sMinZ >= pParty->vPosition.z )
+            result = integer_sqrt(v3 * v3 - v4 * v4);
+            v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
+            if ( v7 < 0 )
+              v7 = 0;
+            if ( v7 < stru_721530.field_7C )
             {
-              v3 = stru_721530.prolly_normal_d + v1;
-              v11 = pParty->vPosition.x - stru_721530.normal.x;
-              v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
-                  - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
-              v10 = pParty->vPosition.y - stru_721530.normal.y;
-              result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
-                          - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
-              if ( result <= v3 )
-              {
-                result = v10 * stru_721530.direction.y;
-                v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
-                if ( v5 > 0 )
-                {
-                  v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
-                  result = pParty->vPosition.z;
-                  if ( v6 >= pParty->vPosition.z )
-                  {
-                    result = v9 + pParty->vPosition.z;
-                    if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
-                    {
-                      result = integer_sqrt(v3 * v3 - v4 * v4);
-                      v7 = v5 - result;
-                      if ( v7 < 0 )
-                        v7 = 0;
-                      if ( v7 < stru_721530.field_7C )
-                      {
-                        stru_721530.field_7C = v7;
-                        stru_721530.uFaceID = 4;
-                      }
-                    }
-                  }
-                }
-              }
+              stru_721530.field_7C = v7;
+              stru_721530.uFaceID = 4;
             }
           }
         }
@@ -669,76 +477,51 @@
 //----- (0046F04E) --------------------------------------------------------
 int _46F04E_collide_against_portals()
 {
-  BLVSector *v0; // ecx@1
   unsigned int v1; // eax@1
-  int v2; // eax@2
-  BLVFace *v3; // eax@3
+  BLVFace *face; // eax@3
   int v4; // ecx@9
   int v5; // edx@9
   signed int result; // eax@21
-  BLVFace *v7; // eax@22
-  signed int v8; // [sp+0h] [bp-14h]@1
-  BLVSector *v9; // [sp+4h] [bp-10h]@1
   unsigned int v10; // [sp+8h] [bp-Ch]@1
   int a3; // [sp+Ch] [bp-8h]@13
   int v12; // [sp+10h] [bp-4h]@15
 
-  v8 = 0;
-  v0 = &pIndoor->pSectors[stru_721530.uSectorID];
   v1 = 0xFFFFFFu;
   v10 = 0xFFFFFFu;
-  v9 = v0;
-  if ( v0->uNumPortals > 0 )
+  for ( uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i )
   {
-    do
+    if ( pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80 )
     {
-      v2 = v0->pPortals[v8];
-      if ( v2 != stru_721530.field_80 )
+      face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]];
+      if ( stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1
+        && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1
+        && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1 )
       {
-        v3 = &pIndoor->pFaces[v2];
-        if ( stru_721530.sMaxX <= v3->pBounding.x2 )
+        v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist
+            + stru_721530.normal.y * face->pFacePlane_old.vNormal.y
+            + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16;
+        v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist
+            + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x
+            + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16;
+        if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
+          && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
+          && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face))
+          && a3 < (signed int)v10 )
         {
-          if ( stru_721530.sMinX >= v3->pBounding.x1
-            && stru_721530.sMaxY <= v3->pBounding.y2
-            && stru_721530.sMinY >= v3->pBounding.y1
-            && stru_721530.sMaxZ <= v3->pBounding.z2
-            && stru_721530.sMinZ >= v3->pBounding.z1 )
-          {
-            v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x + v3->pFacePlane_old.dist
-                + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
-                + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16;
-            v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z + v3->pFacePlane_old.dist
-                + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x
-                + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16;
-            if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
-              && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
-              && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, v3))
-              && a3 < (signed int)v10 )
-            {
-              v0 = v9;
-              v10 = a3;
-              v12 = v9->pPortals[v8];
-            }
-            else
-            {
-              v0 = v9;
-            }
-          }
+          v10 = a3;
+          v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i];
         }
       }
-      ++v8;
     }
-    while ( v8 < v0->uNumPortals );
-    v1 = v10;
   }
+  v1 = v10;
   if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C )
   {
     stru_721530.field_80 = v12;
-    v7 = &pIndoor->pFaces[v12];
-    if ( v7->uSectorID == stru_721530.uSectorID )
-      stru_721530.uSectorID = v7->uBackSectorID;
+    if ( pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID )
+      stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID;
     else
-      stru_721530.uSectorID = v7->uSectorID;
+      stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID;
     stru_721530.field_7C = 268435455;
     result = 0;
   }
@@ -860,61 +643,28 @@
 //----- (004706C6) --------------------------------------------------------
 void UpdateActors_ODM()
 {
-  Actor *v0; // esi@2
-  AIState uAIState; // ax@2
-  //unsigned int v2; // ecx@6
   int v3; // ebx@6
-  //int v4; // eax@8
   int v5; // eax@10
   int v6; // ecx@10
-  //signed int v7; // ebx@10
   signed int v8; // ebx@17
-  //unsigned __int8 v9; // zf@17
   unsigned __int8 v10; // sf@17
   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; // eax@33
-  //int v17; // edi@34
-  //int v18; // edx@42
-  //int v19; // ecx@42
   __int16 v20; // ax@42
-  //int v21; // ebx@42
-  //int v22; // edi@42
-  //int v23; // ecx@42
-  //__int16 v24; // ax@42
   int v25; // eax@45
   signed int v26; // ecx@50
-  //int v27; // eax@52
   int v28; // eax@54
   signed int v29; // ebx@57
   signed int v30; // eax@57
   int v31; // edi@57
   signed int i; // ebx@57
   unsigned int v33; // ecx@58
-  //int v34; // ebx@64
   int v35; // edi@64
   int v36; // eax@64
-  //unsigned __int16 v37; // cx@66
-  signed int v38; // edx@71
   unsigned int v39; // edi@71
-  BSPModel *v40; // eax@75
-  ODMFace *v41; // edi@75
-  int v42; // ebx@76
-  int v43; // ecx@77
-  int v44; // edx@77
-  __int16 v45; // dx@82
+  ODMFace *face; // edi@75
   int v46; // ecx@82
   signed int v47; // ebx@85
   int v48; // edi@85
-  int v49; // edi@85
-  //int v50; // eax@85
-  //unsigned __int64 v51; // qax@85
-  //unsigned __int8 v52; // zf@87
-  //unsigned __int8 v53; // sf@87
- // unsigned __int8 v54; // of@104
   int v55; // eax@107
   unsigned int v56; // edi@107
   int v57; // ST10_4@107
@@ -925,10 +675,7 @@
   Vec3_int_ v62; // [sp+Ch] [bp-44h]@42
   int v63; // [sp+18h] [bp-38h]@64
   int v64; // [sp+1Ch] [bp-34h]@64
-  int v65; // [sp+20h] [bp-30h]@2
-  int v66; // [sp+24h] [bp-2Ch]@2
   bool v67; // [sp+28h] [bp-28h]@10
-  //unsigned int v68; // [sp+2Ch] [bp-24h]@10
   unsigned int v69; // [sp+30h] [bp-20h]@6
   unsigned int v70; // [sp+34h] [bp-1Ch]@10
   int v71; // [sp+38h] [bp-18h]@62
@@ -941,49 +688,38 @@
 
   for (v75 = 0; v75 < uNumActors; ++v75)
   {
-    v0 = &pActors[v75];
-    v66 = v0->vPosition.x;
-    v65 = v0->vPosition.y;
-    uAIState = v0->uAIState;
-    if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed )
-	{
-		continue;
-	}
+    if ( pActors[v75].uAIState == Removed || pActors[v75].uAIState == Disabled || pActors[v75].uAIState == Summoned
+     || !pActors[v75].uMovementSpeed )
+      continue;
     v3 = 0;
     v69 = 0;
-    if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
+    if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
       v3 = 1;
-    v0->uSectorID = 0;
-    uIsFlying = v0->pMonsterInfo.uFlying;
-    if ( !v0->CanAct() )
+    pActors[v75].uSectorID = 0;
+    uIsFlying = pActors[v75].pMonsterInfo.uFlying;
+    if ( !pActors[v75].CanAct() )
       uIsFlying = 0;
-    v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y);
-    v5 = ODM_GetFloorLevel(
-           v0->vPosition.x,
-           v0->vPosition.y,
-           v0->vPosition.z,
-           v0->uActorHeight,
-           &uIsOnWater,
-           (int *)&v69,
-           v3);
-    v6 = v0->vPosition.z;
+    v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y);
+    v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z,
+           pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3);
+    v6 = pActors[v75].vPosition.z;
     uIsAboveFloor = 0;
     v67 = v69 == 0;
     if ( v6 > v5 + 1 )
       uIsAboveFloor = 1;
-    if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor )
+    if ( pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor )
     {
-      v0->uAIState = Removed;
-	  continue;
+      pActors[v75].uAIState = Removed;
+      continue;
     }
-    if ( v0->uCurrentActionAnimation == ANIM_Walking )
+    if ( pActors[v75].uCurrentActionAnimation == ANIM_Walking )
     {
-      v8 = v0->uMovementSpeed;
-      if ( (signed __int64)v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 )
+      v8 = pActors[v75].uMovementSpeed;
+      if ( (signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 )
       {
         v8 = (signed __int64)((double)v8 * 0.5);
       }
-      if ( uAIState == Fleeing || uAIState == Pursuing )
+      if ( pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing )
       {
         v8 *= 2;
       }
@@ -992,100 +728,97 @@
       if ( v8 > 1000 )
         v8 = 1000;
 
-      v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v0->uYawAngle), v8);
-      v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v0->uYawAngle), v8);
+      pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8);
+      pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8);
       if ( uIsFlying )
       {
-        v0->vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(v0->uPitchAngle), v8);
+        pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8);
       }
       //v7 = v68;
     }
     else
     {
-      v0->vVelocity.x = fixpoint_mul(55000, v0->vVelocity.x);
-      v0->vVelocity.y = fixpoint_mul(55000, v0->vVelocity.y);
+      pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x);
+      pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y);
       if ( uIsFlying )
-      {
-        v0->vVelocity.z = fixpoint_mul(55000, v0->vVelocity.z);
-      }
+        pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z);
     }
-    if ( v0->vPosition.z < v5 )
+    if ( pActors[v75].vPosition.z < v5 )
     {
-      v16 = uIsFlying;
-      v0->vPosition.z = v5;
-      v0->vVelocity.z = v16 != 0 ? 0x14 : 0;
+      pActors[v75].vPosition.z = v5;
+      pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0;
     }
     //v17 = 0;
     if ( !uIsAboveFloor || uIsFlying )
     {
       if ( v70 && !uIsAboveFloor && v67 )
       {
-        v0->vPosition.z = v5;
-        ODM_GetTerrainNormalAt(v0->vPosition.x, v0->vPosition.y, &v62);
+        pActors[v75].vPosition.z = v5;
+        ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62);
         v20 = GetGravityStrength();
         //v21 = v62.y;
         //v22 = v62.z;
         //v23 = v62.y * v0->vVelocity.y;
-        v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
-        int v73 = abs(v62.x * v0->vVelocity.x + v62.z * v0->vVelocity.z + v62.y * v0->vVelocity.y) >> 16;
+        pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
+        int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16;
         //v72b = v21;
-        v0->vVelocity.x += fixpoint_mul(v73, v62.x);
-        v0->vVelocity.y += fixpoint_mul(v73, v62.y);
-        v0->vVelocity.z += fixpoint_mul(v73, v62.z);
+        pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x);
+        pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y);
+        pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z);
         //v17 = 0;
       }
     }
     else
     {
-      v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
+      pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
     }
-    if ( pParty->armageddon_timer != 0 && v0->CanAct() )
+    if ( pParty->armageddon_timer != 0 && pActors[v75].CanAct() )
     {
-      v0->vVelocity.x += rand() % 100 - 50;
-      v0->vVelocity.y += rand() % 100 - 50;
-      v0->vVelocity.z += rand() % 100 - 20;
+      pActors[v75].vVelocity.x += rand() % 100 - 50;
+      pActors[v75].vVelocity.y += rand() % 100 - 50;
+      pActors[v75].vVelocity.z += rand() % 100 - 20;
       v25 = rand();
-      v0->uAIState = Stunned;
-      v0->uYawAngle += v25 % 32 - 16;
-      v0->UpdateAnimation();
+      pActors[v75].uAIState = Stunned;
+      pActors[v75].uYawAngle += v25 % 32 - 16;
+      pActors[v75].UpdateAnimation();
     }
-    if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 )
+    if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0 )
     {
-      v0->vVelocity.y = 0;
-      v0->vVelocity.x = 0;
+      pActors[v75].vVelocity.y = 0;
+      pActors[v75].vVelocity.x = 0;
     }
     stru_721530.field_0 = 1;
     if ( !uIsFlying )
       v26 = 40;
     else
-      v26 = v0->uActorRadius;
+      v26 = pActors[v75].uActorRadius;
 
     stru_721530.field_84 = -1;
     stru_721530.field_8_radius = v26;
     stru_721530.prolly_normal_d = v26;
-    stru_721530.height = v0->uActorHeight;
+    stru_721530.height = pActors[v75].uActorHeight;
     stru_721530.field_70 = 0;
-    v69 = 0;
-    while ( 1 )
+
+    for ( v69 = 0; v69 < 100; ++v69 )
     {
-      stru_721530.position.x = v0->vPosition.x;
+      stru_721530.position.x = pActors[v75].vPosition.x;
       stru_721530.normal.x = stru_721530.position.x;
-      stru_721530.position.y = v0->vPosition.y;
+      stru_721530.position.y = pActors[v75].vPosition.y;
       stru_721530.normal.y = stru_721530.position.y;
-      v28 = v0->vPosition.z;
+      v28 = pActors[v75].vPosition.z;
       stru_721530.normal.z = v28 + v26 + 1;
       stru_721530.position.z = v28 - v26 + stru_721530.height - 1;
       if ( stru_721530.position.z < stru_721530.normal.z )
         stru_721530.position.z = v28 + v26 + 1;
-      stru_721530.velocity.x = v0->vVelocity.x;
+      stru_721530.velocity.x = pActors[v75].vVelocity.x;
       stru_721530.uSectorID = 0;
-      stru_721530.velocity.y = v0->vVelocity.y;
-      stru_721530.velocity.z = v0->vVelocity.z;
+      stru_721530.velocity.y = pActors[v75].vVelocity.y;
+      stru_721530.velocity.z = pActors[v75].vVelocity.z;
       if ( stru_721530._47050A(0) )
         break;
-      _46E889_collide_against_bmodels(1u);
-      v29 = WorldPosToGridCellZ(v0->vPosition.y);
-      v30 = WorldPosToGridCellX(v0->vPosition.x);
+      _46E889_collide_against_bmodels(1);
+      v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y);
+      v30 = WorldPosToGridCellX(pActors[v75].vPosition.x);
       _46E26D_collide_against_sprites(v30, v29);
       _46EF01_collision_chech_player(0);
       _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75));
@@ -1101,182 +834,159 @@
         v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
       //v34 = 0;
       v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
-      v36 = ODM_GetFloorLevel(stru_721530.normal2.x,
-              stru_721530.normal2.y,
+      v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y,
               stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
-              v0->uActorHeight,
-              (int *)&v63,
-              &v64,
-              0);
+              pActors[v75].uActorHeight, (int *)&v63, &v64, 0);
       if ( uIsOnWater )
       {
         if ( v35 < v36 + 60 )
         {
-          if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled )
+          if ( pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed
+            || pActors[v75].uAIState == Disabled )
           {
             if ( v64 )
               v61 = v36 + 30;
             else
               v61 = v5 + 60;
-            sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61);
-            v0->uAIState = Removed;
+            sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61);
+            pActors[v75].uAIState = Removed;
             return;
           }
         }
       }
       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;
+        pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x);
+        pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y);
+        pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
         break;
       }
       //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x);
-      v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
+      pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
       //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
+      pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
       //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
-      v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
-      v38 = stru_721530.uFaceID;
+      pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
       stru_721530.field_70 += stru_721530.field_7C;
-	  v39 = PID_ID(v38);
-      switch ( PID_TYPE(v38) )
+      v39 = PID_ID(stru_721530.uFaceID);
+      switch ( PID_TYPE(stru_721530.uFaceID) )
       {
         case OBJECT_Actor:
           if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 )
           {
 			//if(pParty->bTurnBasedModeOn == 1)
 				//v34 = 0;
-            if ( v0->pMonsterInfo.uHostilityType )
+            if ( pActors[v75].pMonsterInfo.uHostilityType )
             {
               if ( v71 == 0 )
-			  {
-				  Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
-			  }
-			  else
-			  {
-				  Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
-			  }
+                Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
+              else
+                Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
             }
             else if ( v71 )
-			{
               Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
-			}
-			else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
-            {
-              Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
-            }
-			else
-			{
-				Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
-			}
+            else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
+              Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
+            else
+              Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
           }
           break;
         case OBJECT_Player:
-          if ( !v0->GetActorsRelation(0) )
+          if ( !pActors[v75].GetActorsRelation(0) )
           {
-            v38 = stru_721530.uFaceID;
-            Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
+            Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
             break;
           }
           //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0;
           //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0;
-          v0->vVelocity.y = 0;
-          v0->vVelocity.x = 0;
+          pActors[v75].vVelocity.y = 0;
+          pActors[v75].vVelocity.x = 0;
           //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) )
-		  if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0)
+          if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0)
             pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
           viewparams->bRedrawGameUI = 1;
           break;
         case OBJECT_Decoration:
-          v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
-          v48 = stru_5C6E00->Atan2(
-                  v0->vPosition.x - pLevelDecorations[v39].vPosition.x,
-                  v0->vPosition.y - pLevelDecorations[v39].vPosition.y);
-          v49 = v48;
-          v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47);
-          v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
+          v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y);
+          v48 = stru_5C6E00->Atan2( pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x,
+                  pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y);
+          //v49 = v48;
+          pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47);
+          pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
           break;
         case OBJECT_BModel:
-          v40 = &pOutdoor->pBModels[v38 >> 9];
-          v41 = &v40->pFaces[v39 & 0x3F];
-          if ( !(v41->uAttributes & 0x20000000) )
+          face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F];
+          if ( !face->Ethereal() )
           {
-            v42 = v41->uPolygonType;
-            if ( v42 == 3 )
+            if ( face->uPolygonType == 3 )
             {
-              v43 = v0->vVelocity.y;
-              v44 = v0->vVelocity.x;
-              v0->vVelocity.z = 0;
-              v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1;
-              if ( v44 * v44 + v43 * v43 < 400 )
+              pActors[v75].vVelocity.z = 0;
+              pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1;
+              if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x
+                 + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 )
               {
-                v0->vVelocity.y = 0;
-                v0->vVelocity.x = 0;
+                pActors[v75].vVelocity.y = 0;
+                pActors[v75].vVelocity.x = 0;
               }
             }
             else
             {
-              v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z
-                                                                    + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16;
+              v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z
+                                                                    + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16;
               if ( (stru_721530.speed >> 3) > v72b )
                 v72b = stru_721530.speed >> 3;
 
-              v0->vVelocity.x += fixpoint_mul(v72b, v41->pFacePlane.vNormal.x);
-              v0->vVelocity.y += fixpoint_mul(v72b, v41->pFacePlane.vNormal.y);
-              v0->vVelocity.z += fixpoint_mul(v72b, v41->pFacePlane.vNormal.z);
-              if ( v42 != 4 )
+              pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x);
+              pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y);
+              pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z);
+              if ( face->uPolygonType != 4 )
               {
-                v45 = v0->vPosition.z;
                 v46 = stru_721530.prolly_normal_d
-                    - ((v41->pFacePlane.dist
-                      + v41->pFacePlane.vNormal.x * v0->vPosition.x
-                      + v41->pFacePlane.vNormal.y * v0->vPosition.y
-                      + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16);
+                    - ((face->pFacePlane.dist
+                      + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x
+                      + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y
+                      + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16);
                 if ( v46 > 0 )
                 {
-                  v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16;
-                  v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16;
-                  v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16);
+                  pActors[v75].vPosition.x += (unsigned int)(v46 * face->pFacePlane.vNormal.x) >> 16;
+                  pActors[v75].vPosition.y += (unsigned int)(v46 * face->pFacePlane.vNormal.y) >> 16;
+                  pActors[v75].vPosition.z += (unsigned int)(v46 * face->pFacePlane.vNormal.z) >> 16;
                 }
-                v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y);
+                pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y);
               }
             }
           }
           break;
       }
 
-      v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x);
-      v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y);
-      v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z);
-
-      ++v69;
-      if ( v69 >= 100 )
-        break;
+      pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x);
+      pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y);
+      pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z);
+
       v26 = stru_721530.prolly_normal_d;
     }
-    v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1;
-    v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1;
-    if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) 
-		&& WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y)
-		&& v58 
-		|| v67 != 0 )
+
+    v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
+    v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
+    if ( WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x) 
+      && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y)
+      && v58  || v67 != 0 )
     {
-      if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
+      if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
       {
         v58 = v58 == 0;
         v59 = v59 == 0;
       }
       if ( !uIsFlying && v58 && !v59 )
       {
-        v0->vPosition.x = v66;
-        v0->vPosition.y = v65;
-        if ( v0->CanAct() )
+        pActors[v75].vPosition.x = pActors[v75].vPosition.x;
+        pActors[v75].vPosition.y = pActors[v75].vPosition.y;
+        if ( pActors[v75].CanAct() )
         {
-          v0->uYawAngle -= 32;
-          v0->uCurrentActionTime = 0;
-          v0->uCurrentActionLength = 128;
-          v0->uAIState = Fleeing;
+          pActors[v75].uYawAngle -= 32;
+          pActors[v75].uCurrentActionTime = 0;
+          pActors[v75].uCurrentActionLength = 128;
+          pActors[v75].uAIState = Fleeing;
         }
       }
     }
@@ -1290,13 +1000,11 @@
   //unsigned int v1; // edi@1
   //char *v2; // esi@2
   //__int16 v3; // dx@5
-  ObjectDesc *v4; // eax@5
+  ObjectDesc *object; // eax@5
   int v5; // ecx@6
   __int16 v6; // cx@7
   signed int v7; // eax@9
-  __int16 v8; // cx@14
-  __int16 v9; // dx@14
-  unsigned int v10; // ecx@16
+  //unsigned int v10; // ecx@16
   signed int v11; // eax@17
   int v12; // edi@27
   int v13; // eax@27
@@ -1321,47 +1029,45 @@
       item->uAttributes &= ~OBJECT_40;
     else
     {
-              //v3 = item->uObjectDescID;
-      v4 = &pObjectList->pObjects[item->uObjectDescID];
+      object = &pObjectList->pObjects[item->uObjectDescID];
       if (item->AttachedToActor())
       {
           v5 = PID_ID(item->spell_target_pid);
-		  item->vPosition.x = pActors[v5].vPosition.x;
+          item->vPosition.x = pActors[v5].vPosition.x;
           item->vPosition.y = pActors[v5].vPosition.y;
           item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
-		  if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) )
+          if ( !item->uObjectDescID )
             continue;
-          if ( v6 >= 0 )
+          item->uSpriteFrameID += pEventTimer->uTimeElapsed;
+          if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
+            continue;
+          if ( item->uSpriteFrameID >= 0 )
           {
-            v7 = v4->uLifetime;
-            if (item->uAttributes & 2)
+            v7 = object->uLifetime;
+            if (item->uAttributes & ITEM_BROKEN)
               v7 = item->field_20;
-            if ( v6 < v7 )
+            if ( item->uSpriteFrameID < v7 )
               continue;
           }
-            v10 = i;
-            SpriteObject::OnInteraction(v10);
-            continue;
+          SpriteObject::OnInteraction(i);
+          continue;
       }
 
         if ( item->uObjectDescID )
         {
-          v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID;
-          item->uSpriteFrameID = v8;
-          v9 = v4->uFlags;
-          if ( v9 & 4 )
-		  {    
-			  if ( v8 < 0 )
-			  {
-				v10 = i;
-				SpriteObject::OnInteraction(v10);
-				continue;
-			  }
-			  v11 = v4->uLifetime;
-			  if (item->uAttributes & 2)
-				v11 = item->field_20;
-		  }
-		  if ( !(v9 & 4) || v8 < v11 )
+          item->uSpriteFrameID += pEventTimer->uTimeElapsed;
+          if ( object->uFlags & OBJECT_DESC_TEMPORARY )
+          {
+            if ( item->uSpriteFrameID < 0 )
+            {
+              SpriteObject::OnInteraction(i);
+              continue;
+            }
+            v11 = object->uLifetime;
+            if (item->uAttributes & ITEM_BROKEN)
+              v11 = item->field_20;
+          }
+          if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || item->uSpriteFrameID < v11 )
           {
             if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
               SpriteObject::UpdateObject_fn0_BLV(i);
@@ -1395,23 +1101,17 @@
             v0 = (unsigned int)(11 * v14) >> 5;
             if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
               continue;
-            v10 = i;
-            SpriteObject::OnInteraction(v10);
+            SpriteObject::OnInteraction(i);
             continue;
           }
-          v10 = i;
-          if ( !(v9 & 0x40) )
-		  {
-            SpriteObject::OnInteraction(v10);
+          if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
+          {
+            SpriteObject::OnInteraction(i);
             continue;
-		  }
+          }
           _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
         }
     }
-      //v2 += 112;
-      //v1 = v20++ + 1;
-    //}
-    //while ( v20 < (signed int)uNumSpriteObjects );
   }
 }
 
@@ -1451,623 +1151,15 @@
   return result;
 }
 
-//----- (00472866) --------------------------------------------------------
-void BLV_ProcessPartyActions()
+//----- (0047531C) --------------------------------------------------------
+bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10)
 {
-  int v1; // ebx@1
-  int v2; // edi@1
-  //int v6; // eax@18
-  //signed __int64 v8; // qax@27
-  //int v9; // eax@27
-  double v10; // st7@27
-  unsigned int v12; // eax@49
-  double v13; // st7@50
-  //int v14; // eax@51
-  //signed __int64 v15; // qax@53
-  //double v16; // st7@54
-  int v17; // eax@62
-  double v18; // st7@62
-  int v19; // ST40_4@62
-  int v20; // eax@65
-  double v21; // st7@65
-  int v22; // ST40_4@65
-  int v23; // eax@66
-  double v24; // st7@66
-  int v25; // ST40_4@66
-  int v26; // eax@67
-  double v27; // st7@67
-  int v28; // ST40_4@67
-  unsigned int v35; // eax@74
-  int v36; // ecx@88
-  int new_party_z; // esi@96
-  int v38; // eax@96
-  int v39; // ecx@106
-  int v40; // eax@106
-  Player **v41; // esi@113
-  int v42; // eax@120
-  signed int v43; // ecx@123
-  BLVFace *v44; // esi@126
-  PolygonType v45; // al@126
-  int v46; // ecx@133
-  char v47; // zf@133
-  int v48; // eax@133
-  int v49; // ST40_4@136
-  int v50; // ST40_4@140
-  int v51; // eax@140
-  int v52; // eax@140
-  signed int v53; // edi@146
-  int v54; // ebx@146
-  int v55; // ST30_4@146
-  AudioPlayer *v56; // ecx@162
-  SoundID v57; // [sp-20h] [bp-80h]@163
-  signed int v58; // [sp-1Ch] [bp-7Ch]@161
-  unsigned int v59; // [sp-18h] [bp-78h]@161
-  signed int v60; // [sp-14h] [bp-74h]@161
-  signed int v61; // [sp-10h] [bp-70h]@161
-  int v62; // [sp-Ch] [bp-6Ch]@161
-  int v63; // [sp-8h] [bp-68h]@75
-  unsigned int v64; // [sp-8h] [bp-68h]@161
-  int v65; // [sp-4h] [bp-64h]@75
-  int v66; // [sp-4h] [bp-64h]@161
-  //int v68; // [sp+10h] [bp-50h]@45
-  int v69; // [sp+10h] [bp-50h]@140
-  unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1
-  //signed int v71; // [sp+18h] [bp-48h]@1
-  signed int v72; // [sp+1Ch] [bp-44h]@1
-  signed int v73; // [sp+20h] [bp-40h]@100
-  int v74; // [sp+20h] [bp-40h]@140
-  bool bFeatherFall; // [sp+24h] [bp-3Ch]@15
-  unsigned int uSectorID; // [sp+28h] [bp-38h]@1
-  int v78; // [sp+2Ch] [bp-34h]@1
-  unsigned int uFaceID; // [sp+30h] [bp-30h]@1
-  int v80; // [sp+34h] [bp-2Ch]@1
-  int v81; // [sp+38h] [bp-28h]@47
-  int v82; // [sp+3Ch] [bp-24h]@47
-  int _view_angle; // [sp+40h] [bp-20h]@47
-  int bJumping; // [sp+44h] [bp-1Ch]@1
-  int new_party_y; // [sp+48h] [bp-18h]@1
-  int new_party_x; // [sp+4Ch] [bp-14h]@1
-  int party_z; // [sp+50h] [bp-10h]@1
-  //int v89; // [sp+58h] [bp-8h]@1
-  int angle; // [sp+5Ch] [bp-4h]@47
-
-  uFaceEvent = 0;
-  //v89 = pParty->uFallSpeed;
-  v1 = 0;
-  v2 = 0;
-  new_party_x = pParty->vPosition.x;
-  new_party_y = pParty->vPosition.y;
-  party_z = pParty->vPosition.z;
-  uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-  v72 = 0;
-  v78 = 0;
-  bJumping = 0;
-
-  uFaceID = -1;
-  int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
-
-  if ( pParty->bFlying )
-  {
-    pParty->bFlying = false;
-    if (pParty->FlyActive())
-      pOtherOverlayList->pOverlays[pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID - 1].field_E |= 1;
-  }
-
-  if ( floor_level == -30000  || uFaceID == -1)
-  {
-    floor_level = collide_against_floor_approximate(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
-    if ( floor_level == -30000 || uFaceID == -1)
-    {
-      __debugbreak(); // level built with errors 
-      pParty->vPosition.x = blv_prev_party_x;
-      pParty->vPosition.y = blv_prev_party_z;
-      pParty->vPosition.z = blv_prev_party_y;
-      pParty->uFallStartY = blv_prev_party_y;
-      return;
-    }
-  }
-
-  blv_prev_party_x = pParty->vPosition.x;
-  blv_prev_party_z = pParty->vPosition.y;
-  blv_prev_party_y = pParty->vPosition.z;
-  if (!pParty->bTurnBasedModeOn)
-  {
-    int v67 = GetTickCount() / 500;
-    if (dword_720CDC != v67 )
-    {
-      dword_4F8580[3 * dword_4F8580[1]] = pParty->vPosition.x;
-      dword_4F8580[3 * dword_4F8580[2]] = pParty->vPosition.y;
-      dword_4F8580[3 * dword_4F8580[3]] = pParty->vPosition.z;
-      if ( dword_4F8580[0] > 60 )
-        dword_4F8580[0] = 1;
-    }
-    dword_720CDC = v67;
-  }
-
-  uint fall_start;
-  if (!pParty->FeatherFallActive())
-  {
-    bFeatherFall = false;
-    if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&  // grants feather fall
-        !pParty->pPlayers[1].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&
-        !pParty->pPlayers[2].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&
-        !pParty->pPlayers[3].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT))
-    {
-      fall_start = pParty->uFallStartY;
-    }
-  }
-  else
-  {
-    fall_start = floor_level;
-    bFeatherFall = true;
-    pParty->uFallStartY = floor_level;
-  }
-
-
-  if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1)
-  {
-    assert(~pParty->uFlags & PARTY_FLAGS_1_LANDING); // why land in indoor?
-    if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
-      pParty->uFlags &= ~PARTY_FLAGS_1_LANDING;
-    else for (uint i = 0; i < 4; ++i)
-    {                                      // receive falling damage
-      Player* player = &pParty->pPlayers[i];
-      if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS))
-      {
-        player->ReceiveDamage((pParty->uFallStartY - party_z) * (0.1f * player->GetMaxHealth()) / 256, DMGT_PHISYCAL);
-        v10 = (double)(20 - player->GetParameterBonus(player->GetActualEndurance())) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
-        player->SetRecoveryTime((signed __int64)v10);
-      }
-    }
-  }
-
-  if ( party_z > floor_level + 1 )
-    bJumping = 1;
-
-  bool jumping_up = false;
-
-  if ( party_z - floor_level <= 32 )
-  {
-    pParty->uFallStartY = party_z;
-    jumping_up = true;
-  }
-
-  if (bWalkSound && pParty->walk_sound_timer)
-  {
-    if (pParty->walk_sound_timer > pEventTimer->uTimeElapsed)
-      pParty->walk_sound_timer -= pEventTimer->uTimeElapsed;
-    else pParty->walk_sound_timer = 0;
-  }
-
-
-  if (party_z <= floor_level + 1)
-  {
-    party_z = floor_level + 1;
-    pParty->uFallStartY = floor_level + 1;
-
-    if (!bJumping && pParty->floor_face_pid != uFaceID)
-    {
-      BLVFace* pFace = &pIndoor->pFaces[uFaceID];
-      if (pFace->uAttributes & FACE_PRESSURE_PLATE)
-        uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
-    }
-  }
-  if (!bJumping)
-    pParty->floor_face_pid = uFaceID;
-
-  bool on_water = false;
-  if ( pIndoor->pFaces[uFaceID].Fluid())
-    on_water = true;
-
-  v81 = pParty->uWalkSpeed;
-  angle = pParty->sRotationY;
-  _view_angle = pParty->sRotationX;
-  v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi)
-                                          / 180)) >> 16;
-//LABEL_87:
-  while ( pPartyActionQueue->uNumActions )
-  {
-    switch ( pPartyActionQueue->Next() )
-    {
-      case PARTY_TurnLeft:
-        if (uTurnSpeed)
-          angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed);
-        else
-          angle = stru_5C6E00->uDoublePiMask & (angle + (int)(v82 * fTurnSpeedMultiplier));
-        break;
-      case PARTY_TurnRight:
-        if (uTurnSpeed)
-          angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed);
-        else
-          angle = stru_5C6E00->uDoublePiMask & (angle - (int)(v82 * fTurnSpeedMultiplier));
-        break;
-
-      case PARTY_FastTurnLeft:
-        if (uTurnSpeed)
-          angle = stru_5C6E00->uDoublePiMask & (angle + uTurnSpeed);
-        else
-          angle = stru_5C6E00->uDoublePiMask & (angle + (int)(2.0f * fTurnSpeedMultiplier * (double)v82));
-        break;
-
-      case PARTY_FastTurnRight:
-        if (uTurnSpeed)
-          angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed);
-        else
-          angle = stru_5C6E00->uDoublePiMask & (angle - (int)(2.0f * fTurnSpeedMultiplier * (double)v82));
-        break;
-
-      case PARTY_StrafeLeft:
-        v2 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
-        v1 += fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
-        v78 = 1;
-        break;
-      case PARTY_StrafeRight:
-        v2 += fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2);
-        v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2);
-        v78 = 1;
-        break;
-      case PARTY_WalkForward:
-        v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier);
-        v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier);
-        v78 = 1;
-        break;
-      case PARTY_WalkBackward:
-        v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
-        v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
-        v78 = 1;
-        break;
-      case PARTY_RunForward:
-        v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier);
-        v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier);
-        v72 = 1;
-        break;
-      case PARTY_RunBackward:
-        //v32 = stru_5C6E00->SinCos(angle);
-        //v33 = (double)v81;
-        //v88 = (double)v81;
-        v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier);
-        //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
-        v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier);
-        v72 = 1;
-        break;
-      case PARTY_LookUp:
-        _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
-        if ( _view_angle > 128 )
-          _view_angle = 128;
-        v35 = uActiveCharacter;
-        if ( uActiveCharacter )
-          pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0);
-        break;
-      case PARTY_LookDown:
-        _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
-        if ( _view_angle < -128 )
-          _view_angle = -128;
-        v35 = uActiveCharacter;
-        if ( uActiveCharacter )
-          pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_64, 0);
-        break;
-      case PARTY_CenterView:
-        _view_angle = 0;
-        break;
-      case PARTY_Jump:
-        if ( (!bJumping || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 )
-        {
-          bJumping = 1;
-          pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
-        }
-        break;
-      default:
-        break;
-    }
-  }
-  v36 = 0;
-  pParty->sRotationY = angle;
-  pParty->sRotationX = _view_angle;
-  if ( bJumping )
-  {
-	pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
-	if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
-	{
-		if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
-		{
-			v41 = &pPlayers[1];
-			do
-			{
-				if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
-					(*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
-				++v41;
-			}
-			while ( (signed int)v41 <= (signed int)&pPlayers[4] );
-		}
-	}
-	else
-		pParty->uFallStartY = party_z;
-  }
-  else
-  {
-    if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 )
-    {
-      pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength();
-      pParty->uFallStartY = party_z;
-    }
-	else
-	{
-		if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) )
-		  pParty->uFallSpeed = 0;
-		pParty->uFallStartY = party_z;
-	}
-  }
-  if ( v2 * v2 + v1 * v1 < 400 )
-  {
-    v1 = 0;
-    v2 = 0;
-  }
-  stru_721530.field_84 = -1;
-  stru_721530.field_70 = 0;
-  stru_721530.prolly_normal_d = pParty->field_14_radius;
-  stru_721530.field_8_radius = pParty->field_14_radius / 2;
-  int v83 = 0;
-  stru_721530.field_0 = 1;
-  stru_721530.height = pParty->uPartyHeight - 32;
-  while ( 1 )
-  {
-    new_party_z = party_z;
-    stru_721530.position.x = new_party_x;
-    stru_721530.normal.x = new_party_x;
-    stru_721530.velocity.x = v2;
-    stru_721530.position.y = new_party_y;
-    stru_721530.normal.y = new_party_y;
-    stru_721530.velocity.y = v1;
-    stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
-    stru_721530.position.z = stru_721530.height + party_z + 1;
-    stru_721530.velocity.z = pParty->uFallSpeed;
-    stru_721530.uSectorID = uSectorID;
-    v38 = 0;
-    if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
-      v38 = 13312;
-    if ( stru_721530._47050A(v38) )
-      break;
-    v73 = 0;
-    do
-    {
-      _46E44E_collide_against_faces_and_portals(1u);
-      _46E0B2_collide_against_decorations();
-      for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
-        Actor::_46DF1A_collide_against_actor(v80, 0);
-      if ( _46F04E_collide_against_portals() )
-        break;
-      ++v73;
-    }
-    while ( v73 < 100 );
-    if ( stru_721530.field_7C >= stru_721530.field_6C )
-    {
-      v39 = stru_721530.normal2.x;
-      uSectorID = stru_721530.normal2.y;
-      v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
-    }
-    else
-    {
-      v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16) + new_party_x;
-      uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16);
-      v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16);
-    }
-    v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID);
-    if ( v42 == -30000 || v42 - new_party_z > 128 )
-      return;
-    if ( stru_721530.field_7C >= stru_721530.field_6C )
-    {
-      new_party_x = stru_721530.normal2.x;
-      new_party_y = stru_721530.normal2.y;
-      new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
-      break;
-    }
-    new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
-    new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16;
-    v43 = stru_721530.uFaceID;
-    uSectorID = stru_721530.uSectorID;
-    stru_721530.field_70 += stru_721530.field_7C;
-    unsigned long long v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z;
-    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
-    {
-      if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0
-        && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) )
-        pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
-      viewparams->bRedrawGameUI = 1;
-    }
-	else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
-    {
-      v53 = integer_sqrt(v2 * v2 + v1 * v1);
-      v80 = v53;
-      v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x,
-              new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y);
-      v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)v53) >> 16;
-      v55 = stru_5C6E00->Sin(v54);
-      v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16;
-    }
-    else
-    {
-      if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
-      {
-        v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3];
-        v45 = v44->uPolygonType;
-        if ( v45 == 3 )
-        {
-          if ( pParty->uFallSpeed < 0 )
-            pParty->uFallSpeed = 0;
-          v87 = pIndoor->pVertices[*v44->pVertexIDs].z + 1;
-          if ( pParty->uFallStartY - v87 < 512 )
-            pParty->uFallStartY = v87;
-          if ( v2 * v2 + v1 * v1 < 400 )
-          {
-            v1 = 0;
-            v2 = 0;
-          }
-          if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-        }
-		else
-		{
-			v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
-			v47 = v45 == 4;
-			v48 = v44->pFacePlane_old.vNormal.x;
-			if ( !v47 )
-			{
-			  v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-			  if ((stru_721530.speed >> 3) > v80 )
-				v80 = stru_721530.speed >> 3;
-			  v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-			  v81 = v44->pFacePlane_old.vNormal.y;
-			  v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-			  v82 = v44->pFacePlane_old.vNormal.z;
-			  v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-			  v2 += v50;
-			  pParty->uFallSpeed += v82;
-			  v74 = v44->pFacePlane_old.vNormal.z;
-			  v51 = v44->pFacePlane_old.vNormal.y;
-			  v69 = v44->pFacePlane_old.vNormal.x;
-			  v80 = v51;
-			  v1 += v81;
-			  v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
-			  if ( v52 > 0 )
-			  {
-				new_party_x += v52 * v69 >> 16;
-				new_party_y += v52 * v80 >> 16;
-				v87 += v52 * v74 >> 16;
-			  }
-			  v43 = stru_721530.uFaceID;
-			  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-				uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-			}
-			else
-			{
-				v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-				if ((stru_721530.speed >> 3) > v80 )
-				  v80 = stru_721530.speed >> 3;
-				v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-				v81 = v44->pFacePlane_old.vNormal.y;
-				v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-				v82 = v44->pFacePlane_old.vNormal.z;
-				v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-				v2 += v49;
-				v1 += v81;
-				pParty->uFallSpeed += v82;
-				if ( v2 * v2 + v1 * v1 >= 400 )
-				{
-				  v43 = stru_721530.uFaceID;
-				  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-					uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-				}
-				else
-				{
-					v2 = 0;
-					v1 = 0;
-					pParty->uFallSpeed = 0;
-				}
-			}
-		}
-      }
-    }
-    v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-    v1 = (unsigned __int64)(58500i64 * v1) >> 16;
-    ++v83;
-    pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-    if ( v83 >= 100 )
-    {
-      new_party_z = v87;
-      break;
-    }
-  }
-  if ( bWalkSound && !pParty->walk_sound_timer)
-  {
-    if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y)
-         * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z)
-         * (pParty->vPosition.z - new_party_z)) <= 16 )
-	{
-      pAudioPlayer->_4AA258(804);
-      pParty->walk_sound_timer = 64;
-	}
-    else if ( v72 && (!bJumping || jumping_up) )
-    {
-      v66 = 0;
-      v64 = 0;
-      v62 = 0;
-      v61 = 0;
-      v60 = -1;
-      v59 = 1;
-      v58 = 804;
-      if ( !on_water )
-      {
-        v56 = pAudioPlayer;
-        if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
-          v57 = (SoundID)50;
-        else
-          v57 = (SoundID)64;
-        pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
-      }
-	  else
-	  {
-		  v57 = (SoundID)63;
-		  v56 = pAudioPlayer;
-		  pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
-	  }
-    }
-    else if ( v78 && (!bJumping || jumping_up) )
-    {
-      v66 = 0;
-      v64 = 0;
-      v62 = 0;
-      v61 = 0;
-      v60 = -1;
-      v59 = 1;
-      v58 = 804;
-      if ( on_water )
-      {
-        v57 = (SoundID)102;
-        v56 = pAudioPlayer;
-      }
-	  else
-	  {
-		  v56 = pAudioPlayer;
-		  if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
-			v57 = (SoundID)89;
-		  else
-			v57 = (SoundID)103;
-	  }
-      pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
-    }
-    else
-    {
-      pAudioPlayer->_4AA258(804);
-      pParty->walk_sound_timer = 64;
-    }
-  }
-  if ( !bJumping || jumping_up )
-    pParty->uFlags &= ~PARTY_FLAGS_1_FALLING;
-  else
-    pParty->uFlags |= PARTY_FLAGS_1_FALLING;
-  pParty->uFlags &= ~0x200;
-  pParty->vPosition.x = new_party_x;
-  pParty->vPosition.z = new_party_z;
-  pParty->vPosition.y = new_party_y;
-  //pParty->uFallSpeed = v89;
-  if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 )
-    pParty->uFlags |= 0x200;
-  if (uFaceEvent)
-    EventProcessor(uFaceEvent, 0, 1);
-}
-
-//----- (0047531C) --------------------------------------------------------
-bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10)
-{
-  BLVFace *v10; // ebx@1
   int v11; // ST1C_4@3
   int v12; // edi@3
   int v13; // esi@3
   int v14; // edi@4
   signed __int64 v15; // qtt@6
   __int16 v16; // si@7
-  int *v18; // [sp+Ch] [bp-Ch]@1
-  int v19; // [sp+10h] [bp-8h]@1
   int a7a; // [sp+30h] [bp+18h]@7
   int a9b; // [sp+38h] [bp+20h]@3
   int a9a; // [sp+38h] [bp+20h]@3
@@ -2075,32 +1167,29 @@
   signed int a10a; // [sp+3Ch] [bp+24h]@4
   int a10c; // [sp+3Ch] [bp+24h]@5
 
-  v10 = a9;
-  v18 = a2;
-  v19 = a1;
-  if ( a10 && BYTE3(a9->uAttributes) & 0x20 )
+  if ( a10 && face->Ethereal() )
     return 0;
-  v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
-  a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
-  a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
+  v11 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16;
+  a10b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16;
+  a9b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16;
   v12 = v11 + a9b + a10b;
   a9a = v11 + a9b + a10b;
   v13 = (a1 << 16)
-      - a3 * v10->pFacePlane_old.vNormal.x
-      - a4 * v10->pFacePlane_old.vNormal.y
-      - a5 * v10->pFacePlane_old.vNormal.z
-      - v10->pFacePlane_old.dist;
+      - pos_x * face->pFacePlane_old.vNormal.x
+      - pos_y * face->pFacePlane_old.vNormal.y
+      - pos_z * face->pFacePlane_old.vNormal.z
+      - face->pFacePlane_old.dist;
   if ( abs((a1 << 16)
-         - a3 * v10->pFacePlane_old.vNormal.x
-         - a4 * v10->pFacePlane_old.vNormal.y
-         - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 )
+         - pos_x * face->pFacePlane_old.vNormal.x
+         - pos_y * face->pFacePlane_old.vNormal.y
+         - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 )
   {
     a10c = abs(v13) >> 14;
     if ( a10c > abs(v12) )
       return 0;
     LODWORD(v15) = v13 << 16;
     HIDWORD(v15) = v13 >> 16;
-    v14 = v19;
+    v14 = a1;
     a10a = v15 / a9a;
   }
   else
@@ -2108,36 +1197,29 @@
     a10a = 0;
     v14 = abs(v13) >> 16;
   }
-  v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16);
-  LOWORD(a7a) = (short)a3
-              + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16)
-              - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16);
-  HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16);
-  if ( !sub_475665(
-          v10,
-          a7a,
-          (short)a5
-        + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16)
-        - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) )
+  v16 = pos_y + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_y) >> 16) >> 16);
+  LOWORD(a7a) = (short)pos_x
+              + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_x) >> 16) >> 16)
+              - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.x) >> 16);
+  HIWORD(a7a) = v16 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.y) >> 16);
+  if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_z) >> 16) >> 16)
+        - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.z) >> 16)) )
     return 0;
-  *v18 = a10a >> 16;
+  *a2 = a10a >> 16;
   if ( a10a >> 16 < 0 )
-    *v18 = 0;
+    *a2 = 0;
   return 1;
 }
 
 //----- (004754BF) --------------------------------------------------------
-bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10, int a11)
+bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10, int a11)
 {
-  BLVFace *v11; // ebx@1
   int v12; // ST1C_4@3
   int v13; // edi@3
   int v14; // esi@3
   int v15; // edi@4
   signed __int64 v16; // qtt@6
   __int16 v17; // si@7
-  int *v19; // [sp+Ch] [bp-Ch]@1
-  int v20; // [sp+10h] [bp-8h]@1
   int a7a; // [sp+30h] [bp+18h]@7
   int a1b; // [sp+38h] [bp+20h]@3
   int a1a; // [sp+38h] [bp+20h]@3
@@ -2145,32 +1227,29 @@
   signed int a11a; // [sp+40h] [bp+28h]@4
   int a11c; // [sp+40h] [bp+28h]@5
 
-  v11 = a9;
-  v19 = a2;
-  v20 = a1;
-  if ( a11 && BYTE3(a9->uAttributes) & 0x20 )
-    return 0;
-  v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
-  a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
-  a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
+  if ( a11 && face->Ethereal() )
+    return false;
+  v12 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16;
+  a11b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16;
+  a1b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16;
   v13 = v12 + a1b + a11b;
   a1a = v12 + a1b + a11b;
   v14 = (a1 << 16)
-      - a3 * v11->pFacePlane_old.vNormal.x
-      - a4 * v11->pFacePlane_old.vNormal.y
-      - a5 * v11->pFacePlane_old.vNormal.z
-      - v11->pFacePlane_old.dist;
+      - X * face->pFacePlane_old.vNormal.x
+      - Y * face->pFacePlane_old.vNormal.y
+      - Z * face->pFacePlane_old.vNormal.z
+      - face->pFacePlane_old.dist;
   if ( abs((a1 << 16)
-         - a3 * v11->pFacePlane_old.vNormal.x
-         - a4 * v11->pFacePlane_old.vNormal.y
-         - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 )
+         - X * face->pFacePlane_old.vNormal.x
+         - Y * face->pFacePlane_old.vNormal.y
+         - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 )
   {
     a11c = abs(v14) >> 14;
     if ( a11c > abs(v13) )
-      return 0;
+      return false;
     LODWORD(v16) = v14 << 16;
     HIDWORD(v16) = v14 >> 16;
-    v15 = v20;
+    v15 = a1;
     a11a = v16 / a1a;
   }
   else
@@ -2178,23 +1257,18 @@
     a11a = 0;
     v15 = abs(v14) >> 16;
   }
-  v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16);
-  LOWORD(a7a) = (short)a3
-              + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16)
-              - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16);
-  HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16);
-  if ( !sub_4759C9(
-          v11,
-          a10,
-          a7a,
-          (short)a5
-        + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16)
-        - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) )
-    return 0;
-  *v19 = a11a >> 16;
+  v17 = Y + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_y) >> 16) >> 16);
+  LOWORD(a7a) = (short)X
+              + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_x) >> 16) >> 16)
+              - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.x) >> 16);
+  HIWORD(a7a) = v17 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.y) >> 16);
+  if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_z) >> 16) >> 16)
+        - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.z) >> 16)) )
+    return false;
+  *a2 = a11a >> 16;
   if ( a11a >> 16 < 0 )
-    *v19 = 0;
-  return 1;
+    *a2 = 0;
+  return true;
 }
 
 //----- (00475665) --------------------------------------------------------
@@ -2346,12 +1420,12 @@
 //----- (004759C9) --------------------------------------------------------
 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
 {
-  unsigned int v4; // eax@1
-  int v5; // edx@4
+  //unsigned int v4; // eax@1
+  //int v5; // edx@4
   __int16 v6; // si@4
-  int v7; // edx@9
+  //int v7; // edx@9
   __int16 v8; // si@9
-  int v9; // edx@13
+  //int v9; // edx@13
   __int16 v10; // si@13
   int v11; // esi@14
   bool v12; // edi@14
@@ -2372,9 +1446,9 @@
   Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
   signed int a4d; // [sp+30h] [bp+Ch]@14
 
-  v4 = a1->uAttributes;
+  //v4 = a1->uAttributes;
   v22 = 0;
-  if ( BYTE1(v4) & 1 )
+  if ( BYTE1(a1->uAttributes) & 1 )
   {
     v23 = (signed __int16)a3;
     v24 = SHIWORD(a3);
@@ -2383,11 +1457,11 @@
       a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
       do
       {
-        v5 = 2 * v22;
+        //v5 = 2 * v22;
         word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x);
         word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y);
         word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x);
-        word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
+        word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
         ++v22;
       }
       while ( v22 < a1->uNumVertices );
@@ -2395,7 +1469,7 @@
   }
   else
   {
-    if ( BYTE1(v4) & 2 )
+    if ( BYTE1(a1->uAttributes) & 2 )
     {
       v23 = (signed __int16)a3;
       v24 = a4;
@@ -2404,11 +1478,11 @@
         a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
         do
         {
-          v7 = 2 * v22;
+          //v7 = 2 * v22;
           word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x);
           word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z);
           word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x);
-          word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
           ++v22;
         }
         while ( v22 < a1->uNumVertices );
@@ -2423,11 +1497,11 @@
         a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
         do
         {
-          v9 = 2 * v22;
+          //v9 = 2 * v22;
           word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y);
           word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z);
           word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y);
-          word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
           ++v22;
         }
         while ( v22 < a1->uNumVertices );
@@ -2543,7 +1617,7 @@
 //----- (00475F30) --------------------------------------------------------
 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
 {
-  BLVFace *v9; // ebx@1
+  //BLVFace *v9; // ebx@1
   int v10; // ST20_4@2
   int v11; // ST28_4@2
   int v12; // ST24_4@2
@@ -2554,14 +1628,14 @@
   int v17; // ST20_4@9
   signed __int64 v18; // qtt@10
   int v19; // ST14_4@11
-  int *v21; // [sp+14h] [bp-10h]@1
+  //int *v21; // [sp+14h] [bp-10h]@1
   int v22; // [sp+1Ch] [bp-8h]@2
   int v23; // [sp+1Ch] [bp-8h]@10
   signed int v24; // [sp+20h] [bp-4h]@10
 
-  v9 = a2;
-  v21 = a1;
-  if ( BYTE3(a2->uAttributes) & 0x20
+  //v9 = a2;
+  //v21 = a1;
+  if ( a2->Ethereal()
     || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16,
         v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16,
         v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16,
@@ -2585,16 +1659,13 @@
   }
   v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
   if ( v17 > abs(v14)
-    || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16)
+    || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16)
     || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
         HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16),
-        !sub_4759C9(
-           v9,
-           a9,
-           v19,
+        !sub_4759C9(a2, a9, v19,
            a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) )
     return 0;
-  *v21 = v24 >> 16;
+  *a1 = v24 >> 16;
   return 1;
 }
 
@@ -5725,98 +4796,98 @@
   }
 }
 
-
-
 //----- (00449A49) --------------------------------------------------------
-__int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2)
+void Door_switch_animation(unsigned int uDoorID, int a2)
 {
-  int v2; // eax@1
-  int v3; // ebx@1
-  signed int v4; // esi@2
-  int v5; // edx@2
-  BLVDoor *v6; // ecx@8
-  unsigned int v7; // edx@18
-  signed int v8; // esi@19
-  int v9; // eax@19
-  //char Args; // [sp+Ch] [bp-78h]@6
-
-  LOWORD(v2) = LOWORD(pIndoor->pDoors);
-  v3 = a2;
+  int old_state; // eax@1
+  signed int door_id; // esi@2
+
   if ( !pIndoor->pDoors )
-    return v2;
-  v4 = 0;
-  v5 = (int)&pIndoor->pDoors->uDoorID;
-  do
+    return;
+  for ( door_id = 0; door_id < 200; ++door_id )
   {
-    if ( *(int *)v5 == uDoorID )
+    if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
       break;
-    ++v4;
-    v5 += 80;
   }
-  while ( v4 < 200 );
-  if ( v4 >= 200 )
+  if ( door_id >= 200 )
   {
     Error("Unable to find Door ID: %i!", uDoorID);
   }
-  v6 = &pIndoor->pDoors[v4];
-  if ( v3 == 2 )
+  old_state = pIndoor->pDoors[door_id].uState;
+  //old_state: 0 - в нижнем положении/закрыто
+  //           2 - в верхнем положении/открыто,
+  //a2: 1 - открыть
+  //    2 - опустить/поднять
+  if ( a2 == 2 )
   {
-    LOWORD(v2) = v6->uState;
-    if ( (short)v2 == 3 || (short)v2 == 1 )
-      return v2;
-    if ( (short)v2 )
-      goto LABEL_14;
+    if ( pIndoor->pDoors[door_id].uState == BLVDoor::Closing || pIndoor->pDoors[door_id].uState == BLVDoor::Opening )
+      return;
+    if ( pIndoor->pDoors[door_id].uState )
+    {
+      if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
+      {
+        pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
+        if ( old_state == BLVDoor::Open )
+        {
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
+          return;
+        }
+        if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
+        {
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
+             - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
+             / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
+          return;
+        }
+        pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
+      }
+      return;
+    }
   }
   else
   {
-    if ( !v3 )
+    if ( a2 == 0 )
     {
-LABEL_14:
-      LOWORD(v2) = v6->uState;
-      if ( (short)v2 && (short)v2 != 3 )
+      if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
       {
-        v6->uState = BLVDoor::Closing;
-        if ( (short)v2 == 2 )
+        pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
+        if ( old_state == BLVDoor::Open )
         {
-LABEL_17:
-          v6->uTimeSinceTriggered = 0;
-          return v2;
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
+          return;
         }
-        v7 = v6->uTimeSinceTriggered;
-        v2 = 15360;
-        if ( v7 != 15360 )
+        if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
         {
-          v8 = v6->uOpenSpeed;
-          v9 = v6->uCloseSpeed;
-LABEL_26:
-          v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8;
-          goto LABEL_27;
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
+             - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
+             / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
+          return;
         }
-        goto LABEL_27;
+        pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
       }
-      return v2;
+      return;
     }
-    if ( v3 != 1 )
-      return v2;
+    if ( a2 != 1 )
+      return;
   }
-  LOWORD(v2) = v6->uState;
-  if ( (short)v2 != 2 && (short)v2 != 1 )
+  if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
   {
-    v6->uState = BLVDoor::Opening;
-    if ( !(short)v2 )
-      goto LABEL_17;
-    v7 = v6->uTimeSinceTriggered;
-    v2 = 15360;
-    if ( v7 != 15360 )
+    pIndoor->pDoors[door_id].uState = BLVDoor::Opening;
+    if ( old_state == BLVDoor::Closed )
+    {
+      pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
+      return;
+    }
+    if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
     {
-      v8 = v6->uCloseSpeed;
-      v9 = v6->uOpenSpeed;
-      goto LABEL_26;
+      pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uCloseSpeed
+         - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uOpenSpeed)
+         / 128 << 7) / pIndoor->pDoors[door_id].uCloseSpeed;
+      return;
     }
-LABEL_27:
-    v6->uTimeSinceTriggered = v2;
+    pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
   }
-  return v2;
+  return;
 }
 
 //----- (00449B57) --------------------------------------------------------
@@ -5845,9 +4916,8 @@
   strcpy(GameUI_Footer_TimedString.data(), pString);
   GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount();
 
-  for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data());
-        i > 450;
-        i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
+  for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450;
+           i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
     GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0;
 }
 
@@ -5888,19 +4958,15 @@
 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int))
 {
   void *v4; // esi@2
-  int v5; // edi@2
-
-  if ( numObjs - 1 >= 0 )
+
+  if ( numObjs > 0 )
   {
     v4 = a1;
-    v5 = numObjs;
-    do
+    for ( int i = numObjs; i; --i )
     {
       constructor((int)v4);
       v4 = (char *)v4 + objSize;
-      --v5;
     }
-    while ( v5 );
   }
 }