diff mm7_3.cpp @ 2139:f9b55be70c1b

Слияние
author Ritor1
date Thu, 02 Jan 2014 09:11:28 +0600
parents 7cc14d9d966d 0d0aa7c1ccdd
children cfe04d858766
line wrap: on
line diff
--- a/mm7_3.cpp	Thu Jan 02 09:11:01 2014 +0600
+++ b/mm7_3.cpp	Thu Jan 02 09:11:28 2014 +0600
@@ -210,7 +210,7 @@
 
   a11 = ecx0;
 
-  BLVFace f; // [sp+Ch] [bp-7Ch]@1
+  BLVFace face; // [sp+Ch] [bp-7Ch]@1
 
   result = 0;
   for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 )
@@ -225,51 +225,51 @@
           && 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 )
         {
-          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() )
+          face.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x;
+          face.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y;
+          face.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z;
+          face.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist;
+          face.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes;
+          face.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1;
+          face.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1;
+          face.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1;
+          face.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2;
+          face.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2;
+          face.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2;
+          face.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1;
+          face.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2;
+          face.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3;
+          face.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements;
+          face.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements;
+          face.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements;
+          face.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType;
+          face.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices;
+          face.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID;
+          face.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs;
+          if ( !face.Ethereal() && !face.Portal() )
           {
-            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;
+            v8 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal.x
+                                        + face.pFacePlane_old.vNormal.y * stru_721530.normal.y
+                                        + face.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16;
             if ( v8 > 0 )
             {
-              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;
+              v9 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal2.x
+                                          + face.pFacePlane_old.vNormal.y * stru_721530.normal2.y
+                                          + face.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 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) )
+                            stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, 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,
+                    if ( !sub_475F30( &a2, &face, 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;
@@ -288,21 +288,21 @@
 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;
+              v15 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.position.x
+                                           + face.pFacePlane_old.vNormal.y * stru_721530.position.y
+                                           + face.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;
+                v16 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.field_4C
+                                             + face.pFacePlane_old.vNormal.y * stru_721530.field_50
+                                             + face.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) )
+                             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, a10, a11) )
                     {
                       if ( a2 < stru_721530.field_7C )
                       {
@@ -315,7 +315,7 @@
                     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,
+                      if ( sub_475F30(&a2, &face, 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;
@@ -371,38 +371,32 @@
   int v10; // ecx@12
   int v11; // esi@13
 
-  if ( (signed int)uNumSpriteObjects > 0 )
+  for ( uint i = 0; i < uNumSpriteObjects; ++i )
   {
-    for ( uint i = 0; i < uNumSpriteObjects; ++i )
+    if ( pSpriteObjects[i].uObjectDescID )
     {
-      if ( pSpriteObjects[i].uObjectDescID )
+      object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
+      if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
       {
-        object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
-        if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
+        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.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 ( 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 )
           {
-            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 )
+            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 )
             {
-              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 )
+              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 )
               {
-                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 )
+                if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
                 {
-                  if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
-                  {
-                    if ( v10 < stru_721530.field_7C )
-                      sub_46DEF2(_this, i);
-                  }
+                  if ( v10 < stru_721530.field_7C )
+                    sub_46DEF2(_this, i);
                 }
               }
             }
@@ -416,35 +410,29 @@
 //----- (0046EF01) --------------------------------------------------------
 int _46EF01_collision_chech_player(int a1)
 {
-  int v1; // edx@1
   int result; // eax@1
   int v3; // ebx@7
   int v4; // esi@7
   int v5; // edi@8
   int v6; // ecx@9
   int v7; // edi@12
-  int v8; // [sp+Ch] [bp-10h]@1
-  unsigned int v9; // [sp+10h] [bp-Ch]@1
   int v10; // [sp+14h] [bp-8h]@7
   int v11; // [sp+18h] [bp-4h]@7
 
-  v8 = a1;
-  v1 = 2 * pParty->field_14_radius;
   result = pParty->vPosition.x;
-  v9 = pParty->uPartyHeight;
-  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 )
+  //v9 = pParty->uPartyHeight;
+  if ( stru_721530.sMaxX <= pParty->vPosition.x + (2 * pParty->field_14_radius) && stru_721530.sMinX >= pParty->vPosition.x - (2 * pParty->field_14_radius)
+    && stru_721530.sMaxY <= pParty->vPosition.y + (2 * pParty->field_14_radius) && stru_721530.sMinY >= pParty->vPosition.y - (2 * pParty->field_14_radius)
+    && stru_721530.sMaxZ <= pParty->vPosition.z + pParty->uPartyHeight && stru_721530.sMinZ >= pParty->vPosition.z )
   {
-    v3 = stru_721530.prolly_normal_d + v1;
+    v3 = stru_721530.prolly_normal_d + (2 * pParty->field_14_radius);
     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 ( result <= stru_721530.prolly_normal_d + (2 * pParty->field_14_radius) )
     {
       result = v10 * stru_721530.direction.y;
       v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
@@ -454,8 +442,8 @@
         result = pParty->vPosition.z;
         if ( v6 >= pParty->vPosition.z )
         {
-          result = v9 + pParty->vPosition.z;
-          if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
+          result = pParty->uPartyHeight + pParty->vPosition.z;
+          if ( v6 <= (signed int)(pParty->uPartyHeight + pParty->vPosition.z) || a1 )
           {
             result = integer_sqrt(v3 * v3 - v4 * v4);
             v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
@@ -535,35 +523,13 @@
 //----- (0047050A) --------------------------------------------------------
 int stru141_actor_collision_object::_47050A(int dt)
 {
-  //stru141_actor_collision_object *v2; // esi@1
-  //signed int v3; // eax@1
-  //int v4; // ecx@1
-  //int v5; // edx@1
-  //int v6; // edx@1
   int v7; // eax@1
-  //int v8; // eax@3
   signed int result; // eax@4
-  //int v10; // eax@5
-  //int v11; // eax@5
-  //int v12; // ebx@5
-  //int v13; // edx@5
-  //int v14; // edi@5
-  //int v15; // ecx@5
-  //int v16; // eax@5
   int v17; // eax@5
   int v18; // eax@7
-  //int v19; // edx@9
-  //int v20; // edi@9
   int v21; // eax@9
   int v22; // eax@11
-  //int v23; // edx@13
-  //int v24; // eax@13
-  //int v25; // eax@14
-  //int v26; // eax@16
-  //int v27; // eax@17
-  //int v28; // [sp+14h] [bp+8h]@5
-
-  //v2 = this;
+
   int speed = 1 | integer_sqrt(this->velocity.z * this->velocity.z + this->velocity.y * this->velocity.y + this->velocity.x * this->velocity.x);
 
   this->direction.x = 65536 / speed * this->velocity.x;
@@ -681,7 +647,6 @@
   int v71; // [sp+38h] [bp-18h]@62
   int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10
   int v72b;
-  //int v73; // [sp+40h] [bp-10h]@17
   int uIsFlying; // [sp+44h] [bp-Ch]@8
   unsigned int v75; // [sp+48h] [bp-8h]@1
   int uIsOnWater; // [sp+4Ch] [bp-4h]@10
@@ -997,14 +962,10 @@
 void UpdateObjects()
 {
   unsigned int v0; // ebx@0
-  //unsigned int v1; // edi@1
-  //char *v2; // esi@2
-  //__int16 v3; // dx@5
   ObjectDesc *object; // eax@5
   int v5; // ecx@6
   __int16 v6; // cx@7
   signed int v7; // eax@9
-  //unsigned int v10; // ecx@16
   signed int v11; // eax@17
   int v12; // edi@27
   int v13; // eax@27
@@ -1014,103 +975,94 @@
   unsigned int v17; // edx@32
   int v18; // [sp+4h] [bp-10h]@27
   int v19; // [sp+8h] [bp-Ch]@27
-  //signed int v20; // [sp+10h] [bp-4h]@1
-
-  //v1 = 0;
-  //v20 = 0;
+
   for (uint i = 0; i < uNumSpriteObjects; ++i)
   {
-    SpriteObject* item = &pSpriteObjects[i];
-    //v2 = (char *)&item->uSpriteFrameID;
-    //do
-    //{
-      //LOWORD(v0) = item->uAttributes;
-    if (item->uAttributes & OBJECT_40)
-      item->uAttributes &= ~OBJECT_40;
+    if (pSpriteObjects[i].uAttributes & OBJECT_40)
+      pSpriteObjects[i].uAttributes &= ~OBJECT_40;
     else
     {
-      object = &pObjectList->pObjects[item->uObjectDescID];
-      if (item->AttachedToActor())
+      object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
+      if (pSpriteObjects[i].AttachedToActor())
       {
-          v5 = PID_ID(item->spell_target_pid);
-          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 )
-            continue;
-          item->uSpriteFrameID += pEventTimer->uTimeElapsed;
-          if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
-            continue;
-          if ( item->uSpriteFrameID >= 0 )
-          {
-            v7 = object->uLifetime;
-            if (item->uAttributes & ITEM_BROKEN)
-              v7 = item->field_20;
-            if ( item->uSpriteFrameID < v7 )
-              continue;
-          }
-          SpriteObject::OnInteraction(i);
+        v5 = PID_ID(pSpriteObjects[i].spell_target_pid);
+        pSpriteObjects[i].vPosition.x = pActors[v5].vPosition.x;
+        pSpriteObjects[i].vPosition.y = pActors[v5].vPosition.y;
+        pSpriteObjects[i].vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
+        if ( !pSpriteObjects[i].uObjectDescID )
           continue;
-      }
-
-        if ( item->uObjectDescID )
+        pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
+        if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
+          continue;
+        if ( pSpriteObjects[i].uSpriteFrameID >= 0 )
         {
-          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);
-            else
-              SpriteObject::UpdateObject_fn0_ODM(i);
-			if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) )
-              continue;
-			v12 = abs(pParty->vPosition.x - item->vPosition.x);
-			v18 = abs(pParty->vPosition.y - item->vPosition.y);
-			v19 = abs(pParty->vPosition.z - item->vPosition.z);
-            v13 = v12;
-            v14 = v18;
-            v15 = v19;
-            if ( v12 < v18 )
-            {
-              v13 = v18;
-              v14 = v12;
-            }
-            if ( v13 < v19 )
-            {
-              v16 = v13;
-              v13 = v19;
-              v15 = v16;
-            }
-            if ( v14 < (signed int)v15 )
-            {
-              v17 = v15;
-              v15 = v14;
-              v14 = v17;
-            }
-            v0 = (unsigned int)(11 * v14) >> 5;
-            if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
-              continue;
-            SpriteObject::OnInteraction(i);
-            continue;
-          }
-          if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
+          v7 = object->uLifetime;
+          if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
+             v7 = pSpriteObjects[i].field_20;
+          if ( pSpriteObjects[i].uSpriteFrameID < v7 )
+             continue;
+        }
+        SpriteObject::OnInteraction(i);
+        continue;
+      }
+      if ( pSpriteObjects[i].uObjectDescID )
+      {
+        pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
+        if ( object->uFlags & OBJECT_DESC_TEMPORARY )
+        {
+          if ( pSpriteObjects[i].uSpriteFrameID < 0 )
           {
             SpriteObject::OnInteraction(i);
             continue;
           }
-          _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
+          v11 = object->uLifetime;
+          if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
+            v11 = pSpriteObjects[i].field_20;
         }
+        if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || pSpriteObjects[i].uSpriteFrameID < v11 )
+        {
+          if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+            SpriteObject::UpdateObject_fn0_BLV(i);
+          else
+            SpriteObject::UpdateObject_fn0_ODM(i);
+          if ( pParty->bTurnBasedModeOn != 1 || !(pSpriteObjects[i].uSectorID & 4) )
+            continue;
+          v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x);
+          v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y);
+          v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z);
+          v13 = v12;
+          v14 = v18;
+          v15 = v19;
+          if ( v12 < v18 )
+          {
+            v13 = v18;
+            v14 = v12;
+          }
+          if ( v13 < v19 )
+          {
+            v16 = v13;
+            v13 = v19;
+            v15 = v16;
+          }
+          if ( v14 < (signed int)v15 )
+          {
+            v17 = v15;
+            v15 = v14;
+            v14 = v17;
+          }
+          v0 = (unsigned int)(11 * v14) >> 5;
+          if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
+            continue;
+          SpriteObject::OnInteraction(i);
+          continue;
+        }
+        if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
+        {
+          SpriteObject::OnInteraction(i);
+          continue;
+        }
+        _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
+      }
     }
   }
 }
@@ -1118,32 +1070,26 @@
 //----- (0047272C) --------------------------------------------------------
 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
 {
-  signed int v5; // ebx@1
   int result; // eax@1
-  int v7; // [sp+10h] [bp-8h]@1
-  signed int v8; // [sp+14h] [bp-4h]@1
-
-  v5 = x - 2;
-  v7 = x;
-  v8 = y;
+
   *pSectorID = pIndoor->GetSector(x - 2, y, z + 40);
-  result = collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID);
+  result = collide_against_floor(x - 2, y, z + 40, pSectorID, pFaceID);
   if ( result == -30000 || !*pSectorID )
   {
-    *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40);
-    result = collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID);
+    *pSectorID = pIndoor->GetSector(x + 2, y, z + 40);
+    result = collide_against_floor(x + 2, y, z + 40, pSectorID, pFaceID);
     if ( result == -30000 || !*pSectorID )
     {
-      *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40);
-      result = collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID);
+      *pSectorID = pIndoor->GetSector(x, y - 2, z + 40);
+      result = collide_against_floor(x, y - 2, z + 40, pSectorID, pFaceID);
       if ( result == -30000 || !*pSectorID )
       {
-        *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40);
-        result = collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID);
+        *pSectorID = pIndoor->GetSector(x, y + 2, z + 40);
+        result = collide_against_floor(x, y + 2, z + 40, pSectorID, pFaceID);
         if ( result == -30000 || !*pSectorID )
         {
-          *pSectorID = pIndoor->GetSector(v7, v8, z + 140);
-          result = collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID);
+          *pSectorID = pIndoor->GetSector(x, y, z + 140);
+          result = collide_against_floor(x, y, z + 140, pSectorID, pFaceID);
         }
       }
     }
@@ -1272,25 +1218,9 @@
 }
 
 //----- (00475665) --------------------------------------------------------
-int sub_475665(BLVFace *_this, int a2, __int16 a3)
+int sub_475665(BLVFace *face, int a2, __int16 a3)
 {
-  unsigned int v3; // eax@1
-  Vec3_short_ *v4; // edx@3
-  signed int v5; // eax@4
-  int v6; // esi@4
-  signed int v7; // eax@7
-  Vec3_short_ *v8; // edx@8
-  signed int v9; // eax@9
-  int v10; // esi@9
-  signed int v11; // eax@11
-  Vec3_short_ *v12; // edx@12
-  signed int v13; // eax@13
-  int v14; // esi@13
-  int v15; // esi@14
   bool v16; // edi@14
-  int v17; // ecx@16
-  signed int v18; // edx@16
-  int v19; // eax@17
   signed int v20; // ebx@18
   int v21; // edi@20
   signed int v22; // ST14_4@22
@@ -1304,113 +1234,86 @@
   signed int v30; // [sp+30h] [bp+Ch]@11
   signed int v31; // [sp+30h] [bp+Ch]@14
 
-  v3 = _this->uAttributes;
-  if ( BYTE1(v3) & 1 )
+  if ( face->uAttributes & FACE_XY_PLANE )
   {
-    v28 = 0;
     v26 = (signed __int16)a2;
     v27 = SHIWORD(a2);
-    if ( _this->uNumVertices )
+    if ( face->uNumVertices )
     {
-      v4 = pIndoor->pVertices;
-      do
+      for ( v28 = 0; v28 < face->uNumVertices; v28++ )
       {
-        v5 = v28;
-        v6 = 2 * v28;
-        word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x;
-        word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y;
-        word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1]
-                                                 + v4[_this->pVertexIDs[v5 + 1]].x;
-        word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y;
+        word_720C10_intercepts_xs[2 * v28] = face->pXInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].x;
+        word_720B40_intercepts_zs[2 * v28] = face->pYInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].y;
+        word_720C10_intercepts_xs[2 * v28 + 1] = face->pXInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].x;
+        word_720B40_intercepts_zs[2 * v28 + 1] = face->pYInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].y;
       }
-      while ( v28 < _this->uNumVertices );
     }
   }
   else
   {
-    if ( BYTE1(v3) & 2 )
+    if ( face->uAttributes & FACE_XZ_PLANE )
     {
       v26 = (signed __int16)a2;
-      v7 = a3;
-      v29 = 0;
-      v27 = v7;
-      if ( _this->uNumVertices )
+      v27 = a3;
+      if ( face->uNumVertices )
       {
-        v8 = pIndoor->pVertices;
-        do
+        for ( v29 = 0; v29 < face->uNumVertices; v29++ )
         {
-          v9 = v29;
-          v10 = 2 * v29;
-          word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x;
-          word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z;
-          word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x;
-          word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z;
+          word_720C10_intercepts_xs[2 * v29] = face->pXInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].x;
+          word_720B40_intercepts_zs[2 * v29] = face->pZInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].z;
+          word_720C10_intercepts_xs[2 * v29 + 1] = face->pXInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].x;
+          word_720B40_intercepts_zs[2 * v29 + 1] = face->pZInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].z;
         }
-        while ( v29 < _this->uNumVertices );
       }
     }
     else
     {
       v26 = SHIWORD(a2);
-      v11 = a3;
-      v30 = 0;
-      v27 = v11;
-      if ( _this->uNumVertices )
+      v27 = a3;
+      if ( face->uNumVertices )
       {
-        v12 = pIndoor->pVertices;
-        do
+        for ( v30 = 0; v30 < face->uNumVertices; v30++ )
         {
-          v13 = v30;
-          v14 = 2 * v30;
-          word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y;
-          word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z;
-          word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y;
-          word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z;
+          word_720C10_intercepts_xs[2 * v30] = face->pYInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].y;
+          word_720B40_intercepts_zs[2 * v30] = face->pZInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].z;
+          word_720C10_intercepts_xs[2 * v30 + 1] = face->pYInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].y;
+          word_720B40_intercepts_zs[2 * v30 + 1] = face->pZInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].z;
         }
-        while ( v30 < _this->uNumVertices );
       }
     }
   }
-  v15 = 2 * _this->uNumVertices;
   v31 = 0;
-  word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0];
-  word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0];
-  v25 = 0;
+  word_720C10_intercepts_xs[2 * face->uNumVertices] = word_720C10_intercepts_xs[0];
+  word_720B40_intercepts_zs[2 * face->uNumVertices] = word_720B40_intercepts_zs[0];
   v16 = word_720B40_intercepts_zs[0] >= v27;
-  if ( v15 <= 0 )
+  if ( 2 * face->uNumVertices <= 0 )
     return 0;
-  do
+  for ( v25 = 0; v25 < 2 * face->uNumVertices; ++v25 )
   {
     if ( v31 >= 2 )
       break;
-    v17 = v25;
-    v18 = word_720B40_intercepts_zs[v25 + 1];
-    if ( v16 ^ (v18 >= v27) )
+    if ( v16 ^ (word_720B40_intercepts_zs[v25 + 1] >= v27) )
     {
-      v19 = word_720C10_intercepts_xs[v17 + 1];
-      if ( v19 >= v26 )
+      if ( word_720C10_intercepts_xs[v25 + 1] >= v26 )
         v20 = 0;
       else
         v20 = 2;
-      v21 = v20 | (word_720C10_intercepts_xs[v17] < v26);
+      v21 = v20 | (word_720C10_intercepts_xs[v25] < v26);
       if ( v21 != 3 )
       {
+        v22 = word_720C10_intercepts_xs[v25 + 1] - word_720C10_intercepts_xs[v25];
+        LODWORD(v23) = v22 << 16;
+        HIDWORD(v23) = v22 >> 16;
         if ( !v21
-          || (v22 = v19 - word_720C10_intercepts_xs[v17],
-              LODWORD(v23) = v22 << 16,
-              HIDWORD(v23) = v22 >> 16,
-              word_720C10_intercepts_xs[v17]
-            + ((signed int)(((unsigned __int64)(v23
-                                              / (v18 - word_720B40_intercepts_zs[v17])
-                                              * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16)
-                          + 32768) >> 16) >= v26) )
+          || (word_720C10_intercepts_xs[v25] + ((signed int)(((unsigned __int64)(v23
+           / (word_720B40_intercepts_zs[v25 + 1] - word_720B40_intercepts_zs[v25])
+           * ((v27 - (signed int)word_720B40_intercepts_zs[v25]) << 16)) >> 16)
+               + 32768) >> 16) >= v26) )
           ++v31;
       }
     }
-    ++v25;
-    v16 = v18 >= v27;
+    v16 = word_720B40_intercepts_zs[v25 + 1] >= v27;
   }
-  while ( v25 < v15 );
   result = 1;
   if ( v31 != 1 )
     result = 0;
@@ -1418,20 +1321,9 @@
 }
 
 //----- (004759C9) --------------------------------------------------------
-bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
+bool __fastcall sub_4759C9(BLVFace *face, int a2, int a3, __int16 a4)
 {
-  //unsigned int v4; // eax@1
-  //int v5; // edx@4
-  __int16 v6; // si@4
-  //int v7; // edx@9
-  __int16 v8; // si@9
-  //int v9; // edx@13
-  __int16 v10; // si@13
-  int v11; // esi@14
   bool v12; // edi@14
-  int v13; // ecx@16
-  signed int v14; // edx@16
-  int v15; // eax@17
   signed int v16; // ebx@18
   int v17; // edi@20
   signed int v18; // ST14_4@22
@@ -1441,113 +1333,88 @@
   signed int v22; // [sp+18h] [bp-Ch]@1
   int v23; // [sp+1Ch] [bp-8h]@2
   signed int v24; // [sp+20h] [bp-4h]@2
-  Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3
-  Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8
-  Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
   signed int a4d; // [sp+30h] [bp+Ch]@14
 
-  //v4 = a1->uAttributes;
-  v22 = 0;
-  if ( BYTE1(a1->uAttributes) & 1 )
+  if ( face->uAttributes & FACE_XY_PLANE )
   {
     v23 = (signed __int16)a3;
     v24 = SHIWORD(a3);
-    if ( a1->uNumVertices )
+    if ( face->uNumVertices )
     {
-      a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
-      do
+      for ( v22 = 0; v22 < face->uNumVertices; ++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[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
-        ++v22;
+        word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
+        word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
+        word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
+        word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
       }
-      while ( v22 < a1->uNumVertices );
     }
   }
   else
   {
-    if ( BYTE1(a1->uAttributes) & 2 )
+    if ( face->uAttributes & FACE_XZ_PLANE )
     {
       v23 = (signed __int16)a3;
       v24 = a4;
-      if ( a1->uNumVertices )
+      if ( face->uNumVertices )
       {
-        a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
-        do
+        for ( v22 = 0; v22 < face->uNumVertices; ++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[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
-          ++v22;
+          word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
+          word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
         }
-        while ( v22 < a1->uNumVertices );
       }
     }
     else
     {
       v23 = SHIWORD(a3);
       v24 = a4;
-      if ( a1->uNumVertices )
+      if ( face->uNumVertices )
       {
-        a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
-        do
+        for ( v22 = 0; v22 < face->uNumVertices; ++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[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
-          ++v22;
+          word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
+          word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
         }
-        while ( v22 < a1->uNumVertices );
       }
     }
   }
-  v11 = 2 * a1->uNumVertices;
   a4d = 0;
-  word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
-  word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0];
-  v21 = 0;
+  word_720A70_intercepts_xs_plus_xs[2 * face->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
+  word_7209A0_intercepts_ys_plus_ys[2 * face->uNumVertices] = word_7209A0_intercepts_ys_plus_ys[0];
   v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
-  if ( v11 <= 0 )
+  if ( 2 * face->uNumVertices <= 0 )
     return 0;
-  do
+  for ( v21 = 0; v21 < 2 * face->uNumVertices; ++v21 )
   {
     if ( a4d >= 2 )
       break;
-    v13 = v21;
-    v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1];
-    if ( v12 ^ (v14 >= v24) )
+    if ( v12 ^ (word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24) )
     {
-      v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1];
-      if ( v15 >= v23 )
+      if ( word_720A70_intercepts_xs_plus_xs[v21 + 1] >= v23 )
         v16 = 0;
       else
         v16 = 2;
-      v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v13] < v23);
+      v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v21] < v23);
       if ( v17 != 3 )
       {
+        v18 = word_720A70_intercepts_xs_plus_xs[v21 + 1] - word_720A70_intercepts_xs_plus_xs[v21];
+        LODWORD(v19) = v18 << 16;
+        HIDWORD(v19) = v18 >> 16;
         if ( !v17
-          || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13],
-              LODWORD(v19) = v18 << 16,
-              HIDWORD(v19) = v18 >> 16,
-              word_720A70_intercepts_xs_plus_xs[v13]
-            + ((signed int)(((unsigned __int64)(v19
-                                              / (v14 - word_7209A0_intercepts_ys_plus_ys[v13])
-                                              * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16)
-                          + 32768) >> 16) >= v23) )
+          || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19
+              / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21])
+              * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16)
+              + 32768) >> 16) >= v23) )
           ++a4d;
       }
     }
-    ++v21;
-    v12 = v14 >= v24;
+    v12 = word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24;
   }
-  while ( v21 < v11 );
   result = 1;
   if ( a4d != 1 )
     result = 0;
@@ -1617,24 +1484,19 @@
 //----- (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
   int v10; // ST20_4@2
   int v11; // ST28_4@2
   int v12; // ST24_4@2
   char v13; // zf@2
   int v14; // edi@2
-  int v15; // eax@5
   signed int v16; // esi@5
   int v17; // ST20_4@9
   signed __int64 v18; // qtt@10
   int v19; // ST14_4@11
-  //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 ( 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,
@@ -1645,11 +1507,10 @@
         v13)
     || v14 > 0 && !a2->Portal())
     return 0;
-  v15 = a4 * a2->pFacePlane_old.vNormal.y;
-  v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
+  v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
   if ( v14 <= 0 )
   {
-    if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
+    if ( a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
       return 0;
   }
   else
@@ -1657,7 +1518,7 @@
     if ( v16 < 0 )
       return 0;
   }
-  v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
+  v17 = abs(-(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + 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 > *a1 << 16)
     || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
@@ -1726,6 +1587,7 @@
   float v39; // [sp+D0h] [bp-8h]@6
   int *v40; // [sp+D4h] [bp-4h]@2
 
+  __debugbreak();// 
   v2 = (char *)&this->field_64[4 * this->uNumVertices];
   v38 = 0;
   *(int *)v2 = this->field_64[0];
@@ -1873,6 +1735,7 @@
   float v39; // [sp+D0h] [bp-8h]@6
   int *v40; // [sp+D4h] [bp-4h]@2
 
+  __debugbreak();// 
   v2 = (char *)&this->field_64[4 * this->uNumVertices];
   v38 = 0;
   *(int *)v2 = this->field_64[0];
@@ -2022,7 +1885,7 @@
   float v41; // [sp+2Ch] [bp-4h]@6
   float v42; // [sp+2Ch] [bp-4h]@9
 
-  //v1 = this;
+  __debugbreak();// 
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     v2 = 0;
@@ -2133,7 +1996,6 @@
 bool stru6_stru1_indoor_sw_billboard::sub_477F63()
 {
   signed int v1; // ebx@1
-  stru6_stru1_indoor_sw_billboard *v2; // esi@1
   double v3; // st7@2
   int v4; // edx@4
   char *v5; // ecx@5
@@ -2142,10 +2004,8 @@
   signed int v9; // [sp+Ch] [bp-8h]@1
   float v10; // [sp+10h] [bp-4h]@2
 
-  stru6_stru1_indoor_sw_billboard* a1 = this;
-
+  __debugbreak();//  - sw  hw?
   v1 = 0;
-  v2 = a1;
   v9 = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
@@ -2157,15 +2017,14 @@
     v10 = (double)pODMRenderParams->shading_dist_mist;
     v3 = 8.0;
   }
-  v4 = a1->uNumVertices;
+  v4 = this->uNumVertices;
   if ( v4 <= 0 )
   {
-    memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
-    return v2->uNumVertices != 0;
+    memcpy(&this->field_14[40], &this->field_14[20], 16 * v4);
+    return this->uNumVertices != 0;
   }
-  v5 = (char *)&a1->field_14[20];
-  v6 = v4;
-  do
+  v5 = (char *)&this->field_14[20];
+  for ( v6 = v4; v6; --v6 )
   {
     if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 )
     {
@@ -2175,81 +2034,68 @@
         v1 = 1;
     }
     v5 += 16;
-    --v6;
   }
-  while ( v6 );
   if ( !v1 )
   {
     if ( v9 )
     {
-      v2->_477927(v10);
-      return v2->uNumVertices != 0;
+      this->_477927(v10);
+      return this->uNumVertices != 0;
     }
-    memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
-    return v2->uNumVertices != 0;
+    memcpy(&this->field_14[40], &this->field_14[20], 16 * v4);
+    return this->uNumVertices != 0;
   }
   v7 = v3;
   _4775ED(v7);
-  return v2->uNumVertices != 0;
+  return this->uNumVertices != 0;
 }
 
 //----- (0047802A) --------------------------------------------------------
 int stru6_stru1_indoor_sw_billboard::sub_47802A()
 {
   double v6; // st7@4
-  double v12; // st7@16
   signed int v16; // [sp+38h] [bp-Ch]@1
   int a6; // [sp+3Ch] [bp-8h]@5
   int a5; // [sp+40h] [bp-4h]@5
 
-  stru6_stru1_indoor_sw_billboard* a1 = this;
-
+  __debugbreak(); //  this->field_B4[i*4+16]
   v16 = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
-	for(int i = 0; i < a1->uNumVertices; i++)
+    for(int i = 0; i < this->uNumVertices; i++)
     {
-		v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / a1->field_B4[i*4];
-		if ( pRenderer->pRenderD3D )
-		{
-			pGame->pIndoorCameraD3D->Project(
-				round(a1->field_B4[i*4]),
-				round(a1->field_B4[i*4+1]),
-				round(a1->field_B4[i*4+2]),
-				&a5,
-				&a6);
-			a1->field_B4[i*4+16] = (double)a5;
-			a1->field_B4[i*4+17] = (double)a6;
-			a1->field_B4[i*4+18] = round(a1->field_B4[i*4]);
-		}
-		else
-		{
-			a1->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * a1->field_B4[i*4+1];
-			a1->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * a1->field_B4[i*4+2];
-			a1->field_B4[i*4+18] = a1->field_B4[i*4];
-		}
-		a1->field_B4[i*4+19] = a1->field_B4[i*4+3];
-		if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+16]
-			&& (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+16]
-			&& (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+17]
-			&& (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+17] )
-			v16 = 1;
+      v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / this->field_B4[i*4];
+      if ( pRenderer->pRenderD3D )
+      {
+        pGame->pIndoorCameraD3D->Project(round_to_int(this->field_B4[i*4]), round_to_int(this->field_B4[i*4+1]), round_to_int(this->field_B4[i*4+2]),
+           &a5, &a6);
+        this->field_B4[i*4+16] = (double)a5;
+        this->field_B4[i*4+17] = (double)a6;
+        this->field_B4[i*4+18] = round_to_int(this->field_B4[i*4]);
+      }
+      else
+      {
+        this->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * this->field_B4[i*4+1];
+        this->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * this->field_B4[i*4+2];
+        this->field_B4[i*4+18] = this->field_B4[i*4];
+      }
+      this->field_B4[i*4+19] = this->field_B4[i*4+3];
+      if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+16] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+16]
+        && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+17] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+17] )
+        v16 = 1;
     }
   }
   else
   {
-	for(int i = 0; i < a1->uNumVertices; i++)
+    for(int i = 0; i < this->uNumVertices; i++)
     {
-		v12 = (double)pODMRenderParams->int_fov_rad / a1->field_B4[i*4];
-		a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1];
-		a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2];
-		*((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4];
-		*((int *)&a1->field_B4[i*4+23]) = a1->field_B4[i*4+3];
-		if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+20]
-			&& (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+20]
-			&& (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+21]
-			&& (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+21] )
-			v16 = 1;
+       this->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - (double)pODMRenderParams->int_fov_rad / this->field_B4[i*4] * this->field_B4[i*4+1];
+       this->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - (double)pODMRenderParams->int_fov_rad / this->field_B4[i*4] * this->field_B4[i*4+2];
+       *((int *)&this->field_B4[i*4+22]) = (int)this->field_B4[i*4];
+       *((int *)&this->field_B4[i*4+23]) = this->field_B4[i*4+3];
+       if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+20] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+20]
+         && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+21] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+21] )
+         v16 = 1;
     }
   }
   return v16;
@@ -2260,56 +2106,34 @@
 //----- (00479089) --------------------------------------------------------
 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
 {
-  BSPModel *v2; // eax@1
   int v3; // edi@1
   int v4; // ebx@1
-  int v5; // ST28_4@1
-  int v6; // ecx@1
-  int v7; // ebx@3
-  int v8; // eax@3
   int v9; // eax@3
-  //int v10; // ebx@3
   signed int v11; // esi@6
   int v12; // esi@8
   bool result; // eax@9
-  //unsigned int v14; // [sp+Ch] [bp-20h]@1
-  int v15; // [sp+Ch] [bp-20h]@5
-  //int *v16; // [sp+10h] [bp-1Ch]@1
   int v17; // [sp+1Ch] [bp-10h]@1
-  int v18; // [sp+20h] [bp-Ch]@1
   int v19; // [sp+20h] [bp-Ch]@3
   int angle; // [sp+24h] [bp-8h]@1
-  int v21; // [sp+28h] [bp-4h]@1
-  //int v22; // [sp+28h] [bp-4h]@3
-
-  //v16 = unused;
-  angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 >> 1;
-  //v14 = uModelID;
-  v2 = &pOutdoor->pBModels[uModelID];
-  v3 = v2->vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
-  v4 = v2->vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
-  v5 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY);
-  v21 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
-  v18 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX);
+
+  angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2;
+  v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
+  v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
   stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
-  v6 = v5;
-  v17 = v3 * v5 + v4 * v21;
+  v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
   if (pGame->pIndoorCameraD3D->sRotationX)
-    v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16;
-  v19 = v4 * v6 - v3 * v21;
-  v7 = abs(v4);
-  v8 = abs(v3);
-  v9 = int_get_vector_length(v8, v7, 0);
+    v17 = (unsigned __int64)(v17 * (signed __int64)stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX)) >> 16;
+  v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
+  v9 = int_get_vector_length(abs(v3), abs(v4), 0);
   //v10 = v14 * 188;
   //v22 = v9;
   *reachable = false;
   if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 )
     *reachable = true;
-  v15 = stru_5C6E00->Sin(angle);
   if ( v19 >= 0 )
-    v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16);
+    v11 = ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16);
   else
-    v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16);
+    v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16);
   v12 = v11 >> 16;
   if ( v9 <= pODMRenderParams->shading_dist_mist + 2048 )
   {
@@ -2329,28 +2153,25 @@
 //----- (00479295) --------------------------------------------------------
 int Polygon::_479295()
 {
-  ODMFace *v2; // esi@1
   int v3; // ecx@4
   int v4; // eax@4
   int v5; // edx@4
   int v6; // ST14_4@5
-  int v7; // ST04_4@5
-  stru149 *v8; // ecx@5
   Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
   int v11; // [sp+18h] [bp-4h]@4
 
-  v2 = this->pODMFace;
-  if ( !v2->pFacePlane.vNormal.z )
+  if ( !this->pODMFace->pFacePlane.vNormal.z )
   {
-    v3 = v2->pFacePlane.vNormal.x;
-    v4 = -v2->pFacePlane.vNormal.y;
+    v3 = this->pODMFace->pFacePlane.vNormal.x;
+    v4 = -this->pODMFace->pFacePlane.vNormal.y;
     v5 = 0;
     v11 = 65536;
   }
-  else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
+  else if ( (this->pODMFace->pFacePlane.vNormal.x || this->pODMFace->pFacePlane.vNormal.y)
+      && abs(this->pODMFace->pFacePlane.vNormal.z) < 59082 )
   {
-    thisa.x = -v2->pFacePlane.vNormal.y;
-    thisa.y = v2->pFacePlane.vNormal.x;
+    thisa.x = -this->pODMFace->pFacePlane.vNormal.y;
+    thisa.y = this->pODMFace->pFacePlane.vNormal.x;
     thisa.z = 0;
     thisa.Normalize_float();
     v4 = thisa.x;
@@ -2365,12 +2186,9 @@
 	  v11 = 0;
 	  v5 = -65536;
   }
-  v6 = v11;
-  sTextureDeltaU = v2->sTextureDeltaU;
-  v7 = v3;
-  v8 = ptr_38;
-  sTextureDeltaV = v2->sTextureDeltaV;
-  v8->_48616B_frustum_odm(v4, v7, 0, 0, v5, v6);
+  sTextureDeltaU = this->pODMFace->sTextureDeltaU;
+  sTextureDeltaV = this->pODMFace->sTextureDeltaV;
+  ptr_38->_48616B_frustum_odm(v4, v3, 0, 0, v5, v11);
   return 1;
 }
 
@@ -3377,21 +3195,14 @@
 //----- (0048257A) --------------------------------------------------------
 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater)
 {
-  //unsigned int v4; // ebx@1
-  //unsigned int v5; // edi@1
   int result; // eax@9
-  //int v7; // ebx@10
   int v8; // ebx@11
   int v9; // eax@11
   int v10; // ecx@11
-  //int v11; // [sp+Ch] [bp-Ch]@1
-  //int v12; // [sp+10h] [bp-8h]@1
   int v13; // [sp+10h] [bp-8h]@11
   signed int v14; // [sp+14h] [bp-4h]@3
   int v15; // [sp+24h] [bp+Ch]@11
 
-  //v11 = a1;
-  //v12 = a2;
   unsigned int grid_x = WorldPosToGridCellX(a1);
   unsigned int grid_z = WorldPosToGridCellZ(a2) - 1;
 
@@ -3450,10 +3261,6 @@
     return y_x1z1;
 }
 
-
-
-
-
 //----- (00485F53) --------------------------------------------------------
 void  sr_485F53(Vec2_int_ *v)
 {
@@ -3472,15 +3279,14 @@
 //----- (00486089) --------------------------------------------------------
 void Polygon::_normalize_v_18()
 {
-  double v2; // st7@1
-  double v3; // st6@1
-  double v5; // st5@1
-
-  //v1 = this;
-  v2 = (double)this->v_18.x;
-  v3 = (double)this->v_18.y;
-  v5 = (double)this->v_18.z;
-  float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2);
+  //double v2; // st7@1
+  //double v3; // st6@1
+  //double v5; // st5@1
+
+ // v2 = (double)this->v_18.x;
+  //v3 = (double)this->v_18.y;
+ // v5 = (double)this->v_18.z;
+  float len = sqrt((double)this->v_18.z * (double)this->v_18.z + (double)this->v_18.y * (double)this->v_18.y + (double)this->v_18.x * (double)this->v_18.x);
   if (fabsf(len) < 1e-6f)
   {
     v_18.x = 0;
@@ -3489,9 +3295,9 @@
   }
   else
   {
-    v_18.x = round(v2 / len * 65536.0);
-    v_18.y = round(v3 / len * 65536.0);
-    v_18.y = round(v5 / len * 65536.0);
+    v_18.x = round_to_int((double)this->v_18.x / len * 65536.0);
+    v_18.y = round_to_int((double)this->v_18.y / len * 65536.0);
+    v_18.y = round_to_int((double)this->v_18.z / len * 65536.0);
   }
 }
 
@@ -3499,28 +3305,13 @@
 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7)
 {
   int v7; // ebx@1
-  //int v8; // esi@1
   int v9; // edi@1
-  //int v10; // eax@1
   int v11; // edx@1
-  //int v12; // esi@2
-  //int v13; // eax@2
-  //int v14; // ST10_4@3
-  //int v15; // esi@3
-  //int v16; // eax@5
   int v17; // ST0C_4@6
-  //int v18; // eax@8
   int v19; // ST0C_4@9
-  //int v20; // eax@10
-  //int v21; // edx@10
-  //int v22; // eax@10
-  //int result; // eax@10
   int v24; // [sp+14h] [bp-14h]@1
   int v25; // [sp+18h] [bp-10h]@1
-  //int v26; // [sp+1Ch] [bp-Ch]@1
   int v27; // [sp+24h] [bp-4h]@1
-  //int v28; // [sp+30h] [bp+8h]@10
-  //int v29; // [sp+3Ch] [bp+14h]@10
 
   v25 = pGame->pIndoorCameraD3D->int_cosine_x;
   v7 = pGame->pIndoorCameraD3D->int_sine_y;
@@ -3939,7 +3730,7 @@
       if ( !pLevelStr[i] )
       {
         pLevelStrOffsets[string_num] = i + 1;
-		++string_num;
+        ++string_num;
         if ( i - prev_string_offset > max_string_length )
           max_string_length = i - prev_string_offset;
         prev_string_offset = i;
@@ -3968,7 +3759,7 @@
   {
     for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
     {
-		test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
+      test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
       if ( test_event->_e_type == EVENT_OnMapLeave )
       {
         EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num);
@@ -3980,161 +3771,150 @@
 //----- (00443FDC) --------------------------------------------------------
 void OnMapLoad()
 {
-	stru176 *v3; // esi@7
-	__int16 v4; // cx@9
-	__int16 v5; // di@9
-	int v6; // eax@9
-	signed __int64 v8; // qax@26
-	unsigned int v9; // ecx@26
-	signed __int64 v10; // qax@26
-	signed __int64 v11; // qax@26
-	int v12; // ST50_4@26
-	signed __int64 v13; // qax@26
-	signed __int64 v14; // qax@26
-	int v15; // ST58_4@26
-	signed __int64 v16; // qax@26
-	int hours; // ebx@26
-	unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
-	signed __int64 seconds; // [sp+14h] [bp-3Ch]@26
-	unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
-	int minutes; // [sp+2Ch] [bp-24h]@26
-	int years; // [sp+34h] [bp-1Ch]@26
-	int weeks; // [sp+38h] [bp-18h]@26
-	int v26; // [sp+3Ch] [bp-14h]@15
-	int days; // [sp+3Ch] [bp-14h]@26
-	int months; // [sp+40h] [bp-10h]@26
-	__int16 v29; // [sp+46h] [bp-Ah]@9
-	__int16 v30; // [sp+48h] [bp-8h]@9
-	__int16 v31; // [sp+4Ah] [bp-6h]@9
-	__int16 v32; // [sp+4Ch] [bp-4h]@9
-	__int16 v33; // [sp+4Eh] [bp-2h]@9
-
-	for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
-	{
-		EventIndex pEvent = pLevelEVT_Index[i];
-
-		_evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]);
-
-		if (_evt->_e_type == EVENT_PlaySound)
-		{
-			pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
-		}
-		else if (_evt->_e_type == EVENT_OnMapReload)
-		{
-			EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
-		}
-		else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
-		{
-			v3 = &array_5B5928_timers[dword_5B65C8_timers_count];
-			v20 = pOutdoor->loc_time.uLastVisitDay;
-			if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-				v20 = pIndoor->stru1.uLastVisitDay;
-
-			v3->timer_evt_type = _evt->_e_type;
-			v3->timer_evt_ID = pEvent.uEventID;
-			v3->timer_evt_seq_num = pEvent.event_sequence_num;
-
-			v3->field_10 = _evt->v5;
-			v3->field_12 = _evt->v6;
-			v3->field_14 = _evt->v7;
-			v3->field_16 = _evt->v8;
-			v3->field_18 = _evt->v9;
-			v3->field_1A = _evt->v10;
-
-
-			v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-
-			v3->time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-            v3->fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-			if (v3->timer_evt_type  == EVENT_Initialize && !(short)v6 )
-			{
-				if ( v20 )
-					v18 = pParty->uTimePlayed - v20;
-				else
-					v18 = 0i64;
-				v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
-
-				if ( v26 / 7 / 4 / 12 )
-				{
-					if ( v3->field_10 )
-					{
-						++dword_5B65C8_timers_count;
-                        v3->next_fire_time = 0;
-						continue;
-					}
-				}
-				if (v26 / 7 / 4 != 0 && v3->field_12 != 0 ||
-					v26 / 7 != 0 && v3->field_14 != 0 ||
-					v26 != 0 || !v20)
-				{
-					++dword_5B65C8_timers_count;
-					v3->next_fire_time = 0;
-					continue;
-				}
-			}
-			else
-			{
-				v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
-				v9 = v8;
-				v10 = (signed int)v8 / 60;
-				minutes = v10 % 60;
-				v11 = (signed int)(v10 / 60);
-				v12 = v11 % 24;
-				v13 = (signed int)(v11 / 24);
-				days = v13 % 7;
-				v14 = (signed int)(v13 / 7);
-				v15 = v14 % 4;
-				v16 = (signed int)(v14 / 4);
-				years = v16 / 12;
-
-				unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
-				__int64 _2 = ((__int64)v9 << 32) | _1;
-
-				seconds = _2 % 60;
-				//v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
-				//                        v9)
-				//    % 60;
-
-				hours = v12;
-				weeks = v15;
-				months = v16 % 12;
-				if ( v3->field_10 )
-				{
-					++years;
-				}
-				else
-				{
-					if ( v3->field_12 )
-					{
-						++months;
-					}
-					else
-					{
-						if ( v3->field_14 )
-						{
-							++weeks;
-						}
-						else
-						{
-							++days;
-							minutes = v3->field_18;
-							hours = v3->field_16;
-							seconds = v3->field_1A;
-						}
-					}
-				}
-                v3->next_fire_time = (signed __int64)((double)((seconds
-					+ 60 * minutes
-					+ 3600 * hours
-					+ 0x93A80 * weeks
-					+ 0x15180 * days
-					+ 0x24EA00 * (months + 12i64 * years)) << 7)
-					* 0.033333335);
-
-				++dword_5B65C8_timers_count;
-			}
-		}
-	}
+  __int16 v4; // cx@9
+  __int16 v5; // di@9
+  int v6; // eax@9
+  signed __int64 v8; // qax@26
+  unsigned int v9; // ecx@26
+  signed __int64 v10; // qax@26
+  signed __int64 v11; // qax@26
+  int v12; // ST50_4@26
+  signed __int64 v13; // qax@26
+  signed __int64 v14; // qax@26
+  int v15; // ST58_4@26
+  signed __int64 v16; // qax@26
+  int hours; // ebx@26
+  unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
+  signed __int64 seconds; // [sp+14h] [bp-3Ch]@26
+  unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
+  int minutes; // [sp+2Ch] [bp-24h]@26
+  int years; // [sp+34h] [bp-1Ch]@26
+  int weeks; // [sp+38h] [bp-18h]@26
+  int v26; // [sp+3Ch] [bp-14h]@15
+  int days; // [sp+3Ch] [bp-14h]@26
+  int months; // [sp+40h] [bp-10h]@26
+  __int16 v29; // [sp+46h] [bp-Ah]@9
+  __int16 v30; // [sp+48h] [bp-8h]@9
+  __int16 v31; // [sp+4Ah] [bp-6h]@9
+  __int16 v32; // [sp+4Ch] [bp-4h]@9
+  __int16 v33; // [sp+4Eh] [bp-2h]@9
+
+  for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
+  {
+    EventIndex pEvent = pLevelEVT_Index[i];
+
+    _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]);
+
+    if (_evt->_e_type == EVENT_PlaySound)
+      pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
+    else if (_evt->_e_type == EVENT_OnMapReload)
+      EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
+    else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
+    {
+      //v3 = &array_5B5928_timers[dword_5B65C8_timers_count];
+      v20 = pOutdoor->loc_time.uLastVisitDay;
+      if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        v20 = pIndoor->stru1.uLastVisitDay;
+
+      array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type = _evt->_e_type;
+      array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_ID = pEvent.uEventID;
+      array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_seq_num = pEvent.event_sequence_num;
+
+      array_5B5928_timers[dword_5B65C8_timers_count].field_10 = _evt->v5;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_12 = _evt->v6;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_14 = _evt->v7;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_16 = _evt->v8;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_18 = _evt->v9;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_1A = _evt->v10;
+
+
+      v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+
+      array_5B5928_timers[dword_5B65C8_timers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+      array_5B5928_timers[dword_5B65C8_timers_count].fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+      if (array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type  == EVENT_Initialize && !(short)v6 )
+      {
+        if ( v20 )
+          v18 = pParty->uTimePlayed - v20;
+        else
+          v18 = 0i64;
+        v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
+
+        if ( v26 / 7 / 4 / 12 )
+        {
+          if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
+          {
+            ++dword_5B65C8_timers_count;
+            array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0;
+            continue;
+          }
+        }
+        if (v26 / 7 / 4 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_12 != 0 ||
+          v26 / 7 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_14 != 0 ||
+          v26 != 0 || !v20)
+        {
+          ++dword_5B65C8_timers_count;
+          array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0;
+          continue;
+        }
+      }
+      else
+      {
+        v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
+        v9 = v8;
+        v10 = (signed int)v8 / 60;
+        minutes = v10 % 60;
+        v11 = (signed int)(v10 / 60);
+        v12 = v11 % 24;
+        v13 = (signed int)(v11 / 24);
+        days = v13 % 7;
+        v14 = (signed int)(v13 / 7);
+        v15 = v14 % 4;
+        v16 = (signed int)(v14 / 4);
+        years = v16 / 12;
+
+        unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
+        __int64 _2 = ((__int64)v9 << 32) | _1;
+
+        seconds = _2 % 60;
+        //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
+        //                        v9)
+        //    % 60;
+
+        hours = v12;
+        weeks = v15;
+        months = v16 % 12;
+        if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
+          ++years;
+        else
+        {
+          if ( array_5B5928_timers[dword_5B65C8_timers_count].field_12 )
+            ++months;
+          else
+          {
+            if ( array_5B5928_timers[dword_5B65C8_timers_count].field_14 )
+              ++weeks;
+            else
+            {
+              ++days;
+              minutes = array_5B5928_timers[dword_5B65C8_timers_count].field_18;
+              hours = array_5B5928_timers[dword_5B65C8_timers_count].field_16;
+              seconds = array_5B5928_timers[dword_5B65C8_timers_count].field_1A;
+            }
+          }
+        }
+        array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = (signed __int64)((double)((seconds
+                    + 60 * minutes
+                    + 3600 * hours
+                    + 0x93A80 * weeks
+                    + 0x15180 * days
+                    + 0x24EA00 * (months + 12i64 * years)) << 7)
+                    * 0.033333335);
+
+        ++dword_5B65C8_timers_count;
+      }
+    }
+  }
 }
 
 //----- (00444360) --------------------------------------------------------
@@ -4154,31 +3934,26 @@
 //----- (00444D80) --------------------------------------------------------
 int GetTravelTime()
 {
-  signed int v0; // esi@1
-
-  v0 = uDefaultTravelTime_ByFoot;
+  signed int new_travel_time; // esi@1
+
+  new_travel_time = uDefaultTravelTime_ByFoot;
   if ( CheckHiredNPCSpeciality(Guide) )
-    --v0;
+    --new_travel_time;
   if ( CheckHiredNPCSpeciality(Tracker) )
-    v0 -= 2;
+    new_travel_time -= 2;
   if ( CheckHiredNPCSpeciality(Pathfinder) )
-    v0 -= 3;
+    new_travel_time -= 3;
   if ( CheckHiredNPCSpeciality(Explorer) )
-    --v0;
-  if ( v0 < 1 )
-    v0 = 1;
-  return v0;
+    --new_travel_time;
+  if ( new_travel_time < 1 )
+    new_travel_time = 1;
+  return new_travel_time;
 }
 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot;
 
 //----- (004451A8) --------------------------------------------------------
 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
 {
-  int v3; // esi@1
-  int v4; // edi@1
-
-  v3 = a2;
-  v4 = a1;
   if ( !pGUIWindow2 )
   {
     if ( pParty->uFlags & 2 )
@@ -4186,8 +3961,8 @@
     pAudioPlayer->StopChannels(-1, -1);
     pMiscTimer->Pause();
     pEventTimer->Pause();
-    dword_5C3418 = v4;
-    dword_5C341C = v3;
+    dword_5C3418 = a1;
+    dword_5C341C = a2;
     _591094_decoration = activeLevelDecoration;
     pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0);
     pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
@@ -4209,7 +3984,7 @@
 }
 
 //----- (004465DF) --------------------------------------------------------
-int sub_4465DF_check_season(int a1)
+bool sub_4465DF_check_season(int a1)
 {
   unsigned int v1; // eax@1
   unsigned int v2; // edx@1
@@ -4219,185 +3994,132 @@
 
   v1 = pParty->uCurrentMonth + 1;
   v2 = pParty->uDaysPlayed + 1;
-  if ( a1 )
+  if ((v1 == (a1 + 1) * 3 && v2 >= 21) || v1 == (a1 + 1) % 4 * 3 + 1 || v1 == (a1 + 1) % 4 * 3 + 2 || (v1 == (a1 + 2) % 4 * 3 && v2 < 21))
+	  return true;
+  return false;
+
+  switch (a1)
   {
-    v3 = a1 - 1;
-    if ( v3 )
-    {
-      v4 = v3 - 1;
-      if ( v4 )
-      {
-        if ( v4 != 1 )
-          return 0;
-        if ( v1 != 12 )
-        {
-          if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 )
-            return 1;
-          v6 = v1 == 3;
-LABEL_24:
-          if ( !v6 || (signed int)v2 >= 21 )
-            return 0;
-          return 1;
-        }
-      }
-      else
-      {
-        if ( v1 != 9 )
-        {
-          if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 )
-            return 1;
-          v6 = v1 == 12;
-          goto LABEL_24;
-        }
-      }
-    }
-    else
-    {
-      if ( v1 != 6 )
-      {
-        if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 )
-          return 1;
-        v6 = v1 == 9;
-        goto LABEL_24;
-      }
-    }
-  }
-  else
-  {
-    if ( v1 != 3 )
-    {
-      if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 )
-        return 1;
-      v6 = v1 == 6;
-      goto LABEL_24;
-    }
+	case 3:
+		if (v1 != 12)//12.21 -> 3.20
+		{
+			if ((signed int)v1 >= 1 && (signed int)v1 <= 2)
+				return true;
+			v6 = v1 == 3;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	case 2:
+		if (v1 != 9)//9.21 -> 12.20
+		{
+			if ((signed int)v1 >= 10 && (signed int)v1 <= 11)
+				return true;
+			v6 = v1 == 12;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	case 1:
+		if (v1 != 6)//6.21 -> 9.20
+		{
+			if ((signed int)v1 >= 7 && (signed int)v1 <= 8)
+				return true;
+			v6 = v1 == 9;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	case 0:
+		if (v1 != 3)//3.21 -> 9.20
+		{
+			if ((signed int)v1 >= 4 && (signed int)v1 <= 5)
+				return true;
+			v6 = v1 == 6;
+			if (!v6 || (signed int)v2 >= 21)
+				return false;
+			return true;
+		}
+		break;
+	default:
+		return false;
   }
   if ( (signed int)v2 >= 21 )
-    return 1;
-  return 0;
+    return true;
+  return false;
 }
 
 //----- (0044861E) --------------------------------------------------------
 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename)
 {
-  unsigned int v2; // eax@2
-  unsigned __int16 v3; // di@2
-  signed int v4; // esi@5
-  BLVFace *v5; // eax@7
-  unsigned int *v6; // eax@8
-  char *v7; // eax@9
-  int v8; // edi@16
-  char *v9; // esi@16
-  ODMFace *v10; // eax@17
-  unsigned int *v11; // eax@19
-  unsigned __int16 v12; // [sp+Ch] [bp-18h]@2
-  const char *Str2; // [sp+10h] [bp-14h]@1
-  unsigned int v14; // [sp+14h] [bp-10h]@1
-  signed int v15; // [sp+18h] [bp-Ch]@14
-  int v16; // [sp+1Ch] [bp-8h]@15
-  signed int v17; // [sp+20h] [bp-4h]@4
-  signed int v18; // [sp+20h] [bp-4h]@16
-
-  Str2 = pFilename;
-  v14 = uFaceCog;
+  unsigned int texture; // eax@2
+
   if ( uFaceCog )
   {
-    v2 = pBitmaps_LOD->LoadTexture(pFilename);
-    v3 = v2;
-    v12 = v2;
-    if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 )
+    texture = pBitmaps_LOD->LoadTexture(pFilename);
+    if ( texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0 )
     {
-      pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1);
+      pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1);
 
       if ( uCurrentlyLoadedLevelType == 1 )
       {
-        v17 = 1;
         if ( (signed int)pIndoor->uNumFaceExtras > 1 )
         {
-          v4 = 1;
-          do
+          for ( uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i )
           {
-            if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 )
+            if ( pIndoor->pFaceExtras[i].sCogNumber == uFaceCog )
             {
-              v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C];
-              if ( BYTE1(v5->uAttributes) & 0x40 )
+              if ( BYTE1(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes) & 0x40 )
               {
-                pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(
-                                                                              Str2);
-                v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID;
-                if ( *(_WORD *)v6 )
+                pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename);
+                if ( pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID)
                 {
-                  pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6);
+                  pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID);
                 }
                 else
                 {
-                  *(_WORD *)v6 = v3;
-                  v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
-                  v7[1] &= 0xBFu;
+                  pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
+                  BYTE1(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes) &= 0xBFu;
                 }
               }
               else
               {
-                v5->uBitmapID = v3;
+                pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
               }
             }
-            ++v17;
-            ++v4;
           }
-          while ( v17 < (signed int)pIndoor->uNumFaceExtras );
         }
-        pParty->uFlags |= 2u;
+        pParty->uFlags |= 2;
       }
       else
       {
-        v15 = 0;
-        if ( (signed int)pOutdoor->uNumBModels > 0 )
+        for ( uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j )
         {
-          v16 = 0;
-          do
+          for ( uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i )
           {
-            v8 = 0;
-            v9 = (char *)&pOutdoor->pBModels[v16].pVertices;
-            v18 = 0;
-            if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 )
+            if ( pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog )
             {
-              do
+              if ( BYTE1(pOutdoor->pBModels[j].pFaces[i].uAttributes) & 0x40 )
               {
-                v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4));
-                if ( v10->sCogNumber == v14 )
+                pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename);
+                if ( pOutdoor->pBModels[j].pFaces[i].uTextureID )
+                  pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID);
+                else
                 {
-                  if ( BYTE1(v10->uAttributes) & 0x40 )
-                  {
-                    *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
-                                                                   Str2);
-                    v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272);
-                    if ( *(_WORD *)v11 )
-                    {
-                      pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11);
-                    }
-                    else
-                    {
-                      *(_WORD *)v11 = v12;
-                      *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu;
-                    }
-                  }
-                  else
-                  {
-                    v10->uTextureID = v12;
-                  }
+                  pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
+                  BYTE1(pOutdoor->pBModels[j].pFaces[i].uAttributes) &= 0xBFu;
                 }
-                ++v18;
-                v8 += 308;
               }
-              while ( v18 < *((_DWORD *)v9 + 2) );
+              else
+                pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
             }
-            ++v15;
-            ++v16;
           }
-          while ( v15 < (signed int)pOutdoor->uNumBModels );
         }
       }
-      pParty->uFlags |= 2u;
+      pParty->uFlags |= 2;
     }
   }
 }
@@ -4420,7 +4142,7 @@
       else
         pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE;
 
-      pParty->uFlags |= 2u;
+      pParty->uFlags |= 2;
     }
   }
 }
@@ -4428,148 +4150,42 @@
 //----- (0044892E) --------------------------------------------------------
 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on)
 {
-  signed int v3; // esi@2
-  signed int v4; // ecx@4
-  char *v5; // eax@6
-  int v6; // edi@13
-  char *v7; // esi@13
-  signed int v8; // ecx@13
-  ODMFace *v9; // eax@14
-  int v10; // [sp+0h] [bp-Ch]@1
-  signed int v11; // [sp+4h] [bp-8h]@11
-  int v12; // [sp+8h] [bp-4h]@12
-
-  v10 = sCogNumber;
   if ( sCogNumber )
   {
-    v3 = 1;
     if ( uCurrentlyLoadedLevelType == 1 )
     {
-      if ( (signed int)pIndoor->uNumFaceExtras > 1 )
+      for ( uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i )
       {
-        v4 = 1;
-        do
+        if ( pIndoor->pFaceExtras[i].sCogNumber == sCogNumber )
         {
-          if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 )
-          {
-            v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
-            if ( on )
-              *(_DWORD *)v5 |= bit;
-            else
-              *(_DWORD *)v5 &= ~bit;
-          }
-          ++v3;
-          ++v4;
+          if ( on )
+            pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit;
+          else
+            pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit;
         }
-        while ( v3 < (signed int)pIndoor->uNumFaceExtras );
       }
-      pParty->uFlags |= 2u;
+      pParty->uFlags |= 2;
     }
     else
     {
-      v11 = 0;
-      if ( (signed int)pOutdoor->uNumBModels > 0 )
+      for ( uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j )
       {
-        v12 = 0;
-        do
+        for ( uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i )
         {
-          v6 = 0;
-          v7 = (char *)&pOutdoor->pBModels[v12].pVertices;
-          v8 = 0;
-          if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 )
+          if ( pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber )
           {
-            do
-            {
-              v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4));
-              if ( v9->sCogNumber == v10 )
-              {
-                if ( on )
-                  v9->uAttributes |= bit;
-                else
-                  v9->uAttributes &= ~bit;
-              }
-              ++v8;
-              v6 += 308;
-            }
-            while ( v8 < *((_DWORD *)v7 + 2) );
+            if ( on )
+              pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit;
+            else
+              pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit;
           }
-          ++v11;
-          ++v12;
         }
-        while ( v11 < (signed int)pOutdoor->uNumBModels );
       }
     }
-    pParty->uFlags |= 2u;
+    pParty->uFlags |= 2;
   }
 }
 
-//----- (00448A98) --------------------------------------------------------
-void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
-{
-  unsigned int v3; // ebx@1
-  unsigned int v4; // ebp@1
-  signed int v5; // edi@1
-  Actor *v6; // esi@4
-  size_t v7; // ecx@10
-  Actor *v8; // eax@11
-  unsigned __int16 v9; // dx@14
-
-  v4 = uGroupID;
-  v5 = Standing;
-  v3 = uFlag;
-  if ( uGroupID )
-  {
-    if ( bToggle )
-    {
-      if ( (signed int)uNumActors > Standing )
-      {
-        v6 = pActors.data();//[0].uAttributes;
-        do
-        {
-          if ( v6->uGroup == v4 )
-          {
-            v6->uAttributes |= v3;
-            if ( v3 == 0x10000 )
-            {
-              v6->uAIState = Disabled;
-              v6->UpdateAnimation();
-            }
-          }
-          ++v5;
-          ++v6;
-        }
-        while ( v5 < (signed int)uNumActors );
-      }
-    }
-    else
-    {
-      v7 = uNumActors;
-      if ( (signed int)uNumActors > Standing )
-      {
-        v8 = pActors.data();//[0].uAIState;
-        do
-        {
-          if ( v8->uGroup == v4 )
-          {
-            if ( v3 == 0x10000 )
-            {
-              v9 = v8->uAIState;
-              if ( v8->uAIState != Dead )
-              {
-                if ( v9 != 4 && v9 != 11 )
-                  v8->uAIState = Standing;
-              }
-            }
-			LODWORD(v8->uAttributes) &= ~v3;
-          }
-          ++v8;
-          --v7;
-        }
-        while ( v7 );
-      }
-    }
-  }
-}
 
 //----- (00448B45) --------------------------------------------------------
 void  GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide)
@@ -4652,63 +4268,44 @@
 //----- (00448CF4) --------------------------------------------------------
 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName)
 {
-  __int16 v8; // di@1
-  __int16 v9; // si@1
-  unsigned int v10; // eax@1
-  size_t v11; // ebx@2
-  signed int v12; // esi@2
-  Actor *pActor;//Actor_uYawAngle_cr *v13; // ebx@3
-  AIDirection a3; // [sp+Ch] [bp-50h]@2
+  unsigned int map_id; // eax@1
+  size_t old_num_actors; // ebx@2
   AIDirection v15; // [sp+28h] [bp-34h]@2
-  //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
-
-  v8 = typeindex;
-  v9 = level;
-
-  SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
-  //SpawnPointMM7::SpawnPointMM7(&v16);
-
-  v16.vPosition.x = x;
-  v16.vPosition.y = y;
-  v16.vPosition.z = z;
-  v16.uGroup = group;
-  v16.uRadius = 32;
-  v16.uKind = 3;
-  v16.uIndex = v8 + 2 * v9 + v9;
-  v10 = pMapStats->GetMapInfo(pCurrentMapName);
-  if ( v10 )
+  SpawnPointMM7 pSpawnPoint; // [sp+44h] [bp-18h]@1
+
+  pSpawnPoint.vPosition.x = x;
+  pSpawnPoint.vPosition.y = y;
+  pSpawnPoint.vPosition.z = z;
+  pSpawnPoint.uGroup = group;
+  pSpawnPoint.uRadius = 32;
+  pSpawnPoint.uKind = 3;
+  pSpawnPoint.uIndex = typeindex + 2 * level + level;
+  map_id = pMapStats->GetMapInfo(pCurrentMapName);
+  if ( map_id )
   {
-    v11 = uNumActors;
-    SpawnEncounter(&pMapStats->pInfos[v10], &v16, 0, count, 0);
-    Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &v15, 1);
-    v12 = v11;
-    if ( (signed int)v11 < (signed int)uNumActors )
+    old_num_actors = uNumActors;
+    SpawnEncounter(&pMapStats->pInfos[map_id], &pSpawnPoint, 0, count, 0);
+    Actor::GetDirectionInfo(PID(OBJECT_Actor, old_num_actors), 4, &v15, 1);
+    for ( uint i = (unsigned int)old_num_actors; i < (unsigned int)uNumActors; ++i )
     {
-      for ( pActor = &pActors[v11]; v12 < (signed int)uNumActors; ++pActor )
-      {
-        pActor->PrepareSprites(0);
-        ++v12;
-        pActor->uYawAngle = v15.uYawAngle;
-        pActor->dword_000334_unique_name = uUniqueName;
-      }
+      pActors[i].PrepareSprites(0);
+      pActors[i].uYawAngle = v15.uYawAngle;
+      pActors[i].dword_000334_unique_name = uUniqueName;
     }
   }
 }
 
 
 //----- (0044987B) --------------------------------------------------------
-void sub_44987B(const char *pMapName, MapStartPoint start_point)
+void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point)
 {
-  const char *v2; // edi@1
-
-  v2 = pMapName;
   pAudioPlayer->StopChannels(-1, -1);
   pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None);
-  if ( _stricmp(pCurrentMapName, v2) )
+  if ( _stricmp(pCurrentMapName, pMapName) )
     SaveGame(1, 0);
 
-  uGameState = GAME_STATE_2;
-  strcpy(pCurrentMapName, v2);
+  uGameState = GAME_STATE_CHANGE_LOCATION;
+  strcpy(pCurrentMapName, pMapName);
   uLevel_StartingPointType = start_point;
 }
 // 6BE35C: using guessed type int uLevel_StartingPointType;
@@ -4716,58 +4313,42 @@
 //----- (004498D5) --------------------------------------------------------
 void TeleportToStartingPoint(MapStartPoint point)
 {
-  //unsigned int v1; // ecx@2
-  //int v2; // ecx@3
-  //int v3; // ecx@4
-  unsigned __int16 v4; // ax@11
-  signed int v5; // ecx@12
-  LevelDecoration *v6; // edx@13
-  signed int v7; // ecx@17
-  int v8; // eax@17
-  int v9; // ecx@17
-  const char *v10; // [sp-4h] [bp-84h]@6
+  const char *model_name; // [sp-4h] [bp-84h]@6
   char pName[128]; // [sp+8h] [bp-78h]@11
 
   switch (point)
   {
-    case MapStartPoint_Party: v10 = "Party Start"; break;
-    case MapStartPoint_North: v10 = "North Start"; break;
-    case MapStartPoint_South: v10 = "South Start"; break;
-    case MapStartPoint_East: v10 = "East Start";  break;
-    case MapStartPoint_West: v10 = "West Start";  break;
+    case MapStartPoint_Party: model_name = "Party Start"; break;
+    case MapStartPoint_North: model_name = "North Start"; break;
+    case MapStartPoint_South: model_name = "South Start"; break;
+    case MapStartPoint_East: model_name = "East Start";  break;
+    case MapStartPoint_West: model_name = "West Start";  break;
     default:
       Error("Invalid enum value: %u", point);
   }
 
-  strcpy(pName, v10);
-  v4 = pDecorationList->GetDecorIdByName(pName);
-  if ( v4 )
+  strcpy(pName, model_name);
+  if ( pDecorationList->GetDecorIdByName(pName) )
   {
-    v5 = 0;
+    
     if ( (signed int)uNumLevelDecorations > 0 )
     {
-      v6 = pLevelDecorations.data();
-      while ( v6->uDecorationDescID != (signed __int16)v4 )
+      for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )
       {
-        ++v5;
-        ++v6;
-        if ( v5 >= (signed int)uNumLevelDecorations )
-          goto LABEL_20;
+        if ( pLevelDecorations[i].uDecorationDescID == (signed __int16)pDecorationList->GetDecorIdByName(pName) )
+        {
+          pParty->vPosition.x = pLevelDecorations[i].vPosition.x;
+          pParty->vPosition.y = pLevelDecorations[i].vPosition.y;
+          pParty->vPosition.z = pLevelDecorations[i].vPosition.z;
+          pParty->uFallStartY = pParty->vPosition.z;
+          pParty->sRotationY = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[i].field_1A) / 90;
+          if ( pLevelDecorations[i].field_10_y_rot )
+            pParty->sRotationY = pLevelDecorations[i].field_10_y_rot;
+          pParty->sRotationX = 0;
+          pParty->uFallSpeed = 0;
+        }
       }
-      v7 = v5;
-      pParty->vPosition.x = pLevelDecorations[v7].vPosition.x;
-      pParty->vPosition.y = pLevelDecorations[v7].vPosition.y;
-      pParty->vPosition.z = pLevelDecorations[v7].vPosition.z;
-      pParty->uFallStartY = pParty->vPosition.z;
-      v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90;
-      v9 = pLevelDecorations[v7].field_10_y_rot;
-      pParty->sRotationY = v8;
-      if ( v9 )
-        pParty->sRotationY = v9;
-      pParty->sRotationX = 0;
-      pParty->uFallSpeed = 0;
     }
-LABEL_20:
     if ( dword_5B65C0 )
     {
       if ( _5B65A8_npcdata_uflags_or_other )
@@ -4796,96 +4377,6 @@
   }
 }
 
-//----- (00449A49) --------------------------------------------------------
-void Door_switch_animation(unsigned int uDoorID, int a2)
-{
-  int old_state; // eax@1
-  signed int door_id; // esi@2
-
-  if ( !pIndoor->pDoors )
-    return;
-  for ( door_id = 0; door_id < 200; ++door_id )
-  {
-    if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
-      break;
-  }
-  if ( door_id >= 200 )
-  {
-    Error("Unable to find Door ID: %i!", uDoorID);
-  }
-  old_state = pIndoor->pDoors[door_id].uState;
-  if ( a2 == 2 )
-  {
-    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 ( a2 == 0 )
-    {
-      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;
-    }
-    if ( a2 != 1 )
-      return;
-  }
-  if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
-  {
-    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 )
-    {
-      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;
-    }
-    pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
-  }
-  return;
-}
-
 //----- (00449B57) --------------------------------------------------------
 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
 {
@@ -4945,7 +4436,7 @@
   dword_5B65C0 = 0;
 
   pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
-  sub_44987B("nwc.blv", MapStartPoint_Party);
+  Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party);
   pCurrentScreen = SCREEN_GAME;
   return true;
 }