changeset 67:476145dc3441

Слияние
author Ritor1
date Fri, 26 Oct 2012 23:22:41 +0600
parents 5ec98919c8fd (current diff) 427b6c3b4e0f (diff)
children efefae49c990 636f4dbd156d
files mm7_4.cpp mm7_5.cpp
diffstat 43 files changed, 2669 insertions(+), 2634 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Actor.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -258,17 +258,17 @@
             0x88u,
             9u,
             0,
-            nullstring,
+            "",
             0);
           pDialogueWindow->_41D08F(4, 1, 0, 1);
         }
       }
     }
   }
-  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   if ( v17 && uActiveCharacter && !(v5->uFlags & 0x80) )
   {
     if ( pParty->uCurrentHour < 5 || pParty->uCurrentHour > 0x15 )
@@ -729,10 +729,10 @@
           }
           if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
             return;
-          v118 = pParty->vPosition.y;
+          v118 = pParty->vPosition.z;
           v111 = pParty->vPosition.x;
-          v114 = pParty->vPosition.y + 2500;
-          v113 = pParty->vPosition.z;
+          v114 = pParty->vPosition.z + 2500;
+          v113 = pParty->vPosition.y;
           v23 = 8;
           if ( uSkillLevel & 0x0100 )
           {
@@ -1786,8 +1786,8 @@
     if ( !v4 )
     {
       outx = pParty->vPosition.x;
-      outy = pParty->vPosition.z;
-      v14 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+      outy = pParty->vPosition.y;
+      v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
 LABEL_27:
       outz = v14;
       goto LABEL_28;
@@ -1807,21 +1807,21 @@
           v39 = &outy;
           v38 = &outx;
           v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
-          v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+          v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
           goto LABEL_20;
         }
         v40 = &outz;
         v39 = &outy;
         v38 = &outx;
         v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
-        v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
       }
       else
       {
         v40 = &outz;
         v39 = &outy;
         v38 = &outx;
-        v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
       }
       *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
@@ -1834,7 +1834,7 @@
     v40 = &outz;
     v39 = &outy;
     v38 = &outx;
-    v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+    v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
     v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
 LABEL_20:
     *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
@@ -1891,11 +1891,11 @@
   if ( v21 == 4 )
   {
     LODWORD(v45) = pParty->vPosition.x;
-    LODWORD(v44) = pParty->vPosition.z;
+    LODWORD(v44) = pParty->vPosition.y;
     v29 = a4;
     if ( !a4 )
       v29 = pParty->sEyelevel;
-    v28 = pParty->vPosition.y + v29;
+    v28 = pParty->vPosition.z + v29;
     goto LABEL_44;
   }
   if ( v21 == 5 )
@@ -2155,8 +2155,8 @@
       if ( (edx0 & 7) == 4 )
       {
         v6 = (AIDirection *)pParty->vPosition.x;
-        v7 = (AIDirection *)pParty->vPosition.z;
-        v23 = pParty->vPosition.y + pParty->sEyelevel;
+        v7 = (AIDirection *)pParty->vPosition.y;
+        v23 = pParty->vPosition.z + pParty->sEyelevel;
       }
       else
       {
@@ -2554,8 +2554,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.z;
-      v21 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v21 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2666,8 +2666,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.z;
-      v21 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v21 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2777,8 +2777,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.z;
-      v20 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v20 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2873,8 +2873,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = pParty->vPosition.x;
-      v5 = pParty->vPosition.z;
-      v22 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = pParty->vPosition.y;
+      v22 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -3436,7 +3436,7 @@
   v19 = stru_5C6E00->SinCos(v18 + v13 - stru_5C6E00->uIntegerHalfPi);
   v7->uYawAngle = stru_5C6E00->Atan2(
                     v17 - v7->vPosition.x,
-                    pParty->vPosition.z
+                    pParty->vPosition.y
                   + ((unsigned __int64)(v19 * (signed __int64)v10->uDistanceXZ) >> 16)
                   - v7->vPosition.y);
   if ( uActionLength )
@@ -3800,8 +3800,8 @@
       if ( !v3->pMonsterInfo.uHostilityType )
         v15 = dword_4DF380[v14];
       v16 = abs(v3->vPosition.x - pParty->vPosition.x);
-      v28 = abs(v3->vPosition.y - pParty->vPosition.z);
-      v17 = abs(v3->vPosition.z - pParty->vPosition.y);
+      v28 = abs(v3->vPosition.y - pParty->vPosition.y);
+      v17 = abs(v3->vPosition.z - pParty->vPosition.z);
       if ( v16 <= v15 && v28 <= v15 && v17 <= v15 )
       {
         if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 )
--- a/AudioPlayer.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/AudioPlayer.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -825,12 +825,12 @@
           if ( !a5 )
             v75 = pParty->vPosition.x;
           if ( !a6 )
-            a6 = pParty->vPosition.z;
+            a6 = pParty->vPosition.y;
           if ( uNumRepeats )
             AIL_set_sample_loop_count(v73->hSample, uNumRepeats - 1);
           v83 = sub_4AB66C(v75, a6);
           AIL_set_sample_pan(v73->hSample, v83);
-          v84 = GetSoundStrengthByDistanceFromParty(v75, a6, pParty->vPosition.y);
+          v84 = GetSoundStrengthByDistanceFromParty(v75, a6, pParty->vPosition.z);
           AIL_set_sample_volume(v73->hSample, v84);
           v76 = a3;
           goto LABEL_184;
@@ -1049,8 +1049,8 @@
           v12 = 10;
 LABEL_46:
           a1.vWorldPosition.x = (double)pParty->vPosition.x;
-          a1.vWorldPosition.y = (double)pParty->vPosition.z;
-          v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.y;
+          a1.vWorldPosition.y = (double)pParty->vPosition.y;
+          v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
           goto LABEL_47;
         }
         v12 = 10 * v13 / 16;
@@ -1259,10 +1259,10 @@
           if ( (a3 & 7) != 5 )
           {
             a1.vWorldPosition.x = (double)pParty->vPosition.x;
-            v43 = (double)pParty->vPosition.z;
+            v43 = (double)pParty->vPosition.y;
 LABEL_100:
             a1.vWorldPosition.y = v43;
-            v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.y;
+            v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
             goto LABEL_101;
           }
           v44 = (LayingItem *)&pLevelDecorations[a3 >> 3];
@@ -1427,8 +1427,8 @@
             if ( v10 != 2 )
             {
               a1.vWorldPosition.x = (double)pParty->vPosition.x;
-              a1.vWorldPosition.y = (double)pParty->vPosition.z;
-              v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.y;
+              a1.vWorldPosition.y = (double)pParty->vPosition.y;
+              v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
               goto LABEL_21;
             }
             v12 = (LayingItem *)&pLevelDecorations[v6->field_4 >> 3];
@@ -1451,8 +1451,8 @@
             if ( pBLVRenderParams->sPartyRotX )
             {
               v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
-              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.z;
-              v18 = a1.vWorldPosition.z - (double)pParty->vPosition.y;
+              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
+              v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
               if ( pRenderer->pRenderD3D )
               {
                 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
@@ -1470,7 +1470,7 @@
             else
             {
               v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
-              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.z;
+              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
               if ( pRenderer->pRenderD3D )
               {
                 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
@@ -1482,7 +1482,7 @@
                 v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
               }
               a1.vWorldViewPosition.y = v21;
-              a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.y;
+              a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
             }
           }
           else
@@ -1623,8 +1623,8 @@
         LODWORD(v56) = 1;
         v43 = 4 * v59 + 6817720;
         v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]];
-        v45 = abs(v44->vPosition.z - pParty->vPosition.y);
-        v46 = abs(v44->vPosition.y - pParty->vPosition.z);
+        v45 = abs(v44->vPosition.z - pParty->vPosition.z);
+        v46 = abs(v44->vPosition.y - pParty->vPosition.y);
         v47 = abs(v44->vPosition.x - pParty->vPosition.x);
         if ( sub_4621DA(v47, v46, v45) <= 8192 )
           break;
@@ -1692,7 +1692,7 @@
 {
   signed int v2; // eax@1
 
-  v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.z)
+  v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y)
                                   - stru_5C6E00->uIntegerHalfPi
                                   - pParty->sRotationY);
   if ( v2 > (signed int)stru_5C6E00->uIntegerPi )
@@ -1714,8 +1714,8 @@
 
   v3 = a2;
   v4 = a1;
-  v5 = abs(a3 - pParty->vPosition.y);
-  v6 = abs(v3 - pParty->vPosition.z);
+  v5 = abs(a3 - pParty->vPosition.z);
+  v6 = abs(v3 - pParty->vPosition.y);
   v7 = abs(v4 - pParty->vPosition.x);
   v9 = sub_4621DA(v7, v6, v5);
   if ( v9 <= 8192 )
@@ -2201,8 +2201,8 @@
   if ( pBLVRenderParams->sPartyRotX )
   {
     v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
-    v11 = a1->vWorldPosition.y - (double)pParty->vPosition.z;
-    v4 = a1->vWorldPosition.z - (double)pParty->vPosition.y;
+    v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
+    v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
     if ( pRenderer->pRenderD3D )
     {
       v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY;
@@ -2220,8 +2220,8 @@
   else
   {
     v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
-    v12 = a1->vWorldPosition.y - (double)pParty->vPosition.z;
-    v7 = a1->vWorldPosition.z - (double)pParty->vPosition.y;
+    v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
+    v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
     if ( pRenderer->pRenderD3D )
     {
       a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY;
--- a/DecalBuilder.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/DecalBuilder.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -202,20 +202,20 @@
   {
     v16 = a4;
   }
-  v18 = v16->vNormal.z;
-  v19 = v16->vNormal.y;
-  v20 = v16->vNormal.x;
-  v37 = (int)&stru_AE4F7C;
-  stru_AE4F64.y = v19;
-  stru_AE4F64.x = v20;
-  LODWORD(v36) = (DWORD)&stru_AE4F70;
-  stru_AE4F64.z = v18;
-  dword_AE4F88 = LODWORD(v16->field_10);
+  v18 = v16->face_plane.vNormal.z;
+  v19 = v16->face_plane.vNormal.y;
+  v20 = v16->face_plane.vNormal.x;
+  v37 = (int)&static_AE4F60.field_1C;
+  static_AE4F60.field_4.y = v19;
+  static_AE4F60.field_4.x = v20;
+  LODWORD(v36) = (DWORD)&static_AE4F60.field_10;
+  static_AE4F60.field_4.z = v18;
+  static_AE4F60.dist = v16->face_plane.dist;
   if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
-          v16->field_14,
-          &stru_AE4F64,
-          &stru_AE4F70,
-          &stru_AE4F7C) )
+          v16->polygonType,
+          &static_AE4F60.field_4,
+          &static_AE4F60.field_10,
+          &static_AE4F60.field_1C) )
   {
       MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
   }
@@ -242,7 +242,7 @@
       v27 = (signed __int64)v21->y;
       v37 = a8;
       v40 = (signed __int64)v26;
-      v28 = *(float *)&v21->field_14;
+      v28 = v21->dot_dist;
       LODWORD(v36) = (uint32)a11;
       a5a = v25;
       v39 = v27;
@@ -374,7 +374,7 @@
     v28 = v18->field_4.y * *(float *)v25
         + *((float *)v25 - 1) * v18->field_4.x
         + *((float *)v25 + 1) * v18->field_4.z
-        + *(float *)&v18->field_28;
+        + v18->dist;
     *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
     *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
     v25 += 48;
@@ -401,7 +401,7 @@
     v39 = a8;
     pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
     v40 = 0;
-    pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v32, *v31, 0);
+    pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
     if ( !(uClipFlags & 1) )
     {
 LABEL_19:
@@ -420,7 +420,7 @@
       {
         v40 = (unsigned int *)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436CDC(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
 LABEL_14:
         v40 = v31;
         v39 = v12->pVertices;
@@ -431,7 +431,7 @@
       {
         v40 = (unsigned int *)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
         goto LABEL_14;
       }
       v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
@@ -453,64 +453,43 @@
 }
 
 //----- (0049BBBD) --------------------------------------------------------
-char DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
+bool DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
 {
-  int v2; // edi@1
-  unsigned int v3; // ebx@1
-  BLVFace *v4; // esi@2
-  unsigned int v5; // eax@2
-  char *v6; // edx@5
   double v7; // st7@12
 
-  v2 = 0;
-  this->uNumDecals = 0;
-  v3 = pBloodsplatContainer->std__vector_pBloodsplats_size;
-  if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
+  if (!pBloodsplatContainer->std__vector_pBloodsplats_size)
+    return true;
+  
+  auto pFace = &pIndoor->pFaces[uFaceID];
+
+  if (pFace->uAttributes & 0x400000)
+    return true;
+  if (pFace->Animated())
+    return true;
+
+  for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
   {
-    v4 = &pIndoor->pFaces[uFaceID];
-    v5 = v4->uAttributes;
-    if ( !(v5 & 0x400000) )
+    auto pBloodsplat = pBloodsplatContainer->std__vector_pBloodsplats + i;
+    if (pFace->pBounding.x1 - pBloodsplat->radius < pBloodsplat->x &&
+        pFace->pBounding.x2 + pBloodsplat->radius > pBloodsplat->x &&
+        pFace->pBounding.y1 - pBloodsplat->radius < pBloodsplat->y &&
+        pFace->pBounding.y2 + pBloodsplat->radius > pBloodsplat->y &&
+        pFace->pBounding.z1 - pBloodsplat->radius < pBloodsplat->z &&
+        pFace->pBounding.z2 + pBloodsplat->radius > pBloodsplat->z)
     {
-      if ( !(v5 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
+      v7 = pFace->pFacePlane.vNormal.z * pBloodsplat->z +
+           pFace->pFacePlane.vNormal.y * pBloodsplat->y +
+           pFace->pFacePlane.vNormal.x * pBloodsplat->x +
+           pFace->pFacePlane.dist;
+      if (v7 <= pBloodsplat->radius)
       {
-        v6 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
-        do
-        {
-          if ( (double)v4->pBounding.x1 - *((float *)v6 + 2) < *((float *)v6 - 1) )
-          {
-            if ( (double)v4->pBounding.x2 + *((float *)v6 + 2) > *((float *)v6 - 1) )
-            {
-              if ( (double)v4->pBounding.y1 - *((float *)v6 + 2) < *(float *)v6 )
-              {
-                if ( (double)v4->pBounding.y2 + *((float *)v6 + 2) > *(float *)v6 )
-                {
-                  if ( (double)v4->pBounding.z1 - *((float *)v6 + 2) < *((float *)v6 + 1) )
-                  {
-                    if ( (double)v4->pBounding.z2 + *((float *)v6 + 2) > *((float *)v6 + 1) )
-                    {
-                      v7 = v4->pFacePlane.vNormal.z * *((float *)v6 + 1)
-                         + v4->pFacePlane.vNormal.y * *(float *)v6
-                         + v4->pFacePlane.vNormal.x * *((float *)v6 - 1)
-                         + v4->pFacePlane.dist;
-                      if ( v7 <= *((float *)v6 + 2) )
-                      {
-                        *((float *)v6 + 3) = v7;
-                        this->std__vector_30B00C[this->uNumDecals++] = v2;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-          ++v2;
-          v6 += 40;
-        }
-        while ( v2 < (signed int)v3 );
+        pBloodsplat->dot_dist = v7;
+        std__vector_30B00C[uNumDecals++] = i;
       }
     }
   }
-  return 1;
+
+  return true;
 }
 
 //----- (0049BCEB) --------------------------------------------------------
@@ -530,7 +509,7 @@
   v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
   if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
   {
-    v3 = pFace->uFaceAttributes;
+    v3 = pFace->uAttributes;
     if ( !(v3 & 0x400000) )
     {
       if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
--- a/DecalBuilder.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/DecalBuilder.h	Fri Oct 26 23:22:41 2012 +0600
@@ -93,7 +93,7 @@
   void Reset(unsigned int bPreserveBloodsplats);
   char ApplyDecals(int a2, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, struct IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID);
   char _49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, struct RenderVertexSoft *a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
-  char ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
+  bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
   bool _49BE8A(struct stru148 *a2, float a3, int a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
   void DrawDecal(Decal *pDecal, float z_bias);
@@ -155,7 +155,7 @@
   float y;
   float z;
   float radius;
-  int field_14;
+  float dot_dist;
   char r;
   char g;
   char b;
--- a/GUIWindow.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/GUIWindow.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -312,7 +312,7 @@
     v41 = v31;
   }
   while ( (signed int)v46 < (signed int)&dword_506978 );
-  v39 = nullstring;
+  v39 = "";
   if ( uFramesetIDa == v30 )
     v39 = pGlobalTXT_LocalizationStrings[153];
   sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[450], v39);
@@ -589,7 +589,7 @@
           0xB3u,
           v19,
           0,
-          nullstring,
+          "",
           0);
         ++v19;
       }
@@ -632,7 +632,7 @@
           0xB7u,
           v16,
           0,
-          nullstring,
+          "",
           0);
         ++v16;
       }
@@ -887,7 +887,7 @@
                             2u,
                             0,
                             pGlobalTXT_LocalizationStrings[192],// Scroll Up
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             pBtn_Book_4 = v1->CreateButton(
                             pViewport->uViewportX + 397,
@@ -900,7 +900,7 @@
                             3u,
                             0,
                             pGlobalTXT_LocalizationStrings[193],// Scroll Down
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             pBtn_Book_5 = v1->CreateButton(
                             pViewport->uViewportX + 397,
@@ -913,7 +913,7 @@
                             4u,
                             0,
                             pGlobalTXT_LocalizationStrings[573],// "Scroll Right"
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             pBtn_Book_6 = v1->CreateButton(
                             pViewport->uViewportX + 397,
@@ -926,7 +926,7 @@
                             5u,
                             0,
                             pGlobalTXT_LocalizationStrings[572],// "Scroll Left"
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             return;
           }
@@ -1257,14 +1257,14 @@
         0x56u,
         v3,
         0,
-        nullstring,
+        "",
         0);
       ++a2;
     }
     ++v3;
   }
   while ( (signed int)v3 < 11 );
-  v2->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, nullstring, 0);
+  v2->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, "", 0);
   if ( a2 )
     v2->_41D08F(a2, 0, 0, 0);
   if ( v1->pActiveSkills[12] )
@@ -1295,7 +1295,7 @@
     0x58u,
     0,
     0,
-    nullstring,
+    "",
     0);
   ptr_5064F8 = v2->CreateButton(
                  0x1DCu,
@@ -1307,7 +1307,7 @@
                  0x58u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  pTexture_506444,
                  0);
   v2->CreateButton(
@@ -2229,7 +2229,7 @@
                       0x88u,
                       0x13u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2250,7 +2250,7 @@
                       0x88u,
                       0x14u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2271,7 +2271,7 @@
                       0x88u,
                       0x15u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2292,7 +2292,7 @@
                       0x88u,
                       0x16u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2313,7 +2313,7 @@
                       0x88u,
                       0x17u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2334,7 +2334,7 @@
                       0x88u,
                       0x18u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2439,11 +2439,11 @@
       return pWindow;
     }
 LABEL_62:
-    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
-    pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, nullstring, 0);
+    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+    pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
     return pWindow;
   }
   if (eWindowType == WINDOW_HouseInterior)
--- a/Game.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Game.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -61,11 +61,11 @@
   pIndoorCamera->pos.x = pParty->vPosition.x
                       - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
                                           * (signed __int64)pParty->field_18) >> 16);
-  pIndoorCamera->pos.y = pParty->vPosition.z
+  pIndoorCamera->pos.y = pParty->vPosition.y
                       - ((unsigned __int64)(stru_5C6E00->SinCos(
                                               pParty->sRotationY - stru_5C6E00->uIntegerHalfPi)
                                           * (signed __int64)pParty->field_18) >> 16);
-  pIndoorCamera->pos.z = pParty->vPosition.y + pParty->sEyelevel;
+  pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   pIndoorCamera->Initialize2();
   pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
   pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum();
@@ -79,13 +79,13 @@
   }
   else
   {
-    if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.z != pParty->vPrevPosition.z | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.y != pParty->vPrevPosition.y | pParty->sEyelevel != pParty->sPrevEyelevel )
+    if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.z | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.z != pParty->vPrevPosition.y | pParty->sEyelevel != pParty->sPrevEyelevel )
       pParty->uFlags |= 2u;
     pParty->vPrevPosition.x = pParty->vPosition.x;
-    pParty->vPrevPosition.y = pParty->vPosition.y;
+    pParty->vPrevPosition.y = pParty->vPosition.z;
     //v0 = &pRenderer;
     pParty->sPrevRotationY = pParty->sRotationY;
-    pParty->vPrevPosition.z = pParty->vPosition.z;
+    pParty->vPrevPosition.z = pParty->vPosition.y;
     pParty->sPrevRotationX = pParty->sRotationX;
     pParty->sPrevEyelevel = pParty->sEyelevel;
     pRenderer->BeginSceneD3D();
@@ -419,21 +419,21 @@
       if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 136) )
       {
         pParty->vPosition.x = -17331;            // respawn in harmondale
-        pParty->vPosition.z = 12547;
-        pParty->vPosition.y = 465;
+        pParty->vPosition.y = 12547;
+        pParty->vPosition.z = 465;
         pParty->sRotationY = 0;
         v13 = "out02.odm";
       }
       else
       {
         pParty->vPosition.x = 12552;             // respawn on emerald isle
-        pParty->vPosition.z = 1816;
-        pParty->vPosition.y = 0;
+        pParty->vPosition.y = 1816;
+        pParty->vPosition.z = 0;
         pParty->sRotationY = 512;
         v13 = "out01.odm";
       }
       strcpy(Source, v13);
-      pParty->uFallStartY = pParty->vPosition.y;
+      pParty->uFallStartY = pParty->vPosition.z;
       pParty->sRotationX = 0;
       pParty->uFallSpeed = 0;
       pParty->field_6E4 = 0;
@@ -442,8 +442,8 @@
       {
         strcpy(pCurrentMapName, Source);
         _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x;
-        _5B65AC_npcdata_fame_or_other = pParty->vPosition.z;
-        _5B65B0_npcdata_rep_or_other = pParty->vPosition.y;
+        _5B65AC_npcdata_fame_or_other = pParty->vPosition.y;
+        _5B65B0_npcdata_rep_or_other = pParty->vPosition.z;
         _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY;
         _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX;
         dword_5B65C0 = 1;
@@ -646,7 +646,7 @@
     }
     if (uFlags & 0x0400)
       uFlags2 |= 0x01;
-    if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && uNumMobileLightsApplied )
+    if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive )
     {
       uFlags2 |= 0x01;
       field_E10 = qword_5C6DF0;
@@ -654,10 +654,10 @@
     v6 = qword_5C6DF0 - field_E10;
     if ( qword_5C6DF0 - field_E10 == 1 )
       uFlags2 |= v6;
-    if (uNumStationaryLights_in_pStationaryLightsStack != uNumStationaryLightsApplied )
+    if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive )
     {
       uFlags2 |= 1u;
-      uNumStationaryLights_in_pStationaryLightsStack = uNumStationaryLightsApplied;
+      uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive;
     }
     _44E904();
     LOBYTE(result) = 1;
@@ -688,7 +688,7 @@
 //----- (0044EE30) --------------------------------------------------------
 bool Game::_44EE30(ODMFace *a2, int a3)
 {
-  if (uFlags2 & 0x2 && a2->uFaceAttributes & 0x02)
+  if (uFlags2 & 0x2 && a2->uAttributes & 0x02)
   {
     *(int *)a3 = sub_48A959(*(int *)a3, 1.0, _E28_timed_gamma_strength, -1.0);
     return true;
@@ -758,7 +758,7 @@
   float a4a; // [sp+1Ch] [bp+10h]@9
   float a4b; // [sp+1Ch] [bp+10h]@11
 
-  if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uFaceAttributes & 2 )
+  if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 )
   {
     v4 = (double)a4;
     a2a = v4;
--- a/GameUIs.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/GameUIs.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -110,7 +110,7 @@
       v5 = v15.FindContainer("image.pcx", true);
       if ( !v5 )
       {
-        v9 = nullstring;
+        v9 = "";
 LABEL_22:
         pSavegameUsedSlots[v3] = 0;
         strcpy(Dest->pName, v9);
@@ -148,13 +148,13 @@
   uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10);
   uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, "", 0);
   ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
                  241u,
                  302u,
@@ -165,7 +165,7 @@
                  0xA4u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
                  0);
   ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
@@ -178,7 +178,7 @@
                  0xA6u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
                  0);
   ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
@@ -191,7 +191,7 @@
                  0xA2u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
                  0);
   v7 = pGUIWindow_CurrentMenu->CreateButton(
@@ -204,7 +204,7 @@
          0xA3u,
          uNumSavegameFiles,
          0,
-         nullstring,
+         "",
          (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
          0);
   v16 = -1;
@@ -309,13 +309,13 @@
   uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
   pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, "", 0);
   ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
                  0xF1u,
                  0x12Eu,
@@ -326,7 +326,7 @@
                  0xA4u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
                  0);
   ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
@@ -339,7 +339,7 @@
                  0xA6u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
                  0);
   ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
@@ -352,7 +352,7 @@
                  0xA2u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
                  0);
   v7 = pGUIWindow_CurrentMenu->CreateButton(
@@ -365,7 +365,7 @@
          0xA3u,
          0x22u,
          0,
-         nullstring,
+         "",
          (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
          0);
   v12 = -1;
--- a/Indoor.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Indoor.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -69,7 +69,7 @@
 //----- (0043F39E) --------------------------------------------------------
 void __fastcall sub_43F39E(IndoorLocation_drawstru *_this)
 {
-  int *v1; // ecx@1
+  //int *v1; // ecx@1
   //double v2; // ST30_8@3
   //double v3; // ST30_8@6
   //double v4; // ST28_8@6
@@ -82,13 +82,14 @@
   //unsigned __int8 v11; // [sp+1Ch] [bp-4h]@3
   signed int v12; // [sp+1Ch] [bp-4h]@8
 
-  pBLVRenderParams->Set(_this);
-  uNumMobileLightsApplied = 0;
+  pBLVRenderParams->Reset(_this);
+  pMobileLightsStack->uNumLightsActive = 0;
+  //uNumMobileLightsApplied = 0;
   uNumDecorationsDrawnThisFrame = 0;
   _unused000 = 0;
   uNumSpritesDrawnThisFrame = 0;
   uNumBillboardsToDraw = 0;
-  if ( !byte_4D864C || !(BYTE1(pGame->uFlags) & 0x10) )
+  if ( !byte_4D864C || !(pGame->uFlags & 0x1000) )
   {
     //v2 = pParty->flt_TorchlightColorB + 6.7553994e15;
     //v11 = LOBYTE(v2);
@@ -96,19 +97,19 @@
       v5 = 800;
     else
       v5 = 800 * pParty->pPartyBuffs[16].uPower;
-    LOBYTE(v1) = byte_4E94D0;
+    //LOBYTE(v1) = byte_4E94D0;
     //v4 = pParty->flt_TorchlightColorR + 6.7553994e15;
     //v3 = pParty->flt_TorchlightColorG + 6.7553994e15;
     pMobileLightsStack->AddLight(
-      SLOWORD(pBLVRenderParams->vPartyPos.x),
-      SLOWORD(pBLVRenderParams->vPartyPos.y),
-      SLOWORD(pBLVRenderParams->vPartyPos.z),
-      SLOWORD(pBLVRenderParams->uRadius),
+      pBLVRenderParams->vPartyPos.x,
+      pBLVRenderParams->vPartyPos.y,
+      pBLVRenderParams->vPartyPos.z,
+      pBLVRenderParams->uPartySectorID,
       v5,
       floorf(pParty->flt_TorchlightColorR + 0.5f),
       floorf(pParty->flt_TorchlightColorG + 0.5f),
       floorf(pParty->flt_TorchlightColorB + 0.5f),
-      v1);
+      byte_4E94D0);
   }
   PrepareWallsRenderList_BLV();
   PrepareItemsRenderList_BLV();
@@ -135,7 +136,7 @@
 
 
 //----- (004407D9) --------------------------------------------------------
-int BLVRenderParams::Set(IndoorLocation_drawstru *a2)
+int BLVRenderParams::Reset(IndoorLocation_drawstru *a2)
 {
   IndoorLocation_drawstru *v2; // ebx@1
   BLVRenderParams *v3; // esi@1
@@ -179,15 +180,15 @@
   v6 = this->vPartyPos.x;
   this->sPartyRotX = a2->sRotationX;
   v7 = pIndoor->GetSector(v6, v5, v4);
-  v3->uRadius = v7;
+  v3->uPartySectorID = v7;
   if ( !v7 )
   {
     v8 = v3->vPartyPos.z;
     v3->vPartyPos.x = pParty->vPosition.x;
-    v9 = pParty->vPosition.z;
+    v9 = pParty->vPosition.y;
     v10 = v3->vPartyPos.x;
-    v3->vPartyPos.y = pParty->vPosition.z;
-    v3->uRadius = pIndoor->GetSector(v10, v9, v8);
+    v3->vPartyPos.y = pParty->vPosition.y;
+    v3->uPartySectorID = pIndoor->GetSector(v10, v9, v8);
   }
   if ( pRenderer->pRenderD3D )
   {
@@ -253,7 +254,7 @@
   result = 0;
   v3->field_8C = 0;
   v3->field_84 = 0;
-  v3->field_80 = 0;
+  v3->uNumFacesRenderedThisFrame = 0;
   v3->field_88 = 0;
   pBLVRenderParams->field_90 = 64;
   pBLVRenderParams->field_94 = 6;
@@ -270,7 +271,7 @@
 
   if (bD3D)
   {
-    pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+    pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     for (uint i = 0; i < pStru170->uNumFaceIDs; ++i)
     {
       v2 = pStru170->pFaceIDs[2 * i + 1];
@@ -284,7 +285,7 @@
         v3 = pStru170->field_FA8[v2].std__vector_0007AC;
         v6 = pStru170->field_FA8[v2].pVertices;
       }
-      IndoorLocation::ExecDraw_d3d(pStru170->pFaceIDs[2 * i], v3, 4u, v6);
+      IndoorLocation::ExecDraw_d3d(pStru170->pFaceIDs[2 * i], v3, 4, v6);
     }
   }
   else
@@ -310,7 +311,7 @@
   int v7; // [sp+Ch] [bp-4h]@8
 
   sub_43F39E(_this);
-  if ( pBLVRenderParams->uRadius )
+  if (pBLVRenderParams->uPartySectorID)
     IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0);
   pRenderer->DrawBillboardList_BLV();
   if ( !pRenderer->pRenderD3D )
@@ -362,7 +363,7 @@
   int v0; // eax@1
   IndoorLocation_drawstru _this; // [sp+0h] [bp-4Ch]@5
   int v2; // [sp+44h] [bp-8h]@5
-  float v3; // [sp+48h] [bp-4h]@5
+  int v3; // [sp+48h] [bp-4h]@5
 
   v0 = 0;
   if ( viewparams->field_50_draw_debug_outlines )
@@ -375,9 +376,9 @@
                    - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
                                        * (signed __int64)pParty->field_18) >> 16);
   v2 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
-  LODWORD(v3) = (unsigned __int64)(v2 * (signed __int64)pParty->field_18) >> 16;
+  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->field_18) >> 16;
   _this.field_1C_mb_fov = 65;
-  _this.vPosition.y = pParty->vPosition.z - LODWORD(v3);
+  _this.vPosition.y = pParty->vPosition.y - v3;
   _this.sRotationY = pParty->sRotationY;
   _this.sRotationX = pParty->sRotationX;
   _this.pRenderTarget = pRenderer->pTargetSurface;
@@ -386,7 +387,7 @@
   _this.uViewportZ = pViewport->uScreenZ;
   _this.uViewportW = pViewport->uScreenW;
   _this.field_3C = pViewport->field_30;
-  _this.vPosition.z = pParty->vPosition.y + pParty->sEyelevel;
+  _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel;
   _this.uTargetWidth = 640;
   _this.uTargetHeight = 480;
   _this.pTargetZ = pRenderer->pActiveZBuffer;
@@ -410,7 +411,7 @@
   this->pFacePlane.vNormal.z = (double)(a2->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022
                              + (double)(a2->pFacePlane.vNormal.z >> 16);
   this->pFacePlane.dist = (double)(a2->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(a2->pFacePlane.dist >> 16);
-  this->uAttributes = a2->uFaceAttributes;
+  this->uAttributes = a2->uAttributes;
   this->pBounding.x1 = a2->pBoundingBox.x1;
   this->pBounding.y1 = a2->pBoundingBox.y1;
   this->pBounding.z1 = a2->pBoundingBox.z1;
@@ -446,10 +447,10 @@
   //unsigned __int8 v15; // sf@19
   //unsigned __int8 v16; // of@19
   int v17; // ebx@25
-  double v18; // st7@27
-  double v19; // st6@27
-  double v20; // st5@27
-  char v21; // dl@27
+  //double v18; // st7@27
+  //double v19; // st6@27
+  //double v20; // st5@27
+  //char v21; // dl@27
   unsigned int v22; // eax@44
   unsigned int v23; // eax@35
   DWORD v24; // eax@37
@@ -482,41 +483,28 @@
     return;
 
 
-      if ( !(pFace->uAttributes & 0x2000) )
-      {
-        ++pBLVRenderParams->field_80;
-        LOBYTE(pFace->uAttributes) |= 0x80u;
-        v28 = pFace->GetTexture();
-        if ( v28 )
-        {
-          //v10 = pGame->pIndoorCameraD3D;
-          //v31 = pGame->pIndoorCameraD3D;
-          //pStru4 = pGame->pLightmapBuilder;
-          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(pFace) )
-          {
-            //v11 = 0;
-            //uNumVerticesa = pFace->uNumVertices;
-              //v12 = pIndoor->pVertices;
-              //v13 = (char *)&static_vertices_F7C228[0].vWorldPosition.z;
-            for (uint i = 0; i < pFace->uNumVertices; ++i)
-            {
-              static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x;
-              static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y;
-              static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z;
-              static_vertices_F7C228[i].u = pFace->pVertexUIDs[i];
-              static_vertices_F7C228[i].v = pFace->pVertexUIDs[i];
-                //v14 = v11++;
-                //*((float *)v13 - 2) = (double)v12[v9->pVertexIDs[v14]].x;
-                //*((float *)v13 - 1) = (double)v12[v9->pVertexIDs[v14]].y;
-                //*(float *)v13 = (double)v12[v9->pVertexIDs[v14]].z;
-                //v13 += 48;
-                //v16 = __OFSUB__(v11, uNumVerticesa);
-                //v15 = ((v11 - uNumVerticesa) & 0x80000000u) != 0;
-                //*((float *)v13 - 5) = (double)v9->pVertexUIDs[v14];
-                //*((float *)v13 - 4) = (double)v9->pVertexVIDs[v14];
-              //while ( v15 ^ v16 );
-              //v10 = v31;
-            }
+  if (pFace->Invisible())
+    return;
+  
+  ++pBLVRenderParams->uNumFacesRenderedThisFrame;
+  pFace->uAttributes |= 0x80u;
+
+  if (!pFace->GetTexture())
+    return;
+
+  v28 = pFace->GetTexture();
+
+  if (!pGame->pIndoorCameraD3D->IsCulled(pFace))
+  {
+    uNumVerticesa = pFace->uNumVertices;
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
+    {
+      static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x;
+      static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y;
+      static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z;
+      static_vertices_F7C228[i].u = (signed)pFace->pVertexUIDs[i];
+      static_vertices_F7C228[i].v = (signed)pFace->pVertexUIDs[i];
+    }
             if ( !pVertices
               || (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
             {
@@ -526,31 +514,29 @@
                      static_vertices_F7B628,
                      pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum,
                      4,
-                     0,
+                     false,
                      0) != 1
                 || uNumVerticesa )
               {
-                a4a = SHIWORD(stru_F8AD28.field_2C);
-                v17 = (248 - 8 * SHIWORD(stru_F8AD28.field_2C)) | (((248 - 8 * SHIWORD(stru_F8AD28.field_2C)) | ((248 - 8 * SHIWORD(stru_F8AD28.field_2C)) << 8)) << 8);
+                a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel);
+                v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8);
                 sub_4B0E07(uFaceID);
                 pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID);
                 pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID);
-                pGame->pIndoorCameraD3D->_4364C5(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
-                pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(array_507D30, uNumVerticesa, 0);
+                pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
+                pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0);
                 pGame->pLightmapBuilder->std__vector_000004_size = 0;
-                if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+                if (stru_F8AD28.uNumLightsApplied > 0 ||
+                    pDecalBuilder->uNumDecals > 0)
                 {
-                  v18 = pFace->pFacePlane.dist;
-                  v19 = pFace->pFacePlane.vNormal.z;
-                  v20 = pFace->pFacePlane.vNormal.y;
-                  v21 = pFace->uPolygonType;
-                  stru_F7B60C.vNormal.x = pFace->pFacePlane.vNormal.x;
-                  stru_F7B60C.field_14 = v21;
-                  stru_F7B60C.vNormal.y = v20;
-                  stru_F7B60C.vNormal.z = v19;
-                  stru_F7B60C.field_10 = v18;
+                  stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x;
+                  stru_F7B60C.polygonType = pFace->uPolygonType;
+                  stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y;
+                  stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z;
+                  stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist;
                 }
-                if ( stru_F8AD28.field_AC > 0 && !(BYTE2(pFace->uAttributes) & 0x40) )
+                if (stru_F8AD28.uNumLightsApplied > 0 &&
+                    !(pFace->uAttributes & 0x400000))
                   pGame->pLightmapBuilder->ApplyLights(
                     &stru_F8AD28,
                     &stru_F7B60C,
@@ -558,7 +544,8 @@
                     array_507D30,
                     pVertices,
                     0);
-                if ( pDecalBuilder->uNumDecals > 0 )
+
+                if (pDecalBuilder->uNumDecals > 0)
                   pDecalBuilder->ApplyDecals(
                     a4a,
                     1,
@@ -614,9 +601,7 @@
                 goto LABEL_42;
               }
             }
-          }
-        }
-      }
+  }
 }
 
 //----- (004AFF79) --------------------------------------------------------
@@ -777,7 +762,7 @@
         if ( !(v3 & 0x10) || (sub_4AD504(uFaceID), pRenderer->pRenderD3D) )
         {
           v4 = v2->GetTexture();
-          ++pBLVRenderParams->field_80;
+          ++pBLVRenderParams->uNumFacesRenderedThisFrame;
           v5 = v4;
           v108 = v4;
           if ( v4 )
@@ -796,7 +781,7 @@
               {
                 if ( v2->uPolygonType == 1 )
                 {
-                  for ( i = 0; i < stru_F8AD28.field_AC; stru_F8AD28._blv_lights_ys[v18] = v20 )
+                  for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 )
                   {
                     v18 = i;
                     v120 = stru_F8AD28._blv_lights_xs[i];
@@ -820,7 +805,7 @@
                     {
 LABEL_16:
                       a2 = 0;
-                      if ( stru_F8AD28.field_AC > 0 )
+                      if ( stru_F8AD28.uNumLightsApplied > 0 )
                       {
                         do
                         {
@@ -857,7 +842,7 @@
                           stru_F8AD28._blv_lights_ys[v8] += v128;
                           ++a2;
                         }
-                        while ( a2 < stru_F8AD28.field_AC );
+                        while ( a2 < stru_F8AD28.uNumLightsApplied );
                         v2 = v103;
                       }
                       goto LABEL_24;
@@ -869,7 +854,7 @@
                       goto LABEL_16;
                     }
                   }
-                  for ( j = 0; j < stru_F8AD28.field_AC; *(int *)v15 = v16 )
+                  for ( j = 0; j < stru_F8AD28.uNumLightsApplied; *(int *)v15 = v16 )
                   {
                     v14 = v128;
                     stru_F8AD28._blv_lights_xs[j] += v126;
@@ -2706,7 +2691,7 @@
     auto pSector = pSectors + i;
 
     pSector->pFloors = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_4;
+    j += pSector->uNumFloors;
 
     pSector->pWalls = ptr_0002B0_sector_rdata + j;
     j += pSector->field_C;
@@ -2788,7 +2773,7 @@
 
   for (uint i = 0, j = 0; i < uNumSectors; ++i)
   {
-    pSectors->pLights = (BLVLightMM7 *)(ptr_0002B8_sector_lrdata + j);
+    pSectors->pLights = (unsigned __int16 *)(ptr_0002B8_sector_lrdata + j);
     j += pSectors->uNumLights;
   }
 
@@ -3180,33 +3165,33 @@
   //unsigned __int8 v5; // zf@1
   //unsigned __int8 v6; // sf@1
   //unsigned __int8 v7; // of@1
-  BLVSector *v8; // eax@3
-  int v9; // edi@9
-  int v10; // eax@9
-  int v11; // edx@9
-  int v12; // eax@10
-  unsigned __int16 v13; // ax@12
-  int v14; // edi@14
-  BLVFace *v15; // eax@14
-  BLVFace *v16; // edi@14
-  PolygonType v17; // al@14
-  unsigned __int16 *pVertexIDs; // esi@16
-  Vec3_short_ *v19; // eax@16
-  int v20; // edx@16
-  unsigned __int16 *v21; // esi@17
-  int v22; // edi@19
-  int v23; // edi@20
-  Vec3_short_ *v24; // edx@20
+  //BLVSector *v8; // eax@3
+  //int v9; // edi@9
+  //int v10; // eax@9
+  //int v11; // edx@9
+  //int v12; // eax@10
+  //unsigned __int16 v13; // ax@12
+  //int v14; // edi@14
+  //BLVFace *v15; // eax@14
+  //BLVFace *v16; // edi@14
+  //PolygonType v17; // al@14
+  //unsigned __int16 *pVertexIDs; // esi@16
+  //Vec3_short_ *v19; // eax@16
+  //int v20; // edx@16
+  //unsigned __int16 *v21; // esi@17
+  //int v22; // edi@19
+  //int v23; // edi@20
+  //Vec3_short_ *v24; // edx@20
   signed int v25; // edx@21
   int v26; // ebx@23
-  int v27; // edx@26
-  signed __int64 v28; // qtt@26
-  Vec3_short_ *v29; // eax@26
-  Vec3_short_ *v30; // edx@26
-  int v31; // edx@26
+  //int v27; // edx@26
+  //signed __int64 v28; // qtt@26
+  ///Vec3_short_ *v29; // eax@26
+  //Vec3_short_ *v30; // edx@26
+  //int v31; // edx@26
   signed int v32; // edi@27
   signed __int64 v33; // qtt@27
-  Vec3_short_ *v34; // edx@27
+  //Vec3_short_ *v34; // edx@27
   int v35; // edx@32
   int v37; // edi@38
   int v38; // ebx@40
@@ -3215,21 +3200,21 @@
   PolygonType v41; // dl@42
   int v42; // edx@43
   int v43[50]; // [sp+Ch] [bp-108h]@1
-  int v44; // [sp+D4h] [bp-40h]@9
-  int v45; // [sp+D8h] [bp-3Ch]@14
-  int v46; // [sp+DCh] [bp-38h]@14
-  int v47; // [sp+E0h] [bp-34h]@19
-  int v48; // [sp+E4h] [bp-30h]@9
-  Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19
+  //int v44; // [sp+D4h] [bp-40h]@9
+  //int v45; // [sp+D8h] [bp-3Ch]@14
+  //int v46; // [sp+DCh] [bp-38h]@14
+  //int v47; // [sp+E0h] [bp-34h]@19
+  //int v48; // [sp+E4h] [bp-30h]@9
+  //Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19
   bool v50; // [sp+ECh] [bp-28h]@19
   int v51; // [sp+F0h] [bp-24h]@9
-  unsigned int v52; // [sp+F4h] [bp-20h]@2
+  //unsigned int v52; // [sp+F4h] [bp-20h]@2
   int v53; // [sp+F8h] [bp-1Ch]@10
   int v54; // [sp+FCh] [bp-18h]@16
   int v55; // [sp+100h] [bp-14h]@1
   int v56; // [sp+104h] [bp-10h]@1
   int v57; // [sp+108h] [bp-Ch]@16
-  Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20
+  //Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20
   int v59; // [sp+110h] [bp-4h]@16
 
   v4 = 0;
@@ -3238,140 +3223,134 @@
   //v6 = this->uNumSectors - 1 < 0;
   v55 = 0;
   v43[0] = 0;
-  v56 = 1;
+  //v56 = 1;
   if (uNumSectors < 2)
     return 0;
 
-  v52 = 116;
-  do
+  for (uint i = 1; i < uNumSectors; ++i)
   {
-    v8 = &this->pSectors[v52 / 0x74];
-    if ( v8->pBounding.x1 <= sX )
-    {
-      if ( v8->pBounding.x2 >= sX )
-      {
-        if ( v8->pBounding.y1 <= sY )
+    auto pSector = pSectors + i;
+
+    if (pSector->pBounding.x1 <= sX  && pSector->pBounding.x2 >= sX)
+      if (pSector->pBounding.y1 <= sY  && pSector->pBounding.y2 >= sY)
+        if (pSector->pBounding.z1 - 64 <= sZ && pSector->pBounding.z2 + 64 >= sZ)
         {
-          if ( v8->pBounding.y2 >= sY )
-          {
-            if ( v8->pBounding.z1 - 64 <= sZ )
-            {
-              if ( v8->pBounding.z2 + 64 >= sZ )
-              {
-                v9 = v8->field_4;
-                v10 = v9 + v8->uNumPortals;
-                v11 = 0;
-                v44 = v9;
-                v51 = v10;
-                v48 = 0;
-                if ( v10 > 0 )
-                {
-                  v12 = -2 * v9;
-                  v53 = -2 * v9;
-                  do
-                  {
-                    if ( v11 < v44 )
-                      v13 = this->pSectors[v52 / 0x74].pFloors[v11];
+          Log::Warning(L"Sector[%u]", i);
+          v51 = pSector->uNumFloors + pSector->uNumPortals;
+          if (!v51)
+            continue;
+
+          //v9 = pSector->uNumFloors;
+                //v10 = v9 + pSector->uNumPortals;
+                //v11 = 0;
+                //v44 = v9;
+                //v48 = 0;
+
+                  //v12 = -2 * v9;
+                  //v53 = -2 * v9;
+           for (uint j = 0; j < v51; ++j)
+           {
+             unsigned int uFaceID;
+             if (j < pSector->uNumFloors)
+               uFaceID = pSector->pFloors[j];
+             else
+               uFaceID = pSector->pPortals[j - pSector->uNumFloors];
+
+             auto pFace = pFaces + uFaceID;
+                    //v14 = (signed __int16)v13;
+                    //v15 = this->pFaces;
+                    //v46 = v13;
+                    //v14 *= 96;
+                    //v45 = v13 * sizeof(BLVFace);
+                    //v16 = pFaces + uFaceID;
+                    //v17 = v16->uPolygonType;
+             if (pFace->uPolygonType == POLYGON_Floor ||
+                 pFace->uPolygonType == POLYGON_InBetweenFloorAndWall)
+             {
+               //pVertexIDs = pFace->pVertexIDs;
+                      //v19 = this->pVertices;
+               //v20 = pVertices[pFace->pVertexIDs[0]].y;
+                      v54 = 0;
+                      //v57 = 0;
+                      //v5 = v16->uNumVertices == 0;
+                      v59 = pVertices[pFace->pVertexIDs[0]].y >= sY;
+
+                        //v21 = pFace->pVertexIDs + 1;
+               for (uint k = 1; k < pFace->uNumVertices; ++k)
+               {
+                 if (v54 >= 2)
+                   break;
+
+                 //v49 = &pVertices[pFace->pVertexIDs[k]];
+                 auto v2 = &pVertices[pFace->pVertexIDs[k]];
+                          //v22 = pVertex->y;
+                          //v47 = pVertex->y;
+                 v50 = v2->y >= sY;
+                 if ( v59 ^ v50 )
+                 {
+                            //v58 = &pVertices[pFace->pVertexIDs[k - 1]];
+                   auto v1 = &pVertices[pFace->pVertexIDs[k - 1]];
+                            //v23 = v58->x;
+                            //HIWORD(v24) = HIWORD(v49);
+                            //LOWORD(v24) = v49->x;
+                            //v49 = v24;
+                            //v59 = v49->x;
+                   v25 = v1->x >= sX ? 0 : 2;  // BUG TODO TROLOLO
+                   v26 = v25 | v2->x < sX;     // SWAP v1 and v2 till the result's correct
+                   if ( v26 != 3 )
+                   {
+                    if (!v26)
+                      ++v54;
                     else
-                      v13 = *(unsigned __int16 *)((char *)this->pSectors[v52 / 0x74].pPortals + v12);
-                    v14 = (signed __int16)v13;
-                    v15 = this->pFaces;
-                    v46 = v14;
-                    v14 *= 96;
-                    v45 = v14;
-                    v16 = (BLVFace *)((char *)v15 + v14);
-                    v17 = v16->uPolygonType;
-                    if ( v17 == 3 || v17 == 4 )
                     {
-                      pVertexIDs = v16->pVertexIDs;
-                      v19 = this->pVertices;
-                      v20 = v19[*pVertexIDs].y;
-                      v54 = 0;
-                      v57 = 0;
-                      //v5 = v16->uNumVertices == 0;
-                      v59 = v20 >= sY;
-                      if (v16->uNumVertices)
+                      if (v1->x >= v2->x)
                       {
-                        v21 = pVertexIDs + 1;
-                        do
-                        {
-                          if ( v54 >= 2 )
-                            break;
-                          v49 = &v19[*v21];
-                          v22 = v49->y;
-                          v47 = v49->y;
-                          v50 = v22 >= sY;
-                          if ( v59 ^ v50 )
-                          {
-                            v58 = &v19[*(v21 - 1)];
-                            v23 = v58->x;
-                            HIWORD(v24) = HIWORD(v49);
-                            LOWORD(v24) = v49->x;
-                            v49 = v24;
-                            v59 = (signed __int16)v24;
-                            v25 = (signed __int16)v24 >= sX ? 0 : 2;
-                            v26 = v25 | v23 < sX;
-                            if ( v26 != 3 )
-                            {
-                              if ( !v26
-                                || (v58->x >= (signed __int16)v49 ? (v32 = v23 - v59,
-                                                                     v58 = (Vec3_short_ *)(v58->y - v47),
-                                                                     LODWORD(v33) = v32 << 16,
-                                                                     HIDWORD(v33) = v32 >> 16,
-                                                                     v59 = v33 / (signed int)v58,
-                                                                     v34 = this->pVertices,
-                                                                     v58 = (Vec3_short_ *)(v33 / (signed int)v58),
-                                                                     v59 = sY - v34[*v21].y,
-                                                                     v59 = (unsigned __int64)((signed int)v58
-                                                                                            * (signed __int64)v59) >> 16,
-                                                                     v31 = *v21) : (v27 = v58->y,
-                                                                                    v59 -= v23,
-                                                                                    v58 = (Vec3_short_ *)(v47 - v27),
-                                                                                    LODWORD(v28) = v59 << 16,
-                                                                                    HIDWORD(v28) = v59 >> 16,
-                                                                                    v59 = v28 / (v47 - v27),
-                                                                                    v29 = (Vec3_short_ *)(v28 / (v47 - v27)),
-                                                                                    v30 = this->pVertices,
-                                                                                    v58 = v29,
-                                                                                    v59 = sY - v30[*(v21 - 1)].y,
-                                                                                    v59 = (unsigned __int64)((signed int)v29 * (signed __int64)v59) >> 16,
-                                                                                    v31 = *(v21 - 1)),
-                                    v19 = this->pVertices,
-                                    v59 + v19[v31].x > sX) )
-                                ++v54;
-                            }
-                          }
-                          ++v57;
-                          v59 = v50;
-                          ++v21;
-                        }
-                        while ( v57 < *(&this->pFaces->uNumVertices + v45) );
-                        if ( v54 == 1 )
-                        {
-                          v35 = v55++;
-                          v43[v35] = v46;
-                        }
+                        int _a58;
+                        int _a59;
+
+                        v32 = v1->x - v2->x;
+                        LODWORD(v33) = v32 << 16;
+                        HIDWORD(v33) = v32 >> 16;
+                        _a58 = v33 / (v1->y - v2->y);
+                        _a59 = (unsigned __int64)(_a58 * (__int64)(sY - v2->y)) >> 16;
+
+                        if (v59 + pVertices[k].x > sX)
+                          ++v54;
+                      }
+                      else
+                      {
+                        int _a58;
+                        int _a59;
+                        v32 = v2->x - v1->x;
+                        LODWORD(v33) = v32 << 16;
+                        HIDWORD(v33) = v32 >> 16;
+                        _a58 = v33 / (v2->y - v1->y);
+                        _a59 = (unsigned __int64)(_a58 * (signed __int64)(sY - v1->y)) >> 16;
+
+                        if (_a59 + pVertices[k - 1].x > sX)
+                          ++v54;
                       }
                     }
-                    v11 = v48 + 1;
-                    v12 = v53 + 2;
-                    //v7 = __OFSUB__(v48 + 1, v51);
-                    //v6 = v48++ + 1 - v51 < 0;
-                    v53 += 2;
-                  }
-                  while ( ++v48 < v51 );
-                  v4 = v43[0];
-                }
-              }
+                   }
+                 }
+
+                 v59 = v50;
+               }
+
+               if (pFace->uNumVertices)
+               {
+                 if (v54 == 1)
+                 {
+                   v35 = v55++;
+                   v43[v35] = uFaceID;
+                 }
+               }
+             }
             }
+            v4 = v43[0];
           }
-        }
-      }
-    }
-    ++v56;
-    v52 += 116;
   }
-  while ( v56 < this->uNumSectors );
+
   if ( v55 == 1 )
     return this->pFaces[v4].uSectorID;
   v37 = 0;
@@ -4495,7 +4474,7 @@
   ptr_6A0D08 = 0;
   _6A0D0C_txt_lod_loading = 0;
   TryLoadLevelFromLOD();
-  uNumStationaryLightsApplied = 0;
+  pStationaryLightsStack->uNumLightsActive = 0;
   v4 = pIndoor->Load(
          pCurrentMapName,
          (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1,
@@ -4760,8 +4739,8 @@
   {
     pParty->sRotationX = 0;
     pParty->sRotationY = 0;
+    pParty->vPosition.z = 0;
     pParty->vPosition.y = 0;
-    pParty->vPosition.z = 0;
     pParty->vPosition.x = 0;
     pParty->uFallStartY = 0;
     pParty->uFallSpeed = 0;
--- a/Indoor.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/Indoor.h	Fri Oct 26 23:22:41 2012 +0600
@@ -185,7 +185,7 @@
   char uGreen;
   char uBlue;
   char uType;
-  __int16 uAtributes;
+  __int16 uAtributes;           // & 0x08    doesn't light faces
   __int16 uBrightness;
 };
 #pragma pack(pop)
@@ -250,6 +250,14 @@
 #pragma pack(pop)
 
 
+#define FACE_TWO_SIDED        0x00000001 // portal/two-sided
+#define FACE_TEXTURE_ANIMATED 0x00000010 // like wavy water
+#define FACE_INVISIBLE        0x00002000
+#define FACE_TEXTURE_FRAME    0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
+#define FACE_TEXTURE_FLOW     0x00040000 // The texture moves slowly. For horizontal facets only.
+#define FACE_CLICKABLE        0x02000000 // Event can be triggered by clicking on the facet.
+#define FACE_PRESSURE_PLATE   0x04000000 // Event can be triggered by stepping on the facet.
+#define FACE_ETHEREAL         0x20000000 // Untouchable. You can pass through it.
 
 /*   93 */
 #pragma pack(push, 1)
@@ -271,6 +279,11 @@
   struct Texture *GetTexture();
   void FromODM(struct ODMFace *a2);
 
+  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Visible() const   {return !Invisible();}
+  inline bool TwoSided() const  {return uAttributes & FACE_TWO_SIDED;}
+  inline bool Animated() const  {return uAttributes & FACE_TEXTURE_ANIMATED;}
+
 
   struct Plane_float_ pFacePlane;
   struct Plane_int_ pFacePlane_old;
@@ -328,7 +341,7 @@
 struct BLVSector
 {
   int field_0;
-  __int16 field_4;
+  unsigned __int16 uNumFloors;
   __int16 field_6;
   unsigned __int16 *pFloors;
   __int16 field_C;
@@ -360,7 +373,7 @@
   unsigned __int16 *pMarkers;
   __int16 uNumLights;
   __int16 field_56;
-  BLVLightMM7 *pLights;
+  unsigned __int16 *pLights;
   __int16 uWaterLevel;
   __int16 uMistLevel;
   __int16 uLightDistanceMultiplier;
@@ -510,14 +523,14 @@
 #pragma pack(push, 1)
 struct BLVRenderParams
 {
-  int Set(struct IndoorLocation_drawstru *a2);
+  int Reset(struct IndoorLocation_drawstru *a2);
 
   int field_0_timer_;
   int uFlags;
   Vec3_int_ vPartyPos;
   int sPartyRotY;
   int sPartyRotX;
-  int uRadius;
+  int uPartySectorID;
   int sCosineY;
   int sSineY;
   int sCosineNegX;
@@ -542,7 +555,7 @@
   int uViewportCenterX;
   int uViewportCenterY;
   struct stru170_stru2 *field_7C;
-  int field_80;
+  unsigned int uNumFacesRenderedThisFrame;
   int field_84;
   int field_88;
   int field_8C;
--- a/IndoorCamera.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/IndoorCamera.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -41,14 +41,14 @@
   v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
   if ( sRotationX )
   {
-    v6 = v5;
+    v6 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
     a1->vWorldViewPosition.x = v5 * fRotationXCosine + fRotationXSine * vCamToVertexZ;
     a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
     a1->vWorldViewPosition.z = v8 * vCamToVertexZ - v6 * v7;
   }
   else
   {
-    a1->vWorldViewPosition.x = v5;
+    a1->vWorldViewPosition.x = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
     a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
     a1->vWorldViewPosition.z = vCamToVertexZ;
   }
@@ -75,38 +75,38 @@
 //----- (004239A7) --------------------------------------------------------
 void IndoorCamera::Initialize2()
 {
-  IndoorCamera *v1; // esi@1
+  //IndoorCamera *v1; // esi@1
   double v2; // st7@4
-  double v3; // st7@6
-  int v4; // eax@6
-  int v5; // eax@6
-  int v6; // ST04_4@6
-  int v7; // eax@6
-  int v8; // ST04_4@6
+  //double v3; // st7@6
+  //int v4; // eax@6
+  //int v5; // eax@6
+  //int v6; // ST04_4@6
+  //int v7; // eax@6
+  //int v8; // ST04_4@6
 
-  v1 = this;
-  this->fRotationYSine = sin((3.141592653589793 + 3.141592653589793) * (double)this->sRotationY * 0.00048828125);
-  v1->fRotationYCosine = cos((3.141592653589793 + 3.141592653589793) * (double)v1->sRotationY * 0.00048828125);
+  //v1 = this;
+  fRotationYSine = sin((3.141592653589793 + 3.141592653589793) * (double)sRotationY * 0.00048828125);
+  fRotationYCosine = cos((3.141592653589793 + 3.141592653589793) * (double)sRotationY * 0.00048828125);
   if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    v1->fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)-v1->sRotationX * 0.00048828125);
-    v2 = (3.141592653589793 + 3.141592653589793) * (double)-v1->sRotationX;
+    fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)-sRotationX * 0.00048828125);
+    v2 = (3.141592653589793 + 3.141592653589793) * (double)-sRotationX;
   }
   else
   {
-    v1->fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)v1->sRotationX * 0.00048828125);
-    v2 = (3.141592653589793 + 3.141592653589793) * (double)v1->sRotationX;
+    fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)sRotationX * 0.00048828125);
+    v2 = (3.141592653589793 + 3.141592653589793) * (double)sRotationX;
   }
-  v3 = cos(v2 * 0.00048828125);
-  v4 = v1->sRotationY;
-  v1->fRotationXCosine = v3;
-  v5 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi);
-  v6 = v1->sRotationY;
-  v1->_int_sine = v5;
-  v1->_int_cosine = stru_5C6E00->SinCos(v6);
-  v7 = stru_5C6E00->SinCos(v1->sRotationX - stru_5C6E00->uIntegerHalfPi);
-  v8 = v1->sRotationX;
-  v1->_int_sine_2 = v7;
-  v1->_int_cosine_2 = stru_5C6E00->SinCos(v8);
+  //v3 = cos(v2 * 0.00048828125);
+  //v4 = sRotationY;
+  fRotationXCosine = cos(v2 * 0.00048828125);
+  //v5 = stru_5C6E00->SinCos(sRotationY - stru_5C6E00->uIntegerHalfPi);
+  //v6 = sRotationY;
+  _int_sine = stru_5C6E00->SinCos(sRotationY - stru_5C6E00->uIntegerHalfPi);
+  _int_cosine = stru_5C6E00->SinCos(sRotationY);
+  //v7 = stru_5C6E00->SinCos(sRotationX - stru_5C6E00->uIntegerHalfPi);
+  //v8 = sRotationX;
+  _int_sine_2 = stru_5C6E00->SinCos(sRotationX - stru_5C6E00->uIntegerHalfPi);
+  _int_cosine_2 = stru_5C6E00->SinCos(sRotationX);
 }
 // 4D864C: using guessed type char byte_4D864C;
\ No newline at end of file
--- a/IndoorCameraD3D.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/IndoorCameraD3D.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -13,31 +13,18 @@
 
 
 //----- (004364C5) --------------------------------------------------------
-void IndoorCameraD3D::_4364C5(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *a1, stru320 *a5)
+void IndoorCameraD3D::ViewTransfrom_OffsetUV(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutVertices, stru320 *a5)
 {
-  unsigned int v5; // ebx@1
-  char *v6; // edx@2
-  char *v7; // eax@2
-
-  v5 = uNumVertices;
-  if ( (signed int)uNumVertices > 0 )
+  for (uint i = 0; i < uNumVertices; ++i)
   {
-    v6 = (char *)&a1->vWorldPosition.z;
-    v7 = (char *)&pVertices->vWorldPosition.z;
-    do
-    {
-      *((int *)v6 - 2) = *((int *)v7 - 2);
-      *((int *)v6 - 1) = *((int *)v7 - 1);
-      *(int *)v6 = *(int *)v7;
-      v7 += 48;
-      v6 += 48;
-      --v5;
-      *((float *)v6 - 5) = (double)a5->pDeltaUV[0] + *((float *)v7 - 5);
-      *((float *)v6 - 4) = (double)a5->pDeltaUV[1] + *((float *)v7 - 4);
-    }
-    while ( v5 );
+    pOutVertices[i].vWorldPosition.x = pVertices[i].vWorldPosition.x;
+    pOutVertices[i].vWorldPosition.y = pVertices[i].vWorldPosition.y;
+    pOutVertices[i].vWorldPosition.z = pVertices[i].vWorldPosition.z;
+
+    pOutVertices[i].u = pVertices[i].u + a5->pDeltaUV[0];
+    pOutVertices[i].v = pVertices[i].v + a5->pDeltaUV[1];
   }
-  ViewTransform(a1, uNumVertices);
+  ViewTransform(pOutVertices, uNumVertices);
 }
 
 //----- (0043669D) --------------------------------------------------------
@@ -108,153 +95,216 @@
 
 
 //----- (00436455) --------------------------------------------------------
-bool IndoorCameraD3D::IsFaceFacedTowardsCamera(BLVFace *pFace)
+bool IndoorCameraD3D::IsCulled(BLVFace *pFace)
 {
-  IndoorCameraD3D *v2; // edi@1
-  bool result; // eax@1
   RenderVertexSoft v; // [sp+8h] [bp-30h]@1
 
-  v2 = this;
   Vec3_short__to_RenderVertexSoft(&v, &pIndoor->pVertices[*pFace->pVertexIDs]);
-  LOBYTE(result) = is_vertex_with_normal_from_face_towards_camera(pFace, &v);
-  return result;
+  return is_face_faced_to_camera(pFace, &v);
 }
 
 //----- (00436523) --------------------------------------------------------
 void IndoorCameraD3D::ViewTransform(RenderVertexSoft *a1a, unsigned int uNumVertices)
 {
-  __debugbreak();
-  /*
-  unsigned int v3; // esi@4
-  unsigned int v4; // ecx@7
-  float v7; // [sp+4h] [bp-4h]@7
-
-  auto a1 = this;
-  if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
+  if (byte_4D864C && pGame->uFlags & 0x80 ||
+      uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    __asm
-    {
-      fld     pIndoorCamera->fRotationYCosine
-      fld     pIndoorCamera->fRotationYSine
-      fld     pIndoorCamera->fRotationXCosine
-    }
-    v4 = uNumVertices;
-    v7 = pIndoorCamera->fRotationXSine;
+    float sin_x = pIndoorCamera->fRotationXSine,
+          cos_x = pIndoorCamera->fRotationXCosine;
+    float sin_y = pIndoorCamera->fRotationYSine,
+          cos_y = pIndoorCamera->fRotationYCosine;
+
+    //v4 = uNumVertices;
+    //v7 = pIndoorCamera->fRotationXSine;
     if ( pIndoorCamera->sRotationX )
     {
-      if ( (signed int)uNumVertices > 0 )
-      {
-        _EAX = a1a;
-        do
-        {
-          __asm
-          {
-            fild    pIndoorCamera->pos.x
-            fsubr   dword ptr [eax]
-            fstp    [ebp+a1]
-            fild    pIndoorCamera->pos.y
-            fsubr   dword ptr [eax+4]
-            fstp    [ebp+uNumVertices]
-            fild    pIndoorCamera->pos.z
-            fsubr   dword ptr [eax+8]
-          }
+
+        //_EAX = a1a;
+    for (uint i = 0; i < uNumVertices; ++i)
+    {
+          float st0, st1, st2;
           if ( pRenderer->pRenderD3D )
           {
-            __asm
+            /*__asm
             {
-              fld     [ebp+uNumVertices]
-              fmul    st, st(3)
-              fld     [ebp+a1]
-              fmul    st, st(5)
-              faddp   st(1), st
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(6)
-              fsubp   st(1), st
-            }
+              fld     [ebp+uNumVertices] // [(a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fmul    st, st(3)          // [pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fld     [ebp+a1]           // [(a1a[i].x - pIndoorCamera->pos.x)]   [pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fmul    st, st(5)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              faddp   st(1), st          // [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fld     [ebp+a1]           // [(a1a[i].x - pIndoorCamera->pos.x)]   [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // [pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]   [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+
+              fld     [ebp+uNumVertices] // 0[a1a[i].y - pIndoorCamera->pos.y]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+
+              fmul    st, st(6)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+
+              fsubp   st(1), st          // 0[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+            }*/
+            st0 = sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            st2 = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z);
           }
           else
           {
-            __asm
+            /*__asm
             {
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(4)
-              fsubp   st(1), st
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(6)
-              faddp   st(1), st
-            }
+              fld     [ebp+a1]           // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 2[pIndoorCamera->fRotationXCosine]
+                                         // 3[pIndoorCamera->fRotationYSine]
+                                         // 4[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 2[pIndoorCamera->fRotationXCosine]
+                                         // 3[pIndoorCamera->fRotationYSine]
+                                         // 4[pIndoorCamera->fRotationYCosine]
+              fld     [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // 0[pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fsubp   st(1), st          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 2[pIndoorCamera->fRotationXCosine]
+                                         // 3[pIndoorCamera->fRotationYSine]
+                                         // 4[pIndoorCamera->fRotationYCosine]
+              fld     [ebp+a1]           // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // 0[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fld     [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(6)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+              faddp   st(1), st          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y) + pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+            }*/
+            st0 = cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y) + sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x);
+            st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            st2 = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z);
           }
-          __asm
-          {
-            fld     st(1)
-            fmul    st, st(4)
-            fld     st(3)
-            fmul    [ebp+var_4]
-          }
-          ++_EAX;
-          --v4;
-          __asm
-          {
-            fsubp   st(1), st
-            fstp    dword ptr [eax-24h]
-            fstp    dword ptr [eax-20h]
-            fmul    [ebp+var_4]
-            fld     st(1)
-            fmul    st, st(3)
-            faddp   st(1), st
-            fstp    dword ptr [eax-1Ch]
-            fstp    st
-          }
-        }
-        while ( v4 );
+
+          a1a[i].vWorldViewPosition.x = st1*cos_x - st2*sin_x;
+          a1a[i].vWorldViewPosition.y = st0;
+          a1a[i].vWorldViewPosition.z = st2*cos_x + st1*sin_x;
       }
-      __asm { fstp    st }
     }
     else
     {
-      __asm { fstp    st }
-      if ( (signed int)uNumVertices > 0 )
+      for (uint i = 0; i < uNumVertices; ++i)
       {
-        _EAX = a1a;
-        do
-        {
-          __asm
-          {
-            fild    pIndoorCamera->pos.x
-            fsubr   dword ptr [eax]
-            fstp    [ebp+a1]
-            fild    pIndoorCamera->pos.y
-            fsubr   dword ptr [eax+4]
-            fstp    [ebp+uNumVertices]
-            fild    pIndoorCamera->pos.z
-            fsubr   dword ptr [eax+8]
-          }
           if ( pRenderer->pRenderD3D )
           {
-            __asm
+            /*__asm
             {
-              fld     [ebp+uNumVertices]
-              fmul    st, st(2)
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              faddp   st(1), st
+              fld     [ebp+uNumVertices]   // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fmul    st, st(2)            // 0[sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fld     [ebp+a1]             // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              fmul    st, st(4)            // 0[cos_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              faddp   st(1), st            // 0[cos_y * (a1a[i].x - pIndoorCamera->pos.x) + sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
               fstp    dword ptr [eax+0Ch]
-              fld     [ebp+a1]
-              fmul    st, st(2)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(4)
-              fsubp   st(1), st
-            }
+              fld     [ebp+a1]             // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fmul    st, st(2)            // 0[sin_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fld     [ebp+uNumVertices]   // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[sin_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              fmul    st, st(4)            // 0[cos_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[sin_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              fsubp   st(1), st            // 0[sin_y * (a1a[i].x - pIndoorCamera->pos.x) - cos_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fstp    dword ptr [eax+10h]
+              fstp    dword ptr [eax+14h]
+            }*/
+            a1a[i].vWorldViewPosition.x = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            a1a[i].vWorldViewPosition.y = sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            a1a[i].vWorldViewPosition.z = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z);
           }
           else
           {
-            __asm
+            __debugbreak();
+            /*__asm
             {
               fld     [ebp+a1]
               fmul    st, st(3)
@@ -267,101 +317,95 @@
               fld     [ebp+uNumVertices]
               fmul    st, st(4)
               faddp   st(1), st
-            }
+
+              fstp    dword ptr [eax+10h]
+              fstp    dword ptr [eax+14h]
+            }*/
           }
-          __asm
-          {
-            fstp    dword ptr [eax+10h]
-            fstp    dword ptr [eax+14h]
-          }
-          ++_EAX;
-          --v4;
-        }
-        while ( v4 );
       }
     }
-    __asm
-    {
-      fstp    st
-      fstp    st
-    }
   }
-  else
-  {
-    v3 = uNumVertices;
-    if ( (signed int)uNumVertices > 0 )
-    {
-      do
-      {
-        :ViewTransform(a1a);
-        ++a1a;
-        --v3;
-      }
-      while ( v3 );
-    }
-  }*/
+  else for (uint i = 0; i < uNumVertices; ++i)
+    pIndoorCamera->ViewTransform(a1a + i);
 }
 
 
 //----- (00436932) --------------------------------------------------------
-char IndoorCameraD3D::GetFacetOrientation(char a1, Vec3_float_ *a2, Vec3_float_ *a3, Vec3_float_ *a4)
+bool IndoorCameraD3D::GetFacetOrientation(char polyType, Vec3_float_ *a2, Vec3_float_ *a3, Vec3_float_ *a4)
 {
-  Vec3_float_ *v5; // eax@9
-  double v6; // st7@9
-
-  if ( a1 == 1 )
+  switch ((PolygonType)polyType)
   {
-    a4->x = -a2->y;
-    a4->y = a2->x;
-    a4->z = 0.0;
-LABEL_9:
-    v5 = a3;
-    a3->x = 0.0;
-    a3->y = 0.0;
-    v6 = 1.0;
-LABEL_11:
-    v5->z = v6;
-    return 1;
-  }
-  if ( a1 == 3 || a1 == 5 )
-  {
-LABEL_10:
-    a4->x = 1.0;
-    a4->y = 0.0;
-    a4->z = 0.0;
-    v5 = a3;
-    a3->x = 0.0;
-    a3->y = 1.0;
-    v6 = 0.0;
-    goto LABEL_11;
-  }
-  if ( a1 == 4 || a1 == 6 )
-  {
-    if ( fabs(a2->z) < 0.70811361 )
+    case POLYGON_VerticalWall:
     {
       a4->x = -a2->y;
       a4->y = a2->x;
       a4->z = 0.0;
-      a4->Normalize();
-      goto LABEL_9;
+
+      a3->x = 0.0;
+      a3->y = 0.0;
+      a3->z = 1.0f;
+    }
+    return true;
+
+    case POLYGON_Floor:
+    case POLYGON_Ceiling:
+    {
+      a4->x = 1.0;
+      a4->y = 0.0;
+      a4->z = 0.0;
+
+      a3->x = 0.0;
+      a3->y = 1.0;
+      a3->z = 0.0;
     }
-    goto LABEL_10;
+    return true;
+
+    case POLYGON_InBetweenFloorAndWall:
+    case POLYGON_InBetweenCeilingAndWall:
+    {
+      if (fabs(a2->z) < 0.70811361)
+      {
+        a4->x = -a2->y;
+        a4->y = a2->x;
+        a4->z = 0.0;
+        a4->Normalize();
+
+        a3->x = 0.0;
+        a3->y = 0.0;
+        a3->z = 1.0;
+      }
+      else
+      {
+        a4->x = 1.0;
+        a4->y = 0.0;
+        a4->z = 0.0;
+
+        a3->x = 0.0;
+        a3->y = 1.0;
+        a3->z = 0.0;
+      }
+    }
+    return true;
+
+    default:
+      return false;
   }
-  return 1;
 }
 
 
 //----- (00438258) --------------------------------------------------------
-bool IndoorCameraD3D::is_vertex_with_normal_from_face_towards_camera(BLVFace *pFace, RenderVertexSoft *a2)
+bool IndoorCameraD3D::is_face_faced_to_camera(BLVFace *pFace, RenderVertexSoft *a2)
 {
-  char result; // al@2
+  if (pFace->TwoSided())
+    return false;
 
+  //really strange cull; dot(to_cam, normal) < 0 means we see the BACK face, not font %_%
   if ( (a2->vWorldPosition.z - (double)pIndoorCamera->pos.z) * (double)pFace->pFacePlane_old.vNormal.z
      + (a2->vWorldPosition.y - (double)pIndoorCamera->pos.y) * (double)pFace->pFacePlane_old.vNormal.y
-     + (a2->vWorldPosition.x - (double)pIndoorCamera->pos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0
-    || (result = 1, pFace->uAttributes & 1) )
-    result = 0;
-  return result;
+     + (a2->vWorldPosition.x - (double)pIndoorCamera->pos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0)
+    return false;
+
+  return true;
 }
 
 //----- (00438250) --------------------------------------------------------
@@ -562,7 +606,7 @@
   while ( v10 < 1 );
   if ( v10 < 1 )
   {
-    _436BB7_project_and_stuff(vert, 1u, 0);
+    Project(vert, 1u, 0);
 LABEL_15:
     pD3DVertices[0].pos.x = vert[0].vWorldViewProjX;
     pD3DVertices[0].pos.y = vert[0].vWorldViewProjY;
@@ -815,7 +859,7 @@
       || (signed int)uOutNumVertices >= 2 )
     {
       ViewTransform(pVertices, 2u);
-      _436BB7_project_and_stuff(pVertices, 2u, 0);
+      Project(pVertices, 2u, 0);
       goto LABEL_11;
     }
   }
@@ -930,7 +974,7 @@
 
 
 //----- (004378BA) --------------------------------------------------------
-void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *a3)
+void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *out)
 {
   float *v4; // ecx@1
   float *v5; // eax@1
@@ -941,7 +985,7 @@
   double v10; // st7@3
   double v11; // st6@3
 
-  v4 = (float *)a3;
+  v4 = (float *)out;
   v5 = &a1->_12;
   v6 = 3;
   do
@@ -970,162 +1014,125 @@
 //----- (004376E7) --------------------------------------------------------
 void IndoorCameraD3D::CreateWorldMatrixAndSomeStuff()
 {
-  IndoorCameraD3D *v1; // esi@1
+  //IndoorCameraD3D *v1; // esi@1
   double v2; // st7@1
-  signed int v3; // edi@1
-  int v4; // eax@1
-  double v5; // st7@2
-  double v6; // st7@3
-  Matrix3x3_float_ a3; // [sp+10h] [bp-B8h]@1
-  Matrix3x3_float_ v8; // [sp+34h] [bp-94h]@1
-  Matrix3x3_float_ a2; // [sp+58h] [bp-70h]@1
-  Matrix3x3_float_ v10; // [sp+7Ch] [bp-4Ch]@1
-  Matrix3x3_float_ a1; // [sp+A0h] [bp-28h]@1
+  //signed int v3; // edi@1
+  //int v4; // eax@1
+  //double v5; // st7@2
+  //double v6; // st7@3
+  Matrix3x3_float_ m1; // [sp+10h] [bp-B8h]@1
+  Matrix3x3_float_ m2; // [sp+34h] [bp-94h]@1
+  Matrix3x3_float_ m3; // [sp+58h] [bp-70h]@1
+  Matrix3x3_float_ m4; // [sp+7Ch] [bp-4Ch]@1
+  Matrix3x3_float_ m5; // [sp+A0h] [bp-28h]@1
   float v12; // [sp+C4h] [bp-4h]@1
 
-  v1 = this;
-  a1._13 = 0.0;
-  a1._23 = 0.0;
-  a1._31 = 0.0;
-  a1._32 = 0.0;
-  a1._33 = 1.0;
-  v10._11 = 1.0;
-  v10._12 = 0.0;
-  v10._13 = 0.0;
-  v10._21 = 0.0;
-  v10._31 = 0.0;
-  a2._12 = 0.0;
-  a2._21 = 0.0;
-  a2._22 = 1.0;
-  a2._23 = 0.0;
-  a2._32 = 0.0;
-  v12 = cos(0.0);
-  v2 = sin(0.0);
-  a1._11 = v12;
-  a1._12 = v2;
-  a1._21 = -v2;
-  a1._22 = v12;
-  v10._22 = pIndoorCamera->fRotationXCosine;
-  v10._32 = -pIndoorCamera->fRotationXSine;
-  v10._23 = pIndoorCamera->fRotationXSine;
-  v10._33 = pIndoorCamera->fRotationXCosine;
-  a2._11 = pIndoorCamera->fRotationYCosine;
-  a2._13 = -pIndoorCamera->fRotationYSine;
-  a2._31 = pIndoorCamera->fRotationYSine;
-  a2._33 = pIndoorCamera->fRotationYCosine;
-  MatrixMultiply(&a1, &a2, &a3);
-  MatrixMultiply(&v10, &a3, &v8);
-  v3 = 0;
-  v4 = (int)&v1->field_4.x;
-  do
+ //RotationZ(0)
+  m5._11 = cosf(0);         m5._12 = sinf(0);        m5._13 = 0;
+  m5._21 = -sinf(0);        m5._22 = cosf(0);        m5._23 = 0;
+  m5._31 = 0;               m5._32 = 0;              m5._33 = 1;
+
+  float cos_x1 = pIndoorCamera->fRotationXCosine,
+        sin_x1 = pIndoorCamera->fRotationXSine;
+ //RotationX(x)
+  m4._11 = 1;               m4._12 = 0;              m4._13 = 0;
+  m4._21 = 0;               m4._22 = cos_x1;         m4._23 = sin_x1;
+  m4._31 = 0;               m4._32 = -sin_x1;        m4._33 = cos_x1;
+  
+  float cos_y1 = pIndoorCamera->fRotationYCosine,
+        sin_y1 = pIndoorCamera->fRotationYSine;
+ //RotationY(some_angle)
+  m3._11 = cos_y1;          m3._12 = 0;              m3._13 = -sin_y1;
+  m3._21 = 0;               m3._22 = 1;              m3._23 = 0;
+  m3._31 = sin_y1;          m3._32 = 0;              m3._33 = cos_y1;
+
+  MatrixMultiply(&m5, &m3, &m1);
+  MatrixMultiply(&m4, &m1, &m2);
+
+  for (uint i = 0; i < 3; ++i)
   {
-    v5 = *(&v8._11 + v3++);
-    *(float *)(v4 + 16) = v5;
-    *(float *)v4 = *(float *)((char *)&v8._12 - (char *)v1 + v4);
-    *(float *)(v4 + 32) = *(float *)((char *)&v8._22 - (char *)v1 + v4);
-    v4 += 4;
+    field_4[0].v[i] = m2.v[1][i];
+    field_4[1].v[i] = m2.v[0][i];
+    field_4[2].v[i] = m2.v[2][i];
   }
-  while ( v3 < 3 );
-  LODWORD(v1->field_D8) = 0x3F91361Du;
-  v1->flt_D0 = (double)pViewport->uScreenWidth * 0.8814736;
-  v6 = 0.8814736 * (double)pViewport->uScreenHeight;
-  v1->flt_D4 = v6;
-  if ( v1->flt_D0 > v6 )
-    v6 = v1->flt_D0;
-  v1->flt_fov = v6;
-  v1->field_C8 = (double)pViewport->uScreenCenterX;
-  v1->field_CC = (double)(pViewport->uScreenCenterY - pViewport->uScreenY);
+
+  inv_fov = 1.1344639;
+  fov_x = (double)pViewport->uScreenWidth * 0.8814736;
+
+  fov_y = 0.8814736 * (double)pViewport->uScreenHeight;
+  fov = fov_y;
+  if ( fov_x > fov )
+    fov = fov_x;
+  screenCenterX = (double)pViewport->uScreenCenterX;
+  screenCenterY = (double)(pViewport->uScreenCenterY - pViewport->uScreenY);
 }
 
 
 //----- (00437691) --------------------------------------------------------
-IndoorCameraD3D_Vec3 *IndoorCameraD3D::Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut)
+void IndoorCameraD3D::Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut)
 {
-  IndoorCameraD3D_Vec3 *result; // eax@1
-
-  result = (IndoorCameraD3D_Vec3 *)pVector;
-  pOut->y = this->field_14.x * pVector->x + this->field_4.x * pVector->y + this->field_24.x * pVector->z;
-  pOut->z = this->field_14.y * result->x + this->field_4.y * result->y + this->field_24.y * result->z;
-  pOut->x = this->field_14.z * result->x + this->field_4.z * result->y + this->field_24.z * pVector->z;
-  return result;
+  pOut->y = field_4[1].x * pVector->x + field_4[0].x * pVector->y + field_4[2].x * pVector->z;
+  pOut->z = field_4[1].y * pVector->x + field_4[0].y * pVector->y + field_4[2].y * pVector->z;
+  pOut->x = field_4[1].z * pVector->x + field_4[0].z * pVector->y + field_4[2].z * pVector->z;
 }
 
 //----- (00437607) --------------------------------------------------------
 void IndoorCameraD3D::_437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2)
 {
-  IndoorCameraD3D *v3; // edi@1
   double v4; // st7@1
-  signed int v5; // ecx@1
-  char *v6; // eax@1
-  double v7; // st6@2
   IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1
-  Vec3_float_ v9; // [sp+Ch] [bp-18h]@1
-  int v10; // [sp+20h] [bp-4h]@1
 
-  v3 = this;
-  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v8);
-  v10 = 0;
-  v9.x = (double)pIndoorCamera->pos.x;
-  v9.y = (double)pIndoorCamera->pos.y;
-  v9.z = (double)pIndoorCamera->pos.z;
+  v8.x = (double)pIndoorCamera->pos.x;
+  v8.y = (double)pIndoorCamera->pos.y;
+  v8.z = (double)pIndoorCamera->pos.z;
   Vec3Transform(a1, a2);
-  v4 = 0.0;
-  v5 = 0;
-  v6 = (char *)&a2->x;
-  do
-  {
-    v7 = *(&v9.x + v5++) * *(float *)v6;
-    v6 += 4;
-    v4 = v4 + v7;
-  }
-  while ( v5 < 3 );
-  v10 = -1;
+
+  v4 = v8.x * a2->x + v8.y * a2->y + v8.z * a2->z;
   a2->dot = v4 + 0.000099999997;
-  //IndoorCameraD3D_Vec3::dtor(&v8);
 }
 
 //----- (004374E8) --------------------------------------------------------
 void IndoorCameraD3D::_4374E8_ProllyBuildFrustrum()
 {
-  IndoorCameraD3D *v1; // esi@1
-  double v2; // st7@1
+  //IndoorCameraD3D *v1; // esi@1
+  //double v2; // st7@1
   double v3; // st7@1
-  double v4; // st7@1
+  //double v4; // st7@1
   double v5; // st7@1
-  double v6; // st7@1
+  //double v6; // st7@1
   IndoorCameraD3D_Vec3 v7; // [sp+Ch] [bp-24h]@1
-  float v8; // [sp+10h] [bp-20h]@1
-  float v9; // [sp+14h] [bp-1Ch]@1
-  float v10; // [sp+18h] [bp-18h]@1
-  float v11; // [sp+1Ch] [bp-14h]@1
-  float v12; // [sp+20h] [bp-10h]@1
-  int v13; // [sp+2Ch] [bp-4h]@1
+  //float v8; // [sp+10h] [bp-20h]@1
+  //float v9; // [sp+14h] [bp-1Ch]@1
+  //float v10; // [sp+18h] [bp-18h]@1
+  //float v11; // [sp+1Ch] [bp-14h]@1
+  //float v12; // [sp+20h] [bp-10h]@1
+  //int v13; // [sp+2Ch] [bp-4h]@1
 
-  v1 = this;
+  //v1 = this;
   //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v7);
-  v2 = 2.0 / v1->field_D8;
-  v13 = 0;
-  v3 = atan(v2 * v1->flt_fov / v1->flt_D0);
-  v12 = v3;
-  v11 = sin(v3);
-  v4 = cos(v12);
-  v8 = -v11;
-  v9 = 0.0;
-  v10 = v4;
-  _437607(&v7, v1->std__vector_000034_prolly_frustrum);
-  v8 = v11;
-  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[1]);
-  v5 = atan(2.0 / v1->field_D8 * v1->flt_fov / (v1->flt_D4 + 0.5));
-  v12 = v5;
-  v11 = sin(v5);
-  v6 = cos(v12);
-  v9 = v11;
-  v8 = 0.0;
-  v10 = v6;
-  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[2]);
-  v9 = -v11;
-  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[3]);
-  v13 = -1;
+  //v2 = 2.0 / inv_fov;
+  //v13 = 0;
+  v3 = atan(2.0 / inv_fov * fov / fov_x);
+  //v12 = v3;
+  //v11 = sin(v3);
+  //v4 = cos(v3);
+  v7.x = -sin(v3);
+  v7.y = 0.0;
+  v7.z = cos(v3);
+  _437607(&v7, std__vector_000034_prolly_frustrum);
+  v7.x = sin(v3);
+  _437607(&v7, &std__vector_000034_prolly_frustrum[1]);
+  v5 = atan(2.0 / inv_fov * fov / (fov_y + 0.5));
+  //v12 = v5;
+  //v11 = sin(v5);
+  //v6 = cos(v5);
+  v7.y = sin(v5);
+  v7.x = 0.0;
+  v7.z = cos(v5);
+  _437607(&v7, &std__vector_000034_prolly_frustrum[2]);
+  v7.y = -sin(v5);
+  _437607(&v7, &std__vector_000034_prolly_frustrum[3]);
+  //v13 = -1;
   //IndoorCameraD3D_Vec3::dtor(&v7);
 }
 
@@ -1155,9 +1162,9 @@
   if ( (signed int)*pOutNumVertices <= 3
     || ((v5 = a2,
          memcpy(&v18, a2, sizeof(v18)),
-         (v18.vWorldPosition.z - (double)pBLVRenderParams->vPartyPos.z) * thisa->vNormal.z
-       + (v18.vWorldPosition.y - (double)pBLVRenderParams->vPartyPos.y) * thisa->vNormal.y
-       + (v18.vWorldPosition.x - (double)pBLVRenderParams->vPartyPos.x) * thisa->vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0),
+         (v18.vWorldPosition.z - (double)pBLVRenderParams->vPartyPos.z) * thisa->face_plane.vNormal.z
+       + (v18.vWorldPosition.y - (double)pBLVRenderParams->vPartyPos.y) * thisa->face_plane.vNormal.y
+       + (v18.vWorldPosition.x - (double)pBLVRenderParams->vPartyPos.x) * thisa->face_plane.vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0),
         a2_3 = 0,
         memcpy(&v5[v4], v5, sizeof(v5[v4])),
         memcpy(&v5[*pOutNumVertices + 1], &v5[1], sizeof(v5[*pOutNumVertices + 1])),
@@ -1249,7 +1256,7 @@
   v11 = 2 * (a6 == 0) + 1;
   //a6a = 0;
   v18 = v11;
-  if ( uNumVertices <= 0 )
+  if (uNumVertices <= 0)
     return false;
 
     //v12 = *pOutNumVertices;
@@ -1257,7 +1264,7 @@
   uint i = 0;
     while ( 1 )
     {
-      if (i % 2 )
+      if (i % 2)
       {
         v14 = a1;
         v15 = sr_vertices_50D9D8;
@@ -1267,19 +1274,18 @@
         v15 = a1;
         v14 = sr_vertices_50D9D8;
       }
-      ++i;
-      if (i == uNumVertices )
+      if (i == uNumVertices - 1)
         v14 = pVertices;
       a5.x = a4[i].x;
       a5.y = a4[i].y;
       a5.z = a4[i].z;
       pGame->pStru9Instance->_4985FB(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused);
       //v12 = *pOutNumVertices;
-      if ( (signed int)*pOutNumVertices < v18 )
+      if (*pOutNumVertices < v18)
         break;
       //result = a6a;
       //v13 += 24;
-      if (i >= uNumVertices)
+      if (++i >= uNumVertices)
         return a7a;
     }
     *pOutNumVertices = 0;
@@ -1385,7 +1391,7 @@
   return result;
 }
 //----- (00436F09) --------------------------------------------------------
-void IndoorCameraD3D::_436F09(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
+void IndoorCameraD3D::_436F09_mess_with_lightmap__clipflag_4(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
   unsigned int *pOutNumVertices_; // ebx@1
   double v6; // st7@2
@@ -1488,7 +1494,7 @@
 
 
 //----- (00436CDC) --------------------------------------------------------
-void IndoorCameraD3D::_436CDC(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
+void IndoorCameraD3D::_436CDC_mess_with_lightmap__clipflag_2(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
   signed int v5; // esi@2
   char *v6; // edx@5
@@ -1584,11 +1590,8 @@
 
 
 //----- (00436BB7) --------------------------------------------------------
-void IndoorCameraD3D::_436BB7_project_and_stuff(RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4)
+void IndoorCameraD3D::Project(RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4)
 {
-  unsigned int v4; // ebx@1
-  IndoorCameraD3D *v5; // edi@1
-  float *v6; // esi@2
   double v7; // st7@7
   double v8; // st7@9
   double v9; // st6@10
@@ -1599,65 +1602,59 @@
   float uNumVerticesa; // [sp+14h] [bp+Ch]@13
   float uNumVerticesb; // [sp+14h] [bp+Ch]@20
 
-  v4 = uNumVertices;
-  v5 = this;
-  if ( (signed int)uNumVertices > 0 )
+  for (uint i = 0; i < uNumVertices; ++i)
   {
-    v6 = &pVertices->vWorldViewProjX;
-    do
+    if (byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
     {
-      if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      {
-        v7 = 1.0 / *(v6 - 3);
-        *v6 = *(v6 - 2) * v5->flt_fov * v7 + v5->field_C8;
-        v6[1] = (double)(signed int)pViewport->uViewportW - (*(v6 - 1) * v5->flt_fov * v7 + v5->field_CC);
-      }
-      else
-      {
-        extern void _outdoor_project(RenderVertexSoft *v);
-        _outdoor_project((RenderVertexSoft *)(v6 - 6));
-      }
+      v7 = 1.0 / pVertices[i].vWorldViewPosition.x;
+
+      pVertices[i].vWorldViewProjX = pVertices[i].vWorldViewPosition.y * fov * v7 + screenCenterX;
+      pVertices[i].vWorldViewProjY = (signed int)pViewport->uViewportW - (pVertices[i].vWorldViewPosition.z * fov * v7 + screenCenterY);
+    }
+    else
+    {
+      extern void _outdoor_project(RenderVertexSoft *v);
+      _outdoor_project(pVertices + i);
+    }
+
       if ( a4 )
       {
+        __debugbreak();
         v8 = (double)(signed int)pViewport->uViewportZ;
-        if ( v8 >= *v6 )
-          v9 = *v6;
+        if ( v8 >= pVertices[i].vWorldViewProjX )
+          v9 = pVertices[i].vWorldViewProjX;
         else
           v9 = v8;
         v10 = (double)(signed int)pViewport->uViewportX;
         if ( v10 <= v9 )
         {
-          if ( v8 >= *v6 )
-            v8 = *v6;
+          if ( v8 >= pVertices[i].vWorldViewProjX)
+            v8 = pVertices[i].vWorldViewProjX;
         }
         else
         {
           uNumVerticesa = v10;
           v8 = uNumVerticesa;
         }
-        *v6 = v8;
+        pVertices[i].vWorldViewProjX = v8;
         v11 = (double)(signed int)pViewport->uViewportW;
-        if ( v11 >= v6[1] )
-          v12 = v6[1];
+        if ( v11 >= pVertices[i].vWorldViewProjY)
+          v12 = pVertices[i].vWorldViewProjY;
         else
           v12 = v11;
         v13 = (double)(signed int)pViewport->uViewportY;
         if ( v13 <= v12 )
         {
-          if ( v11 >= v6[1] )
-            v11 = v6[1];
+          if ( v11 >= pVertices[i].vWorldViewProjY)
+            v11 = pVertices[i].vWorldViewProjY;
         }
         else
         {
           uNumVerticesb = v13;
           v11 = uNumVerticesb;
         }
-        v6[1] = v11;
+        pVertices[i].vWorldViewProjY = v11;
       }
-      v6 += 12;
-      --v4;
-    }
-    while ( v4 );
   }
 }
 
@@ -1676,10 +1673,10 @@
   if ( pRenderer->pRenderD3D )
   {
     v6 = 1.0 / (double)x;
-    a2a = (double)y * flt_fov * v6 + field_C8;
+    a2a = (double)y * fov * v6 + screenCenterX;
     //v7 = a2a + 6.7553994e15;
     *a5 = floorf(a2a + 0.5f);
-    a2b = (double)z * flt_fov * v6 + field_CC;
+    a2b = (double)z * fov * v6 + screenCenterY;
     //v8 = a2b + 6.7553994e15;
     *a6 = pViewport->uViewportW - floorf(a2b + 0.5f);
   }
--- a/IndoorCameraD3D.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/IndoorCameraD3D.h	Fri Oct 26 23:22:41 2012 +0600
@@ -15,9 +15,17 @@
   //void ~IndoorCameraD3D_Vec3() {}
 
   void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D_Vec3 *, bool);
-  float x;
-  float y;
-  float z;
+
+  union
+  {
+    struct
+    {
+      float x;
+      float y;
+      float z;
+    };
+    float v[3];
+  };
 };
 #pragma pack(pop)
 
@@ -121,16 +129,16 @@
   double GetPolygonMinZ(struct RenderVertexSoft *pVertices, unsigned int uStripType);
   struct IDirect3DTexture2 *LoadTextureAndGetHardwarePtr(char *Str1);
   void Project(signed int x, signed int y, signed int z, int *a5, int *a6);
-  void _436BB7_project_and_stuff(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4);
-  void _436CDC(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
-  void _436F09(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
+  void Project(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4);
+  void _436CDC_mess_with_lightmap__clipflag_2(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
+  void _436F09_mess_with_lightmap__clipflag_4(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
   int _437143(unsigned int uNumInVertices, struct RenderVertexSoft *pOutVertices, struct RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices);
   bool _4371C3(struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused);
   bool _437285_prolly_colide_vertices_against_frustrum(struct RenderVertexSoft *a1, unsigned int *pOutNumVertices, struct RenderVertexSoft *pVertices, IndoorCameraD3D_Vec4 *a4, signed int uNumVertices, char a6, int _unused);
   char _437376(struct stru154 *thisa, struct RenderVertexSoft *a2, unsigned int *pOutNumVertices);
   void _4374E8_ProllyBuildFrustrum();
   void _437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2);
-  IndoorCameraD3D_Vec3 *Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut);
+  void Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut);
   void CreateWorldMatrixAndSomeStuff();
   void MatrixMultiply(struct Matrix3x3_float_ *a1, struct Matrix3x3_float_ *a2, struct Matrix3x3_float_ *a3);
   void PrepareAndDrawDebugOutline(struct BLVFace *pFace, unsigned int uDiffuse);
@@ -142,24 +150,24 @@
   void _438141_draw_list_0037C();
   void _438240_draw_lits();
   void Reset_list_0037C();
-  bool is_vertex_with_normal_from_face_towards_camera(struct BLVFace *pFace, struct RenderVertexSoft *a2);
-  char GetFacetOrientation(char a1, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4);
+  bool is_face_faced_to_camera(struct BLVFace *pFace, struct RenderVertexSoft *a2);
+  bool GetFacetOrientation(char polyType, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4);
   void ViewTransform(struct RenderVertexSoft *a1a, unsigned int uNumVertices);
-  bool IsFaceFacedTowardsCamera(struct BLVFace *pFace);
-  void _4364C5(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *a1, struct stru320 *a5);
+  bool IsCulled(struct BLVFace *pFace);
+  void ViewTransfrom_OffsetUV(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pOutVertices, struct stru320 *a5);
   char ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow);
 
   void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D *, bool);
-  IndoorCameraD3D_Vec3 field_4;
-  IndoorCameraD3D_Vec3 field_14;
-  IndoorCameraD3D_Vec3 field_24;
+  IndoorCameraD3D_Vec3 field_4[3];
+  //IndoorCameraD3D_Vec3 field_14;
+  //IndoorCameraD3D_Vec3 field_24;
   IndoorCameraD3D_Vec4 std__vector_000034_prolly_frustrum[6];
-  float flt_fov;
-  float field_C8;
-  float field_CC;
-  float flt_D0;
-  float flt_D4;
-  float field_D8;
+  float fov;
+  float screenCenterX;
+  float screenCenterY;
+  float fov_x;
+  float fov_y;
+  float inv_fov;
   float field_DC;
   float field_E0;
   float field_E4;
--- a/Indoor_stuff.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/Indoor_stuff.h	Fri Oct 26 23:22:41 2012 +0600
@@ -161,7 +161,7 @@
   Plane_int_ plane_4;
   Vec3_int_ vec_14;
   Vec3_int_ vec_20;
-  int field_2C;
+  unsigned int uCurrentAmbientLightLevel;
   int field_30;
   int field_34;
   int field_38;
@@ -179,7 +179,7 @@
   int field_98;
   Vec3_int_ vec_9C;
   int field_A8;
-  int field_AC;
+  unsigned int uNumLightsApplied;
   int _blv_lights_radii[20];
   int _blv_lights_inv_radii[20];
   int _blv_lights_xs[20];
@@ -209,13 +209,13 @@
   float _blv_lights_rs[20];
   float _blv_lights_gs[20];
   float _blv_lights_bs[20];
-  char _blv_lights_smthngs[20];
+  char _blv_lights_types[20];
   int field_3E4;
   int field_3E8;
   int field_3EC;
   int field_3F0;
   int field_3F4;
-  int field_3F8;
+  unsigned int uDefaultAmbientLightLevel;
 };
 #pragma pack(pop)
 
@@ -375,14 +375,13 @@
   {}
 
   int _49B04D(struct ODMFace *a2, struct BSPVertexBuffer *a3);
-  int _49B0C9(struct Vec3_float_ *pNormal, float a3);
+  int _49B0C9(struct Vec3_float_ *pNormal, float dist);
   int _49B13D(struct ODMFace *pFace, struct BSPVertexBuffer *pVertices, struct Vec3_float_ *a3, float *a4);
 
 
   void (__thiscall ***vdestructor_ptr)(stru154 *, bool);
-  Vec3_float_ vNormal;
-  float field_10;
-  char field_14;
+  Plane_float_ face_plane;
+  PolygonType polygonType;
   char field_15;
   char field_16;
   char field_17;
--- a/LayingItem.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/LayingItem.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -36,8 +36,8 @@
   v1 = this;
   pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)];
   v3 = abs(pParty->vPosition.x - v1->vPosition.x);
-  v15 = abs(pParty->vPosition.z - v1->vPosition.y);
-  v16 = abs(pParty->vPosition.y + pParty->sEyelevel - v1->vPosition.z);
+  v15 = abs(pParty->vPosition.y - v1->vPosition.y);
+  v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z);
   v4 = v3;
   v5 = v15;
   v6 = v16;
--- a/LightmapBuilder.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/LightmapBuilder.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -13,11 +13,11 @@
 
 
 LightsStack_StationaryLight_ *pStationaryLightsStack = new LightsStack_StationaryLight_;
-StationaryLight pStationaryLights[400];
-int uNumStationaryLightsApplied; // weak
+//StationaryLight pStationaryLights[400];
+//int uNumStationaryLightsApplied; // weak
 LightsStack_MobileLight_ *pMobileLightsStack = new LightsStack_MobileLight_;
-MobileLight pMobileLights[400];
-int uNumMobileLightsApplied;
+//MobileLight pMobileLights[400];
+//int uNumMobileLightsApplied;
 
 
 
@@ -36,11 +36,6 @@
 //----- (0045BB06) --------------------------------------------------------
 LightmapBuilder::LightmapBuilder()
 {
-  //std__vector_000004.reserve(512);
-  //std__vector_183808.reserve(768);
-
-  for (uint i = 0; i < 256; ++i)
-    field_3C8C34[i].flt_2C = 0.0f;
 }
 
 
@@ -48,186 +43,103 @@
 
 
 //----- (0045BC07) --------------------------------------------------------
-char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char a7)
+bool LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char uClipFlag)
 {
-  char *v7; // eax@3
-  signed int v8; // ecx@3
-  RenderVertexSoft *v9; // eax@10
-  unsigned int v10; // edx@10
-  const void *v11; // esi@11
-  void *v12; // edi@11
-  char v13; // zf@11
-  stru154 *v14; // esi@12
-  double v16; // st7@17
-  double v17; // st6@17
-  float v18; // eax@17
-  int *v19; // esi@20
-  double v20; // st7@21
-  int v21; // eax@21
-  unsigned int v22; // eax@21
-  int v23; // ecx@23
-  float v24; // ST04_4@23
-  float v25; // [sp+8h] [bp-64h]@18
-  Vec3_float_ *v26; // [sp+18h] [bp-54h]@17
-  int v27; // [sp+1Ch] [bp-50h]@17
-  int arg0; // [sp+2Ch] [bp-40h]@21
-  int v29; // [sp+30h] [bp-3Ch]@21
-  int v30; // [sp+34h] [bp-38h]@21
-  //double v31; // [sp+38h] [bp-34h]@21
-  //double v32; // [sp+40h] [bp-2Ch]@21
-  //double v33; // [sp+48h] [bp-24h]@21
-  int v34; // [sp+50h] [bp-1Ch]@24
-  LightmapBuilder *thisa; // [sp+54h] [bp-18h]@1
-  int v36; // [sp+58h] [bp-14h]@21
-  int v37; // [sp+5Ch] [bp-10h]@21
-  unsigned __int64 v38; // [sp+60h] [bp-Ch]@21
-  int a9; // [sp+68h] [bp-4h]@8
+  Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21
+  RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8
+
+  if (!uNumVertices)
+    return false;
+
+  static RenderVertexSoft static_69B140[64];
 
-  thisa = this;
-  if ( !uNumVertices )
-    return 0;
+  a9 = a5;
+  if (a6)
+  {
+    for (uint i = 0; i < uNumVertices; ++i)
+      memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft));
 
-  static bool _static_initialized = false;
-  static RenderVertexSoft LightmapBuilder_static_sub_45BC07_stru_69B140[64];
-  if (!_static_initialized)
-  {
-    for (uint i = 0; i < 64; ++i)
-      LightmapBuilder_static_sub_45BC07_stru_69B140[i].flt_2C = 0.0f;
-    _static_initialized = true;
+    __debugbreak();
+    if (pGame->pIndoorCameraD3D->_437376(
+           a3,
+           static_69B140,
+           &uNumVertices) == 1)
+    {
+      if ( !uNumVertices )
+        return false;
+      a9 = static_69B140;
+    }
   }
 
-  a9 = (int)a5;
-  if ( !a6)
-  {
-    v14 = a3;
-  }
-  else
-  {
-    if ( (signed int)uNumVertices > 0 )
-    {
-      v9 = LightmapBuilder_static_sub_45BC07_stru_69B140;
-      v10 = (char *)a5 - (char *)LightmapBuilder_static_sub_45BC07_stru_69B140;
-      a5 = (RenderVertexSoft *)uNumVertices;
-      do
-      {
-        v11 = (char *)v9 + v10;
-        v12 = v9;
-        ++v9;
-        v13 = a5 == (RenderVertexSoft *)1;
-        a5 = (RenderVertexSoft *)((char *)a5 - 1);
-        memcpy(v12, v11, 0x30u);
-      }
-      while ( !v13 );
-    }
-    v14 = a3;
-    if ( pGame->pIndoorCameraD3D->_437376(
-           a3,
-           LightmapBuilder_static_sub_45BC07_stru_69B140,
-           &uNumVertices) == 1 )
-    {
-      if ( !uNumVertices )
-        return 0;
-      a9 = (int)LightmapBuilder_static_sub_45BC07_stru_69B140;
-    }
-  }
-  v16 = v14->vNormal.z;
-  v17 = v14->vNormal.y;
-  v18 = v14->vNormal.x;
-
-  static stru314 LightmapBuilder_static_sub_45BC07_stru_69B110;
-  v27 = (int)&LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C;
-  LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.y = v17;
-  LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.x = v18;
-  v26 = &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10;
-  LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.z = v16;
-  dword_69B138 = LODWORD(v14->field_10);
-  if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
-          v14->field_14,
-          &LightmapBuilder_static_sub_45BC07_stru_69B110.field_4,
-          &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10,
-          &LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C) )
+  static stru314 static_69B110;
+  static_69B110.field_4.x = a3->face_plane.vNormal.x;
+  static_69B110.field_4.y = a3->face_plane.vNormal.y;
+  static_69B110.field_4.z = a3->face_plane.vNormal.z;
+  static_69B110.dist = a3->face_plane.dist;
+  if (!pGame->pIndoorCameraD3D->GetFacetOrientation(
+          a3->polygonType,
+          &static_69B110.field_4,
+          &static_69B110.field_10,
+          &static_69B110.field_1C))
   {
     MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0);
     ExitProcess(0);
   }
-  a5 = 0;
-  if ( a2->field_AC > 0 )
+
+  for (uint i = 0; i < a2->uNumLightsApplied; ++i)
   {
-    v19 = a2->_blv_lights_ys;
-    do
+    pos.x = a2->_blv_lights_xs[i];
+    pos.y = a2->_blv_lights_ys[i];
+    pos.z = a2->_blv_lights_zs[i];
+
+    uint uColorR = (uint)floorf(a2->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF,
+         uColorG = (uint)floorf(a2->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF,
+         uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF;
+    uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB;
+    if (!uColor)
+      uColor = 0x00FFFFF;
+
+    if (!_45BE86_build_light_polygon(
+              &pos,
+              a2->_blv_lights_radii[i],
+              uColor,
+              a2->_blv_lights_light_dot_faces[i],
+              a2->_blv_lights_types[i],
+              &static_69B110,
+              uNumVertices,
+              a9,
+              uClipFlag) )
     {
-      v20 = *((float *)v19 + 80) * 255.0;
-      arg0 = *(v19 - 20);
-      v29 = *v19;
-      v30 = v19[60];
-      v21 = *(v19 - 60);
-      //a6 = v20;
-      v36 = v21;
-      v37 = v19[20];
-      auto _a6_1 = floorf(v20 + 0.5f);
-      //v33 = a6 + 6.7553994e15;
-      auto _a6_2 = *((float *)v19 + 100) * 255.0;
-      //v32 = a6 + 6.7553994e15;
-      auto _a6_3 = *((float *)v19 + 120) * 255.0;
-      //v31 = a6 + 6.7553994e15;
-      //v38 = __PAIR__(LODWORD(v32), LODWORD(v31));
-      v38 = __PAIR__((int)floorf(_a6_2 + 0.5f), (int)floorf(_a6_3 + 0.5f));
-      //v22 = LODWORD(v31) | ((LODWORD(v32) | (LODWORD(v33) << 8)) << 8);
-      v22 = (int)floorf(_a6_3 + 0.5f) | (((int)floorf(_a6_2 + 0.5f) | ((int)floorf(_a6_1 + 0.5f) << 8)) << 8);
-      if (!v22)
-        v22 = 0x00FFFFFF;
-      v27 = a7;
-      v23 = (int)a5;
-      v26 = (Vec3_float_ *)a9;
-      LOBYTE(v23) = *((unsigned char *)&a5[20].vWorldViewPosition.y + (unsigned int)a2);
-      v25 = (double)v37;
-      v24 = (double)v36;
-      if ( !_45BE86_build_light_polygon(
-              (int)&arg0,
-              v24,
-              v22,
-              v25,
-              v23,
-              &LightmapBuilder_static_sub_45BC07_stru_69B110,
-              uNumVertices,
-              (RenderVertexSoft *)a9,
-              a7) )
-      {
-        MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
-        v34 = 5080748;
-      }
-      a5 = (RenderVertexSoft *)((char *)a5 + 1);
-      ++v19;
+      MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
     }
-    while ( (signed int)a5 < a2->field_AC );
   }
-  return 1;
+  return true;
 }
 
 //----- (0045BE86) --------------------------------------------------------
-char LightmapBuilder::_45BE86_build_light_polygon(int arg0, float a4, unsigned int uColorMask, float a5, int uLightType, stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag)
+bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag)
 {
-  LightmapBuilder *v10; // esi@1
+  //LightmapBuilder *v10; // esi@1
   Lightmap *v11; // edi@3
-  double v12; // st7@5
-  double v13; // st7@5
-  stru314 *v14; // ebx@5
-  double v15; // st7@5
-  RenderVertexSoft *pLightmapVertices; // edx@5
+  //double v12; // st7@5
+  //double v13; // st7@5
+  //stru314 *v14; // ebx@5
+  //double v15; // st7@5
+  //RenderVertexSoft *pLightmapVertices; // edx@5
   double v17; // st7@5
-  double v18; // st7@5
-  char *v19; // eax@5
-  double v20; // st6@5
-  double v21; // st5@5
-  signed int v22; // ecx@5
-  double v23; // st5@5
+  //double v18; // st7@5
+  //char *v19; // eax@5
+  //double v20; // st6@5
+  //double v21; // st5@5
+  //signed int v22; // ecx@5
+  //double v23; // st5@5
   double v24; // st7@6
-  int v25; // ebx@8
-  double v26; // st7@8
-  int v27; // eax@8
-  double v28; // st6@8
-  double v29; // st6@8
-  double v30; // st5@8
+  //int v25; // ebx@8
+  //double v26; // st7@8
+  //int v27; // eax@8
+  //double v28; // st6@8
+  //double v29; // st6@8
+  //double v30; // st5@8
   int v31; // eax@8
   int v32; // ebx@8
   unsigned int v33; // ecx@8
@@ -238,156 +150,186 @@
   double v38; // st7@14
   double v39; // st7@16
   double v40; // st7@16
-  double v41; // st7@22
-  stru9 *v42; // ecx@22
-  char result; // al@22
-  unsigned int *v44; // ebx@23
+  //double v41; // st7@22
+  //stru9 *v42; // ecx@22
+  //char result; // al@22
+  //unsigned int *v44; // ebx@23
   int v45; // eax@24
-  RenderVertexSoft *v46; // edi@27
-  std::string *v47; // ecx@34
-  char *v48; // esi@39
-  int v49; // eax@39
-  unsigned __int8 v50; // sf@39
-  unsigned __int8 v51; // of@39
-  const char *v52; // [sp-Ch] [bp-58h]@34
+  //RenderVertexSoft *v46; // edi@27
+  //std::string *v47; // ecx@34
+  //char *v48; // esi@39
+  //int v49; // eax@39
+  //unsigned __int8 v50; // sf@39
+  //unsigned __int8 v51; // of@39
+  //const char *v52; // [sp-Ch] [bp-58h]@34
   int v53; // [sp-8h] [bp-54h]@34
-  std::string v54; // [sp-4h] [bp-50h]@19
-  float v55; // [sp+0h] [bp-4Ch]@22
-  float v56; // [sp+4h] [bp-48h]@22
-  int v57; // [sp+8h] [bp-44h]@22
-  unsigned int v58; // [sp+Ch] [bp-40h]@16
-  void *v59; // [sp+10h] [bp-3Ch]@16
-  float v60; // [sp+20h] [bp-2Ch]@8
-  float v61; // [sp+24h] [bp-28h]@8
-  float v62; // [sp+28h] [bp-24h]@8
-  Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
+  //std::string v54; // [sp-4h] [bp-50h]@19
+  //float v55; // [sp+0h] [bp-4Ch]@22
+  //float v56; // [sp+4h] [bp-48h]@22
+  //int v57; // [sp+8h] [bp-44h]@22
+  //unsigned int v58; // [sp+Ch] [bp-40h]@16
+  //void *v59; // [sp+10h] [bp-3Ch]@16
+  //float v60; // [sp+20h] [bp-2Ch]@8
+  //float v61; // [sp+24h] [bp-28h]@8
+  //float v62; // [sp+28h] [bp-24h]@8
+  //Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
   //double v64; // [sp+38h] [bp-14h]@8
-  int pLightmapVertices_; // [sp+40h] [bp-Ch]@5
-  float v66; // [sp+44h] [bp-8h]@5
-  char v67; // [sp+4Bh] [bp-1h]@2
-  float arg0b; // [sp+54h] [bp+8h]@8
-  int arg0c; // [sp+54h] [bp+8h]@8
-  int arg0a; // [sp+54h] [bp+8h]@8
+  //int pLightmapVertices_; // [sp+40h] [bp-Ch]@5
+  //float v66; // [sp+44h] [bp-8h]@5
+  //char v67; // [sp+4Bh] [bp-1h]@2
+  //float arg0b; // [sp+54h] [bp+8h]@8
+  //int arg0c; // [sp+54h] [bp+8h]@8
+  //int arg0a; // [sp+54h] [bp+8h]@8
 
-  v10 = this;
-  if ( a4 == 0.0 )
-    return 1;
-  v67 = uLightType & 1;
+  //auto a4 = radius;
+  //auto a5 = dot_dist;
+
+  //v10 = this;
+  if (fabsf(radius) < 1e-6f)
+    return true;
+
+  //v67 = uLightType & 1;
   v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] :
                          &std__vector_183808[std__vector_183808_size];
-  v12 = a4 - a5;
-  this->flt_3C8C24 = v12;
-  v13 = sqrt((a4 + a4 - v12) * v12);
-  v10->flt_3C8C28 = v13;
-  v14 = a7;
-  v66 = 1.0 / a4;
-  v10->flt_3C8C2C_lightmaps_brightness = 1.0 - (a4 - v13) * v66;
-  v11->field_C08 = (signed __int64)((double)*(signed int *)arg0 - a5 * v14->field_4.x);
-  v11->field_C0A = (signed __int64)((double)*(signed int *)(arg0 + 4) - a5 * v14->field_4.y);
-  v15 = a4;
-  v11->field_C0C = (signed __int64)((double)*(signed int *)(arg0 + 8) - a5 * v14->field_4.z);
-  pLightmapVertices = v11->pVertices;
-  v17 = v15 * v10->flt_3C8C2C_lightmaps_brightness;
-  pLightmapVertices_ = (int)v11->pVertices;
-  v10->flt_3C8C30 = v17;
-  v10->flt_3C8C0C = v17 * v14->field_10.x;
-  v10->flt_3C8C10 = v17 * v14->field_10.y;
-  v10->flt_3C8C14 = v17 * v14->field_10.z;
-  v10->flt_3C8C18 = v17 * v14->field_1C.x;
-  v10->flt_3C8C1C = v17 * v14->field_1C.y;
-  v10->flt_3C8C20 = v17 * v14->field_1C.z;
-  LODWORD(a5) = v11->field_C08;
-  v18 = (double)SLODWORD(a5);
-  v11->pVertices[0].vWorldPosition.x = v18 - v10->flt_3C8C18 + v10->flt_3C8C0C;
-  LODWORD(a5) = v11->field_C0A;
-  v19 = (char *)&v11->pVertices[0].vWorldPosition.y;
-  v20 = (double)SLODWORD(a5);
-  v21 = v20 - v10->flt_3C8C1C;
-  LODWORD(a5) = v11->field_C0C;
-  v22 = 4;
-  v11->pVertices[0].vWorldPosition.y = v21 + v10->flt_3C8C10;
-  v23 = (double)SLODWORD(a5);
-  a5 = v23;
-  v11->pVertices[0].vWorldPosition.z = v23 - v10->flt_3C8C20 + v10->flt_3C8C14;
+  //v12 = radius - dot_dist;
+  flt_3C8C24 = radius - dot_dist;
+  //v13 = sqrt((radius + dot_dist) * (radius - dot_dist));
+  flt_3C8C28 = sqrt((radius + dot_dist) * (radius - dot_dist));
+  //v14 = a7;
+  //v66 = 1.0 / radius;
+  flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius;
+  v11->field_C08 = (double)pos->x - dot_dist * a7->field_4.x;
+  v11->field_C0A = (double)pos->y - dot_dist * a7->field_4.y;
+  v11->field_C0C = (double)pos->z - dot_dist * a7->field_4.z;
+  //v15 = a4;
+  //pLightmapVertices = v11->pVertices;
+  v17 = radius * flt_3C8C2C_lightmaps_brightness;
+  //pLightmapVertices_ = (int)v11->pVertices;
+  flt_3C8C30 = v17;
+  flt_3C8C0C = v17 * a7->field_10.x;
+  flt_3C8C10 = v17 * a7->field_10.y;
+  flt_3C8C14 = v17 * a7->field_10.z;
+  flt_3C8C18 = v17 * a7->field_1C.x;
+  flt_3C8C1C = v17 * a7->field_1C.y;
+  flt_3C8C20 = v17 * a7->field_1C.z;
+  //LODWORD(a5) = v11->field_C08;
+  //v18 = (double)SLODWORD(a5);
+  //LODWORD(a5) = v11->field_C0A;
+  //v19 = (char *)&v11->pVertices[0].vWorldPosition.y;
+  //v20 = (double)SLODWORD(a5);
+  //v21 = v11->field_C0A - flt_3C8C1C;
+  //LODWORD(a5) = v11->field_C0C;
+  //v22 = 4;
+  //v23 = (double)SLODWORD(a5);
+  //a5 = v23;
+
+
+  /*
+  v11->pVertices[0].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C;
+  v11->pVertices[0].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10;
+  v11->pVertices[0].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14;
   v11->pVertices[0].u = 0.0;
   v11->pVertices[0].v = 0.0;
-  v11->pVertices[1].vWorldPosition.x = v18 - v10->flt_3C8C18 - v10->flt_3C8C0C;
-  v11->pVertices[1].vWorldPosition.y = v20 - v10->flt_3C8C1C - v10->flt_3C8C10;
-  v11->pVertices[1].vWorldPosition.z = v23 - v10->flt_3C8C20 - v10->flt_3C8C14;
+
+  v11->pVertices[1].vWorldPosition.x = v11->field_C08 - flt_3C8C18 - flt_3C8C0C;
+  v11->pVertices[1].vWorldPosition.y = v11->field_C0A - flt_3C8C1C - flt_3C8C10;
+  v11->pVertices[1].vWorldPosition.z = v11->field_C0C - flt_3C8C20 - flt_3C8C14;
   v11->pVertices[1].u = 0.0;
   v11->pVertices[1].v = 1.0;
-  v11->pVertices[2].vWorldPosition.x = v18 + v10->flt_3C8C18 - v10->flt_3C8C0C;
-  v11->pVertices[2].vWorldPosition.y = v20 + v10->flt_3C8C1C - v10->flt_3C8C10;
-  v11->pVertices[2].vWorldPosition.z = v23 + v10->flt_3C8C20 - v10->flt_3C8C14;
+
+  v11->pVertices[2].vWorldPosition.x = v11->field_C08 + flt_3C8C18 - flt_3C8C0C;
+  v11->pVertices[2].vWorldPosition.y = v11->field_C0A + flt_3C8C1C - flt_3C8C10;
+  v11->pVertices[2].vWorldPosition.z = v11->field_C0C + flt_3C8C20 - flt_3C8C14;
   v11->pVertices[2].u = 1.0;
   v11->pVertices[2].v = 1.0;
-  v11->pVertices[3].vWorldPosition.x = v18 + v10->flt_3C8C18 + v10->flt_3C8C0C;
-  v11->pVertices[3].vWorldPosition.y = v20 + v10->flt_3C8C1C + v10->flt_3C8C10;
-  v11->pVertices[3].vWorldPosition.z = a5 + v10->flt_3C8C20 + v10->flt_3C8C14;
+
+  v11->pVertices[3].vWorldPosition.x = v11->field_C08 + flt_3C8C18 + flt_3C8C0C;
+  v11->pVertices[3].vWorldPosition.y = v11->field_C0A + flt_3C8C1C + flt_3C8C10;
+  v11->pVertices[3].vWorldPosition.z = v11->field_C0C + flt_3C8C20 + flt_3C8C14;
   v11->pVertices[3].u = 1.0;
   v11->pVertices[3].v = 0.0;
-  do
+  */
+  //v19 = (char *)&v11->pVertices[0].vWorldPosition.y;
+  for (uint i = 0; i < 4; ++i)
   {
-    v24 = v14->field_4.y * *(float *)v19
-        + *((float *)v19 + 1) * v14->field_4.z
-        + v14->field_4.x * *((float *)v19 - 1)
-        + *(float *)&v14->field_28;
-    *((float *)v19 - 1) = *((float *)v19 - 1) - v24 * v14->field_4.x;
-    *(float *)v19 = *(float *)v19 - v24 * v14->field_4.y;
-    v19 += 48;
-    --v22;
-    *((float *)v19 - 11) = *((float *)v19 - 11) - v24 * v14->field_4.z;
+    v11->pVertices[i].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C;
+    v11->pVertices[i].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10;
+    v11->pVertices[i].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14;
+    v11->pVertices[i].u = 0.0;
+    v11->pVertices[i].v = 0.0;
+
+    v24 = a7->field_4.y * v11->pVertices[i].vWorldPosition.y
+        + a7->field_4.z * v11->pVertices[i].vWorldPosition.z
+        + a7->field_4.x * v11->pVertices[i].vWorldPosition.x
+        + a7->dist;
+
+    v11->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x;
+    v11->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y;
+    v11->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z;
+    //v19 += 48;
+    //--v22;
   }
-  while ( v22 );
+  //while ( v22 );
+
   v11->uColorMask = uColorMask;
   v11->uNumVertices = 4;
-  if ( pGame->uFlags2 & 4 )
+
+  if (~pGame->uFlags2 & 4)
+    v11->fBrightness = flt_3C8C2C_lightmaps_brightness;
+  else
   {
-    LODWORD(a5) = v11->field_C0C;
-    v25 = arg0;
-    v26 = (double)SLODWORD(a5);
-    LODWORD(a5) = v11->field_C0A;
-    v27 = v11->field_C08;
-    a5 = (double)SLODWORD(a5);
-    uColorMask = v27;
-    v28 = (double)v27;
-    v61 = a5;
-    v60 = v28;
-    v62 = v26;
-    *(float *)&uColorMask = (double)*(signed int *)(arg0 + 8);
-    arg0b = (double)*(signed int *)(arg0 + 4);
-    v29 = (double)*(signed int *)v25 - v28;
-    v30 = arg0b - a5;
-    a5 = *(float *)&uColorMask - v26;
-    a1.x = v29;
-    a1.z = a5;
-    a1.y = v30;
+    //LODWORD(a5) = v11->field_C0C;
+    //v25 = pos;
+    //v26 = v11->field_C0C;
+    //LODWORD(a5) = v11->field_C0A;
+    //v27 = v11->field_C08;
+    //a5 = v11->field_C0A;
+    //uColorMask = v27;
+    //v28 = (double)v27;
+    //v61 = a5;
+    //v60 = v27;
+    //v62 = v26;
+    //*(float *)&uColorMask = (double)pos->z;
+    //arg0b = (double)pos->y;
+    //v29 = (double)pos->x - v11->field_C08;
+    //v30 = (double)pos->y - v11->field_C0A;
+    //a5 = (double)pos->z - v11->field_C0C;
+    Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
+    a1.x = (double)pos->x - v11->field_C08;
+    a1.y = (double)pos->y - v11->field_C0A;
+    a1.z = (double)pos->z - v11->field_C0C;
     a1.Normalize();
     //v64 = v62 + 6.7553994e15;
     //LODWORD(a5) = LODWORD(v64);
-    LODWORD(a5) = floorf(v62 + 0.5f);
+    //LODWORD(a5) = floorf(v11->field_C0C + 0.5f);
     //v64 = v61 + 6.7553994e15;
     //arg0c = LODWORD(v64);
-    arg0c = floorf(v61 + 0.5f);
+    //arg0c = floorf(v11->field_C0A + 0.5f);
     //v64 = v60 + 6.7553994e15;
     //arg8 = LODWORD(v64);
-    uColorMask = floorf(v60 + 0.5f);
-    auto v64 /*HIDWORD(v64)*/ = abs(*(int *)(v25 + 8) - (signed)LODWORD(a5));
-    arg0a = abs(*(int *)(v25 + 4) - arg0c);
-    v31 = abs(*(int *)v25 - (int)uColorMask);
-    LODWORD(a5) = v31;
-    v32 = arg0a;
-    v33 = v64;//HIDWORD(v64);
-    if ( v31 < arg0a )
+    //uColorMask = floorf(v11->field_C08 + 0.5f);
+    //auto _v64 /*HIDWORD(v64)*/ = abs(pos->z - v11->field_C0C);
+    //arg0a = abs(pos->y - v11->field_C0A);
+    //v31 = abs(pos->x - v11->field_C08);
+    //LODWORD(a5) = v31;
+    //v32 = arg0a;
+    //v33 = _v64;//HIDWORD(v64);
+    auto dist_x = abs(pos->x - v11->field_C08), //v31
+         dist_y = abs(pos->y - v11->field_C0A), //v32  arg0a
+         dist_z = abs(pos->z - v11->field_C0C); //v33  _v64
+    v31 = dist_x;
+    v32 = dist_y;
+    v33 = dist_z;
+    if (v31 < dist_y)
     {
       v34 = v31;
-      v31 = arg0a;
+      v31 = dist_y;
       v32 = v34;
     }
-    if ( v31 < v64)//SHIDWORD(v64) )
+    if (v31 < dist_z)//SHIDWORD(v64) )
     {
       v35 = v31;
-      v31 = v64;//HIDWORD(v64);
+      v31 = dist_z;//HIDWORD(v64);
       v33 = v35;
     }
     if ( v32 < (signed int)v33 )
@@ -397,118 +339,123 @@
       v32 = v36;
     }
     v37 = v33 >> 2;
-    LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31;
-    v38 = (double)SLODWORD(a5);
-    if ( v38 > a4 )
-      return 1;
-    a4 = v66 * v38;
+    //LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31;
+    v38 = (double)(signed)(((unsigned int)(11 * v32) >> 5) + v37 + v31);
+    if (v38 > radius)
+      return true;
+    //radius = (1 / radius) * v38;
     if ( uLightType & 4 )
     {
-      v59 = (void *)v37;
-      uLightType = dword_4D86CC;
-      v58 = v37;
+      //v59 = (void *)v37;
+      //uLightType = flt_4D86CC;
+      //v58 = v37;
       v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y);
-      v40 = v39 * 1.0 * *(float *)&uLightType;
+      v40 = v39 * 1.0 * flt_4D86CC;
+
+      v11->fBrightness = v40 - (1 / radius) * v38 * v40;
+    }
+    else if ( uLightType & 8 )
+    {
+        v40 = 1.0 * 1.0;
+        v11->fBrightness = v40 - (1 / radius) * v38;
     }
     else
     {
-      if ( uLightType & 8 )
-      {
-        v40 = 1.0 * 1.0;
-      }
-      else
-      {
         MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0);
-        v40 = *(float *)&uLightType;
-      }
     }
-    v14 = a7;
-    pLightmapVertices = (RenderVertexSoft *)pLightmapVertices_;
-    v11->fBrightness = v40 - a4 * v40;
-  }
-  else
-  {
-    v11->fBrightness = v10->flt_3C8C2C_lightmaps_brightness;
+    //v14 = a7;
+    //pLightmapVertices = (RenderVertexSoft *)pLightmapVertices_;
   }
-  v41 = v14->field_4.z;
-  v42 = pGame->pStru9Instance;
-  v59 = &v11->uNumVertices;
-  v58 = (unsigned int)pLightmapVertices;
-  *(float *)&v57 = v41;
-  v56 = v14->field_4.y;
-  v55 = v14->field_4.x;
-  result = v42->_4980B9(a9, a2, v55, v56, *(float *)&v57, pLightmapVertices, &v11->uNumVertices);
-  if ( !result )
-    return result;
-  v44 = &v11->uNumVertices;
-  if ( !v11->uNumVertices )
-    return 1;
-  v45 = v10->_45C6D6(a2, a9, v11);
+
+
+  //v41 = a7->field_4.z;
+  //v42 = pGame->pStru9Instance;
+  //v59 = &v11->uNumVertices;
+  //v58 = (unsigned int)pLightmapVertices;
+  //*(float *)&v57 = v41;
+  //v56 = a7->field_4.y;
+  //v55 = a7->field_4.x;
+  //result = v42->_4980B9(a9, a2, v55, v56, *(float *)&v57, pLightmapVertices, &v11->uNumVertices);
+  if (pGame->pStru9Instance->_4980B9(a9, a2,
+                                     a7->field_4.x, a7->field_4.y, a7->field_4.z,
+                                     v11->pVertices, &v11->uNumVertices))
+    return false;
+
+  //v44 = &v11->uNumVertices;
+  if (!v11->uNumVertices)
+    return true;
+
+  v45 = _45C6D6(a2, a9, v11);
   if ( v45 != a2 && v45 > 0 )
-    v10->_45C4B9(a2, a9, v11);
-  v59 = (void *)*v44;
-  v46 = (RenderVertexSoft *)pLightmapVertices_;
-  pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)pLightmapVertices_, (unsigned int)v59);
-  v59 = 0;
-  v58 = *v44;
-  pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v46, v58, 0);
+    _45C4B9(a2, a9, v11);
+  //v59 = v11->uNumVertices;
+  //v46 = (RenderVertexSoft *)pLightmapVertices_;
+  pGame->pIndoorCameraD3D->ViewTransform(v11->pVertices, v11->uNumVertices);
+  //v59 = 0;
+  //v58 = v11->uNumVertices;
+  pGame->pIndoorCameraD3D->Project(v11->pVertices, v11->uNumVertices, 0);
+
+  unsigned int _a4 = 0;
   if ( !(uClipFlag & 1) )
-    goto LABEL_38;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    _a4 = 1;
+  else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
     if ( uClipFlag & 2 )
     {
-      v59 = &a4;
-      v58 = (unsigned int)v10->field_3C8C34;
-      v57 = *v44;
-      pGame->pIndoorCameraD3D->_436CDC(v46, v57, v10->field_3C8C34, (unsigned int *)&a4);
-LABEL_33:
-      v59 = v44;
-      v58 = (unsigned int)v10->field_3C8C34;
-      v57 = (int)v46;
-      v56 = a4;
-      pGame->pIndoorCameraD3D->_437143(LODWORD(a4), v46, v10->field_3C8C34, v44);
-      goto LABEL_37;
+      //v59 = &a4;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = *v44;
+      pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4);
+
+      //v59 = v44;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = (int)v46;
+      //v56 = a4;
+      pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices);
     }
-    if ( uClipFlag & 4 )
+    else if ( uClipFlag & 4 )
     {
-      v59 = &a4;
-      v58 = (unsigned int)v10->field_3C8C34;
-      v57 = *v44;
-      pGame->pIndoorCameraD3D->_436F09(v46, v57, v10->field_3C8C34, (unsigned int *)&a4);
-      goto LABEL_33;
+      //v59 = &a4;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = *v44;
+      pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4);
+
+      //v59 = v44;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = (int)v46;
+      //v56 = a4;
+      pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices);
     }
-    v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330";
-    v52 = "Undefined clip flag specified";
+    else
+      MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0);
   }
   else
-  {
-    v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335";
-    v52 = "Lightpoly builder native indoor clipping not implemented";
-  }
-  MessageBoxA(nullptr, v52, (const char *)v58, 0);
-LABEL_37:
-  if ( a4 != 0.0 )
+    MessageBoxW(nullptr, L"Lightpoly builder native indoor clipping not implemented", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335", 0);
+
+  if (_a4)
   {
-LABEL_38:
-    if ( v67 )
+    if (uLightType & 1)
     {
-      v48 = (char *)&v10->std__vector_000004_size;
-      v49 = *(unsigned int *)v48;
-      v51 = __OFSUB__(*(unsigned int *)v48, 511);
-      v50 = *(unsigned int *)v48 - 511 < 0;
+      //v48 = (char *)&std__vector_000004_size;
+      //v49 = std__vector_000004_size;
+      //v51 = __OFSUB__(std__vector_000004_size, 511);
+      //v50 = std__vector_000004_size - 511 < 0;
+      if (std__vector_000004_size < 512 - 1)
+        ++std__vector_000004_size;
     }
     else
     {
-      v48 = (char *)&v10->std__vector_183808_size;
-      v49 = *(unsigned int *)v48;
-      v51 = __OFSUB__(*(unsigned int *)v48, 767);
-      v50 = *(unsigned int *)v48 - 767 < 0;
+      //v48 = (char *)&std__vector_183808_size;
+      //v49 = std__vector_183808_size;
+      //v51 = __OFSUB__(std__vector_183808_size, 767);
+      //v50 = std__vector_183808_size - 767 < 0;
+      if (std__vector_183808_size < 768 - 1)
+        ++std__vector_183808_size;
     }
-    if ( v50 ^ v51 )
-      *(unsigned int *)v48 = v49 + 1;
+    //if ( v50 ^ v51 )
+    //  *(unsigned int *)v48 = v49 + 1;
   }
-  return 1;
+  return true;
 }
 
 //----- (0045C4B9) --------------------------------------------------------
@@ -726,139 +673,82 @@
 //----- (0045C7F6) --------------------------------------------------------
 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID)
 {
-  BLVFace *pFace; // esi@1
-  int v3; // ebx@1
-  int uSectorID; // edi@1
-  int v5; // ecx@5
-  BLVLightMM7 *v6; // eax@7
-  int v7; // edi@10
-  bool result; // eax@14
-  LightmapBuilder *thisa; // [sp+Ch] [bp-Ch]@1
-  MobileLight *pMobileLight; // [sp+10h] [bp-8h]@2
-  int uSectLights; // [sp+10h] [bp-8h]@5
-  StationaryLight *pStationaryLight; // [sp+10h] [bp-8h]@11
-  int v13; // [sp+14h] [bp-4h]@1
-  int i; // [sp+14h] [bp-4h]@5
+  auto pFace = &pIndoor->pFaces[uFaceID];
+  auto pSector = pIndoor->pSectors + pFace->uSectorID;
+
+  stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;
 
-  pFace = &pIndoor->pFaces[uFaceID];
-  v3 = uNumMobileLightsApplied;
-  v13 = 0;
-  thisa = this;
-  uSectorID = pFace->uSectorID;
-  uFaceID = 0;
-  stru_F8AD28.field_2C = (stru_F8AD28.field_3F8 + pIndoor->pSectors[uSectorID].uMinAmbientLightLevel) << 16;
-  if ( uNumMobileLightsApplied > 0 )
+  uint uNumLightsApplied = 0;
+  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
+  {
+    if (uNumLightsApplied >= 20)
+      break;
+
+    ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0);
+  }
+
+  for (uint i = 0; i < pSector->uNumLights; ++i)
   {
-    pMobileLight = pMobileLights;
-    do
-    {
-      if ( (signed int)uFaceID >= 20 )
-        break;
-      ApplyLight_BLV((StationaryLight *)pMobileLight, pFace, &uFaceID, 1, 0);
-      ++v13;
-      ++pMobileLight;
-    }
-    while ( v13 < v3 );
-  }
-  v5 = 0;
-  i = 0;
-  for ( uSectLights = pIndoor->pSectors[uSectorID].uNumLights; i < uSectLights; v5 = i++ + 1 )
-  {
-    if ( (signed int)uFaceID >= 20 )
+    if (uNumLightsApplied >= 20 )
       break;
-    v6 = &pIndoor->pLights[*(&pIndoor->pSectors[uSectorID].pLights->vPosition.x + v5)];
-    if ( !(v6->uAtributes & 8) )
-      ApplyLight_BLV((StationaryLight *)v6, pFace, &uFaceID, 0, (int)&byte_4E94D0);
+
+    auto pLight = &pIndoor->pLights[pSector->pLights[i]];
+    if (~pLight->uAtributes & 0x08)
+      ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &byte_4E94D0);
   }
-  v7 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
+
+  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
   {
-    pStationaryLight = pStationaryLights;
-    do
-    {
-      if ( (signed int)uFaceID >= 20 )
-        break;
-      ApplyLight_BLV(pStationaryLight, pFace, &uFaceID, 0, (int)&byte_4E94D0);
-      ++pStationaryLight;
-      ++v7;
-    }
-    while ( v7 < uNumStationaryLightsApplied );
+    if (uNumLightsApplied >= 20)
+      break;
+
+    ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &byte_4E94D0);
   }
-  result = uFaceID;
-  stru_F8AD28.field_AC = uFaceID;
-  LOBYTE(result) = 1;
-  return result;
+
+  stru_F8AD28.uNumLightsApplied = uNumLightsApplied;
+  return true;
 }
-// 4E94D0: using guessed type char byte_4E94D0;
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
 
 //----- (0045C911) --------------------------------------------------------
-bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, char X, int a5)
+bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5)
 {
-  BLVFace *result; // eax@0
-  StationaryLight *v7; // edi@1
-  signed int v8; // ecx@1
-  int v9; // edx@2
-  int v10; // edx@4
-  int v11; // esi@4
-  int v12; // edx@6
   double v13; // st7@8
-  __int16 v14; // fps@8
-  char v15; // c0@9
-  char v16; // c2@9
-  char v17; // c3@9
-  double v18; // st6@12
-  __int16 v19; // fps@12
-  char v20; // c0@12
-  char v21; // c2@12
-  char v22; // c3@12
-  signed int v23; // [sp+10h] [bp-4h]@2
-  //float pLighta; // [sp+1Ch] [bp+8h]@13
-  signed int a2a; // [sp+20h] [bp+Ch]@4
+
+  if (!pLight->uRadius)
+    return false;
 
-  v7 = pLight;
-  v8 = pLight->uRadius;
-  if ( v8 > 0
-    && (result = a2, v9 = pLight->vPosition.x, v23 = v9, v9 > a2->pBounding.x1 - v8)
-    && v9 < v8 + a2->pBounding.x2
-    && (v10 = pLight->vPosition.y, v11 = a2->pBounding.y1 - v8, a2a = v10, v10 > v11)
-    && v10 < v8 + result->pBounding.y2
-    && (v12 = pLight->vPosition.z, v12 > result->pBounding.z1 - v8)
-    && v12 < v8 + result->pBounding.z2
-    && ((v13 = (double)v12 * result->pFacePlane.vNormal.z
-             + (double)a2a * result->pFacePlane.vNormal.y
-             + (double)v23 * result->pFacePlane.vNormal.x
-             + result->pFacePlane.dist,
-         //UNDEF(v14),
-         X)
-     || (v15 = v13 < 0.0, v16 = 0, v17 = v13 == 0.0, BYTE1(result) = HIBYTE(v14), v13 >= 0.0))
-    && (v18 = (double)pLight->uRadius,
-        //UNDEF(v19),
-        v20 = v13 < v18,
-        v21 = 0,
-        v22 = v13 == v18,
-        BYTE1(result) = HIBYTE(v19),
-        v13 <= v18) )
+  if (pLight->vPosition.x > a2->pBounding.x1 - pLight->uRadius &&
+      pLight->vPosition.x < a2->pBounding.x2 + pLight->uRadius &&
+      pLight->vPosition.y > a2->pBounding.y1 - pLight->uRadius &&
+      pLight->vPosition.y < a2->pBounding.y2 + pLight->uRadius &&
+      pLight->vPosition.z > a2->pBounding.z1 - pLight->uRadius &&
+      pLight->vPosition.z < a2->pBounding.z2 + pLight->uRadius)
   {
-    stru_F8AD28._blv_lights_radii[*pSlot] = v8;
-    stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v8;
-    stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x;
-    stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y;
-    stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z;
-    stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689;
-    stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
-    stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
-    //pLighta = v13;
-    stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v13 + 0.5f));//COERCE_UNSIGNED_INT64(pLighta + 6.7553994e15));
-    result = (BLVFace *)*pSlot;
-    stru_F8AD28._blv_lights_smthngs[(*pSlot)++] = v7->field_B;
-    LOBYTE(result) = 1;
+    v13 = (double)pLight->vPosition.z * a2->pFacePlane.vNormal.z +
+          (double)pLight->vPosition.y * a2->pFacePlane.vNormal.y +
+          (double)pLight->vPosition.x * a2->pFacePlane.vNormal.x +
+          a2->pFacePlane.dist;
+    if ((bLightBackfaces || v13 >= 0.0f) && fabsf(v13) <= pLight->uRadius)
+    {
+      auto slot = *pSlot;
+
+      stru_F8AD28._blv_lights_radii[slot] = pLight->uRadius;
+      stru_F8AD28._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius;
+      stru_F8AD28._blv_lights_xs[slot] = pLight->vPosition.x;
+      stru_F8AD28._blv_lights_ys[slot] = pLight->vPosition.y;
+      stru_F8AD28._blv_lights_zs[slot] = pLight->vPosition.z;
+      stru_F8AD28._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f;
+      stru_F8AD28._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f;
+      stru_F8AD28._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f;
+      stru_F8AD28._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f));
+      stru_F8AD28._blv_lights_types[slot] = pLight->uLightType;
+
+      *pSlot += 1;
+      return true;
+    }
   }
-  else
-  {
-    LOBYTE(result) = 0;
-  }
-  return (bool)result;
+
+  return false;
 }
 
 //----- (0045CA88) --------------------------------------------------------
@@ -902,7 +792,7 @@
     v19 = v9;
     v20 = v8;
     v7->flt_2C = 0.0;
-    if ( a2->field_AC > 0 )
+    if ( a2->uNumLightsApplied > 0 )
     {
       v10 = (char *)a2->_blv_lights_ys;
       for ( j = a2->_blv_lights_ys; ; v10 = (char *)j )
@@ -912,7 +802,7 @@
         HIDWORD(v12) = *(unsigned int *)v10;
         LODWORD(v13) = *((unsigned int *)v10 + 60);
         v14 = a3a;
-        LOBYTE(v14) = v6->_blv_lights_smthngs[a3a];
+        LOBYTE(v14) = v6->_blv_lights_types[a3a];
         v15 = v11;
         *(_QWORD *)&v16.x = v12;
         v16.z = v13;
@@ -921,7 +811,7 @@
         ++a3a;
         ++j;
         v7->flt_2C = v17;
-        if ( a3a >= a2->field_AC )
+        if ( a3a >= a2->uNumLightsApplied )
           break;
         v6 = a2;
       }
@@ -1137,12 +1027,12 @@
 
   v2 = 0;
   thisa = this;
-  v3 = stru_F8AD28.field_3F8 + pFace->uShadeType;
+  v3 = stru_F8AD28.uDefaultAmbientLightLevel + pFace->uShadeType;
   pSlot = 0;
-  stru_F8AD28.field_2C = v3 << 16;
-  if ( uNumMobileLightsApplied > 0 )
+  stru_F8AD28.uCurrentAmbientLightLevel = v3 << 16;
+  if ( pMobileLightsStack->uNumLightsActive > 0 )
   {
-    pMobileLight = pMobileLights;
+    pMobileLight = pMobileLightsStack->pLights;
     do
     {
       if ( pSlot >= 20 )
@@ -1151,12 +1041,12 @@
       ++v2;
       ++pMobileLight;
     }
-    while ( v2 < uNumMobileLightsApplied );
+    while ( v2 < pMobileLightsStack->uNumLightsActive );
   }
   v5 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
+  if ( pStationaryLightsStack->uNumLightsActive > 0 )
   {
-    pStationaryLight = pStationaryLights;
+    pStationaryLight = pStationaryLightsStack->pLights;
     do
     {
       if ( pSlot >= 20 )
@@ -1165,14 +1055,12 @@
       ++v5;
       ++pStationaryLight;
     }
-    while ( v5 < uNumStationaryLightsApplied );
+    while ( v5 < pStationaryLightsStack->uNumLightsActive );
   }
   result = pSlot;
-  stru_F8AD28.field_AC = pSlot;
-  LOBYTE(result) = 1;
-  return result;
+  stru_F8AD28.uNumLightsApplied = pSlot;
+  return true;
 }
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
 
 //----- (0045CE50) --------------------------------------------------------
 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4)
@@ -1188,6 +1076,8 @@
   RenderD3D *v13; // ecx@11
   char v14; // dl@11
 
+  __debugbreak();
+
   v6 = pLight->uRadius;
   if ( v6 > 0
     && (result = (int)pFace, v7 = pLight->vPosition.x, v7 > pFace->pBoundingBox.x1 - v6)
@@ -1215,16 +1105,16 @@
     v11 = abs(v10);
     v12 = pRenderer->bUsingSpecular;
     stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11;
-    stru_F8AD28._blv_lights_smthngs[*pSlot] = pLight->field_B;
+    stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType;
     v13 = pRenderer->pRenderD3D;
-    v14 = stru_F8AD28._blv_lights_smthngs[*pSlot];
+    v14 = stru_F8AD28._blv_lights_types[*pSlot];
     if ( pRenderer->pRenderD3D && v12 && v14 & 4 )
-      v14 = byte_4E94D2;
-    stru_F8AD28._blv_lights_smthngs[*pSlot] = v14;
+      v14 = _4E94D2_light_type;
+    stru_F8AD28._blv_lights_types[*pSlot] = v14;
     result = 4 * *pSlot;
     if ( v13 && v12 )
     {
-      if ( stru_F8AD28._blv_lights_smthngs[*pSlot] & 4 )
+      if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 )
       {
         *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
                                                                 * 0.33000001;
@@ -1243,54 +1133,53 @@
   }
   return result;
 }
-// 4E94D2: using guessed type char byte_4E94D2;
+// 4E94D2: using guessed type char _4E94D2_light_type;
 
 //----- (0045D036) --------------------------------------------------------
-bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X)
+bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces)
 {
   int v6; // esi@1
-  LightmapBuilder *v7; // edi@1
+  //LightmapBuilder *v7; // edi@1
   MobileLight *v8; // ebx@2
   int v9; // esi@5
   StationaryLight *v10; // ebx@6
-  bool result; // eax@9
+  //bool result; // eax@9
   unsigned int a7; // [sp+Ch] [bp-4h]@1
 
   v6 = 0;
-  v7 = this;
+  //v7 = this;
   a7 = 0;
-  stru_F8AD28.field_2C = pOutdoor->field_CBC_terrain_triangles_shade_type;
-  if ( uNumMobileLightsApplied > 0 )
+  stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type;
+  if ( pMobileLightsStack->uNumLightsActive > 0 )
   {
-    v8 = pMobileLights;
+    v8 = pMobileLightsStack->pLights;
     do
     {
       if ( (signed int)a7 >= 20 )
         break;
-      StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, X, &a7);
+      StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, bLightBackfaces, &a7);
       ++v6;
       ++v8;
     }
-    while ( v6 < uNumMobileLightsApplied );
+    while ( v6 < pMobileLightsStack->uNumLightsActive );
   }
   v9 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
+  if ( pStationaryLightsStack->uNumLightsActive > 0 )
   {
-    v10 = pStationaryLights;
+    v10 = pStationaryLightsStack->pLights;
     do
     {
       if ( (signed int)a7 >= 20 )
         break;
-      StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, X, &a7);
+      StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, bLightBackfaces, &a7);
       ++v9;
       ++v10;
     }
-    while ( v9 < uNumStationaryLightsApplied );
+    while ( v9 < pStationaryLightsStack->uNumLightsActive );
   }
-  result = a7;
-  stru_F8AD28.field_AC = a7;
-  LOBYTE(result) = 1;
-  return result;
+
+  stru_F8AD28.uNumLightsApplied = a7;
+  return true;
 }
 // 519AB4: using guessed type int uNumStationaryLightsApplied;
 
@@ -1483,16 +1372,16 @@
   v54 = abs(v60);
   v55 = pRenderer->bUsingSpecular;
   stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54;
-  stru_F8AD28._blv_lights_smthngs[*v53] = v8->field_B;
+  stru_F8AD28._blv_lights_types[*v53] = v8->uLightType;
   v56 = pRenderer->pRenderD3D;
-  v57 = stru_F8AD28._blv_lights_smthngs[*v53];
+  v57 = stru_F8AD28._blv_lights_types[*v53];
   if ( pRenderer->pRenderD3D && v55 && v57 & 4 )
-    v57 = byte_4E94D2;
-  stru_F8AD28._blv_lights_smthngs[*v53] = v57;
+    v57 = _4E94D2_light_type;
+  stru_F8AD28._blv_lights_types[*v53] = v57;
   result = 4 * *v53;
   if ( v56 && v55 )
   {
-    if ( stru_F8AD28._blv_lights_smthngs[*v53] & 4 )
+    if ( stru_F8AD28._blv_lights_types[*v53] & 4 )
     {
       *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
                                                               * 0.33000001;
@@ -1506,7 +1395,7 @@
   LOBYTE(result) = 1;
   return result;
 }
-// 4E94D2: using guessed type char byte_4E94D2;
+// 4E94D2: using guessed type char _4E94D2_light_type;
 
 //----- (0045D3C7) --------------------------------------------------------
 bool LightmapBuilder::_45D3C7(stru148 *a1)
--- a/LightmapBuilder.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/LightmapBuilder.h	Fri Oct 26 23:22:41 2012 +0600
@@ -42,19 +42,19 @@
   int _45D426(struct Span *a1, struct Edge **a2, unsigned int a3, struct Edge *a4, int a5);
   bool _45D3C7(struct stru148 *a1);
   bool StackLight_TerrainFace(struct StationaryLight *pLight, struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot);
-  bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X);
+  bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces);
   bool ApplyLight_ODM(struct StationaryLight *pLight, struct ODMFace *pFace, unsigned int *pSlot, char a4);
   bool ApplyLights_OutdoorFace(struct ODMFace *pFace);
   double _45CC0C_light(struct Vec3_float_ a1, float a2, float a3, struct Vec3_float_ *pNormal, float a5, int uLightType);
   int _45CBD4(struct RenderVertexSoft *a2, int a3, int *a4, int *a5);
   int _45CB89(struct RenderVertexSoft *a1, int a2);
   int _45CA88(struct stru320 *a2, struct RenderVertexSoft *a3, int a4, struct Vec3_float_ *pNormal);
-  bool ApplyLight_BLV(struct StationaryLight *pLight, struct BLVFace *a2, unsigned int *pSlot, char X, int a5);
+  bool ApplyLight_BLV(struct StationaryLight *pLight, struct BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5);
   bool ApplyLights_IndoorFace(unsigned int uFaceID);
   int _45C6D6(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap);
   int _45C4B9(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap);
-  char _45BE86_build_light_polygon(int arg0, float a4, unsigned int uColorMask, float a5, int uLightType, struct stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag);
-  char ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char a7);
+  bool _45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, struct stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag);
+  bool ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char uClipFlag);
 
 
   void (__thiscall ***vdestructor_ptr)(LightmapBuilder *, bool);
@@ -83,8 +83,8 @@
 
 
 extern LightsStack_StationaryLight_ *pStationaryLightsStack;
-extern StationaryLight pStationaryLights[400];
-extern int uNumStationaryLightsApplied; // weak
+//extern StationaryLight pStationaryLights[400];
+//extern int uNumStationaryLightsApplied; // weak
 extern LightsStack_MobileLight_ *pMobileLightsStack;
-extern MobileLight pMobileLights[400];
-extern int uNumMobileLightsApplied;
\ No newline at end of file
+//extern MobileLight pMobileLights[400];
+//extern int uNumMobileLightsApplied;
\ No newline at end of file
--- a/Lights.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/Lights.h	Fri Oct 26 23:22:41 2012 +0600
@@ -13,7 +13,7 @@
   unsigned __int8 uLightColorR;
   unsigned __int8 uLightColorG;
   unsigned __int8 uLightColorB;
-  char field_B;
+  char uLightType;
 };
 #pragma pack(pop)
 
@@ -28,7 +28,7 @@
   unsigned __int8 uLightColorR;
   unsigned __int8 uLightColorG;
   unsigned __int8 uLightColorB;
-  char field_B;
+  char uLightType;
   __int16 field_C;
   __int16 uSectorID;
   __int16 field_10;
@@ -72,7 +72,7 @@
   }
 
   //----- (004AD3C8) --------------------------------------------------------
-  inline bool AddLight(__int16 x, __int16 y, __int16 z, __int16 a5, unsigned char r, unsigned char g, unsigned char b, char a9)
+  inline bool AddLight(__int16 x, __int16 y, __int16 z, __int16 a5, unsigned char r, unsigned char g, unsigned char b, char uLightType)
   {
     unsigned int v9; // eax@1
     std::string v11; // [sp-18h] [bp-18h]@3
@@ -92,7 +92,7 @@
       pLight->uLightColorR = (unsigned __int8)r;
       pLight->uLightColorG = g;
       pLight->uLightColorB = b;
-      pLight->field_B = a9;
+      pLight->uLightType = uLightType;
       return true;
   }
 
@@ -123,7 +123,7 @@
     this->uNumLightsActive = 0;
   }
   
-  bool AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, int *a10);
+  bool AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, char a10);
 
 
 
--- a/LightsStack.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/LightsStack.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -4,38 +4,25 @@
 #include "mm7_data.h"
 
 //----- (00467D88) --------------------------------------------------------
-bool LightsStack_MobileLight_::AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, int *a10)
+bool LightsStack_MobileLight_::AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, char uLightType)
 {
-  unsigned int v10; // eax@1
-  int v11; // esi@2
-  MobileLight *result; // eax@2
-  std::string v13; // [sp-18h] [bp-1Ch]@3
-  const char *v14; // [sp-8h] [bp-Ch]@3
-  int v15; // [sp-4h] [bp-8h]@3
-
-  v10 = this->uNumLightsActive;
-  if ( (signed int)v10 >= 400 )
+  if (uNumLightsActive >= 400)
   {
     MessageBoxW(nullptr, L"Too many mobile lights!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MobileLightStack.cpp:51", 0);
-    result = 0;
+    return false;
   }
-  else
-  {
-    v11 = uRadius;
-    result = &this->pLights[v10];
-    result->vPosition.x = x;
-    result->vPosition.y = y;
-    result->vPosition.z = z;
-    result->uRadius = v11;
-    result->field_C = (((v11 < 0) - 1) & 0x3E) - 31;
-    result->uSectorID = uSectorID;
-    result->field_10 = v11 * v11 >> 5;
-    result->uLightColorR = r;
-    result->uLightColorG = g;
-    result->uLightColorB = b;
-    result->field_B = (char)a10;
-    ++this->uNumLightsActive;
-    LOBYTE(result) = 1;
-  }
-  return (bool)result;
+
+  pLights[uNumLightsActive].vPosition.x = x;
+  pLights[uNumLightsActive].vPosition.y = y;
+  pLights[uNumLightsActive].vPosition.z = z;
+  pLights[uNumLightsActive].uRadius = uRadius;
+  pLights[uNumLightsActive].field_C = (((uRadius < 0) - 1) & 0x3E) - 31;
+  pLights[uNumLightsActive].uSectorID = uSectorID;
+  pLights[uNumLightsActive].field_10 = uRadius * uRadius >> 5;
+  pLights[uNumLightsActive].uLightColorR = r;
+  pLights[uNumLightsActive].uLightColorG = g;
+  pLights[uNumLightsActive].uLightColorB = b;
+  pLights[uNumLightsActive++].uLightType = uLightType;
+
+  return true;
 }
--- a/Outdoor.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Outdoor.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -61,8 +61,8 @@
                                           * (signed __int64)pParty->field_18) >> 16);
   v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
   pIndoorCamera->field_4C = v1;
-  pIndoorCamera->pos.y = pParty->vPosition.z - ((unsigned __int64)(v3 * (signed __int64)pParty->field_18) >> 16);
-  pIndoorCamera->pos.z = pParty->vPosition.y + pParty->sEyelevel;
+  pIndoorCamera->pos.y = pParty->vPosition.y - ((unsigned __int64)(v3 * (signed __int64)pParty->field_18) >> 16);
+  pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   if ( v2 || pRenderer->pRenderD3D )
   {
     ResetStru148s();
@@ -70,7 +70,7 @@
     sub_481ED9_MessWithOutdoorCamera();
   }
   pIndoorCamera->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x);
-  pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.z);
+  pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y);
   if ( v2 )
   {
     Software_ResetNewEdges();
@@ -104,8 +104,8 @@
   sr_sub_486F92_MessWithEdgesAndSpans();
   pOutdoorCamera->_487355();
 LABEL_16:
-  uNumMobileLightsApplied = 0;
-  uNumStationaryLightsApplied = 0;
+  pMobileLightsStack->uNumLightsActive = 0;
+  pStationaryLightsStack->uNumLightsActive = 0;
   if ( !pRenderer->pRenderD3D )
   {
     pRenderer->ExecOutdoorDrawSW();
@@ -115,7 +115,7 @@
   pGame->PrepareBloodsplats();
   if ( v2 )
   {
-    v4 = WorldPosToGridCellZ(pParty->vPosition.z);
+    v4 = WorldPosToGridCellZ(pParty->vPosition.y);
     v5 = WorldPosToGridCellX(pParty->vPosition.x);
     pOutdoor->_47EF60(v5, v4, 1);
   }
@@ -500,7 +500,7 @@
     || v15 )
     return 2;
   v5 = WorldPosToGridCellX(pParty->vPosition.x);
-  v6 = WorldPosToGridCellZ(pParty->vPosition.z);
+  v6 = WorldPosToGridCellZ(pParty->vPosition.y);
   v7 = _47ED83(v5, v6 - 1);
   v8 = pTileTable->pTiles[_47ECC1(v7)].uTerrainType;
   if ( v8 )
@@ -1805,7 +1805,7 @@
       {
         v62 = pBitmaps_LOD->LoadTexture(Str2);
         v63 = (ODMFace *)pFilename;
-        BYTE1(v63->uFaceAttributes) &= 0xBFu;
+        BYTE1(v63->uAttributes) &= 0xBFu;
 LABEL_68:
         v63->uTextureID = v62;
         v145 = (signed __int16)v62 != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62] : 0;
@@ -2048,7 +2048,7 @@
         File = 0;
         do
         {
-          v106 = (char *)&File->uFaceAttributes + *(int *)(v87 + 84);
+          v106 = (char *)&File->uAttributes + *(int *)(v87 + 84);
           memcpy(v106, v85, 4u);
           v88 = v5->pBModels;
           ++File;
@@ -2070,9 +2070,9 @@
           if ( v90->sCogTriggeredID )
           {
             if ( v90->HasEventHint() )
-              BYTE2(File->uFaceAttributes) |= 0x10u;
+              BYTE2(File->uAttributes) |= 0x10u;
             else
-              BYTE2(File->uFaceAttributes) &= 0xEFu;
+              BYTE2(File->uAttributes) &= 0xEFu;
           }
           ++thisa;
           v89 = v5->pBModels;
@@ -2778,7 +2778,7 @@
   __int16 v13; // cx@21
   SpriteFrame *v14; // eax@24
   SpriteFrame *v15; // ebx@25
-  int *v16; // eax@25
+  //int *v16; // eax@25
   int v17; // eax@35
   int v18; // ST78_4@36
   int v19; // eax@36
@@ -2911,19 +2911,19 @@
 LABEL_25:
       v62 = 0;
       v15 = v14;
-      v16 = (int *)v14->uFlags;
-      if ( (unsigned __int8)v16 & 2 )
+      //v16 = (int *)v14->uFlags;
+      if (v14->uFlags & 2)
         v62 = 2;
-      if ( (unsigned int)v16 & 0x40000 )
+      if (v14->uFlags & 0x40000)
         v62 |= 0x40u;
-      if ( (unsigned int)v16 & 0x20000 )
+      if (v14->uFlags & 0x20000)
         LOBYTE(v62) = v62 | 0x80;
-      if ( (256 << v41) & (unsigned int)v16 )
+      if ((256 << v41) & v14->uFlags)
         v62 |= 4u;
       if ( v15->uGlowRadius )
       {
-        LOBYTE(v16) = byte_4E94D3;
-        pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, v16);
+        //LOBYTE(v16) = byte_4E94D3;
+        pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
       }
       v17 = (x - pIndoorCamera->pos.x) << 16;
       if ( pIndoorCamera->sRotationX )
--- a/Outdoor.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/Outdoor.h	Fri Oct 26 23:22:41 2012 +0600
@@ -74,13 +74,16 @@
 
   
   static bool IsBackfaceCulled(struct ODMFace *a1, struct RenderVertexSoft *a2, struct stru148 *a3);
-
+  
+  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Visible() const   {return !Invisible();}
+  inline bool TwoSided() const  {return uAttributes & FACE_TWO_SIDED;}
 
   struct Plane_int_ pFacePlane;
   int zCalc1;
   int zCalc2;
   int zCalc3;
-  unsigned int uFaceAttributes;
+  unsigned int uAttributes;
   unsigned __int16 pVertexIDs[20];
   unsigned __int16 pTextureUIDs[20];
   unsigned __int16 pTextureVIDs[20];
--- a/ParticleEngine.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/ParticleEngine.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -390,9 +390,9 @@
           1) )
     return 0;
   pGame->pIndoorCameraD3D->Project(uParticleID, y, z, (int *)&a5 + 1, &a6);
-  pParticle->flt_5C = pGame->pIndoorCameraD3D->flt_D0;
+  pParticle->flt_5C = pGame->pIndoorCameraD3D->fov_x;
   v4 = pParticle->flt_5C;
-  pParticle->flt_60 = pGame->pIndoorCameraD3D->flt_D4;
+  pParticle->flt_60 = pGame->pIndoorCameraD3D->fov_y;
   v5 = v4 + 6.7553994e15;
   LODWORD(v6) = 0;
   HIDWORD(v6) = SLOWORD(v5);
--- a/Party.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Party.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -775,8 +775,8 @@
         if ( ((Actor *)((char *)v0 - 59))->Actor::CanAct() && *((char *)v0 + 2) != 4 && *(char *)v0 != 5 )
         {
           v1 = abs(*(short *)((char *)v0 + 83) - pParty->vPosition.x);
-          v2 = abs(*(short *)((char *)v0 + 85) - pParty->vPosition.z);
-          v3 = abs(*(short *)((char *)v0 + 87) - pParty->vPosition.y);
+          v2 = abs(*(short *)((char *)v0 + 85) - pParty->vPosition.y);
+          v3 = abs(*(short *)((char *)v0 + 87) - pParty->vPosition.z);
           if ( (double)sub_4621DA(v1, v2, v3) < 512.0 )
             Actor::_402968(v4, 4, 0, 0);
         }
--- a/Party.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/Party.h	Fri Oct 26 23:22:41 2012 +0600
@@ -148,8 +148,12 @@
   static void TakeFood(unsigned int uNumFood);
   static __int16 GiveFood(unsigned int _this);
 
-  inline bool WizardEyeActive()     {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;}
-  inline int  WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;}
+  inline bool WizardEyeActive()      {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;}
+  inline int  WizardEyeSkillLevel()  {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;}
+  inline bool FlyActive()            {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;}
+  inline bool WaterWalkActive()      {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;}
+  inline bool ImmolationActive()     {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;}
+  inline bool ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;}
 
 
   int field_0;
--- a/Player.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Player.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -4143,7 +4143,7 @@
     LOBYTE(v7) = GetActualSkillLevel(PLAYER_SKILL_UNARMED);
     if ( v7 )
     {
-      v6 = (unsigned __int16)word_4EDEDC;
+      v6 = (unsigned __int16)word_4EDED8[1];
 LABEL_4:
       v47 = v6;
       goto LABEL_17;
--- a/Render.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Render.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -1634,8 +1634,8 @@
           {
             a1->ViewTransform(&ptr_801A08[_ESI], 1u);
             a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->_436BB7_project_and_stuff(&ptr_801A08[_ESI], 1u, 0);
-            a1->_436BB7_project_and_stuff(&ptr_801A04[_ESI], 1u, 0);
+            a1->Project(&ptr_801A08[_ESI], 1u, 0);
+            a1->Project(&ptr_801A04[_ESI], 1u, 0);
           }
           v79 += 512;
           ++_ESI;
@@ -1723,8 +1723,8 @@
           {
             a1->ViewTransform(&ptr_801A08[_ESI], 1u);
             a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->_436BB7_project_and_stuff(&ptr_801A08[_ESI], 1u, 0);
-            a1->_436BB7_project_and_stuff(&ptr_801A04[_ESI], 1u, 0);
+            a1->Project(&ptr_801A08[_ESI], 1u, 0);
+            a1->Project(&ptr_801A04[_ESI], 1u, 0);
           }
           v92 -= 512;
           ++_ESI;
@@ -1988,7 +1988,7 @@
           if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 )
             goto LABEL_162;
           thisa->ViewTransform(array_50AC10, a5);
-          thisa->_436BB7_project_and_stuff(array_50AC10, a5, 0);
+          thisa->Project(array_50AC10, a5, 0);
         }
         this_3 = a2->vWorldViewPosition.x < 8.0
               || a8->vWorldViewPosition.x < 8.0
@@ -2001,7 +2001,7 @@
             || v32 < pVertices->vWorldViewPosition.x;
         LOBYTE(v33) = 0;
         pGame->pLightmapBuilder->std__vector_000004_size = 0;
-        if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
         {
           if ( this_3 )
             LOBYTE(v33) = 3;
@@ -2019,7 +2019,7 @@
               v33,
               -1);
         }
-        if ( stru_F8AD28.field_AC > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 )
           pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
         v34 = a5;
         v35 = byte_4D864C == 0;
@@ -2142,14 +2142,14 @@
         goto LABEL_112;
       }
       thisb->ViewTransform(array_50AC10, uNumVertices);
-      thisb->_436BB7_project_and_stuff(array_50AC10, uNumVertices, 0);
+      thisb->Project(array_50AC10, uNumVertices, 0);
     }
     this_3a = a2->vWorldViewPosition.x < 8.0 || a8->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0;
     v54 = (double)pOutdoorCamera->shading_dist_mist;
     v108 = v54 < a2->vWorldViewPosition.x || v54 < a8->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x;
     a8 = 0;
     v96->std__vector_000004_size = 0;
-    if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
     {
       a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0);
       static_sub_0048034E_stru_76D590._49B0C9(v99, *(float *)&a4);
@@ -2164,7 +2164,7 @@
           (char)a8,
           -1);
     }
-    if ( stru_F8AD28.field_AC > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 )
       v96->ApplyLights(
         &stru_F8AD28,
         &static_sub_0048034E_stru_76D590,
@@ -2279,7 +2279,7 @@
       if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 )
         goto LABEL_126;
       thisc->ViewTransform(array_50AC10, v100);
-      thisc->_436BB7_project_and_stuff(array_50AC10, v100, 0);
+      thisc->Project(array_50AC10, v100, 0);
     }
     this_3b = a2->vWorldViewPosition.x < 8.0
            || pVertices->vWorldViewPosition.x < 8.0
@@ -2288,7 +2288,7 @@
     v108 = v69 < a2->vWorldViewPosition.x || v69 < pVertices->vWorldViewPosition.x || v69 < _ECX->vWorldViewPosition.x;
     LOBYTE(v70) = 0;
     v96->std__vector_000004_size = 0;
-    if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
     {
       if ( this_3b )
         LOBYTE(v70) = 3;
@@ -2306,7 +2306,7 @@
           v70,
           -1);
     }
-    if ( stru_F8AD28.field_AC > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 )
       v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
     v71 = a8;
     v72 = v100;
@@ -2584,7 +2584,7 @@
         array_50AC10[3].u = 1.0;
         array_50AC10[3].v = 0.0;
         pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1);
-        if ( stru_F8AD28.field_AC <= 0 )
+        if ( stru_F8AD28.uNumLightsApplied <= 0 )
         {
           v17->field_108 = 0;
         }
@@ -2700,7 +2700,7 @@
     array_50AC10[2].u = 1.0;
     array_50AC10[2].v = 1.0;
     pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0);
-    if ( stru_F8AD28.field_AC <= 0 )
+    if ( stru_F8AD28.uNumLightsApplied <= 0 )
     {
       v38->field_108 = 0;
     }
@@ -2794,7 +2794,7 @@
           array_50AC10[2].u = 1.0;
           array_50AC10[2].v = 0.0;
           pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1);
-          if ( stru_F8AD28.field_AC <= 0 )
+          if ( stru_F8AD28.uNumLightsApplied <= 0 )
           {
             v17->field_108 = 0;
           }
@@ -3063,7 +3063,7 @@
             if ( a6 )
             {
               LOBYTE(v11) = byte_4E94D3;
-              pMobileLightsStack->AddLight(x, y, z, a5, a6, 0xFFu, 0xFFu, 0xFFu, v11);
+              pMobileLightsStack->AddLight(x, y, z, a5, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
             }
             v12 = (x - pIndoorCamera->pos.x) << 16;
             if ( pIndoorCamera->sRotationX )
--- a/Render.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/Render.h	Fri Oct 26 23:22:41 2012 +0600
@@ -54,8 +54,8 @@
 {
   int field_0;
   int field_4;
-  float flt_8;
-  float flt_C;
+  float fov_x;
+  float fov_y;
   int sZValue;
   int field_14;
   unsigned __int16 uHwSpriteID;
--- a/SaveLoad.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/SaveLoad.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -42,45 +42,13 @@
 //----- (0045EE8A) --------------------------------------------------------
 void __fastcall LoadGame(unsigned int uSlot)
 {
-  //unsigned int v1; // ebx@1
-  //char v2; // zf@1
-  //signed int v3; // esi@3
-  //signed int v4; // esi@8
-  //char *v5; // eax@9
-  //unsigned int v6; // eax@12
-  //unsigned int v7; // esi@13
-  //char *v8; // ecx@14
-  //FILE *v9; // eax@22
-  //FILE *v10; // eax@26
-  //FILE *v11; // eax@29
-  //FILE *v12; // eax@32
-  //FILE *v13; // eax@35
-  //FILE *v14; // eax@38
-  //unsigned int v15; // edi@41
-  //Player *v16; // esi@41
-  //int *v17; // esi@46
-  //int v18; // edi@46
-  //int v19; // ebx@46
-  //int v20; // ecx@49
-  //int v21; // eax@51
-  //int v22; // ecx@56
-  //bool v23; // edx@56
-  //AudioPlayer *v24; // ebx@60
   bool v25; // esi@62
   bool v26; // eax@62
-  //signed int v27; // esi@66
-  //RGBTexture *v28; // edi@67
-  std::string v29; // [sp-18h] [bp-108h]@25
   int v30; // [sp-Ch] [bp-FCh]@65
   int v31; // [sp-8h] [bp-F8h]@4
-  //signed int v32; // [sp-4h] [bp-F4h]@4
   char DstBuf[100]; // [sp+Ch] [bp-E4h]@23
-  //char pContainer; // [sp+20h] [bp-D0h]@62
   char Str[123]; // [sp+70h] [bp-80h]@25
-  //char a3[5]; // [sp+EBh] [bp-5h]@2
 
-  //v1 = uSlot;
-  //v2 = pSavegameUsedSlots[uSlot] == 0;
   dword_5B65C8 = 0;
   if (!pSavegameUsedSlots[uSlot])
   {
@@ -340,13 +308,13 @@
     DstBuf = operator new(0xF4240u);
     pDir.Reset();
     v52 = pParty->vPosition.x;
-    v51 = pParty->vPosition.z;
-    v62 = pParty->vPosition.y;
+    v51 = pParty->vPosition.y;
+    v62 = pParty->vPosition.z;
     v53 = pParty->sRotationY;
     v54 = pParty->sRotationX;
     pParty->vPosition.x = pParty->vPrevPosition.x;
-    pParty->vPosition.z = pParty->vPrevPosition.z;
-    pParty->vPosition.y = pParty->vPrevPosition.y;
+    pParty->vPosition.y = pParty->vPrevPosition.z;
+    pParty->vPosition.z = pParty->vPrevPosition.y;
     pParty->uFallStartY = pParty->vPrevPosition.y;
     pParty->sRotationY = pParty->sPrevRotationY;
     pParty->sRotationX = pParty->sPrevRotationX;
@@ -669,8 +637,8 @@
       }
     }
     pParty->vPosition.x = v52;
-    pParty->vPosition.z = v51;
-    pParty->vPosition.y = v62;
+    pParty->vPosition.y = v51;
+    pParty->vPosition.z = v62;
     pParty->uFallStartY = v62;
     pParty->sRotationY = v53;
     result = v54;
--- a/Texture.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Texture.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -1114,315 +1114,194 @@
 //----- (0040EAD8) --------------------------------------------------------
 unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile)
 {
-  RGBTexture *v4; // esi@1
-  unsigned int result; // eax@2
-  unsigned int v6; // ebx@3
-  unsigned __int16 v7; // cx@5
-  unsigned __int16 v8; // ax@5
-  unsigned int v9; // eax@5
-  char v10; // zf@5
-  signed int v11; // ecx@14
-  int v12; // ebx@19
-  signed int v13; // ecx@19
-  int v14; // ebx@52
-  unsigned __int16 *v15; // edi@52
-  __int16 v16; // ax@54
-  unsigned __int16 *v17; // edi@59
-  __int16 v18; // ax@61
-  unsigned __int16 *v19; // edi@66
-  unsigned __int16 v20; // ax@68
-  int v21; // eax@73
-  char DstBuf[60]; // [sp+Ch] [bp-90h]@3
-  char pColorMap[48]; // [sp+48h] [bp-54h]@3
-  PCXHeader1 pcxh1; // [sp+78h] [bp-24h]@3
-  PCXHeader2 pcxh2; // [sp+88h] [bp-14h]@3
-  int v26; // [sp+90h] [bp-Ch]@51
-  int v27; // [sp+94h] [bp-8h]@54
-  unsigned __int8 v28; // [sp+9Bh] [bp-1h]@54
+  signed int result; // eax@2
+  unsigned char test_byte; // edx@3
+  //unsigned int read_offset; // ebx@37
+  unsigned int row_position; // edi@40
+  unsigned char value; // cl@63
+  char count; // [sp+50h] [bp-Ch]@43
+  unsigned short current_line; // [sp+54h] [bp-8h]@38
+  unsigned short *dec_position; 
+  unsigned short *temp_dec_position; 
+  PCXHeader1 psx_head1;
+  PCXHeader2 psx_head2;
+	short int width, height;
+	BYTE  color_map[48];	// Colormap for 16-color images
 
-  v4 = this;
   if (!pFile)
     return 1;
+  
+ 
+ fread(&psx_head1, 1, 16, pFile);
+ fread(&color_map, 1, 48, pFile);
+ fread(&psx_head2, 1, 6, pFile);
+
+  if (psx_head1.bpp!=8)
+		return 3; 
+ uWidth=(short int )(psx_head1.right-psx_head1.left+1);  // word @ 000014
+ uHeight=(short int )(psx_head1.bottom-psx_head1.up+1);  // word @ 000016
  
 
-    fread(&pcxh1, 1u, 1u, pFile);
-    fread(&pcxh1.version, 1u, 1u, pFile);
-    fread(&pcxh1.encoding, 1u, 1u, pFile);
-    fread(&pcxh1.bpp, 1u, 1u, pFile);
-    v6 = 2;
-    fread(&pcxh1.left, 2u, 1u, pFile);
-    fread(&pcxh1.up, 2u, 1u, pFile);
-    fread(&pcxh1.right, 2u, 1u, pFile);
-    fread(&pcxh1.bottom, 2u, 1u, pFile);
-    fread(&pcxh1.hres, 2u, 1u, pFile);
-    fread(&pcxh1.vres, 2u, 1u, pFile);
-    fread(pColorMap, 0x30u, 1u, pFile);
-    fread(&pcxh2, 1u, 1u, pFile);
-    fread(&pcxh2.planes, 1u, 1u, pFile);
-    fread(&pcxh2.pitch, 2u, 1u, pFile);
-    fread(&pcxh2.palette_info, 2u, 1u, pFile);
-    fread(DstBuf, 58u, 1u, pFile);
-    if ( pcxh1.bpp == 8 )
-    {
-      v7 = pcxh1.right - pcxh1.left + 1;
-      v8 = pcxh1.bottom - pcxh1.up;
-      v4->uWidth = v7;
-      ++v8;
-      v4->uHeight = v8;
-      v9 = (signed __int16)v7 * (signed __int16)v8;
-      v10 = mode == 0;
-      v4->uNumPixels = v9;
-      if ( v10 )
+ uNumPixels=uWidth*uHeight;		  // dword @ 000010
+
+
+      if ( mode == 0 )
       {
-        if ( v4->pPixels )
+        if ( pPixels )
         {
-          pAllocator->FreeChunk(v4->pPixels);
-          v4->pPixels = 0;
+          pAllocator->FreeChunk(pPixels);
+          pPixels = 0;
         }
-        v4->pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk(
-                                            v4->pPixels,
-                                            2 * v4->uNumPixels + 4,
-                                            v4->pName);
-        v6 = 2;
+        pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk(
+                                            pPixels,
+                                            2 * uNumPixels + 4,
+                                            pName);
       }
       else
       {
         if ( mode != 1 && mode == 2 )
         {
-          operator new(2 * v9 + 4);
-          v4->pPixels = 0;
-          *(unsigned int *)&v4->field_20 |= 1u;
+          pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16));
+          field_20 |= 1;
         }
       }
-      if ( v4->pPixels )
+
+
+
+
+      auto pOutPixels = pPixels;
+ 
+ memset(pOutPixels, 0, uNumPixels * sizeof(__int16));
+
+  short i=1;
+  while ( (1<<i) !=uWidth)
+  {
+	  ++i;
+      if (i >= 15)
+	  break;
+  }
+  field_18=i;
+  short i_=1;
+  while ( (1<<i_) !=uHeight)
+  {
+	  ++i_;
+      if (i_ >= 15)
+	  break;
+  }
+  field_1A=i_;
+  switch (field_18)
+	  {
+  case 2:   field_1C = 3;    break;
+  case 3:   field_1C = 7;    break;
+  case 4:   field_1C = 15;   break;
+  case 5:   field_1C = 31;   break;
+  case 6:   field_1C = 63;   break;
+  case 7:   field_1C = 127;  break;
+  case 8:   field_1C = 255;  break;
+  case 9:   field_1C = 511;  break;
+  case 10:  field_1C = 1023; break;
+  case 11:  field_1C = 2047; break;
+  case 12:  field_1C = 4095; break;
+	  }
+
+  switch (field_1A)
+	  {
+  case 2:   field_1E = 3;    break;
+  case 3:   field_1E = 7;    break;
+  case 4:   field_1E = 15;   break;
+  case 5:   field_1E = 31;   break;
+  case 6:   field_1E = 63;   break;
+  case 7:   field_1E = 127;  break;
+  case 8:   field_1E = 255;  break;
+  case 9:   field_1E = 511;  break;
+  case 10:  field_1E = 1023; break;
+  case 11:  field_1E = 2047; break;
+  case 12:  field_1E = 4095; break;
+	  }
+
+
+  fseek(pFile, 128 - 70, SEEK_CUR);
+
+
+  for (uint y = 0; y < uHeight; ++y)
+  {
+    unsigned __int16 *pDst = pPixels + y * uWidth;
+
+    uint x = 0;
+    do
+    {
+      uint ctrl = 0;
+      fread(&ctrl, 1, 1, pFile);
+      if ((ctrl & 0xC0) == 0xC0)
       {
-        v11 = 1;
-        while ( 1 << v11 != v4->uWidth )
-        {
-          ++v11;
-          if ( v11 >= 15 )
-            goto LABEL_19;
-        }
-        v4->field_18 = v11;
-LABEL_19:
-        v12 = v4->uHeight;
-        v13 = 1;
-        while ( 1 << v13 != v12 )
-        {
-          ++v13;
-          if ( v13 >= 15 )
-            goto LABEL_24;
-        }
-        v4->field_1A = v13;
-LABEL_24:
-        switch ( v4->field_18 )
-        {
-          case 2:
-            v4->field_1C = 3;
-            break;
-          case 3:
-            v4->field_1C = 7;
-            break;
-          case 4:
-            v4->field_1C = 15;
-            break;
-          case 5:
-            v4->field_1C = 31;
-            break;
-          case 6:
-            v4->field_1C = 63;
-            break;
-          case 7:
-            v4->field_1C = 127;
-            break;
-          case 8:
-            v4->field_1C = 255;
-            break;
-          case 9:
-            v4->field_1C = 511;
-            break;
-          case 10:
-            v4->field_1C = 1023;
-            break;
-          case 11:
-            v4->field_1C = 2047;
-            break;
-          case 12:
-            v4->field_1C = 4095;
-            break;
-          default:
-            break;
-        }
-        switch ( v4->field_1A )
-        {
-          case 2:
-            v4->field_1E = 3;
-            break;
-          case 3:
-            v4->field_1E = 7;
-            break;
-          case 4:
-            v4->field_1E = 15;
-            break;
-          case 5:
-            v4->field_1E = 31;
-            break;
-          case 6:
-            v4->field_1E = 63;
-            break;
-          case 7:
-            v4->field_1E = 127;
-            break;
-          case 8:
-            v4->field_1E = 255;
-            break;
-          case 9:
-            v4->field_1E = 511;
-            break;
-          case 10:
-            v4->field_1E = 1023;
-            break;
-          case 11:
-            v4->field_1E = 2047;
-            break;
-          case 12:
-            v4->field_1E = 4095;
-            break;
-          default:
-            break;
-        }
-        if ( pcxh2.planes == 1 )
-          Abortf("24bit PCX Only!");
-        if ( pcxh2.planes == 3 )
-        {
-          v26 = 0;
-          if ( v12 > 0 )
-          {
-            do
-            {
-              v14 = 0;
-              v15 = &v4->pPixels[v26 * v4->uWidth];
-              if ( pcxh2.pitch )
-              {
-                do
-                {
-                  fread((char *)&mode + 3, 1u, 1u, pFile);
-                  if ( (BYTE3(mode) & 0xC0) == -64 )
-                  {
-                    BYTE3(mode) &= 0x3Fu;
-                    fread(&v28, 1u, 1u, pFile);
-                    v27 = 0;
-                    v16 = v28;
-                    if ( BYTE3(mode) )
-                    {
-                      do
-                      {
-                        ++v14;
-                        *v15 = LOWORD(pRenderer->uTargetRMask) & (v16 << (pRenderer->uTargetGBits
-                                                                       + pRenderer->uTargetRBits
-                                                                       + pRenderer->uTargetBBits
-                                                                       - 8));
-                        ++v15;
-                        ++v27;
-                      }
-                      while ( v27 < BYTE3(mode) );
-                    }
-                  }
-                  else
-                  {
-                    ++v14;
-                    *v15 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(mode) << (pRenderer->uTargetGBits
-                                                                           + pRenderer->uTargetRBits
-                                                                           + pRenderer->uTargetBBits
-                                                                           - 8));
-                    ++v15;
-                  }
-                }
-                while ( v14 < (unsigned __int16)pcxh2.pitch );
-              }
-              v17 = &v4->pPixels[v26 * v4->uWidth];
-              while ( v14 < 2 * (unsigned __int16)pcxh2.pitch )
-              {
-                fread((char *)&mode + 3, 1u, 1u, pFile);
-                if ( (BYTE3(mode) & 0xC0) == -64 )
-                {
-                  BYTE3(mode) &= 0x3Fu;
-                  fread(&v28, 1u, 1u, pFile);
-                  v27 = 0;
-                  v18 = v28;
-                  if ( BYTE3(mode) )
-                  {
-                    do
-                    {
-                      *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(v18 << (pRenderer->uTargetGBits
-                                                                                + pRenderer->uTargetBBits
-                                                                                - 8));
-                      ++v14;
-                      ++v17;
-                      ++v27;
-                    }
-                    while ( v27 < BYTE3(mode) );
-                  }
-                }
-                else
-                {
-                  *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(mode) << (pRenderer->uTargetGBits
-                                                                                    + pRenderer->uTargetBBits
-                                                                                    - 8));
-                  ++v14;
-                  ++v17;
-                }
-              }
-              v19 = &v4->pPixels[v26 * v4->uWidth];
-              while ( v14 < 3 * (unsigned __int16)pcxh2.pitch )
-              {
-                fread((char *)&mode + 3, 1u, 1u, pFile);
-                if ( (BYTE3(mode) & 0xC0) == -64 )
-                {
-                  BYTE3(mode) &= 0x3Fu;
-                  fread(&v28, 1u, 1u, pFile);
-                  v27 = 0;
-                  v20 = v28;
-                  if ( BYTE3(mode) )
-                  {
-                    do
-                    {
-                      *v19 |= v20 >> (8 - pRenderer->uTargetBBits);
-                      ++v14;
-                      ++v19;
-                      ++v27;
-                    }
-                    while ( v27 < BYTE3(mode) );
-                  }
-                }
-                else
-                {
-                  *v19 |= BYTE3(mode) >> (8 - pRenderer->uTargetBBits);
-                  ++v14;
-                  ++v19;
-                }
-              }
-              v21 = v4->uHeight;
-              ++v26;
-            }
-            while ( v26 < v21 );
-          }
-        }
-        if ( bCloseFile )
-          fclose(pFile);
-        result = 0;
+        uint uNumPixels = ctrl & 0x3F;
+        uint clr = 0;
+        fread(&clr, 1, 1, pFile);
+        for (uint i = 0; i < uNumPixels; ++i)
+          pDst[x++] = pRenderer->uTargetRMask & (clr << (pRenderer->uTargetGBits +
+                                                         pRenderer->uTargetRBits +
+                                                         pRenderer->uTargetBBits - 8));
       }
       else
       {
-        result = v6;
+        pDst[x++] = pRenderer->uTargetRMask & (ctrl << (pRenderer->uTargetGBits +
+                                                        pRenderer->uTargetRBits +
+                                                        pRenderer->uTargetBBits - 8));
       }
-    }
-    else
+    } while (x < psx_head2.pitch);
+
+
+
+
+
+    x = 0;
+    do
     {
-      result = 3;
-    }
+      uint ctrl = 0;
+      fread(&ctrl, 1, 1, pFile);
+      if ((ctrl & 0xC0) == 0xC0)
+      {
+        uint uNumPixels = ctrl & 0x3F;
+        uint clr = 0;
+        fread(&clr, 1, 1, pFile);
+        for (uint i = 0; i < uNumPixels; ++i)
+          pDst[x++] |= pRenderer->uTargetGMask & (clr << (pRenderer->uTargetGBits +
+                                                         pRenderer->uTargetBBits - 8));
+      }
+      else
+      {
+        pDst[x++] |= pRenderer->uTargetGMask & (ctrl << (pRenderer->uTargetGBits +
+                                                        pRenderer->uTargetBBits - 8));
+      }
+    } while (x < psx_head2.pitch);
+ 
+
+
+
 
-  return result;
+    x = 0;
+    do
+    {
+      uint ctrl = 0;
+      fread(&ctrl, 1, 1, pFile);
+      if ((ctrl & 0xC0) == 0xC0)
+      {
+        uint uNumPixels = ctrl & 0x3F;
+        uint clr = 0;
+        fread(&clr, 1, 1, pFile);
+        for (uint i = 0; i < uNumPixels; ++i)
+          pDst[x++] |= pRenderer->uTargetBMask & (clr >> (8 - pRenderer->uTargetBBits));
+      }
+      else
+      {
+        pDst[x++] |= pRenderer->uTargetBMask & (ctrl >> (8 - pRenderer->uTargetRBits));
+      }
+    } while (x < psx_head2.pitch);
+  }
+
+  if (bCloseFile)
+    fclose(pFile);
+  return 0;
 }
 
 //----- (0040E51F) --------------------------------------------------------
--- a/TurnEngine.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/TurnEngine.h	Fri Oct 26 23:22:41 2012 +0600
@@ -18,7 +18,7 @@
 struct stru262_TurnBased
 {
   signed int _404544();
-  int _40471C();
+  void _40471C();
   signed int Start();
   void End(bool bPlaySound);
   void _405E14();
--- a/VideoPlayer.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/VideoPlayer.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -1192,10 +1192,10 @@
     {
       pAudioPlayer->PlaySound(SOUND_0, 0, 0, -1, 0, 0, 0, 0);
       ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
-      ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-      ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-      ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-      ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+      ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+      ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+      ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+      ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
     }
     bGameoverLoop = 0;
   }
--- a/Vis.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/Vis.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -93,7 +93,7 @@
     }
   }
   pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, v7);
-  pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(static_sub_4C1026_array_F8F200, v7, 1);
+  pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, v7, 1);
   v15 = this;
   SortVectors_x(static_sub_4C1026_array_F8F200, 0, v7 - 1);
   if ( static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > (double)a4
@@ -369,7 +369,7 @@
         v7 = v6;
         if ( is_part_of_selection(&pIndoor->pFaces[v6], a5) )
         {
-          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(&pIndoor->pFaces[v7]) )
+          if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v7]) )
           {
             if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, &pIndoor->pFaces[v7], 0xFFFFFFFFu) )
             {
@@ -1997,7 +1997,7 @@
       if ( v5 < (signed int)pIndoor->uNumFaces )
       {
         v6 = &pIndoor->pFaces[v5];
-        if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(&pIndoor->pFaces[v5]) )
+        if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v5]) )
         {
           if ( is_part_of_selection(v6, a2) )
           {
--- a/mm7_1.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_1.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -1758,19 +1758,19 @@
   uTextureID_BUTTMAKE2 = pIcons_LOD->LoadTexture("BUTTMAKE2", TEXTURE_16BIT_PALETTE);
 
   pGUIWindow0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
-  pGUIWindow0->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, 0xAu, 0, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  pGUIWindow0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x172u, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x61u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0xD4u, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x148u, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, nullstring, 0);
+  pGUIWindow0->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, 0xAu, 0, 0, "", 0);
+  pGUIWindow0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  pGUIWindow0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  pGUIWindow0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  pGUIWindow0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+  pGUIWindow0->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, "", 0);
+  pGUIWindow0->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x172u, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x61u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, "", 0);
+  pGUIWindow0->CreateButton(0xD4u, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x148u, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
   uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE);
   v6 = (Texture *)(uTextureID_ib_td1_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0);
   v7 = pGlobalTXT_LocalizationStrings[174];
@@ -1888,11 +1888,11 @@
                    v32,
                    v31,
                    0);
-  pGUIWindow0->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, 0, 0, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x86u, 0, 0x35u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x87u, 0, 0x36u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, 0, 0, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, 0, 0, 0, nullstring, 0);
+  pGUIWindow0->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, 0, 0, 0, "", 0);
+  pGUIWindow0->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x86u, 0, 0x35u, "", 0);
+  pGUIWindow0->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x87u, 0, 0x36u, "", 0);
+  pGUIWindow0->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, 0, 0, 0, "", 0);
+  pGUIWindow0->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, 0, 0, 0, "", 0);
   ptr_5079F8 = pGUIWindow0->CreateButton(
                  0x1DCu,
                  0x1C2u,
@@ -1955,7 +1955,7 @@
                  0xBCu,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_507990 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507990] : 0),
                  0);
   ptr_5079E8 = pGUIWindow0->CreateButton(
@@ -1968,7 +1968,7 @@
                  0xBCu,
                  1u,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_50798C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50798C] : 0),
                  0);
   Load_isn_spells_21_27();
@@ -2647,8 +2647,8 @@
       goto LABEL_116;
     }
     sprintfex(a1, pGlobalTXT_LocalizationStrings[463], *((int *)v3 + 2));
-    strcpy(Dest, nullstring);
-    strcpy(v64, nullstring);
+    strcpy(Dest, "");
+    strcpy(v64, "");
     v20 = v3[28];
     if ( (unsigned __int8)v20 <= 1u )
     {
@@ -3811,8 +3811,8 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
     uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(
                                    pParty->vPosition.x,
-                                   pParty->vPosition.z,
-                                   pParty->vPosition.y);
+                                   pParty->vPosition.y,
+                                   pParty->vPosition.z);
   if ( sub_476387() )
   {
     v0 = (char *)&pParty->pPlayers[0].uClass;
@@ -3858,7 +3858,7 @@
                           0xA7u,
                           0,
                           0,
-                          nullstring,
+                          "",
                           (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0),
                           0);
   pButton_RestUI_507634 = pGUIWindow_CurrentMenu->CreateButton(
@@ -3871,7 +3871,7 @@
                             0x61u,
                             0,
                             0x52u,
-                            nullstring,
+                            "",
                             (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0),
                             0);
   pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton(
@@ -3884,7 +3884,7 @@
                                    0x6Du,
                                    0,
                                    0x44u,
-                                   nullstring,
+                                   "",
                                    (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0),
                                    0);
   pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton(
@@ -3897,7 +3897,7 @@
                                0x60u,
                                0,
                                0x48u,
-                               nullstring,
+                               "",
                                (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0),
                                0);
   pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton(
@@ -3910,7 +3910,7 @@
                                   0x5Fu,
                                   0,
                                   0x4Du,
-                                  nullstring,
+                                  "",
                                   (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0),
                                   0);
 }
@@ -4542,9 +4542,9 @@
     }
     v18 = (double)pParty->vPosition.x - (double)v14;
     *(float *)&a4 = v18;
-    v19 = (double)pParty->vPosition.z - (double)v38;
+    v19 = (double)pParty->vPosition.y - (double)v38;
     v33 = v19;
-    v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.y - (double)v15;
+    v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15;
     *(float *)&sRotY = v19 * v19;
     *(float *)&sRotX = v18 * v18;
     v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY);
@@ -4649,7 +4649,7 @@
                  pGlobalTXT_LocalizationStrings[79],// Exit
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  ptr_507BB8->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, nullstring, 0);
+  ptr_507BB8->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0);
   pCurrentScreen = 10;
   pEventTimer->Pause();
   return 1;
@@ -5025,6 +5025,8 @@
   unsigned int pY; // [sp+D8h] [bp-8h]@1
   unsigned int v45; // [sp+DCh] [bp-4h]@21
 
+  v13 = nullptr;
+
   pMouse->uPointingObjectID = 0;
   pMouse->GetClickPos(&pX, &pY);
   if ( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 )
@@ -5435,7 +5437,7 @@
                  (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
                  papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
                  0);
-  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, nullstring, 0);
+  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
   ptr_507694 = v2->CreateButton(
                  0x258u,
                  0x12Cu,
@@ -5448,12 +5450,12 @@
                  0,
                  pGlobalTXT_LocalizationStrings[64],
                  0);
-  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, nullstring, 0);
-  v2->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  v2->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  v2->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  v2->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
-  v2->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, nullstring, 0);
+  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
+  v2->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  v2->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  v2->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  v2->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+  v2->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
   sub_419100();
   return v2;
 }
@@ -5488,12 +5490,12 @@
                  (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
                  papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
                  0);
-  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, nullstring, 0);
-  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, nullstring, 0);
-  v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
+  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
+  v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   return v2;
 }
 
@@ -5566,16 +5568,16 @@
     }
     a1.field_58 = 4;
     a1.uObjectDescID = v6;
-    a1.vPosition.y = pParty->vPosition.z;
+    a1.vPosition.y = pParty->vPosition.y;
     a1.vPosition.x = pParty->vPosition.x;
-    a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.y;
+    a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
     a1.uSoundID = 0;
     a1.uFacing = 0;
     a1.uAttributes = 8;
     v8 = pIndoor->GetSector(
            pParty->vPosition.x,
-           pParty->vPosition.z,
-           pParty->sEyelevel + pParty->vPosition.y);
+           pParty->vPosition.y,
+           pParty->sEyelevel + pParty->vPosition.z);
     a1.uSpriteFrameID = 0;
     a1.uSectorID = v8;
     memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
@@ -5918,17 +5920,17 @@
               }
             }
             a1.uObjectDescID = v6;
-            a1.vPosition.y = pParty->vPosition.z;
+            a1.vPosition.y = pParty->vPosition.y;
             a1.field_58 = 4;
             a1.vPosition.x = pParty->vPosition.x;
-            a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.y;
+            a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
             a1.uSoundID = 0;
             a1.uFacing = 0;
             a1.uAttributes = 8;
             a1.uSectorID = pIndoor->GetSector(
                              pParty->vPosition.x,
-                             pParty->vPosition.z,
-                             pParty->sEyelevel + pParty->vPosition.y);
+                             pParty->vPosition.y,
+                             pParty->sEyelevel + pParty->vPosition.z);
             a1.uSpriteFrameID = 0;
             memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
             v8 = (int *)pMouse->GetCursorPos(&v25);
@@ -5955,7 +5957,7 @@
       else
       {
         v12 = &pOutdoor->pBModels[(signed int)(unsigned __int16)v0 >> 9].pFaces[v2 & 0x3F];
-        if ( !(v12->uFaceAttributes & 0x2000000) )
+        if ( !(v12->uAttributes & 0x2000000) )
           goto LABEL_11;
         v11 = v12->sCogTriggeredID;
       }
@@ -6481,13 +6483,13 @@
 
   v1 = &pIndoor->pFaces[uFaceID];
   //this = pGame->pIndoorCameraD3D;
-  v2 = &pIndoor->pVertices[*v1->pVertexIDs];
+  v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
   //v3 = *(_DWORD *)&v2->x;
   v4 = v2->z;
   //v5 = 0;
   if ( v1->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
      + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
-     + v1->pFacePlane_old.vNormal.z * (v4 - pBLVRenderParams->vPartyPos.z) < 0 )
+     + v1->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
   {
     dword_50B700 = 1;
   }
--- a/mm7_2.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_2.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -3160,8 +3160,8 @@
                  pGlobalTXT_LocalizationStrings[34],// "Cancel"
                  (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
-  pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
+  pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
   dword_F8B19C = -1;
   v0 = (int)((char *)ptr_507BC0->ptr_1C - 102);
@@ -3273,8 +3273,8 @@
       {
         uDialogueType = 90;
         pParty->vPosition.x = 3849;
-        pParty->vPosition.z = 5770;
-        pParty->vPosition.y = 1;
+        pParty->vPosition.y = 5770;
+        pParty->vPosition.z = 1;
         pParty->uFallStartY = 1;
         pParty->sRotationY = 512;
         pParty->sRotationX = 0;
@@ -3313,10 +3313,10 @@
                    pGlobalTXT_LocalizationStrings[79],
                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                    0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, nullstring, 0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, nullstring, 0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, nullstring, 0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x58u, 0, nullstring, 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x58u, 0, "", 0);
     pDialogueWindow->_41D08F(4, 1, 0, 1);
   }
 }
@@ -3470,8 +3470,8 @@
   pRenderer->EndScene();
   pRenderer->Present();
   pParty->vPosition.x = 3849;
-  pParty->vPosition.z = 5770;
-  pParty->vPosition.y = 1;
+  pParty->vPosition.y = 5770;
+  pParty->vPosition.z = 1;
   pParty->uFallStartY = 1;
   pParty->sRotationY = 512;
   pParty->sRotationX = 0;
@@ -3706,7 +3706,7 @@
                  pGlobalTXT_LocalizationStrings[74],
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  return pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  return pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
 }
 
 //----- (004BCACC) --------------------------------------------------------
@@ -3822,7 +3822,7 @@
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                    (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
                    v1);
-    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, nullstring, (Texture *)v1);
+    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1);
 LABEL_10:
     v3 = dword_F8B198;
     v8 = ptr_507BC0;
@@ -7852,9 +7852,9 @@
   if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) )
   {
     v21 = 0;
-    v22 = pParty->vPosition.y;
+    v22 = pParty->vPosition.z;
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+      v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     v6 = &pActors[v20];
     v7 = (char *)&pMonsterStats->pInfos[v23 + 1];
     v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
@@ -7875,7 +7875,7 @@
     v11 = ((unsigned __int64)(stru_5C6E00->SinCos(v10) * (signed __int64)v19) >> 16) + pParty->vPosition.x;
     v18 = stru_5C6E00->SinCos(v10 - stru_5C6E00->uIntegerHalfPi);
     v23 = (unsigned __int64)(v18 * (signed __int64)v19) >> 16;
-    v12 = pParty->vPosition.z;
+    v12 = pParty->vPosition.y;
     v13 = (unsigned __int64)(v18 * (signed __int64)v19) >> 16;
     v6->vInitialPosition.x = v11;
     v14 = v13 + v12;
@@ -7897,8 +7897,8 @@
     v6->uCurrentActionLength = 256;
     v6->UpdateAnimation();
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
-      || (v22 = pParty->vPosition.y,
-          result = pIndoor->GetSector(v11, v14, pParty->vPosition.y),
+      || (v22 = pParty->vPosition.z,
+          result = pIndoor->GetSector(v11, v14, pParty->vPosition.z),
           result == v21)
       && (result = _46CEC3_get_floor_level(v11, v14, v22, result, &v18), result != -30000)
       && (result = abs(result - v22), result <= 1024) )
@@ -8408,14 +8408,14 @@
       v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16;
       v8 = 0;
       v19.uIndex = v24;
-      v19.vPosition.y = v23 + pParty->vPosition.z;
-      v19.vPosition.z = pParty->vPosition.y;
+      v19.vPosition.y = v23 + pParty->vPosition.y;
+      v19.vPosition.z = pParty->vPosition.z;
       v26 = 0;
       v27 = 0;
       v19.vPosition.z = sub_46D49E_prolly_get_world_y_under_party(
                           v19.vPosition.x,
-                          v23 + pParty->vPosition.z,
-                          pParty->vPosition.y,
+                          v23 + pParty->vPosition.y,
+                          pParty->vPosition.z,
                           0,
                           &v26,
                           &v27,
@@ -8450,7 +8450,7 @@
   else
   {
     v26 = 0;
-    v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+    v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     do
     {
       ++v26;
@@ -8464,17 +8464,17 @@
       v16 = stru_5C6E00->SinCos(v14 - stru_5C6E00->uIntegerHalfPi);
       v20 = v16;
       v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16;
-      v19.vPosition.y = v23 + pParty->vPosition.z;
-      v19.vPosition.z = pParty->vPosition.y;
+      v19.vPosition.y = v23 + pParty->vPosition.y;
+      v19.vPosition.z = pParty->vPosition.z;
       v19.uIndex = v24;
-      v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.z, pParty->vPosition.y);
+      v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z);
       if ( v17 == v22 )
       {
         v18 = _46CEC3_get_floor_level(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &v25);
         v19.vPosition.z = v18;
         if ( v18 != -30000 )
         {
-          if ( abs(v18 - pParty->vPosition.y) <= 1024 )
+          if ( abs(v18 - pParty->vPosition.z) <= 1024 )
             break;
         }
       }
@@ -9003,111 +9003,109 @@
 // return value: angle in integer format (multiplier of Pi/1024)  
 unsigned int stru193_math::Atan2(int x, int y)
 {
-  stru193_math *v3; // esi@1
-  int v4; // edi@1
-  int v5; // ebx@1
-  int v6; // eax@1
-  signed int v7; // ecx@1
-  unsigned int result; // eax@5
-  signed int v9; // ebx@14
-  signed __int64 v10; // qtt@20
-  unsigned int v11; // eax@20
-  int v12; // edx@20
-  int v13; // ecx@38
-  int v14; // eax@38
-  unsigned int v15; // eax@43
-  signed int v16; // [sp-4h] [bp-10h]@13
-
-  v3 = this;
-  v4 = y;
-  v5 = abs(x);
-  v6 = abs(y);
-  v7 = 0;
-  if ( v5 < 65536 && v6 >> 15 >= v5 )
-    x = 0;
-  if ( !x )
-  {
-    result = v3->uIntegerHalfPi;
-    if ( y <= 0 )
-      result += v3->uIntegerPi;
-    return result;
-  }
-  if ( y )
-  {
-    if ( x <= 0 )
-    {
-      x = -x;
-      if ( y >= 0 )
-      {
-        v16 = 4;
-        goto LABEL_19;
-      }
-      v16 = 3;
+  signed int quadrant;
+  __int64 dividend;
+  int quotient;
+  int lowIdx;
+  int highIdx;
+  int angle;
+
+  auto X = x;
+  auto Y = y;
+
+  if ( abs(X) < 65536 )
+  {
+    if ( (abs(Y) >> 15) >= abs(X) )
+      X = 0;
+  }
+
+  if ( !X )
+  {
+    if ( Y > 0 )
+    {
+      return uIntegerHalfPi;   //Pi/2
+    }
+    else
+    {
+      return uIntegerHalfPi + uIntegerPi; //3*(Pi/2)
+    }
+  }
+
+  if ( Y )
+  {
+    if ( X < 0 )
+    {
+      X = -X;
+      if ( Y > 0 )
+      {
+        quadrant = 4;        
+      }
+      else
+      {
+        quadrant = 3;        
+      }      
     }
     else
     {
-      if ( y >= 0 )
-      {
-        v9 = 1;
-        goto LABEL_20;
-      }
-      v16 = 2;
-    }
-    v4 = -y;
-LABEL_19:
-    v9 = v16;
-LABEL_20:
-    LODWORD(v10) = v4 << 16;
-    HIDWORD(v10) = v4 >> 16;
-    v11 = v3->uIntegerHalfPi;
-    v12 = v10 / x;
-    if ( v12 <= v3->pTanTable[(signed int)v3->uIntegerHalfPi >> 1] )
-      v11 = (signed int)v3->uIntegerHalfPi >> 1;
-    else
-      v7 = (signed int)v3->uIntegerHalfPi >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    v13 = v7 + 1;
-    v14 = v11 - 1;
-    while ( v13 < v14 && v12 >= v3->pTanTable[v13] )
-      ++v13;
-    if ( v9 == 2 )
-    {
-      v15 = v3->uIntegerDoublePi;
-    }
-    else
-    {
-      if ( v9 == 3 )
-        return v13 + v3->uIntegerPi;
-      if ( v9 != 4 )
-        return v13;
-      v15 = v3->uIntegerPi;
-    }
-    return v15 - v13;
-  }
-  if ( x <= 0 )
-    result = v3->uIntegerPi;
-  else
-    result = 0;
-  return result;
+      if ( Y > 0 )
+      {
+        quadrant = 1;       
+      }
+      else
+      {
+        quadrant = 2;
+      }      
+    }
+
+    if ( Y < 0 )
+      Y = -Y;
+
+    LODWORD(dividend) = Y << 16;
+    HIDWORD(dividend) = Y >> 16;
+    quotient = dividend / X;        
+
+    //looks like binary search
+    {
+      int i;
+      highIdx = uIntegerHalfPi;
+      lowIdx = 0;
+
+      for (i = 0; i < 6; ++i)
+      {        
+        if (quotient <= pTanTable[(lowIdx + highIdx) / 2])      
+          highIdx = (lowIdx + highIdx) / 2;
+        else
+          lowIdx = (lowIdx + highIdx) / 2;    
+      }
+    }
+
+    angle = lowIdx + 1;
+    while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] )
+      ++angle;
+
+    switch (quadrant)
+    {
+    case 1: //X > 0, Y > 0
+      return angle;        
+
+    case 2: //X > 0, Y < 0
+      return uIntegerDoublePi - angle;   //2*Pi - angle
+
+    case 3: //X > 0, Y < 0
+      return uIntegerPi + angle;        //Pi + angle 
+
+    case 4: //X < 0, Y > 0
+      return uIntegerPi - angle;        //Pi - angle  
+    }
+
+    //should newer get here
+    return 0;
+  }
+
+  if ( X < 0 )    //Y == 0, X < 0
+    return uIntegerPi;  
+
+  return 0;
 }
 
 
@@ -11783,12 +11781,12 @@
     pParty->vPrevPosition.y = v0;
     pParty->vPrevPosition.x = 12552;
     pParty->vPosition.x = 12552;
-    pParty->vPosition.y = v0;
+    pParty->vPosition.z = v0;
     pParty->uFallStartY = v0;
     pParty->sPrevRotationX = v0;
     pParty->sRotationX = v0;
     pParty->vPrevPosition.z = 1816;
-    pParty->vPosition.z = 1816;
+    pParty->vPosition.y = 1816;
     v0 = 1;
     pParty->sPrevRotationY = 512;
     pParty->sRotationY = 512;
@@ -13166,11 +13164,11 @@
   cbData = 4;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v10, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v10, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v11, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    {
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v10, &dwDisposition) )
+      {
+        if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, 0xF003Fu, 0, &v11, &dwDisposition) )
         {
           if ( RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) )
           {
@@ -13208,11 +13206,11 @@
   phkResult = 0;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v8, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v8, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v9, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    {
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
+      {
+        if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, 0xF003Fu, 0, &v9, &dwDisposition) )
         {
           v2 = strlen(Str);
           RegSetValueExA(v9, lpValueName, 0, 1u, (const BYTE *)Str, v2 + 1);
@@ -13250,9 +13248,9 @@
   phkResult = 0;
   v4 = RegCloseKey;
   if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey)
-    || RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
-    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v13, &dwDisposition)
-    || RegCreateKeyExA(v13, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v14, &dwDisposition) )
+    || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
+    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
+    || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
     goto LABEL_7;
   if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
   {
@@ -13301,11 +13299,11 @@
   phkResult = 0;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v7, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v7, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v8, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    {
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v7, &dwDisposition) )
+      {
+        if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
         {
           RegSetValueExA(v8, lpValueName, 0, 4u, Data, 4u);
           RegCloseKey(v8);
@@ -15642,7 +15640,7 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     if ( pRenderer->pRenderD3D )
-      v1 = pGame->pIndoorCameraD3D->flt_fov;
+      v1 = pGame->pIndoorCameraD3D->fov;
     else
       v1 = pIndoorCamera->flt_1C_fov;
     v3 = (signed __int64)v1;
@@ -15663,7 +15661,7 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     if ( pRenderer->pRenderD3D )
-      v1 = pGame->pIndoorCameraD3D->flt_fov;
+      v1 = pGame->pIndoorCameraD3D->fov;
     else
       v1 = pIndoorCamera->flt_1C_fov;
     v3 = (signed __int64)v1;
@@ -15947,7 +15945,7 @@
       if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
       {
         if ( a1 >> 9 >= pOutdoor->uNumBModels
-          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uFaceAttributes) & 0x10)
+          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
           || (v6 = v7->sCogTriggeredID) == 0 )
           return 1;
 LABEL_13:
@@ -16153,8 +16151,8 @@
     do
     {
       v5 = abs(*((short *)v4 - 17) - pParty->vPosition.x);
-      v17 = abs(*((short *)v4 - 16) - pParty->vPosition.z);
-      v18 = abs(*((short *)v4 - 15) - pParty->vPosition.y);
+      v17 = abs(*((short *)v4 - 16) - pParty->vPosition.y);
+      v18 = abs(*((short *)v4 - 15) - pParty->vPosition.z);
       v6 = v5;
       v7 = v17;
       v8 = v18;
@@ -16465,21 +16463,21 @@
   ODM_ProcessPartyActions();
   if ( pParty->vPosition.x < -22528
     || pParty->vPosition.x > 22528
-    || pParty->vPosition.z < -22528
-    || pParty->vPosition.z > 22528 )
+    || pParty->vPosition.y < -22528
+    || pParty->vPosition.y > 22528 )
   {
     strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
-    v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, (char *)&pOut, 32);
+    v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, (char *)&pOut, 32);
     if ( !bUnderwater && (pParty->uFlags & 0x8C || BYTE1(pParty->uFlags) & 2 || pParty->bFlying) || !v0 )
     {
       if ( pParty->vPosition.x < -22528 )
         pParty->vPosition.x = -22528;
       if ( pParty->vPosition.x > 22528 )
         pParty->vPosition.x = 22528;
-      if ( pParty->vPosition.z < -22528 )
-        pParty->vPosition.z = -22528;
-      if ( pParty->vPosition.z > 22528 )
-        pParty->vPosition.z = 22528;
+      if ( pParty->vPosition.y < -22528 )
+        pParty->vPosition.y = -22528;
+      if ( pParty->vPosition.y > 22528 )
+        pParty->vPosition.y = 22528;
     }
     else
     {
--- a/mm7_3.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_3.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -122,7 +122,7 @@
     {
       v9 = &pIndoor->pSectors[v33[result]];
       v10 = 0;
-      v32 = v9->field_4 + v9->field_C + v9->field_14;
+      v32 = v9->uNumFloors + v9->field_C + v9->field_14;
       v26 = 0;
       if ( v32 > 0 )
         break;
@@ -346,7 +346,7 @@
       f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
       v6 = v4->pFacePlane.dist;
       f.pFacePlane_old.dist = v4->pFacePlane.dist;
-      v7 = v4->uFaceAttributes;
+      v7 = v4->uAttributes;
       f.uAttributes = v7;
       f.pBounding.x1 = v4->pBoundingBox.x1;
       f.pBounding.y1 = v4->pBoundingBox.y1;
@@ -649,21 +649,21 @@
   {
     if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
     {
-      if ( stru_721530.sMaxY <= pParty->vPosition.z + v1 )
-      {
-        if ( stru_721530.sMinY >= pParty->vPosition.z - v1 )
-        {
-          if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.y + pParty->uPartyHeight) )
-          {
-            if ( stru_721530.sMinZ >= pParty->vPosition.y )
+      if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 )
+      {
+        if ( stru_721530.sMinY >= pParty->vPosition.y - v1 )
+        {
+          if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) )
+          {
+            if ( stru_721530.sMinZ >= pParty->vPosition.z )
             {
               v3 = stru_721530.prolly_normal_d + v1;
               v11 = pParty->vPosition.x - stru_721530.normal.x;
               v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
-                  - (pParty->vPosition.z - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
-              v10 = pParty->vPosition.z - stru_721530.normal.y;
+                  - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
+              v10 = pParty->vPosition.y - stru_721530.normal.y;
               result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
-                          - (pParty->vPosition.z - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
+                          - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
               if ( result <= v3 )
               {
                 result = v10 * stru_721530.field_58.y;
@@ -671,11 +671,11 @@
                 if ( v5 > 0 )
                 {
                   v6 = ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
-                  result = pParty->vPosition.y;
-                  if ( v6 >= pParty->vPosition.y )
+                  result = pParty->vPosition.z;
+                  if ( v6 >= pParty->vPosition.z )
                   {
-                    result = v9 + pParty->vPosition.y;
-                    if ( v6 <= (signed int)(v9 + pParty->vPosition.y) || v8 )
+                    result = v9 + pParty->vPosition.z;
+                    if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
                     {
                       result = sub_452A9E(v3 * v3 - v4 * v4);
                       v7 = v5 - result;
@@ -1274,7 +1274,7 @@
         case 6:
           v40 = &pOutdoor->pBModels[v38 >> 9];
           v41 = &v40->pFaces[v39 & 0x3F];
-          if ( !(BYTE3(v41->uFaceAttributes) & 0x20) )
+          if ( !(BYTE3(v41->uAttributes) & 0x20) )
           {
             v42 = v41->uPolygonType;
             if ( v42 == 3 )
@@ -2127,7 +2127,7 @@
           }
           v1->vVelocity.z += v37;
 LABEL_70:
-          if ( BYTE3(v32->uFaceAttributes) & 0x10 )
+          if ( BYTE3(v32->uAttributes) & 0x10 )
             EventProcessor(v32->sCogTriggeredID, 0, 1);
           goto LABEL_74;
         }
@@ -2214,6 +2214,7 @@
   v20 = 0;
   if ( (signed int)uNumLayingItems > 0 )
   {
+    __debugbreak();
     v2 = (char *)&pLayingItems[0].uSpriteFrameID;
     do
     {
@@ -2272,8 +2273,8 @@
             if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) )
               goto LABEL_36;
             v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26));
-            v18 = abs(pParty->vPosition.z - *(int *)(v2 - 22));
-            v19 = abs(pParty->vPosition.y - *(int *)(v2 - 18));
+            v18 = abs(pParty->vPosition.y - *(int *)(v2 - 22));
+            v19 = abs(pParty->vPosition.z - *(int *)(v2 - 18));
             v13 = v12;
             v14 = v18;
             v15 = v19;
@@ -2446,15 +2447,15 @@
   int v89; // [sp+58h] [bp-8h]@1
   int angle; // [sp+5Ch] [bp-4h]@47
 
-  v0 = pParty->vPosition.y;
+  v0 = pParty->vPosition.z;
   v89 = pParty->uFallSpeed;
   v1 = 0;
-  v85 = pParty->vPosition.z;
+  v85 = pParty->vPosition.y;
   v70 = 0;
   v2 = 0;
   v86 = pParty->vPosition.x;
-  v87 = pParty->vPosition.y;
-  v77 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+  v87 = pParty->vPosition.z;
+  v77 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   v72 = 0;
   v78 = 0;
   v71 = 0;
@@ -2473,15 +2474,15 @@
     if ( i == -30000 )
     {
       pParty->vPosition.x = blv_prev_party_x;
-      pParty->vPosition.z = blv_prev_party_z;
-      pParty->vPosition.y = blv_prev_party_y;
+      pParty->vPosition.y = blv_prev_party_z;
+      pParty->vPosition.z = blv_prev_party_y;
       pParty->uFallStartY = blv_prev_party_y;
       return;
     }
   }
   blv_prev_party_x = pParty->vPosition.x;
-  blv_prev_party_z = pParty->vPosition.z;
-  blv_prev_party_y = pParty->vPosition.y;
+  blv_prev_party_z = pParty->vPosition.y;
+  blv_prev_party_y = pParty->vPosition.z;
   if ( pParty->bTurnBasedModeOn != 1 )
   {
     v4 = (double)(GetTickCount() / 0x1F4);
@@ -2489,8 +2490,8 @@
     if ( *(int *)&word_720C10_intercepts_xs[102] != LODWORD(v67) )
     {
       dword_4F8584[3 * dword_4F8580[0]] = pParty->vPosition.x;
-      dword_4F8588[3 * dword_4F8580[0]] = pParty->vPosition.z;
-      dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.y;
+      dword_4F8588[3 * dword_4F8580[0]] = pParty->vPosition.y;
+      dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.z;
       if ( dword_4F8580[0] > 60 )
         dword_4F8580[0] = 1;
     }
@@ -2678,7 +2679,8 @@
                                * (signed __int64)(signed int)(2
                                                             * (unsigned __int64)(signed __int64)(v88
                                                                                                * fWalkSpeedMultiplier))) >> 16;
-        goto LABEL_70;
+        v72 = 1;
+        goto LABEL_87;
       case PARTY_RunBackward:
         v32 = stru_5C6E00->SinCos(angle);
         v33 = (double)v81;
@@ -2688,7 +2690,7 @@
         v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
         v1 -= (unsigned __int64)(v34
                                * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16;
-LABEL_70:
+//LABEL_70:
         v72 = 1;
         goto LABEL_87;
       case PARTY_LookUp:
@@ -2938,10 +2940,10 @@
   }
   if ( bWalkSound && pParty->field_6F8 <= 0 )
   {
-    if ( sub_452A9E((pParty->vPosition.x - v86) * (pParty->vPosition.x - v86) + (pParty->vPosition.z - v85)
-                                                                            * (pParty->vPosition.z - v85)
-                                                                            + (pParty->vPosition.y - v37)
-                                                                            * (pParty->vPosition.y - v37)) <= 16 )
+    if ( sub_452A9E((pParty->vPosition.x - v86) * (pParty->vPosition.x - v86) + (pParty->vPosition.y - v85)
+                                                                            * (pParty->vPosition.y - v85)
+                                                                            + (pParty->vPosition.z - v37)
+                                                                            * (pParty->vPosition.z - v37)) <= 16 )
       goto LABEL_188;
     if ( v72 && (!bJumping || bFeatherFalla) )
     {
@@ -3001,8 +3003,8 @@
     pParty->uFlags |= 8u;
   BYTE1(pParty->uFlags) &= 0xFDu;
   pParty->vPosition.x = v86;
-  pParty->vPosition.y = v37;
-  pParty->vPosition.z = v85;
+  pParty->vPosition.z = v37;
+  pParty->vPosition.y = v85;
   pParty->uFallSpeed = v89;
   if ( !bJumping && BYTE3(pIndoor->pFaces[v79].uAttributes) & 0x40 )
     BYTE1(pParty->uFlags) |= 2u;
@@ -3147,17 +3149,17 @@
   int v130; // [sp+90h] [bp-4h]@14
 
   v121 = pParty->uFallSpeed;
-  v123 = pParty->vPosition.y;
+  v123 = pParty->vPosition.z;
   _zero = 0;
   v1 = 0;
   v103 = 0;
   v2 = 0;
   *(float *)&v128 = 0.0;
   v116 = pParty->vPosition.x;
-  v117 = pParty->vPosition.z;
+  v117 = pParty->vPosition.y;
   v113 = pParty->field_6F0;
   bJumping = 0;
-  v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.z);
+  v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.y);
   v114 = 0;
   v124 = 0;
   v108 = 0;
@@ -3286,7 +3288,7 @@
             || pParty->pPartyBuffs[7].uFlags & 1
             || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
           {
-            if ( pParty->vPosition.y < 4000 || bJumping )
+            if ( pParty->vPosition.z < 4000 || bJumping )
             {
               v123 += 30;
               v113 += 30;
@@ -3306,7 +3308,7 @@
                 pParty->field_6E4 = 0;
                 pPartyActionQueue->uNumActions = 0;
                 BYTE1(pParty->uFlags) |= 1u;
-                pParty->vPosition.y = v109 - pParty->uPartyHeight - 31;
+                pParty->vPosition.z = v109 - pParty->uPartyHeight - 31;
                 pParty->field_6F0 = v123;
                 pParty->bFlying = 0;
                 v123 = v109 - pParty->uPartyHeight - 31;
@@ -3635,7 +3637,7 @@
   {
     if ( v34 < -500
       && !pParty->bFlying
-      && pParty->vPosition.y - v111 > 1000
+      && pParty->vPosition.z - v111 > 1000
       && SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0
       && (SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 || !LODWORD(pParty->pPartyBuffs[5].uExpireTime)) )
     {
@@ -3683,7 +3685,7 @@
     if ( stru_721530._47050A(v36) )
       break;
     _46E889_collide_against_bmodels(1u);
-    v37 = WorldPosToGridCellZ(pParty->vPosition.z);
+    v37 = WorldPosToGridCellZ(pParty->vPosition.y);
     v38 = WorldPosToGridCellX(pParty->vPosition.x);
     _46E26D_collide_against_sprites(v38, v37);
     _46ED8A_collide_against_layingItems(4u);
@@ -3856,7 +3858,7 @@
 LABEL_220:
           v45 = stru_721530.uFaceID;
 LABEL_221:
-          if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uFaceAttributes) & 4 )
+          if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uAttributes) & 4 )
           {
             pParty->field_6F4_packedid = v45;
             v103 = v47->sCogTriggeredID;
@@ -3894,14 +3896,14 @@
   if ( bWalkSound && pParty->field_6F8 <= 0 )
   {
     v122 = abs(pParty->vPosition.x - v116);
-    v126 = abs(pParty->vPosition.z - v117);
-    v62 = abs(pParty->vPosition.y - v123);
+    v126 = abs(pParty->vPosition.y - v117);
+    v62 = abs(pParty->vPosition.z - v123);
     if ( sub_452A9E(v122 * v122 + v126 * v126 + v62 * v62) < 8 )
       goto LABEL_344;
     if ( v114 && (!bJumping || v101) )
     {
       if ( !v107
-        && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uFaceAttributes) & 0x20) )
+        && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20) )
       {
         v96 = 0;
         v94 = 0;
@@ -3922,7 +3924,7 @@
       v88 = 804;
       v86 = 1;
 LABEL_255:
-      v63 = WorldPosToGridCellZ(pParty->vPosition.z) - 1;
+      v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
       v64 = WorldPosToGridCellX(pParty->vPosition.x);
       v87 = pOutdoor->_47EE49(v64, v63, v86);
       goto LABEL_257;
@@ -3930,7 +3932,7 @@
     if ( v124 && (!bJumping || v101) )
     {
       if ( v107
-        || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uFaceAttributes) & 0x20 )
+        || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20 )
       {
         v96 = 0;
         v94 = 0;
@@ -3965,7 +3967,7 @@
   else
     pParty->uFlags |= 8u;
   v126 = WorldPosToGridCellX(pParty->vPosition.x);
-  v65 = WorldPosToGridCellZ(pParty->vPosition.z) - 1;
+  v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   v114 = WorldPosToGridCellX(v116);
   v66 = WorldPosToGridCellZ(v117) - 1;
   v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
@@ -3985,25 +3987,25 @@
     pParty->uFallSpeed = v121;
     v73 = v123;
     pParty->vPosition.x = v116;
-    pParty->vPosition.z = v117;
-    pParty->vPosition.y = v123;
+    pParty->vPosition.y = v117;
+    pParty->vPosition.z = v123;
     pParty->field_6F0 = v113;
     if ( v123 > 8160 )
     {
       v73 = 8160;
       pParty->uFallStartY = 8160;
-      pParty->vPosition.y = 8160;
+      pParty->vPosition.z = 8160;
     }
     if ( !v103
       || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
-      && pParty->vPosition.z == v72
-      && (v73 = pParty->vPosition.y, pParty->vPosition.y == v70) )
+      && pParty->vPosition.y == v72
+      && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) )
     {
       if ( v73 < v111 )
       {
         pParty->uFallSpeed = 0;
         v73 = v105;
-        pParty->vPosition.y = v105;
+        pParty->vPosition.z = v105;
         if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )
         {
           if ( pParty->uFlags & 0x100 )
@@ -4026,7 +4028,7 @@
               ++v74;
             }
             while ( (signed int)v74 <= (signed int)&pPlayers[4] );
-            v73 = pParty->vPosition.y;
+            v73 = pParty->vPosition.z;
           }
         }
         pParty->uFallStartY = v70;
@@ -4035,7 +4037,7 @@
       {
         if ( (signed int)(pParty->uPartyHeight + v73) >= v109 )
         {
-          pParty->vPosition.y = v109 - pParty->uPartyHeight - 1;
+          pParty->vPosition.z = v109 - pParty->uPartyHeight - 1;
           pParty->field_6F0 = v109 - pParty->uPartyHeight - 1;
         }
       }
@@ -4070,7 +4072,7 @@
   if ( v78 )
   {
 LABEL_312:
-    pParty->vPosition.z = v117;
+    pParty->vPosition.y = v117;
 LABEL_313:
     if ( bWaterWalk )
     {
@@ -4097,33 +4099,33 @@
 LABEL_318:
   v81 = v123;
   v82 = v123;
-  pParty->vPosition.y = v123;
+  pParty->vPosition.z = v123;
   if ( v123 > 8160 )
   {
     v82 = 8160;
     pParty->uFallStartY = 8160;
-    pParty->vPosition.y = 8160;
+    pParty->vPosition.z = 8160;
   }
   LOWORD(pParty->uFlags) &= 0xFDFBu;
   pParty->uFallSpeed = v121;
   pParty->field_6F0 = v113;
   if ( v114 )
   {
-    v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.z, &v110, 1);
-    v82 = pParty->vPosition.y;
-    if ( pParty->vPosition.y <= v83 )
+    v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
+    v82 = pParty->vPosition.z;
+    if ( pParty->vPosition.z <= v83 )
       pParty->uFlags |= 4u;
   }
   if ( !v103
     || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v116)
-    && pParty->vPosition.z == v117
-    && (v82 = pParty->vPosition.y, pParty->vPosition.y == v81) )
+    && pParty->vPosition.y == v117
+    && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) )
   {
     if ( v82 < v111 )
     {
       v82 = v105;
       pParty->uFallSpeed = 0;
-      pParty->vPosition.y = v105;
+      pParty->vPosition.z = v105;
       if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )
       {
         if ( pParty->uFlags & 0x100 )
@@ -4145,14 +4147,14 @@
             ++v84;
           }
           while ( (signed int)v84 <= (signed int)&pPlayers[4] );
-          v82 = pParty->vPosition.y;
+          v82 = pParty->vPosition.z;
         }
       }
       pParty->uFallStartY = v81;
     }
     if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 )
     {
-      pParty->vPosition.y = v82 + pParty->uPartyHeight - v109 + 1;
+      pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1;
       pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1;
     }
   }
@@ -6797,7 +6799,7 @@
     }
     while ( 1 )
     {
-      if ( pFace->uFaceAttributes & 0x2000 )
+      if (pFace->Invisible())
         goto LABEL_85;
       v5 = (int)*(v2 - 1);
       v6 = pFace->pVertexIDs[0];
@@ -6807,7 +6809,7 @@
       *(int *)&v7->flags = 0;
       pLightmapBuilder = v8;
       v9 = pFace->uTextureID;
-      v10 = (BYTE1(pFace->uFaceAttributes) & 0x40) == 0;
+      v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0;
       v48 = pFace->uTextureID;
       if ( !v10 )
       {
@@ -6819,14 +6821,14 @@
       v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
       v49 = v12;
       v49 = pFaceTexture->uTextureHeight;
-      v10 = (pFace->uFaceAttributes & 0x10) == 0;
+      v10 = (pFace->uAttributes & 0x10) == 0;
       v45 = 1.0 / (double)v12;
       v44 = 1.0 / (double)v49;
       if ( !v10 )
         *(int *)&v7->flags |= 2u;
-      if ( BYTE2(pFace->uFaceAttributes) & 0x40 )
+      if ( BYTE2(pFace->uAttributes) & 0x40 )
         HIBYTE(v7->flags) |= 4u;
-      v13 = pFace->uFaceAttributes;
+      v13 = pFace->uAttributes;
       if ( v13 & 4 )
       {
         HIBYTE(v7->flags) |= 4u;
@@ -6836,7 +6838,7 @@
         if ( v13 & 0x20 )
           HIBYTE(v7->flags) |= 8u;
       }
-      v14 = pFace->uFaceAttributes;
+      v14 = pFace->uAttributes;
       if ( BYTE1(v14) & 8 )
       {
         *(int *)&v7->flags |= 0x2000u;
@@ -6926,7 +6928,7 @@
           }
           else
           {
-            v47->_436BB7_project_and_stuff((RenderVertexSoft *)(v23 - 12), 1u, 0);
+            v47->Project((RenderVertexSoft *)(v23 - 12), 1u, 0);
           }
           v23 += 48;
           --v51;
@@ -7005,7 +7007,7 @@
         pDecalBuilder->ApplyDecals_OutdoorFace(pFace);
         v31->std__vector_000004_size = 0;
         LOBYTE(v31) = 0;
-        if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
         {
           v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0);
           static_RenderBuildingsD3D_stru_73C834._49B04D(pFace, (BSPVertexBuffer *)v56 - 1);
@@ -7027,7 +7029,7 @@
               -1);
           }
         }
-        if ( stru_F8AD28.field_AC > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 )
           pLightmapBuilder->ApplyLights(
             &stru_F8AD28,
             &static_RenderBuildingsD3D_stru_73C834,
@@ -7241,7 +7243,7 @@
             }
             else
             {
-              pGame->pIndoorCameraD3D->_436BB7_project_and_stuff((RenderVertexSoft *)(v9 - 12), 1u, 0);
+              pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0);
             }
             v81 += 2;
             v9 += 48;
@@ -7373,7 +7375,7 @@
         }*/
 
         pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
-        if ( stru_F8AD28.field_AC <= 0 )
+        if ( stru_F8AD28.uNumLightsApplied <= 0 )
         {
           v12->field_108 = 0;
         }
@@ -7383,9 +7385,9 @@
           v12->field_108 = 1;
 
           static_sub_004789DE_stru_73C818._49B04D((ODMFace *)v3, v35);
-          v55 = static_sub_004789DE_stru_73C818.vNormal.x;
-          v56 = static_sub_004789DE_stru_73C818.vNormal.y;
-          v57 = static_sub_004789DE_stru_73C818.vNormal.z;
+          v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x;
+          v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y;
+          v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z;
           pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55);
         }
         if ( v74 )
@@ -12905,18 +12907,18 @@
 void PrepareWallsRenderList_BLV()
 {
   pStru170->uNumFaceIDs = 0;
-  if ( pBLVRenderParams->uRadius )
-  {
-    pStru170->field_FA8[0].uSectorID = LOWORD(pBLVRenderParams->uRadius);
-    pStru170->field_FA8[0].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-    pStru170->field_FA8[0].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-    pStru170->field_FA8[0].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-    pStru170->field_FA8[0].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
+  if ( pBLVRenderParams->uPartySectorID )
+  {
+    pStru170->field_FA8[0].uSectorID = pBLVRenderParams->uPartySectorID;
+    pStru170->field_FA8[0].uViewportW = pBLVRenderParams->uViewportW;
+    pStru170->field_FA8[0].uViewportZ = pBLVRenderParams->uViewportZ;
+    pStru170->field_FA8[0].uViewportY = pBLVRenderParams->uViewportY;
+    pStru170->field_FA8[0].uViewportX = pBLVRenderParams->uViewportX;
     pStru170->field_FA8[0].field_C._43F9E1(
-      SLOWORD(pBLVRenderParams->uViewportX),
-      SLOWORD(pBLVRenderParams->uViewportY),
-      SLOWORD(pBLVRenderParams->uViewportZ),
-      SLOWORD(pBLVRenderParams->uViewportW));
+      pBLVRenderParams->uViewportX,
+      pBLVRenderParams->uViewportY,
+      pBLVRenderParams->uViewportZ,
+      pBLVRenderParams->uViewportW);
     pStru170->field_FA8[0].uFaceID = -1;
     pStru170->field_FA8[0].std__vector_0007A8 = -1;
     pStru170->std__vector_000FA8 = 1;
@@ -13063,10 +13065,10 @@
               else
               {
                 v17 = &pGame->pIndoorCameraD3D;
-                v15->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-                v18 = (*v17)->flt_D4;
-                v19 = v15->flt_8;
-                v15->flt_C = v18;
+                v15->fov_x = pGame->pIndoorCameraD3D->fov_x;
+                v18 = (*v17)->fov_y;
+                v19 = v15->fov_x;
+                v15->fov_y = v18;
                 v31 = v19;
                 v25 = v19 + 6.7553994e15;
                 LODWORD(v20) = 0;
@@ -13075,7 +13077,7 @@
                 LODWORD(v31) = v12->scale;
                 v37 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
                 v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
-                v31 = v15->flt_C;
+                v31 = v15->fov_y;
                 v25 = v31 + 6.7553994e15;
                 LODWORD(v20) = 0;
                 HIDWORD(v20) = SLOWORD(v25);
@@ -13217,7 +13219,7 @@
                 v1->uParticleTrailColorR,
                 v1->uParticleTrailColorG,
                 v1->uParticleTrailColorB,
-                v11);
+                byte_4E94D3);
             }
             if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
                    a1,
@@ -13247,9 +13249,9 @@
               }
               else
               {
-                v3->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-                v3->flt_C = pGame->pIndoorCameraD3D->flt_D4;
-                v18 = (int)floorf(v3->flt_8 + 0.5f) / x;
+                v3->fov_x = pGame->pIndoorCameraD3D->fov_x;
+                v3->fov_y = pGame->pIndoorCameraD3D->fov_y;
+                v18 = (int)floorf(v3->fov_x + 0.5f) / x;
                 v3->field_0 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
                 v31 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
               }
@@ -13766,7 +13768,7 @@
   int a3a; // [sp+44h] [bp-10h]@40
   signed int uCenterY; // [sp+48h] [bp-Ch]@1
   signed int uCenterX; // [sp+4Ch] [bp-8h]@1
-  signed int uZb; // [sp+5Ch] [bp+8h]@27
+  //signed int uZb; // [sp+5Ch] [bp+8h]@27
   signed int uWidth; // [sp+5Ch] [bp+8h]@30
   signed int uZd; // [sp+5Ch] [bp+8h]@45
   signed int uZe; // [sp+5Ch] [bp+8h]@67
@@ -13809,7 +13811,7 @@
     v18 = (double)(1 << (16 - v17));
     v19 = v18;
     v20 = (double)(pParty->vPosition.x + 32768) / v18;
-    v21 = (double)(32768 - pParty->vPosition.z) / v19;
+    v21 = (double)(32768 - pParty->vPosition.y) / v19;
     uWb = v21;
     if ( uZoom == 512 )
     {
@@ -13913,17 +13915,15 @@
       auto pFace1 = pIndoor->pFaces + pOutline->uFace1ID;
       auto pFace2 = pIndoor->pFaces + pOutline->uFace2ID;
       //v9 = pIndoor->pFaces[pMapVertex->uFace1ID].uAttributes;
-      if (~pFace1->uAttributes & 0x2000)
-      {
         //v10 = pIndoor->pFaces[pMapVertex->uFace2ID].uAttributes;
-        if (~pFace2->uAttributes & 0x2000)
-        {
-          v11 = pOutline->uFlags;
-          if ( v11 & 1 )
-            goto LABEL_15;
-          if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
-            goto LABEL_ABC;
-        }
+      if (pFace1->Visible() && pFace2->Visible())
+      {
+        v11 = pOutline->uFlags;
+        if ( v11 & 1 )
+          goto LABEL_15;
+        if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
+          goto LABEL_ABC;
+
       }
       continue;
 
@@ -13942,15 +13942,15 @@
     }
     else
     {
-      v69 = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16)
-                        - uZoom * pParty->vPosition.x) >> 16);
-      lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
-                            - uZoom * pParty->vPosition.z) >> 16);
-      uWa = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16)
-                        - uZoom * pParty->vPosition.x) >> 16);
-      v14 = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
-                        - uZoom * pParty->vPosition.z) >> 16);
-      v15 = abs(pOutline->sZ - pParty->vPosition.y) / 8;
+      auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x);
+      auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16);
+      auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16);
+      v69 =     uCenterX + _c;
+      v69 =     uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
+      lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
+      uWa =     uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
+      v14 =     uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
+      v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8;
       if ( v15 > 100 )
         v15 = 100;
       pRenderer->Line2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
@@ -13958,10 +13958,10 @@
   }
 
 
-  for ( uZb = 0; uZb < (signed int)uNumBlueFacesInBLVMinimap; ++uZb )
+  for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i)
   {
     //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
-    auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
+    auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]];
     pRenderer->Line2D(
       uCenterX
     + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
@@ -13970,7 +13970,7 @@
       uCenterY
     - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                      * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
-                  - uZoom * pParty->vPosition.z) >> 16),
+                  - uZoom * pParty->vPosition.y) >> 16),
       uCenterX
     + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                      * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16)
@@ -13978,7 +13978,7 @@
       uCenterY
     - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
                                                      * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
-                  - uZoom * pParty->vPosition.z) >> 16),
+                  - uZoom * pParty->vPosition.y) >> 16),
       uBlue);
   }
   }
@@ -14045,7 +14045,8 @@
   if ( bWizardEyeActive )
   {
     uZe = 0;
-    if ( (signed int)uNumLayingItems > 0 )
+    //for (uint i = 0; i < uNumLayingItems; ++i)
+    if (uNumLayingItems > 0)
     {
       a2c = (char *)&pLayingItems[0].uObjectDescID;
       while ( 1 )
@@ -14055,7 +14056,7 @@
           || uWizardEyeSkillLevel == 1
           || (v37 = ((unsigned __int64)((*(int *)(a2c + 2) - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
                   + uCenterX,
-              v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16,
+              v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16,
               v38 = uCenterY - v79,
               v37 < pRenderer->field_1C_clipx)
           || v37 > pRenderer->field_24_clipz
@@ -14115,7 +14116,7 @@
           v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
                                   * (signed __int64)(signed int)uZoom) >> 16)
               + uCenterX;
-          v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.z)
+          v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.y)
                                  * (signed __int64)(signed int)uZoom) >> 16;
           v41 = uCenterY - v76;
           if ( v40 >= pRenderer->field_1C_clipx )
@@ -14174,7 +14175,7 @@
       {
         v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
             + uCenterX;
-        v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16;
+        v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16;
         v47 = uCenterY - v77;
         if ( v46 >= pRenderer->field_1C_clipx )
         {
@@ -14206,14 +14207,14 @@
   pRenderer->DrawTextureTransparent(
     0x1D4u,
     v33,
-    (Texture *)(dword_5079D8 != -1 ? (int)&pIcons_LOD->pTextures[dword_5079D8] : 0));
+    (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
   uZooma = (double)pParty->sRotationY * 0.1171875;
   v50 = uZooma + 6.7553994e15;
   pRenderer->Clip(0x21Du, v33, 0x237u, 0x1E0u);
   pRenderer->DrawTextureIndexed(
     LODWORD(v50) + 285,
     0x88u,
-    (Texture *)(dword_5079B4 != -1 ? (int)&pIcons_LOD->pTextures[dword_5079B4] : 0));
+    (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
   pRenderer->ResetClip();
 }
 
@@ -14524,8 +14525,8 @@
   }
 LABEL_38:
   v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
-  v81 = pParty->vPosition.z - v84;
-  v97 = (const void *)((unsigned __int64)((pParty->vPosition.z - v84) * (signed __int64)v5) >> 16);
+  v81 = pParty->vPosition.y - v84;
+  v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
   v48 = 1;
   v49 = v90 - (int)v97 - 3;
   if ( v47 >= (signed int)x_ )
@@ -14789,7 +14790,7 @@
   if ( v1 < 384 )
     this->field_2C = 384;
   this->sPartyPosX = pParty->vPosition.x;
-  this->sPartyPosZ = pParty->vPosition.z;
+  this->sPartyPosZ = pParty->vPosition.y;
   return _4432E7();
 }
 
@@ -14807,7 +14808,7 @@
   if ( v1 > v2 )
     this->field_2C = v2;
   this->sPartyPosX = pParty->vPosition.x;
-  this->sPartyPosZ = pParty->vPosition.z;
+  this->sPartyPosZ = pParty->vPosition.y;
   return _4432E7();
 }
 
@@ -15620,7 +15621,7 @@
   int pX; // [sp+28h] [bp-4h]@1
 
   v24 = pParty->vPosition.x;
-  v0 = pParty->vPosition.z;
+  v0 = pParty->vPosition.y;
   v1 = pOutdoor->uNumBModels;
   *(float *)&v23 = (double)(signed int)viewparams->uMinimapZoom * 0.000015258789;
   v2 = 0;
@@ -15665,13 +15666,13 @@
             v13 = v12->sCogTriggeredID;
             if ( v13 )
             {
-              if ( !(BYTE2(v12->uFaceAttributes) & 0x10) )
+              if ( !(BYTE2(v12->uAttributes) & 0x10) )
               {
                 v14 = _444732_GetEventHintString(v13);
                 v15 = v14;
                 if ( v14 )
                 {
-                  if ( _strcmpi(v14, nullstring) )
+                  if ( _strcmpi(v14, "") )
                     v21 = (char *)v15;
                 }
               }
@@ -15766,13 +15767,13 @@
             v12 = v11->sCogTriggeredID;
             if ( v12 )
             {
-              if ( !(BYTE2(v11->uFaceAttributes) & 0x10) )
+              if ( !(BYTE2(v11->uAttributes) & 0x10) )
               {
                 v13 = _444732_GetEventHintString(v12);
                 v14 = v13;
                 if ( v13 )
                 {
-                  if ( _strcmpi(v13, nullstring) )
+                  if ( _strcmpi(v13, "") )
                     v17 = v14;
                 }
               }
@@ -15864,12 +15865,12 @@
       v1 = pTmpBuf;
       goto LABEL_12;
     }
-    v1 = nullstring;
+    v1 = "";
   }
   if ( !v1 )
   {
     MessageBoxW(nullptr, L"No transition text found!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1410", 0);
-    v1 = nullstring;
+    v1 = "";
   }
 LABEL_12:
   v7 = 3;
@@ -15954,7 +15955,7 @@
 
   memcpy(&v7, pGUIWindow0, sizeof(v7));
   v9 = pMapStats->GetMapInfo(pCurrentMapName);
-  pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, pDestinationMapName, 20);
+  pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
   v0 = pMapStats->GetMapInfo(pDestinationMapName);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(0x1D4u, 0,
@@ -16081,10 +16082,10 @@
     dword_5C341C = v3;
     _591094_decoration = _5C3420_pDecoration;
     pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0);
-    pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-    pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-    pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-    pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+    pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+    pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+    pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+    pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   }
 }
 
@@ -16408,7 +16409,7 @@
         v24 = (&dword_721660)[8 * v23];
         if ( !v24 )
         {
-          v24 = nullstring;
+          v24 = "";
           v15->uControlParam = 0;
         }
         goto LABEL_79;
@@ -16452,7 +16453,7 @@
           goto LABEL_63;
         }
 LABEL_71:
-        v24 = nullstring;
+        v24 = "";
         goto LABEL_79;
       }
       if ( v0->uFlags & 0x80 )
@@ -17162,7 +17163,7 @@
   {
     //v5 = pSomeEVT;
     //v6 = v123;
-    //v7 = nullstring;
+    //v7 = "";
     //while ( 1 )
     //{
       if ( dword_5B65C4 )
@@ -17527,7 +17528,7 @@
             //v4 = v124;
             //v5 = pSomeEVT;
             //v6 = v123;
-            //v7 = nullstring;
+            //v7 = "";
             break;
           case EVENT_CharacterAnimation:
             v54 = _evt->v5;
@@ -18094,8 +18095,8 @@
               if ( v100 )
               {
                 pParty->vPosition.x = v135;
-                pParty->vPosition.z = v132;
-                pParty->vPosition.y = v126;
+                pParty->vPosition.y = v132;
+                pParty->vPosition.z = v126;
                 pParty->uFallStartY = v126;
                 if ( _5B65B4_npcdata_loword_house_or_other != -1 )
                   pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
@@ -18298,7 +18299,7 @@
                 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4));
                 if ( v10->sCogNumber == v14 )
                 {
-                  if ( BYTE1(v10->uFaceAttributes) & 0x40 )
+                  if ( BYTE1(v10->uAttributes) & 0x40 )
                   {
                     *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
                                                                    Str2);
@@ -18465,9 +18466,9 @@
               if ( v9->sCogNumber == v10 )
               {
                 if ( on )
-                  v9->uFaceAttributes |= bit;
+                  v9->uAttributes |= bit;
                 else
-                  v9->uFaceAttributes &= ~bit;
+                  v9->uAttributes &= ~bit;
               }
               ++v8;
               v6 += 308;
@@ -18839,9 +18840,9 @@
   {
     v10 = (double)pParty->vPosition.x - (double)fromx;
     v53 = v10;
-    v11 = (double)pParty->vPosition.z - (double)fromy;
+    v11 = (double)pParty->vPosition.y - (double)fromy;
     v54 = v11;
-    v12 = (double)(pParty->vPosition.y + pParty->sEyelevel);
+    v12 = (double)(pParty->vPosition.z + pParty->sEyelevel);
   }
   a7a = v12 - (double)fromz;
   toza = v11 * v11;
@@ -19403,9 +19404,9 @@
       }
       v7 = v5;
       pParty->vPosition.x = pLevelDecorations[v7].vPosition.x;
-      pParty->vPosition.z = pLevelDecorations[v7].vPosition.y;
-      pParty->vPosition.y = pLevelDecorations[v7].vPosition.z;
-      pParty->uFallStartY = pParty->vPosition.y;
+      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;
@@ -19420,10 +19421,10 @@
       if ( _5B65A8_npcdata_uflags_or_other )
         pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other;
       if ( _5B65AC_npcdata_fame_or_other )
-        pParty->vPosition.z = _5B65AC_npcdata_fame_or_other;
+        pParty->vPosition.y = _5B65AC_npcdata_fame_or_other;
       if ( _5B65B0_npcdata_rep_or_other )
       {
-        pParty->vPosition.y = _5B65B0_npcdata_rep_or_other;
+        pParty->vPosition.z = _5B65B0_npcdata_rep_or_other;
         pParty->uFallStartY = _5B65B0_npcdata_rep_or_other;
       }
       if ( _5B65B4_npcdata_loword_house_or_other )
@@ -19969,8 +19970,8 @@
       *(char *)(v0 + 1) &= 0xFBu;
       if ( ! ((Actor *)(v0 - offsetof(Actor, uAttributes)))->CanAct() )
         goto LABEL_37;
-      v22 = abs(pParty->vPosition.y - *(short *)(v0 + 110));
-      v21 = abs(pParty->vPosition.z - *(short *)(v0 + 108));
+      v22 = abs(pParty->vPosition.z - *(short *)(v0 + 110));
+      v21 = abs(pParty->vPosition.y - *(short *)(v0 + 108));
       v1 = abs(pParty->vPosition.x - *(short *)(v0 + 106));
       v2 = v21;
       v3 = v22;
@@ -20127,7 +20128,7 @@
   int v45; // [sp+20h] [bp-4h]@1
 
   pParty->uFlags &= 0xFFFFFFCFu;
-  v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+  v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   v45 = 0;
   v43 = 0;
   if ( (signed int)uNumActors > 0 )
@@ -20138,8 +20139,8 @@
       v0[1] &= 0xFBu;
       if ( ! ((Actor *)(v0 - 36))->CanAct() )
         goto LABEL_60;
-      v39 = abs(pParty->vPosition.y - *((short *)v0 + 55));
-      v38 = abs(pParty->vPosition.z - *((short *)v0 + 54));
+      v39 = abs(pParty->vPosition.z - *((short *)v0 + 55));
+      v38 = abs(pParty->vPosition.y - *((short *)v0 + 54));
       v1 = abs(pParty->vPosition.x - *((short *)v0 + 53));
       v2 = v38;
       v3 = v39;
@@ -21052,19 +21053,19 @@
 //----- (00402CAE) --------------------------------------------------------
 int stru193_math::SinCos(int angle)
 {
-  unsigned int v2; // edx@1
-  unsigned int v3; // eax@1
-  int result; // eax@4
-
-  v2 = this->uIntegerPi;
-  v3 = this->uDoublePiMask & angle;
-  if ( (signed int)v3 > (signed int)v2 )
-    v3 = this->uIntegerDoublePi - v3;
-  if ( (signed int)v3 >= (signed int)this->uIntegerHalfPi )
-    result = -this->pCosTable[v2 - v3];
-  else
-    result = this->pCosTable[v3];
-  return result;
+  int v2; // eax@1
+
+  //a2: (angle - uIntegerHalfPi)    for  sin(angle)
+  //    (angle)                     for  cos(angle)
+
+  v2 = uDoublePiMask & angle;
+  
+  if ( v2 > uIntegerPi )
+    v2 = uIntegerDoublePi - v2;
+  if ( v2 >= uIntegerHalfPi )
+    return -pCosTable[uIntegerPi - v2];
+  else
+    return pCosTable[v2];
 }
 
 
@@ -21220,16 +21221,13 @@
 }
 
 //----- (0040471C) --------------------------------------------------------
-int stru262_TurnBased::_40471C()
-{
-  int result; // eax@3
-
+void stru262_TurnBased::_40471C()
+{
   if ( pParty->bTurnBasedModeOn == 1 )
   {
     if ( pTurnEngine->field_4 == 2 )
-      result = _406457(0);
-  }
-  return result;
+      _406457(0);
+  }
 }
 
 
--- a/mm7_4.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_4.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -123,8 +123,8 @@
     if ( v1->field_2 & 1 )
     {
       v36 = abs(v1->vPosition.x - pParty->vPosition.x);
-      v25 = abs(v3 - pParty->vPosition.z);
-      v28 = abs(v35 - pParty->vPosition.y);
+      v25 = abs(v3 - pParty->vPosition.y);
+      v28 = abs(v35 - pParty->vPosition.z);
       v4 = v36;
       v5 = v25;
       v6 = v28;
@@ -300,7 +300,7 @@
   v43 = v5;
   v42 = v5->pFloors;
   v7 = pIndoor->pVertices;
-  v39 = v5->field_4;
+  v39 = v5->uNumFloors;
   for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa )
   {
     v40 = (int)&v42[v6];
@@ -594,7 +594,7 @@
                 v11 = &v10->pFaces[v39];
                 v12 = v11->uPolygonType;
                 if ( (v12 == 3 || v12 == 4)
-                  && !(BYTE3(v11->uFaceAttributes) & 0x20)
+                  && !(v11->uAttributes & 0x20000000)
                   && v8 <= v11->pBoundingBox.x2
                   && v8 >= v11->pBoundingBox.x1
                   && v7 <= v11->pBoundingBox.y2
@@ -742,7 +742,7 @@
   {
     v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]];
     *a5 = 0;
-    if ( v32->uFaceAttributes & 0x10 )
+    if ( v32->uAttributes & 0x10 )
       *a5 = 1;
   }
   v33 = dword_7211B0[v27];
@@ -825,7 +825,7 @@
                   v7 = (ODMFace *)((char *)v6->pFaces + v30);
                   v8 = v7->uPolygonType;
                   if ( (v8 == 5 || v8 == 6)
-                    && !(BYTE3(v7->uFaceAttributes) & 0x20)
+                    && !(BYTE3(v7->uAttributes) & 0x20)
                     && v4 <= v7->pBoundingBox.x2
                     && v4 >= v7->pBoundingBox.x1
                     && v40 <= v7->pBoundingBox.y2
@@ -3404,7 +3404,7 @@
   signed int v20; // ebx@25
   Player *v21; // esi@25
   ITEM_EQUIP_TYPE v22; // edi@30
-  int v23; // edx@31
+  //int v23; // edx@31
   signed int v24; // ecx@32
   signed int v25; // eax@33
   int v26; // eax@35
@@ -3442,13 +3442,14 @@
   {
     v51 = 0;
     v4 = (v0 - v2) / 5;
-    if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
+    if (pParty->FlyActive())
     {
       if ( pParty->bFlying )
       {
         if ( !(pParty->pPartyBuffs[7].uFlags & 1) )
         {
           v5 = v4 * pParty->pPartyBuffs[7].uPower;
+          __debugbreak();
           v6 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[7].uCaster + 2000];
           v7 = *(int *)v6 - v5 < 0;
           *(int *)v6 -= v5;
@@ -3462,12 +3463,13 @@
         }
       }
     }
-    if ( (signed __int64)pParty->pPartyBuffs[18].uExpireTime > 0 )
-    {
-      if ( pParty->uFlags & 0x80 )
+    if (pParty->WaterWalkActive())
+    {
+      if (pParty->uFlags & 0x80 )
       {
         if ( !(pParty->pPartyBuffs[18].uFlags & 1) )
         {
+          __debugbreak();
           v8 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[18].uCaster + 2000];
           v7 = *(int *)v8 - v4 < 0;
           *(int *)v8 -= v4;
@@ -3480,8 +3482,7 @@
         }
       }
     }
-    if ( SHIDWORD(pParty->pPartyBuffs[10].uExpireTime) >= 0
-      && (SHIDWORD(pParty->pPartyBuffs[10].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[10].uExpireTime)) )
+    if (pParty->ImmolationActive())
     {
       //LayingItem::LayingItem(&a1);
       v9 = 0;
@@ -3490,7 +3491,7 @@
       a3.x = 0;
       a1.stru_24.Reset();
       a1.field_4C = pParty->pPartyBuffs[10].uPower;
-      a1.field_50 = pParty->pPartyBuffs[10].uSkill;
+      a1.field_50 = pParty->ImmolationSkillLevel();
       v10 = 0;
       a1.uItemType = 1070;
       a1.field_48 = 8;
@@ -3563,7 +3564,9 @@
     {
       if ( v21->HasItemEquipped(v22) )
       {
-        v24 = *(int *)&v21->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v23 + 5];
+        //v23 = v21->pEquipment.pIndices;
+        auto _idx = v21->pEquipment.pIndices[v22];
+        v24 = v21->pInventoryItems[_idx].uItemID;
         if ( v24 > 134 )
         {
           if ( v24 == 529 )
@@ -3582,7 +3585,7 @@
         }
         else
         {
-          v25 = *(int *)&v21->field_1F5[36 * *(int *)v23 + 7];
+          v25 = v21->pInventoryItems[_idx].uAdditionalValue;
           if ( v25 <= 50 )
           {
             if ( v25 != 50 )
@@ -5362,7 +5365,7 @@
   int v98; // eax@71
   int v101; // eax@71
   enum PLAYER_SKILL_TYPE v102; // edi@72
-  size_t uNumLen; // eax@72
+  size_t v103; // eax@72
   signed int v104; // ecx@72
   int v105; // ecx@79
   unsigned int v107; // ST0C_4@81
@@ -5401,19 +5404,22 @@
   uColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   pRenderer->BeginScene();
   pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
+
+  uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
-  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos++ - 640, 2, pTexture_MAKESKY);
-  if ( (signed int)uPlayerCreationUI_SkySliderPos > 640 )
-    uPlayerCreationUI_SkySliderPos = 0;
+  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - 640, 2, pTexture_MAKESKY);
+  //if (uPlayerCreationUI_SkySliderPos > 640)
+    //uPlayerCreationUI_SkySliderPos = 0;
   pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP);
+
   uTitleText = pGlobalTXT_LocalizationStrings[51];
   uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7;
   v2 = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]);
   pGUIWindow_CurrentMenu->DrawText(pFontCChar, v2 + 1, 0, 0, uTitleText, 0, 0, 0);
-  pRenderer->DrawTextureTransparent(17u, 35u, pPlayerPortraits[(char)pParty->pPlayers[0].uFace]);
-  pRenderer->DrawTextureTransparent(176u, 35u, pPlayerPortraits[(char)pParty->pPlayers[1].uFace]);
-  pRenderer->DrawTextureTransparent(335u, 35u, pPlayerPortraits[(char)pParty->pPlayers[2].uFace]);
-  pRenderer->DrawTextureTransparent(494u, 35u, pPlayerPortraits[(char)pParty->pPlayers[3].uFace]);
+  pRenderer->DrawTextureTransparent(17u, 35u, pPlayerPortraits[pParty->pPlayers[0].uFace]);
+  pRenderer->DrawTextureTransparent(176u, 35u, pPlayerPortraits[pParty->pPlayers[1].uFace]);
+  pRenderer->DrawTextureTransparent(335u, 35u, pPlayerPortraits[pParty->pPlayers[2].uFace]);
+  pRenderer->DrawTextureTransparent(494u, 35u, pPlayerPortraits[pParty->pPlayers[3].uFace]);
   v3 = pIconsFrameTable->GetFrame(uIconID_CharacterFrame, pEventTimer->uStartTime);
   if ( uPlayerCreationUI_SelectedCharacter )
   {
@@ -5437,12 +5443,17 @@
   {
     v4 = 12;
   }
+
   pRenderer->DrawTextureTransparent(v4, 29, &pIcons_LOD->pTextures[v3->uTextureID]);
   uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->pCurrentPosActiveItem);
-  pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim + 1]);
-  pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim-- + 1]);
-  if ( uPlayerCreationUI_ArrowAnim < 0 )
-    uPlayerCreationUI_ArrowAnim = 18;
+
+  uPlayerCreationUI_ArrowAnim = 19 - (GetTickCount() % 500) / 25;
+  Log::Warning(L"%u",uPlayerCreationUI_ArrowAnim);
+  pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]);
+  pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]);
+  //if (uPlayerCreationUI_ArrowAnim < 0)
+  //  uPlayerCreationUI_ArrowAnim = 18;
+
   v6 = LOBYTE(pFontCreate->uFontHeight) - 2;
   v128 = LOBYTE(pFontCreate->uFontHeight) - 2;
   strcpy(Str1, pGlobalTXT_LocalizationStrings[205]);// "Skills"
@@ -5597,17 +5608,23 @@
     sprintf(pTmpBuf, "\t%03u%s", v40, pSkillName);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, v128 + 311, uColorWhite, pTmpBuf, 0, 0, 0);
     v41 = pPlayer->GetSkillIdxByOrder(2);
-    v44 = pFontCreate->AlignText_Center(150u, pSkillNames[v41]);
-    sprintf(pTmpBuf, "\t%03u%s", v44, pSkillNames[v41]);
+    v42 = pSkillNames[v41];
+    v43 = pSkillNames[v41];
+    v133 = v41;
+    v44 = pFontCreate->AlignText_Center(150u, v42);
+    sprintf(pTmpBuf, "\t%03u%s", v44, v43);
     v45 = uColorGreen;
-    if ( (signed int)v41 >= 37 )
+    if ( (signed int)v133 >= 37 )
       v45 = uColorTeal;
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 2 * v128 + 311, v45, pTmpBuf, 0, 0, 0);
     v46 = pPlayer->GetSkillIdxByOrder(3);
-    v49 = pFontCreate->AlignText_Center(150u, pSkillNames[v46]);
-    sprintf(pTmpBuf, "\t%03u%s", v49, pSkillNames[v46]);
+    v47 = pSkillNames[v46];
+    v48 = pSkillNames[v46];
+    v133 = v46;
+    v49 = pFontCreate->AlignText_Center(150u, v47);
+    sprintf(pTmpBuf, "\t%03u%s", v49, v48);
     v50 = uColorGreen;
-    if ( (signed int)v46 >= 37 )
+    if ( (signed int)v133 >= 37 )
       v50 = uColorTeal;
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, v123, v50, pTmpBuf, 0, 0, 0);
     pPlayer++;
@@ -5650,7 +5667,7 @@
   v65 = pFontCreate->AlignText_Center(65u, pClassNames[12]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, v65 + 323, v64, v61, pClassNames[12], 0, 0, 0);
   v66 = uColorTeal;
-  if ( uClassType != PLAYER_CLASS_RANGER )
+  if ( uClassType != PLAYER_CLASS_DRUID )
     v66 = uColorWhite;
   v69 = 2 * v128 + 417;
   v126 = 2 * v128 + 417;
@@ -5662,7 +5679,7 @@
   v74 = pFontCreate->AlignText_Center(65u, pClassNames[24]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, v74 + 388, 417, v71, pClassNames[24], 0, 0, 0);
   v75 = uColorTeal;
-  if ( uClassType != PLAYER_CLASS_DRUID )
+  if ( uClassType != 28 )
     v75 = uColorWhite;
   v78 = uColorGreen;
   v79 = pFontCreate->AlignText_Center(65u, pClassNames[28]);
@@ -5697,9 +5714,9 @@
   {
     v102 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(v134 + 4);
     strcpy(Str1, pSkillNames[v102]);
-    uNumLen = strlen(Str1);
+    v103 = strlen(Str1);
     v104 = 0;
-    if ( (signed int)uNumLen > 0 )
+    if ( (signed int)v103 > 0 )
     {
 	  if ( Str1[v104] == 32 )
 	  {
@@ -5710,7 +5727,7 @@
 		while ( Str1[v104] != 32 )
 		{
 		  ++v104;
-		  if ( v104 >= (signed int)uNumLen )
+		  if ( v104 >= (signed int)v103 )
 		   break;
 		}
 	  }
@@ -5831,105 +5848,432 @@
   uXa = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, 0x3Cu, uControlParama, 0, nullstring, 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, 0x3Cu, uControlParama, 0, "", 0);
     uXa += 158;
     ++uControlParama;
   }
   while ( (signed int)uXa < 640 );
-  pCreationUI_BtnPressLeft[0] = pGUIWindow_CurrentMenu->CreateButton(10u, 32u, 11u, 13u, 1, 0, 0xABu, 0, 0,
-                                  nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(169u, 32u, 11u, 13u, 1, 0, 0xABu, 1u, 0,
-                                  nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(327u, 32u, 11u, 13u, 1, 0, 0xABu, 2u, 0,
-                                  nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(486u, 32u, 11u, 13u, 1, 0, 0xABu, 3u, 0,
-                                  nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(74u, 32u, 11u, 13u, 1, 0, 0xACu, 0, 0,
-                                   nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(233u, 32u, 11u, 13u, 1, 0, 0xACu, 1u, 0,
-                                   nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(391u, 32u, 11u, 13u, 1, 0, 0xACu, 2u, 0,
-                                   nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(549u, 32u, 11u, 13u, 1, 0, 0xACu, 3u, 0,
-                                   nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(10u, 103u, 11u, 13u, 1, 0, 0x90u, 0, 0,
-                                   nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(169u, 103u, 11u, 13u, 1, 0, 0x90u, 1u, 0,
-                                   nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(327u, 103u, 11u, 13u, 1, 0, 0x90u, 2u, 0,
-                                   nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(486u, 103u, 11u, 13u, 1, 0, 0x90u, 3u, 0,
-                                   nullstring, pTexture_presleft, 0);
-  pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(74u, 103u, 11u, 13u, 1, 0, 0x91u, 0, 0,
-                                    nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(233u, 103u, 11u, 13u, 1, 0,
-                                    0x91u, 1u, 0, nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(391u, 103u, 11u, 13u, 1, 0,
-                                    0x91u, 2u, 0, nullstring, pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(549u, 103u, 11u, 13u, 1, 0, 0x91u, 3u, 0,
-                                    nullstring, pTexture_pressrigh, 0);
+  pCreationUI_BtnPressLeft[0] = pGUIWindow_CurrentMenu->CreateButton(
+                                  10u,
+                                  32u,
+                                  11u,
+                                  13u,
+                                  1,
+                                  0,
+                                  0xABu,
+                                  0,
+                                  0,
+                                  "",
+                                  pTexture_presleft,
+                                  0);
+  pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(
+                                  169u,
+                                  32u,
+                                  11u,
+                                  13u,
+                                  1,
+                                  0,
+                                  0xABu,
+                                  1u,
+                                  0,
+                                  "",
+                                  pTexture_presleft,
+                                  0);
+  pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(
+                                  327u,
+                                  32u,
+                                  11u,
+                                  13u,
+                                  1,
+                                  0,
+                                  0xABu,
+                                  2u,
+                                  0,
+                                  "",
+                                  pTexture_presleft,
+                                  0);
+  pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(
+                                  486u,
+                                  32u,
+                                  11u,
+                                  13u,
+                                  1,
+                                  0,
+                                  0xABu,
+                                  3u,
+                                  0,
+                                  "",
+                                  pTexture_presleft,
+                                  0);
+  pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(
+                                   74u,
+                                   32u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0xACu,
+                                   0,
+                                   0,
+                                   "",
+                                   pTexture_pressrigh,
+                                   0);
+  pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(
+                                   233u,
+                                   32u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0xACu,
+                                   1u,
+                                   0,
+                                   "",
+                                   pTexture_pressrigh,
+                                   0);
+  pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(
+                                   391u,
+                                   32u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0xACu,
+                                   2u,
+                                   0,
+                                   "",
+                                   pTexture_pressrigh,
+                                   0);
+  pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(
+                                   549u,
+                                   32u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0xACu,
+                                   3u,
+                                   0,
+                                   "",
+                                   pTexture_pressrigh,
+                                   0);
+  pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(
+                                   10u,
+                                   103u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0x90u,
+                                   0,
+                                   0,
+                                   "",
+                                   pTexture_presleft,
+                                   0);
+  pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(
+                                   169u,
+                                   103u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0x90u,
+                                   1u,
+                                   0,
+                                   "",
+                                   pTexture_presleft,
+                                   0);
+  pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(
+                                   327u,
+                                   103u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0x90u,
+                                   2u,
+                                   0,
+                                   "",
+                                   pTexture_presleft,
+                                   0);
+  pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(
+                                   486u,
+                                   103u,
+                                   11u,
+                                   13u,
+                                   1,
+                                   0,
+                                   0x90u,
+                                   3u,
+                                   0,
+                                   "",
+                                   pTexture_presleft,
+                                   0);
+  pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(
+                                    74u,
+                                    103u,
+                                    11u,
+                                    13u,
+                                    1,
+                                    0,
+                                    0x91u,
+                                    0,
+                                    0,
+                                    "",
+                                    pTexture_pressrigh,
+                                    0);
+  pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(
+                                    233u,
+                                    103u,
+                                    11u,
+                                    13u,
+                                    1,
+                                    0,
+                                    0x91u,
+                                    1u,
+                                    0,
+                                    "",
+                                    pTexture_pressrigh,
+                                    0);
+  pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(
+                                    391u,
+                                    103u,
+                                    11u,
+                                    13u,
+                                    1,
+                                    0,
+                                    0x91u,
+                                    2u,
+                                    0,
+                                    "",
+                                    pTexture_pressrigh,
+                                    0);
+  pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(
+                                    549u,
+                                    103u,
+                                    11u,
+                                    13u,
+                                    1,
+                                    0,
+                                    0x91u,
+                                    3u,
+                                    0,
+                                    "",
+                                    pTexture_pressrigh,
+                                    0);
   uControlParamb = 0;
   uXb = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 308u, 150u, v0, 1, 0, 0x48u, uControlParamb, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308, 150u, v0, 1, 0, 0x49u, uControlParamb, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150u, v0, 1, 0, 0x4Au, uControlParamb, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150u, v0, 1, 0, 0x4Bu, uControlParamb, 0, nullstring,  0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 308u, 150u, v0, 1, 0, 0x48u, uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXb,
+      v0 + 308,
+      150u,
+      v0,
+      1,
+      0,
+      0x49u,
+      uControlParamb,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXb,
+      2 * v0 + 308,
+      150u,
+      v0,
+      1,
+      0,
+      0x4Au,
+      uControlParamb,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXb,
+      3 * v0 + 308,
+      150u,
+      v0,
+      1,
+      0,
+      0x4Bu,
+      uControlParamb,
+      0,
+      "",
+      0);
     uXb += 158;
     ++uControlParamb;
   }
   while ( (signed int)uXb < 640 );
-  pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 0, 0x31u, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 1u, 0x32u, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 2u, 0x33u, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 3u, 0x34u, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 0, 0x31u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 1u, 0x32u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 2u, 0x33u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 3u, 0x34u, "", 0);
   uXc = 23;
   uControlParamc = 2;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 169u, 120u, 20u, 1, 0, 0, uControlParamc - 2, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169, 120u, 20u, 1, 0, 0, uControlParamc - 1, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 2 * v0 + 169, 120u, 20u, 1, 0, 0, uControlParamc, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 3 * v0 + 169, 120u, 20u, 1, 0, 0, uControlParamc + 1, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 4 * v0 + 169, 120u, 20u, 1, 0, 0, uControlParamc + 2, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 5 * v0 + 169, 120u, 20u, 1, 0, 0, uControlParamc + 3, 0, nullstring, 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 6 * v0 + 169, 120u, 20u, 1, 0, 0, uControlParamc + 4, 0, nullstring, 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXc, 169u, 120u, 20u, 1, 0, 0, uControlParamc - 2, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXc,
+      v0 + 169,
+      120u,
+      20u,
+      1,
+      0,
+      0,
+      uControlParamc - 1,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXc,
+      2 * v0 + 169,
+      120u,
+      20u,
+      1,
+      0,
+      0,
+      uControlParamc,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXc,
+      3 * v0 + 169,
+      120u,
+      20u,
+      1,
+      0,
+      0,
+      uControlParamc + 1,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXc,
+      4 * v0 + 169,
+      120u,
+      20u,
+      1,
+      0,
+      0,
+      uControlParamc + 2,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXc,
+      5 * v0 + 169,
+      120u,
+      20u,
+      1,
+      0,
+      0,
+      uControlParamc + 3,
+      0,
+      "",
+      0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      uXc,
+      6 * v0 + 169,
+      120u,
+      20u,
+      1,
+      0,
+      0,
+      uControlParamc + 4,
+      0,
+      "",
+      0);
     uControlParamc += 7;
     uXc += 158;
   }
   while ( (signed int)uControlParamc < 30 );
   pGUIWindow_CurrentMenu->_41D08F(28, 0, 7, 40);
-  pGUIWindow_CurrentMenu->CreateButton(323u, 417u, 65u, v0, 1, 0, 0x41u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(323u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0xCu, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(323u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x14u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(388u, 417u, 65u, v0, 1, 0, 0x41u, 0x18u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(388u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0x1Cu, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(388u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x20u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(453u, 417u, 65u, v0, 1, 0, 0x41u, 0x10u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(453u, v0 + 417, 65u, v0, 1, 0, 0x41u, 8u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(453u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 4u, 0, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(323u, 417u, 65u, v0, 1, 0, 0x41u, 0, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0xCu, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x14u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388u, 417u, 65u, v0, 1, 0, 0x41u, 0x18u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0x1Cu, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x20u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453u, 417u, 65u, v0, 1, 0, 0x41u, 0x10u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453u, v0 + 417, 65u, v0, 1, 0, 0x41u, 8u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 4u, 0, "", 0);
   uControlParamd = 0;
   do
   {
     uXd = -5;
     if ( uControlParamd <= 3 )
       uXd = 0;
-    pGUIWindow_CurrentMenu->CreateButton(100 * (uControlParamd / 3) + uXd + 17, v0 * (uControlParamd % 3) + 417,
-                                         100u, v0, 1, 0, 0x40u, uControlParamd, 0, nullstring, 0);
+    pGUIWindow_CurrentMenu->CreateButton(
+      100 * uControlParamd / 3 + uXd + 17,
+      v0 * uControlParamd % 3 + 417,
+      100u,
+      v0,
+      1,
+      0,
+      0x40u,
+      uControlParamd,
+      0,
+      "",
+      0);
     ++uControlParamd;
   }
   while ( uControlParamd < 9 );
-  pPlayerCreationUI_BtnOK = pGUIWindow_CurrentMenu->CreateButton(580u, 431u, 51u, 39u, 1, 0, 0x42u, 0, 0xDu, nullstring,
+  pPlayerCreationUI_BtnOK = pGUIWindow_CurrentMenu->CreateButton(
+                              580u,
+                              431u,
+                              51u,
+                              39u,
+                              1,
+                              0,
+                              0x42u,
+                              0,
+                              0xDu,
+                              "",
                               (Texture *)(uTextureID_BUTTMAKE != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE] : 0),
                               0);
-  pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527u, 431u, 51u, 39u, 1, 0, 0x43u, 0, 0x43u, nullstring,
+  pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(
+                                 527u,
+                                 431u,
+                                 51u,
+                                 39u,
+                                 1,
+                                 0,
+                                 0x43u,
+                                 0,
+                                 0x43u,
+                                 "",
                                  (Texture *)(uTextureID_BUTTMAKE2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0),
                                  0);
-  pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523u, 393u, 20u, 35u, 1, 0, 0x3Fu, 0, 0x2Du, nullstring,
-                                 pTexture_buttminu, 0);
-  pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(613u, 393u, 20u, 35u, 1, 0, 0x3Eu, 1u, 0x2Bu, nullstring,
-                                pTexture_buttplus, 0);
+  pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(
+                                 523u,
+                                 393u,
+                                 20u,
+                                 35u,
+                                 1,
+                                 0,
+                                 0x3Fu,
+                                 0,
+                                 0x2Du,
+                                 "",
+                                 pTexture_buttminu,
+                                 0);
+  pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(
+                                613u,
+                                393u,
+                                20u,
+                                35u,
+                                1,
+                                0,
+                                0x3Eu,
+                                1u,
+                                0x2Bu,
+                                "",
+                                pTexture_buttplus,
+                                0);
   pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0);
 }
 // 4E28F8: using guessed type int pCurrentScreen;
@@ -5971,7 +6315,6 @@
   POINT v25; // [sp+6Ch] [bp-14h]@6
   bool v26; // [sp+74h] [bp-Ch]@1
   POINT v24; // [sp+78h] [bp-8h]@6
-  Player *pPlayer;
 
   v0 = &pTexture_PCX;
   v1 = 0;
@@ -6102,7 +6445,7 @@
     *(char *)(v11 + 6734) = v12;
 LABEL_45:
     pItemsTable->GenerateItem(2, 40, &item);
-    pPlayer->AddItem2(0xFFFFFFFFu, &item);
+    ((Player *)(v10 - 6014))->AddItem2(0xFFFFFFFFu, &item);
     v14 = 0;
     v24.y = 0;
     do
@@ -6145,31 +6488,31 @@
             v18 = 76;
             goto LABEL_69;
           case 12:
-            pPlayer->AddItem(0xFFFFFFFFu, 401);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x191u);
             *(char *)(v11 + 402) = 1;
             break;
           case 13:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 412);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x19Cu);
             *(char *)(v11 + 413) = 1;
             break;
           case 14:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 423);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x1A7u);
             *(char *)(v11 + 424) = 1;
             break;
           case 15:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 434);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x1B2u);
             *(char *)(v11 + 435) = 1;
             break;
           case 16:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 445);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x1BDu);
             *(char *)(v11 + 446) = 1;
             break;
           case 17:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 456);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x1C8u);
             *(char *)(v11 + 457) = 1;
             break;
           case 18:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 467);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0x1D3u);
             *(char *)(v11 + 468) = 1;
             break;
           case 21:
@@ -6178,7 +6521,7 @@
           case 26:
           case 29:
           case 36:
-            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 220);
+            ((Player *)(v10 - 6014))->AddItem(0xFFFFFFFFu, 0xDCu);
             v18 = 5 * (rand() % 3 + 40);
             goto LABEL_69;
           case 30:
@@ -6334,7 +6677,7 @@
     (signed __int16)v21.uWidth);
   free(pString);
   pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr);
-  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, nullstring, 0);
+  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, "", 0);
   pCurrentScreen = 9;
   SetCurrentMenuID(MENU_Credits);
   pRenderer->BeginScene();
@@ -6475,16 +6818,16 @@
   {
     result = 1;
   }
-  v3->vNormal.x = v.x;
-  v3->vNormal.y = v.y;
-  v3->vNormal.z = v.z;
-  v3->field_10 = *(float *)&a3;
-  v3->field_14 = result;
+  v3->face_plane.vNormal.x = v.x;
+  v3->face_plane.vNormal.y = v.y;
+  v3->face_plane.vNormal.z = v.z;
+  v3->face_plane.dist = *(float *)&a3;
+  v3->polygonType = (PolygonType)result;
   return result;
 }
 
 //----- (0049B0C9) --------------------------------------------------------
-int stru154::_49B0C9(Vec3_float_ *pNormal, float a3)
+int stru154::_49B0C9(Vec3_float_ *pNormal, float dist)
 {
   signed int v3; // esi@1
   signed int result; // eax@9
@@ -6518,11 +6861,11 @@
   v5 = pNormal->z;
   v6 = pNormal->y;
   v7 = pNormal->x;
-  this->field_14 = result;
-  this->vNormal.x = v7;
-  this->field_10 = a3;
-  this->vNormal.y = v6;
-  this->vNormal.z = v5;
+  this->polygonType = (PolygonType)result;
+  this->face_plane.vNormal.x = v7;
+  this->face_plane.dist = dist;
+  this->face_plane.vNormal.y = v6;
+  this->face_plane.vNormal.z = v5;
   return result;
 }
 
@@ -7599,7 +7942,7 @@
               v6 = stru_F8AD28.pDeltaUV[0];
               v116 = stru_F8AD28.pDeltaUV[1];
               v7 = 0;
-              for ( i = bUseLoResSprites; v7 < stru_F8AD28.field_AC; *(int *)v9 = v10 )
+              for ( i = bUseLoResSprites; v7 < stru_F8AD28.uNumLightsApplied; *(int *)v9 = v10 )
               {
                 v8 = v116;
                 stru_F8AD28._blv_lights_xs[v7] += v6;
@@ -8098,7 +8441,7 @@
           v48 = v9;
           v50 = v10;
           sub_4AF412();
-          ++pBLVRenderParams->field_80;
+          ++pBLVRenderParams->uNumFacesRenderedThisFrame;
           v11 = sr_sub_47C24C_get_palette(v2, v4->palette_id2, 0, 1);
           v12 = stru_F8A590._viewport_space_y;
           v51 = v11;
@@ -8364,11 +8707,11 @@
 
   v2 = a1 >> SLOBYTE(stru_F8AD28.field_38);
   v3 = a2 >> SLOBYTE(stru_F8AD28.field_38);
-  v17 = stru_F8AD28.field_2C;
+  v17 = stru_F8AD28.uCurrentAmbientLightLevel;
   v4 = 0;
   v15 = v2;
   v16 = 0;
-  if ( stru_F8AD28.field_AC > 0 )
+  if ( stru_F8AD28.uNumLightsApplied > 0 )
   {
     do
     {
@@ -8401,7 +8744,7 @@
       ++v16;
       v2 = v15;
     }
-    while ( v16 < stru_F8AD28.field_AC );
+    while ( v16 < stru_F8AD28.uNumLightsApplied );
     v4 = 0;
   }
   if ( stru_F8AD28.field_3E4 != v4 )
@@ -8545,7 +8888,7 @@
   stru_F8AD28.vec_20.x = v66.x;
   stru_F8AD28.vec_20.y = v66.y;
   stru_F8AD28.vec_20.z = v66.z;
-  stru_F8AD28.field_3F8 = v2->field_22;
+  stru_F8AD28.uDefaultAmbientLightLevel = v2->field_22;
   if ( pBLVRenderParams->sPartyRotX )
   {
     v74 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
@@ -8666,11 +9009,11 @@
   v69 = v17;
   v74 = 0;
   v73 = 0;
-  stru_F8AD28.field_2C = (stru_F8AD28.field_3F8 + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16;
-  v70 = uNumMobileLightsApplied;
-  if ( uNumMobileLightsApplied > 0 )
-  {
-    v18 = (char *)&pMobileLights[0].vPosition.y;
+  stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16;
+  v70 = pMobileLightsStack->uNumLightsActive;
+  if ( pMobileLightsStack->uNumLightsActive > 0 )
+  {
+    v18 = (char *)&pMobileLightsStack->pLights[0].vPosition.y;
     do
     {
       if ( v74 >= 20 )
@@ -8719,7 +9062,7 @@
                     v28 = v74;
                     v29 = v18[9];
                     ++v74;
-                    stru_F8AD28._blv_lights_smthngs[v28] = v29;
+                    stru_F8AD28._blv_lights_types[v28] = v29;
                   }
                 }
               }
@@ -8787,7 +9130,7 @@
                         v16 = 0.0039215689;
                         stru_F8AD28._blv_lights_light_dot_faces[v39] = abs(v38);
                         v40 = v74++;
-                        stru_F8AD28._blv_lights_smthngs[v40] = 1;
+                        stru_F8AD28._blv_lights_types[v40] = 1;
                       }
                     }
                   }
@@ -8804,9 +9147,9 @@
     }
   }
   v73 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
-  {
-    v41 = (char *)&pStationaryLights[0].vPosition.y;
+  if ( pStationaryLightsStack->uNumLightsActive > 0 )
+  {
+    v41 = (char *)&pStationaryLightsStack->pLights[0].vPosition.y;
     do
     {
       if ( v74 >= 20 )
@@ -8855,7 +9198,7 @@
                       v16 = 0.0039215689;
                       stru_F8AD28._blv_lights_light_dot_faces[v48] = abs(v47);
                       v52 = v74++;
-                      stru_F8AD28._blv_lights_smthngs[v52] = 1;
+                      stru_F8AD28._blv_lights_types[v52] = 1;
                     }
                   }
                 }
@@ -8867,9 +9210,9 @@
       ++v73;
       v41 += 12;
     }
-    while ( v73 < uNumStationaryLightsApplied );
-  }
-  stru_F8AD28.field_AC = v74;
+    while ( v73 < pStationaryLightsStack->uNumLightsActive );
+  }
+  stru_F8AD28.uNumLightsApplied = v74;
   v53 = v1->pBounding.x2;
   if ( pBLVRenderParams->vPartyPos.x <= v53 )
   {
@@ -8972,7 +9315,7 @@
   stru_F8AD28.vec_14.z = 0;
   stru_F8AD28.vec_20.x = 0;
   stru_F8AD28.vec_20.z = 0;
-  stru_F8AD28.field_3F8 = 0;
+  stru_F8AD28.uDefaultAmbientLightLevel = 0;
   if ( pBLVRenderParams->sPartyRotX )
   {
     v0 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
@@ -9070,8 +9413,8 @@
                          + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v7) >> 16));
   stru_F8AD28.field_38 = 0;
   stru_F8AD28.field_3E4 = 0;
-  stru_F8AD28.field_2C = 0;
-  stru_F8AD28.field_AC = 0;
+  stru_F8AD28.uCurrentAmbientLightLevel = 0;
+  stru_F8AD28.uNumLightsApplied = 0;
   stru_F8AD28.field_34 = 0;
   return result;
 }
@@ -10432,7 +10775,7 @@
           sprintfex(pTmpBuf, &byte_4F0F98, v32, v31, v30);
           sprintfex(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
           ptr_F8B1E8 = pTmpBuf2;
-          v15 = nullstring;
+          v15 = "";
           goto LABEL_45;
         }
         if ( v28 != 10 )
@@ -10448,7 +10791,7 @@
           if ( !v15 )
           {
             v16->uControlParam = 0;
-            v15 = nullstring;
+            v15 = "";
           }
           goto LABEL_49;
         }
@@ -10468,7 +10811,7 @@
             if ( !v15 )
             {
               v16->uControlParam = 0;
-              v15 = nullstring;
+              v15 = "";
             }
             if ( uDialogueType != 84 )
               goto LABEL_49;
@@ -10495,7 +10838,7 @@
             goto LABEL_33;
           }
 LABEL_41:
-          v15 = nullstring;
+          v15 = "";
           goto LABEL_49;
         }
         v15 = pGlobalTXT_LocalizationStrings[122];
@@ -10601,7 +10944,7 @@
            0x195u,
            a2,
            0,
-           nullstring,
+           "",
            0);
 }
 
@@ -11321,7 +11664,7 @@
                  pGlobalTXT_LocalizationStrings[34],
                  (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(
     0x1E0u,
     0xA0u,
@@ -11351,7 +11694,7 @@
   _4B254D_SkillMasteryTeacher(a4);
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
-  v2 = nullstring;
+  v2 = "";
   ptr_5076F4 = pDialogueWindow->CreateButton(
                  0x1D7u,
                  0x1BDu,
@@ -11365,7 +11708,7 @@
                  pGlobalTXT_LocalizationStrings[34],
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   if ( dword_F8B1A8 )
     v2 = pGlobalTXT_LocalizationStrings[535];
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x4Fu, 0, v2, 0);
@@ -11398,7 +11741,7 @@
                  pGlobalTXT_LocalizationStrings[34],
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   if ( *(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
   {
     pDialogueWindow->CreateButton(
@@ -11527,7 +11870,7 @@
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                    0);
-    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, nullstring, 0);
+    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
     if ( array_5913D8[6] == (NPCData *)1 && dword_591080 )
     {
       result = (GUIButton *)sub_4B3B42(dword_F8B198);
@@ -11537,7 +11880,7 @@
       if ( v17->joins )
       {
         v1 = 1;
-        pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, nullstring, 0);
+        pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, "", 0);
       }
       v5 = (void *)v17->bDrawSomeAnim;
       if ( v5 )
@@ -11556,7 +11899,7 @@
               0xAFu,
               0x13u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11577,7 +11920,7 @@
               0xAFu,
               0x14u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11598,7 +11941,7 @@
               0xAFu,
               0x15u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11619,7 +11962,7 @@
               0xAFu,
               0x16u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11640,7 +11983,7 @@
               0xAFu,
               0x17u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11661,7 +12004,7 @@
               0xAFu,
               0x18u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -13180,11 +13523,11 @@
   v63 = v2 * (100 - v1->GetMerchant()) / 100;
   if ( v63 < v2 / 3 )
     v63 = v2 / 3;
-  strcpy(Dest, nullstring);
-  strcpy(v46, nullstring);
-  strcpy(v47, nullstring);
-  strcpy(v48, nullstring);
-  strcpy(v49, nullstring);
+  strcpy(Dest, "");
+  strcpy(v46, "");
+  strcpy(v47, "");
+  strcpy(v48, "");
+  strcpy(v49, "");
   if ( dword_F8B19C != 1 )
   {
     if ( dword_F8B19C != 18 )
@@ -13771,7 +14114,7 @@
   }
   v63 = 1;
   v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem);
-  strcpy(a1, nullstring);
+  strcpy(a1, "");
   v41->uHeight = 0;
   v41->uY = 0;
   if ( v1->_4B6FF9() )
@@ -14232,7 +14575,7 @@
       v17 = LOBYTE(pFontArrus->uFontHeight) - 3;
       v59 = pDialogueWindow;
       v54 = v17;
-      strcpy(&Dest, nullstring);
+      strcpy(&Dest, "");
       sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1);
       v18 = pFontArrus->CalcTextHeight(pTmpBuf2, &v53, 0, 0);
       v19 = v16->pNumPresenceButton;
@@ -14328,7 +14671,7 @@
           ++v62;
           ++s1;
           a1 += 100;
-          strcpy(v31, nullstring);
+          strcpy(v31, "");
           if ( v24 )
           {
             v24->uW = 0;
@@ -14409,9 +14752,9 @@
           v7 = *((int *)v5 + 4);
           pIndoorCamera->sRotationY = 0;
           pParty->uFlags |= 2u;
-          pParty->vPosition.z = v7;
-          pParty->vPosition.y = *((int *)v5 + 5);
-          pParty->uFallStartY = pParty->vPosition.y;
+          pParty->vPosition.y = v7;
+          pParty->vPosition.z = *((int *)v5 + 5);
+          pParty->uFallStartY = pParty->vPosition.z;
           pParty->sRotationY = *((int *)v5 + 6);
         }
         HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
@@ -14733,7 +15076,7 @@
   int v8; // eax@10
   SpriteFrame *v9; // eax@16
   SpriteFrame *v10; // ebx@18
-  int *v11; // eax@18
+  //int *v11; // eax@18
   int v12; // ecx@28
   //IndoorCameraD3D **v14; // eax@36
   double v15; // st7@36
@@ -14813,19 +15156,19 @@
       v9 = pSpriteFrameTable->GetFrame(v31, v8);
     v41 = 0;
     v10 = v9;
-    v11 = (int *)v9->uFlags;
-    if ( (unsigned __int8)v11 & 2 )
+    //v11 = (int *)v9->uFlags;
+    if (v9->uFlags & 2)
       v41 = 2;
-    if ( (unsigned int)v11 & 0x40000 )
+    if (v9->uFlags & 0x40000)
       v41 |= 0x40u;
-    if ( (unsigned int)v11 & 0x20000 )
+    if (v9->uFlags & 0x20000)
       LOBYTE(v41) = v41 | 0x80;
     v0 = (RenderBillboard *)(256 << v6);
-    if ( (unsigned int)v0 & (unsigned int)v11 )
+    if ( (unsigned int)v0 & v9->uFlags)
       v41 |= 4u;
     if ( v10->uGlowRadius )
     {
-      LOBYTE(v11) = byte_4E94D3;
+      //LOBYTE(v11) = byte_4E94D3;
       pMobileLightsStack->AddLight(
         a1a,
         a2,
@@ -14835,7 +15178,7 @@
         0xFFu,
         0xFFu,
         0xFFu,
-        v11);
+        byte_4E94D3);
     }
     v12 = 0;
     if ( pStru170->uNumVisibleNotEmptySectors <= 0 )
@@ -14872,10 +15215,10 @@
     else
     {
       //v14 = &pGame->pIndoorCameraD3D;
-      v0->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-      v15 = pGame->pIndoorCameraD3D->flt_D4;
-      v16 = v0->flt_8;
-      v0->flt_C = v15;
+      v0->fov_x = pGame->pIndoorCameraD3D->fov_x;
+      v15 = pGame->pIndoorCameraD3D->fov_y;
+      v16 = v0->fov_x;
+      v0->fov_y = v15;
       //v17 = v16 + 6.7553994e15;
       LODWORD(v18) = 0;
       HIDWORD(v18) = floorf(v16 + 0.5f);
@@ -15251,7 +15594,7 @@
   v25 = uHouseID;
   GameUI_StatusBar_TimedString[0] = 0;
   pStatusBarString[0] = 0;
-  ShowStatusBarString(nullstring, 2u);
+  ShowStatusBarString("", 2u);
   if ( pMessageQueue_50CBD0->uNumMessages )
     pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
   viewparams->bRedrawGameUI = 1;
--- a/mm7_5.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_5.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -304,9 +304,12 @@
   if ( pMessageQueue_50CBD0->uNumMessages )
   {
     v0 = 1;
-    v1 = nullstring;
+    v1 = "";
     while ( 2 )
     {
+      if ( !pMessageQueue_50CBD0->uNumMessages )
+        break;
+
       pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199);
       switch ( uMessage )
       {
@@ -786,25 +789,25 @@
           uTextureID_507C00 = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
           uTextureID_507C04 = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_KeyMappingOptions, 0, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, nullstring, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, "", 0);
           dword_506E68 = -1;
           dword_506F08 = 1;
           memset(word_506E6C, 0, 0x1Cu);
@@ -1210,7 +1213,7 @@
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           viewparams->sPartyPosX = pParty->vPosition.x;
-          viewparams->sPartyPosZ = pParty->vPosition.z;
+          viewparams->sPartyPosZ = pParty->vPosition.y;
           pAudioPlayer->StopChannels(-1, -1);
           v26 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
           v27 = 353;
@@ -1527,10 +1530,10 @@
                         pParty->vPosition.x = -22528;
                       if ( pParty->vPosition.x > 22528 )
                         pParty->vPosition.x = 22528;
-                      if ( pParty->vPosition.z < -22528 )
-                        pParty->vPosition.z = -22528;
-                      if ( pParty->vPosition.z > 22528 )
-                        pParty->vPosition.z = 22528;
+                      if ( pParty->vPosition.y < -22528 )
+                        pParty->vPosition.y = -22528;
+                      if ( pParty->vPosition.y > 22528 )
+                        pParty->vPosition.y = 22528;
                       goto LABEL_317;
                     case 16:
                       pVideoPlayer->Unload();
@@ -1687,8 +1690,6 @@
           }
           sub_41426F();
 _continue:
-          if ( !pMessageQueue_50CBD0->uNumMessages )
-            break;
           continue;
         case UIMSG_BC:
           if ( uMessageParam )
@@ -1738,12 +1739,12 @@
             }
             if ( dword_591178_teleporty )
             {
-              pParty->vPosition.z = dword_591178_teleporty;
+              pParty->vPosition.y = dword_591178_teleporty;
               _5B65AC_npcdata_fame_or_other = dword_591178_teleporty;
             }
             if ( dword_591174_teleportz )
             {
-              pParty->vPosition.y = dword_591174_teleportz;
+              pParty->vPosition.z = dword_591174_teleportz;
               _5B65B0_npcdata_rep_or_other = dword_591174_teleportz;
               pParty->uFallStartY = dword_591174_teleportz;
             }
@@ -1799,7 +1800,7 @@
           v195 = (NPCData *)GetTravelTime();
           strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
           if ( bUnderwater != 1 && pParty->bFlying
-            || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, &pOut, 20) != v0 )
+            || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, &pOut, 20) != v0 )
           {
             viewparams->bRedrawGameUI = v0;
 LABEL_387:
@@ -1808,10 +1809,10 @@
               pParty->vPosition.x = -22528;
             if ( pParty->vPosition.x > 22528 )
               pParty->vPosition.x = 22528;
-            if ( pParty->vPosition.z < -22528 )
-              pParty->vPosition.z = -22528;
-            if ( pParty->vPosition.z > 22528 )
-              pParty->vPosition.z = 22528;
+            if ( pParty->vPosition.y < -22528 )
+              pParty->vPosition.y = -22528;
+            if ( pParty->vPosition.y > 22528 )
+              pParty->vPosition.y = 22528;
 LABEL_317:
             sub_44603D();
             pCurrentScreen = 0;
@@ -1882,8 +1883,8 @@
             OnMapLoad();
             pOutdoor->SetFog();
             TeleportToStartingPoint(uLevel_StartingPointType);
-            pParty->vPosition.y = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.z, (int *)&v213, 0);
-            pParty->uFallStartY = pParty->vPosition.y;
+            pParty->vPosition.z = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, (int *)&v213, 0);
+            pParty->uFallStartY = pParty->vPosition.z;
             sub_461103();
             pEventTimer->Resume();
             viewparams->bRedrawGameUI = 1;
@@ -1932,7 +1933,7 @@
             if ( uCurrentlyLoadedLevelType != v0 )
             {
               v50 = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
-              if ( !(BYTE3(v50->uFaceAttributes) & 2) || !v50->sCogTriggeredID )
+              if ( !(v50->uAttributes & 0x02000000) || !v50->sCogTriggeredID )
                 goto _continue;
               v44 = uNumSeconds;
               goto LABEL_415;
@@ -2081,7 +2082,7 @@
           v158 = (unsigned int)thise;
           v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
 _sprintex_draw_status_and_continue:
-          sprintfex(pTmpBuf, v146, v158, v174);
+          sprintf(pTmpBuf, v146, v158, v174);
           goto _set_status_string_pTmpBuf_and_continue;
         case UIMSG_B5:
           dword_50CDC8 = v0;
@@ -2133,9 +2134,9 @@
             else
             {
               pParty->vPosition.x = v195->uFlags;
-              pParty->vPosition.z = v195->fame;
-              pParty->vPosition.y = v195->rep;
-              pParty->uFallStartY = pParty->vPosition.y;
+              pParty->vPosition.y = v195->fame;
+              pParty->vPosition.z = v195->rep;
+              pParty->uFallStartY = pParty->vPosition.z;
               pParty->sRotationY = LOWORD(v195->house);
               pParty->sRotationX = HIWORD(v195->house);
             }
@@ -2164,8 +2165,8 @@
             v195->pName = (char *)v62;
             v61->uPortraitID = HIDWORD(v62);
             v61->uFlags = pParty->vPosition.x;
-            v61->fame = pParty->vPosition.z;
-            v61->rep = pParty->vPosition.y;
+            v61->fame = pParty->vPosition.y;
+            v61->rep = pParty->vPosition.z;
             LOWORD(v61->house) = LOWORD(pParty->sRotationY);
             HIWORD(v61->house) = LOWORD(pParty->sRotationX);
             if ( (signed int)pGames_LOD->uNumSubIndices / 2 <= 0 )
@@ -2208,9 +2209,9 @@
                   if ( v64 == stru_4ECBB8[uMessageParam].uMapInfoID )
                   {
                     pParty->vPosition.x = stru_4ECBB8[v65].pos.x;
-                    pParty->vPosition.z = stru_4ECBB8[v65].pos.y;
-                    pParty->vPosition.y = stru_4ECBB8[v65].pos.z;
-                    pParty->uFallStartY = pParty->vPosition.y;
+                    pParty->vPosition.y = stru_4ECBB8[v65].pos.y;
+                    pParty->vPosition.z = stru_4ECBB8[v65].pos.z;
+                    pParty->uFallStartY = pParty->vPosition.z;
                     pParty->sRotationY = stru_4ECBB8[v65].rot_y;
                     pParty->sRotationX = stru_4ECBB8[v65].rot_x;
                   }
@@ -2351,7 +2352,7 @@
             if ( v70 <= 0 || v70 >= 77 )
             {
 LABEL_90:
-              v1 = nullstring;
+              v1 = "";
 LABEL_91:
               v0 = 1;
               goto _continue;
@@ -2397,8 +2398,8 @@
                 v77 = thisi;
 LABEL_544:
                 pParty->vPosition.x = v74;
-                pParty->vPosition.z = v77;
-                pParty->vPosition.y = v76;
+                pParty->vPosition.y = v77;
+                pParty->vPosition.z = v76;
                 pParty->uFallStartY = v76;
                 goto LABEL_90;
               }
@@ -2673,7 +2674,7 @@
             v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName;
             v157 = pGlobalTXT_LocalizationStrings[483];
 _sprintex_2args_draw_status_and_continue:
-            sprintfex(pTmpBuf, v157, v173);
+            sprintf(pTmpBuf, v157, v173);
           }
           else
           {
@@ -3154,7 +3155,7 @@
           }
           if ( pParty->uCurrentHour < 0xC || (uNumSeconds = v0, pParty->uCurrentHour >= 0x18) )
             uNumSeconds = 0;
-          sprintfex(
+          sprintf(
             pTmpBuf,
             "%d:%02d%s %s %d %s %d",
             v195,
@@ -3171,7 +3172,7 @@
           goto _sprintex_2args_draw_status_and_continue;
         case UIMSG_ShowStatus_Player:
           v106 = pPlayers[uMessageParam];
-          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v106->pName, pClassNames[v106->uClass]);// "%s the %s"
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v106->pName, pClassNames[v106->uClass]);// "%s the %s"
           strcat(pTmpBuf, ": ");
           v107 = v106->GetMajorConditionIdx();
           strcat(pTmpBuf, aCharacterConditionNames[v107]);
@@ -3187,7 +3188,7 @@
           v112 = v110->sMana;
           v113 = pGlobalTXT_LocalizationStrings[108];// "Hit Points"
           v114 = v110->GetMaxHealth();
-          sprintfex(pTmpBuf, "%d / %d %s    %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
+          sprintf(pTmpBuf, "%d / %d %s    %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
           goto _set_status_string_pTmpBuf_and_continue;
         case 0xC:
           if ( pCurrentScreen == 15 )
@@ -3903,17 +3904,13 @@
 }
 
 //----- (0043648F) --------------------------------------------------------
-void __thiscall Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
-{
-  signed int v2; // edx@1
-  double v3; // st7@1
-
+void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
+{
   _this->flt_2C = 0.0;
-  v2 = a2->y;
-  v3 = (double)a2->z;
-  _this->vWorldPosition.x = (double)a2->x;
-  _this->vWorldPosition.y = (double)v2;
-  _this->vWorldPosition.z = v3;
+
+  _this->vWorldPosition.x = a2->x;
+  _this->vWorldPosition.y = a2->y;
+  _this->vWorldPosition.z = a2->z;
 }
 
 //----- (004369DB) --------------------------------------------------------
@@ -4669,18 +4666,18 @@
           if ( v8 == 1 )
           {
             v9 = *(short *)v1;
-            v10 = pParty->vPosition.z - *((short *)v1 - 100);
+            v10 = pParty->vPosition.y - *((short *)v1 - 100);
             a1 = pParty->vPosition.x - *((short *)v1 - 200);
             v48 = v10;
             if ( a1 * a1
                + v10 * v10
-               + ((signed int)(pParty->vPosition.y + pParty->uPartyHeight) >> (1 - v9))
-               * ((signed int)(pParty->vPosition.y + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
+               + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9))
+               * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
             {
               v11.z = *(short *)v1;
               v11.y = *((short *)v1 - 100);
               v11.x = *((short *)v1 - 200);
-              if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y + pParty->sEyelevel, v11) )
+              if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v11) )
               {
                 v12 = stru_50C198.which_player_would_attack(&pActors[v39]);
                 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v12);
@@ -4728,16 +4725,16 @@
       }
       else
       {
-        v23 = pParty->vPosition.z - *((short *)v1 - 100);
+        v23 = pParty->vPosition.y - *((short *)v1 - 100);
         v24 = ((signed int)pParty->uPartyHeight >> 1) - *(short *)v1;
         a1 = pParty->vPosition.x - *((short *)v1 - 200);
         v48 = v23;
-        if ( a1 * a1 + v23 * v23 + (pParty->vPosition.y + v24) * (pParty->vPosition.y + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
+        if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
         {
           v25.z = *(short *)v1;
           v25.y = *((short *)v1 - 100);
           v25.x = *((short *)v1 - 200);
-          if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y + pParty->sEyelevel, v25) )
+          if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v25) )
           {
             v26 = 0;
             v27 = (char *)&pParty->pPlayers[0].pConditions[15];
@@ -4967,9 +4964,9 @@
     v9 = (LayingItem *)uDamageAmount;
     v50 = pParty->vPosition.x - *(int *)(uDamageAmount + 4);
     v55 = abs(v50);
-    pMonsterName = (char *)(pParty->vPosition.z - v9->vPosition.y);
+    pMonsterName = (char *)(pParty->vPosition.y - v9->vPosition.y);
     v51 = (unsigned __int64 *)abs((int)pMonsterName);
-    pPlayerName = (char *)(pParty->vPosition.y - v9->vPosition.z);
+    pPlayerName = (char *)(pParty->vPosition.z - v9->vPosition.z);
     v52 = abs((int)pPlayerName);
     v61 = v55;
     v10 = v55;
@@ -9013,9 +9010,9 @@
   unsigned int v45; // [sp+18h] [bp-Ch]@44
 
   v6 = uBaseLightLevel;
-  for (uint i = 0; i < uNumMobileLightsApplied; ++i)
-  {
-    auto p = pMobileLights + i;
+  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
+  {
+    auto p = pMobileLightsStack->pLights + i;
 
       auto distX = abs(p->vPosition.x - x);
       if ( distX <= p->uRadius)
@@ -9061,8 +9058,8 @@
 
     for (uint i = 0; i < pSector->uNumLights; ++i)
     {
-        v16 = pIndoor->pLights + *(&pSector->pLights->vPosition.x + i);
-        if ( !(v16->uAtributes & 8) )
+        v16 = pIndoor->pLights + pSector->pLights[i];
+        if (~v16->uAtributes & 8)
         {
           v17 = abs(v16->vPosition.x - x);
           if ( v17 <= v16->uRadius )
@@ -9105,9 +9102,9 @@
     }
   }
 
-  for (uint i = 0; i < uNumStationaryLightsApplied; ++i)
-  {
-    auto p = pStationaryLights + i;
+  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
+  {
+    auto p = pStationaryLightsStack->pLights + i;
       v26 = abs(p->vPosition.x - x);
       if ( v26 <= p->uRadius)
       {
@@ -10541,10 +10538,10 @@
       else
       {
         v18 = pParty->vPosition.x;
-        v17 = pParty->sEyelevel + pParty->vPosition.y;
-        v60 = pParty->vPosition.z;
-        v44 = pParty->sEyelevel + pParty->vPosition.y;
-        v43 = pParty->vPosition.z;
+        v17 = pParty->sEyelevel + pParty->vPosition.z;
+        v60 = pParty->vPosition.y;
+        v44 = pParty->sEyelevel + pParty->vPosition.z;
+        v43 = pParty->vPosition.y;
       }
       v19 = pIndoor->GetSector(v18, v43, v44);
     }
@@ -10862,7 +10859,7 @@
   signed int a5a; // [sp+2Ch] [bp+10h]@14
 
   v5 = a4;
-  v6 = a4->uFaceAttributes;
+  v6 = a4->uAttributes;
   v7 = 0;
   if ( v6 & 0x100 )
   {
@@ -11231,7 +11228,7 @@
       sDepthb = 0;
       for ( i = 116 * v59;
             sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->field_C + v61)
-                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v61);
+                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
             ++sDepthb )
       {
         v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
@@ -11385,7 +11382,7 @@
       v162 = 0;
       v112 = v89;
       if ( *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
-         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v89) > 0 )
+         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
         break;
 LABEL_148:
       ++a5c;
@@ -11465,7 +11462,7 @@
       v88 = pIndoor->pSectors;
       ++v162;
       if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
-                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v89) )
+                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
         goto LABEL_148;
     }
   }
@@ -13915,7 +13912,7 @@
   if ( v7 )
     v22.DrawText2(pBook2Font, 0xFFFFFFF2u, 0xCu, 0, pMapStats->pInfos[v7].pName, 3u);
   v22.uFrameX = 0;
-  sprintfex(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.z);
+  sprintfex(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y);
   return v22.DrawText2(pFontComic, 0, 0x140u, 0, Str, 0);
 }
 
@@ -15571,7 +15568,7 @@
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
-      v39.z = pParty->vPosition.y + pParty->sEyelevel;
+      v39.z = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -15645,7 +15642,7 @@
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
-      v39.z = pParty->vPosition.y + pParty->sEyelevel;
+      v39.z = pParty->vPosition.z + pParty->sEyelevel;
     }
     *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x;
     Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42);
@@ -15774,7 +15771,7 @@
         {
           lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
           if ( !lpsz )
-            lpsz = nullstring;
+            lpsz = "";
         }
         a1.Hint = 0;
         a1.uFrameX = 38;
@@ -17498,7 +17495,7 @@
                    0xA9u,
                    0,
                    0,
-                   nullstring,
+                   "",
                    (Texture *)(uTextureID_ar_up_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_up] : 0),
                    uTextureID_ar_up_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_dn] : 0,
                    0);
@@ -17512,7 +17509,7 @@
                    0xAAu,
                    0,
                    0,
-                   nullstring,
+                   "",
                    (Texture *)(uTextureID_ar_dn_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_up] : 0),
                    uTextureID_ar_dn_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_dn] : 0,
                    0);
@@ -17526,7 +17523,7 @@
                    0xC0u,
                    0,
                    0,
-                   nullstring,
+                   "",
                    0);
   }
 }
@@ -17629,7 +17626,7 @@
         0x79u,
         *v14,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17657,7 +17654,7 @@
         0x79u,
         *v15,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17685,7 +17682,7 @@
         0x79u,
         *v16,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17713,7 +17710,7 @@
         0x79u,
         *v17,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
--- a/mm7_6.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_6.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -2343,10 +2343,10 @@
         if ( ptr_507BD4 )
           return result;
         ptr_507BD4 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
-        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 0, 0x31u, nullstring, 0);
-        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 1u, 0x32u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 2u, 0x33u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 3u, 0x34u, nullstring, 0);
+        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 0, 0x31u, "", 0);
+        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 1u, 0x32u, "", 0);
+        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 2u, 0x33u, "", 0);
+        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 3u, 0x34u, "", 0);
         return sub_421B2C_PlaceInInventory_or_DropPickedItem();
       }
       if ( v6 & 8 )
@@ -2355,7 +2355,7 @@
           return result;
         v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
         v29 = 0;
-        v28 = nullstring;
+        v28 = "";
         v27 = 0;
         v26 = 0;
         v25 = 70;
@@ -2378,7 +2378,7 @@
           return result;
         v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
         v29 = 0;
-        v28 = nullstring;
+        v28 = "";
         v27 = 0;
         v26 = 0;
         v25 = 190;
@@ -2401,12 +2401,12 @@
         if ( ptr_507BD4 )
           return result;
         ptr_507BD4 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), 20 * result + 5292232, 0);
-        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 0, 0x31u, nullstring, 0);
-        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, nullstring, 0);
+        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 0, 0x31u, "", 0);
+        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, "", 0);
+        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, "", 0);
+        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, "", 0);
         v29 = 0;
-        v28 = nullstring;
+        v28 = "";
         v27 = 0;
         v26 = 0;
         v25 = 140;
@@ -2432,7 +2432,7 @@
                        0xBCu,
                        0,
                        0,
-                       nullstring,
+                       "",
                        (Texture *)(uTextureID_507990 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507990] : 0),
                        0);
         ptr_5079E8 = ptr_507BD4->CreateButton(
@@ -2445,10 +2445,10 @@
                        0xBCu,
                        1u,
                        0,
-                       nullstring,
+                       "",
                        (Texture *)(uTextureID_50798C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50798C] : 0),
                        0);
-        ptr_507BD4->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 4u, 0x35u, nullstring, 0);
+        ptr_507BD4->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 4u, 0x35u, "", 0);
         result = (bool)ptr_507BD4->CreateButton(
                          0x231u,
                          0x95u,
@@ -2459,7 +2459,7 @@
                          0x8Fu,
                          5u,
                          0x36u,
-                         nullstring,
+                         "",
                          0);
       }
     }
@@ -3490,10 +3490,10 @@
         if ( v17->WearsItem(510, 2) )
           a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = 0;
         a1.uSpriteFrameID = 0;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v19 = 8 * v3->uPlayerID;
         LOBYTE(v19) = v19 | 4;
         a1.field_58 = v19;
@@ -3528,10 +3528,10 @@
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = 0;
         a1.uSpriteFrameID = 0;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
         v22 = 8 * v3->uPlayerID;
         LOBYTE(v22) = v22 | 4;
         a1.field_58 = v22;
@@ -3545,7 +3545,7 @@
                                                                          * pParty->pPlayers[v3->uPlayerID].pEquipment.uMainHand
                                                                          + 5],
           sizeof(a1.stru_24));
-        v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, a1.vPosition.z);
+        v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, a1.vPosition.z);
         HIBYTE(a1.uAttributes) |= 1u;
         a1.uSectorID = v23;
         if ( pParty->bTurnBasedModeOn == 1 )
@@ -3629,14 +3629,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v34 = 8 * v3->uPlayerID;
         LOBYTE(v34) = v34 | 4;
@@ -3791,14 +3791,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v50 = 8 * v3->uPlayerID;
         LOBYTE(v50) = v50 | 4;
@@ -3823,10 +3823,10 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        v51 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
-        a1.vPosition.y = pParty->vPosition.z;
-        v671 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
-        v660 = pParty->vPosition.z;
+        v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
+        a1.vPosition.y = pParty->vPosition.y;
+        v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
+        v660 = pParty->vPosition.y;
         goto LABEL_153;
       case 87:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
@@ -3937,13 +3937,13 @@
         a1.stru_24.Reset();
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v62 = 8 * v3->uPlayerID;
         LOBYTE(v62) = v62 | 4;
@@ -4308,8 +4308,8 @@
         {
           v730 = a2 >> 3;
           v112 = &pActors[a2 >> 3];
-          v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.y);
-          v721 = abs(v112->vPosition.y - pParty->vPosition.z);
+          v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z);
+          v721 = abs(v112->vPosition.y - pParty->vPosition.y);
           v113 = abs(v112->vPosition.x - pParty->vPosition.x);
           _this = (ItemGen *)v113;
           v114 = v721;
@@ -4504,8 +4504,8 @@
           v155 = stru_5C6E00->SinCos(pParty->sRotationY);
           uRequiredMana = pParty->vPosition.x + sub_42EBBE(2048, v155);
           v156 = stru_5C6E00->_42EBDB(pParty->sRotationY);
-          LODWORD(v727) = pParty->vPosition.z + sub_42EBBE(2048, v156);
-          v154 = pParty->vPosition.y;
+          LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156);
+          v154 = pParty->vPosition.z;
         }
         HIDWORD(v733) = v154;
         v713 = v154 + 2500;
@@ -4728,14 +4728,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v187 = 8 * v3->uPlayerID;
         LOBYTE(v187) = v187 | 4;
@@ -4909,8 +4909,8 @@
           LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212);
           v213 = stru_5C6E00->_42EBDB(pParty->sRotationY);
           v214 = sub_42EBBE(2048, v213);
-          v211 = pParty->vPosition.y;
-          v713 = pParty->vPosition.z + v214;
+          v211 = pParty->vPosition.z;
+          v713 = pParty->vPosition.y + v214;
           v208 = LODWORD(v725);
         }
         v726 = (Player *)v211;
@@ -5038,10 +5038,10 @@
           a1.field_50 = v731;
           a1.field_4C = v2;
           a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-          a1.vPosition.y = pParty->vPosition.z;
-          v51 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
-          v671 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
-          v660 = pParty->vPosition.z;
+          a1.vPosition.y = pParty->vPosition.y;
+          v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+          v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+          v660 = pParty->vPosition.y;
 LABEL_153:
           a1.uAttributes = v1;
           a1.vPosition.x = pParty->vPosition.x;
@@ -5076,14 +5076,14 @@
           a1.field_4C = v2;
           a1.field_50 = v731;
           a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-          a1.vPosition.y = pParty->vPosition.z;
+          a1.vPosition.y = pParty->vPosition.y;
           a1.vPosition.x = pParty->vPosition.x;
           a1.uAttributes = v1;
-          a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+          a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
           a1.uSectorID = pIndoor->GetSector(
                            pParty->vPosition.x,
-                           pParty->vPosition.z,
-                           pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                           pParty->vPosition.y,
+                           pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
           a1.uSpriteFrameID = v1;
           v226 = 8 * v3->uPlayerID;
           LOBYTE(v226) = v226 | 4;
@@ -5661,14 +5661,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v326 = 8 * v3->uPlayerID;
         LOBYTE(v326) = v326 | 4;
@@ -5695,11 +5695,11 @@
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = v1;
         a1.uSectorID = v1;
         a1.uSpriteFrameID = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v327 = 8 * v3->uPlayerID;
         LOBYTE(v327) = v327 | 4;
         a1.field_60_distance_related_prolly_lod = 0;
@@ -7360,13 +7360,13 @@
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
         a1.uSpriteFrameID = v1;
         v595 = 8 * v3->uPlayerID;
         LOBYTE(v595) = v595 | 4;
@@ -7694,7 +7694,7 @@
           v642 = rand() % 4096 - 2048;
           v643 = rand();
           v721 = v642 + pParty->vPosition.x;
-          y = (char *)(pParty->vPosition.z + v643 % 4096 - 2048);
+          y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048);
           v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, v1);
           v644 = rand();
           sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, v1, v1, (ItemGen *)v1);
@@ -7909,7 +7909,7 @@
     {
       a2 = v34 >> 3;
       v8 = &pActors[v34 >> 3];
-      v34 = sub_452A9E((v8->vPosition.x - pParty->vPosition.x) * (v8->vPosition.x - pParty->vPosition.x) + (v8->vPosition.y - pParty->vPosition.z) * (v8->vPosition.y - pParty->vPosition.z) + (v8->vPosition.z - pParty->vPosition.y) * (v8->vPosition.z - pParty->vPosition.y))
+      v34 = sub_452A9E((v8->vPosition.x - pParty->vPosition.x) * (v8->vPosition.x - pParty->vPosition.x) + (v8->vPosition.y - pParty->vPosition.y) * (v8->vPosition.y - pParty->vPosition.y) + (v8->vPosition.z - pParty->vPosition.z) * (v8->vPosition.z - pParty->vPosition.z))
           - v8->uActorRadius;
       if ( v34 >= 0 )
       {
@@ -7956,8 +7956,8 @@
       if ( (double)v34 <= 407.2 )
       {
         a3.x = v8->vPosition.x - pParty->vPosition.x;
-        a3.y = v8->vPosition.y - pParty->vPosition.z;
-        a3.z = v8->vPosition.z - pParty->vPosition.y;
+        a3.y = v8->vPosition.y - pParty->vPosition.y;
+        a3.z = v8->vPosition.z - pParty->vPosition.z;
         Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
         DamageMonsterFromParty((8 * v0 - 8) | 4, a2, &a3);
         if ( v1->WearsItem(506, 1) || v1->WearsItem(506, 0) )
@@ -8321,8 +8321,8 @@
     while ( 1 )
     {
       v2 = abs(*((short *)v1 - 17) - pParty->vPosition.x);
-      v11 = abs(*((short *)v1 - 16) - pParty->vPosition.z);
-      v12 = abs(*((short *)v1 - 15) - pParty->vPosition.y);
+      v11 = abs(*((short *)v1 - 16) - pParty->vPosition.y);
+      v12 = abs(*((short *)v1 - 15) - pParty->vPosition.z);
       v3 = v2;
       v4 = v11;
       v5 = v12;
@@ -9277,7 +9277,7 @@
   }
   while ( v12 < 30 );
 LABEL_176:
-  if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) )
+  if (pGame->pKeyboardInstance->bUsingAsynKeyboard)
   {
     AsyncKeyboard::LeaveCriticalSection();
     v16 = pAsyncKeyboard;
--- a/mm7_data.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_data.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -316,10 +316,11 @@
 
 
 
+#include "stru314.h"
 
 
 
-char nullstring[1] = {0};
+
 //-------------------------------------------------------------------------
 // Data declarations
 
@@ -330,7 +331,7 @@
 int dword_4C9920[16]; // weak
 _UNKNOWN unk_4D8548; // weak
 char byte_4D864C; // weak
-int dword_4D86CC; // weak
+float flt_4D86CC = 1.0f; // weak
 int dword_4D86D8; // weak
 int dword_4DAFCC; // weak
 int (__stdcall *off_4DAFDC)(char); // weak
@@ -1138,9 +1139,10 @@
 char aInvalidLight_0[777]; // idb
 char aUknownStripTyp[777]; // idb
 char aInvalidLightma[777]; // idb
-char byte_4E94D0; // weak
-char byte_4E94D2; // weak
-char byte_4E94D3; // weak
+char byte_4E94D0 = 5; // weak
+char byte_4E94D1 = 9; // weak
+char _4E94D2_light_type = 6; // weak
+char byte_4E94D3 = 10; // weak
 unsigned int saveload_dlg_xs[2] = {82, 0};
 unsigned int saveload_dlg_ys[2] = {60, 0};
 unsigned int saveload_dlg_zs[2] = {460, 640};
@@ -1698,8 +1700,7 @@
 int dword_4EDEA0[777]; // weak
 int dword_4EDEB4[777]; // weak
 int dword_4EDEC4[777]; // weak
-__int16 word_4EDED8[777]; // weak
-__int16 word_4EDEDC; // weak
+__int16 word_4EDED8[16] = {100, 90, 60, 100, 80, 100, 80, 30, 10, 10, 20, 30, 100, 0, 0, 0};
 _UNKNOWN unk_4EDF40; // weak
 unsigned int pHiredNPCsIconsOffsetsX[2] = {489, 559};
 unsigned int pHiredNPCsIconsOffsetsY[2] = {152, 152};
@@ -2274,7 +2275,7 @@
 int _6807E8_level_decorations_ids[777]; // idb
 int _6836C8_num_decorations_6807E8; // weak
 int dword_69B010[64];
-int dword_69B138; // weak
+float flt_69B138_dist; // weak
 char byte_69BD41_unused; // weak
 unsigned int uTextureID_x_u;
 unsigned int uTextureID_LS_saveU;
@@ -2508,10 +2509,6 @@
 char byte_AE336B; // weak
 int dword_AE336C; // weak
 int dword_AE3370; // weak
-Vec3_float_ stru_AE4F64; // idb
-Vec3_float_ stru_AE4F70; // idb
-Vec3_float_ stru_AE4F7C; // idb
-int dword_AE4F88; // weak
 char byte_AE5B91; // weak
 int dword_F1B430[32]; // weak
 int dword_F8B144; // idb
--- a/mm7_data.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/mm7_data.h	Fri Oct 26 23:22:41 2012 +0600
@@ -317,7 +317,7 @@
 extern int dword_4C9920[16]; // weak
 extern _UNKNOWN unk_4D8548; // weak
 extern char byte_4D864C; // weak
-extern int dword_4D86CC; // weak
+extern float flt_4D86CC; // weak
 extern int dword_4D86D8; // weak
 extern int dword_4DAFCC; // weak
 extern int (__stdcall *off_4DAFDC)(char); // weak
@@ -1116,7 +1116,7 @@
 extern char aUknownStripTyp[]; // idb
 extern char aInvalidLightma[]; // idb
 extern char byte_4E94D0; // weak
-extern char byte_4E94D2; // weak
+extern char _4E94D2_light_type; // weak
 extern char byte_4E94D3; // weak
 extern unsigned int saveload_dlg_xs[2];
 extern unsigned int saveload_dlg_ys[2];
@@ -1668,7 +1668,6 @@
 extern int dword_4EDEB4[]; // weak
 extern int dword_4EDEC4[]; // weak
 extern __int16 word_4EDED8[]; // weak
-extern __int16 word_4EDEDC; // weak
 extern _UNKNOWN unk_4EDF40; // weak
 extern unsigned int pHiredNPCsIconsOffsetsX[2];
 extern unsigned int pHiredNPCsIconsOffsetsY[2];
@@ -1968,7 +1967,6 @@
 extern char *aMoonPhaseNames[5];
 extern int dword_506568; // weak
 extern char bRecallingBeacon; // weak
-extern char nullstring[];
 extern int uLastPointedObjectID; // weak
 //extern unsigned __int8 bMonsterInfoUI_bDollInitialized;
 extern char *aSpellNames[44];
@@ -2227,7 +2225,7 @@
 extern int _6807E8_level_decorations_ids[]; // idb
 extern int _6836C8_num_decorations_6807E8; // weak
 extern int dword_69B010[64];
-extern int dword_69B138; // weak
+extern float flt_69B138_dist; // weak
 extern char byte_69BD41_unused; // weak
 extern struct SavegameHeader *pSavegameHeader;
 extern unsigned int uTextureID_x_u;
@@ -2464,10 +2462,6 @@
 extern char byte_AE336B; // weak
 extern int dword_AE336C; // weak
 extern int dword_AE3370; // weak
-extern Vec3_float_ stru_AE4F64; // idb
-extern Vec3_float_ stru_AE4F70; // idb
-extern Vec3_float_ stru_AE4F7C; // idb
-extern int dword_AE4F88; // weak
 extern char byte_AE5B91; // weak
 extern int dword_F1B430[32]; // weak
 extern int dword_F8B144; // idb
@@ -2740,7 +2734,7 @@
 void __cdecl GUI_MainMenuMessageProc();
 double __cdecl get_shading_dist_mist();
 double __cdecl GetPickDepth();
-void __thiscall Vec3_short__to_RenderVertexSoft(struct RenderVertexSoft *_this, struct Vec3_short_ *a2);
+void Vec3_short__to_RenderVertexSoft(struct RenderVertexSoft *_this, struct Vec3_short_ *a2);
 void __cdecl nullsub_4(); // idb
 void __cdecl nullsub_5(); // idb
 void __cdecl nullsub_6(); // idb
--- a/stru10.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/stru10.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -711,8 +711,8 @@
       if ( !LOBYTE(field_4) )
       {
         v26.vWorldPosition.x = pParty->vPosition.x;
-        v26.vWorldPosition.y = pParty->vPosition.z;
-        v26.vWorldPosition.z = pParty->vPosition.y + pParty->sEyelevel;
+        v26.vWorldPosition.y = pParty->vPosition.y;
+        v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel;
 
         pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, arg0, 0xFF0000u, 0, 0);
         pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, arg0 + 1, 0xFF00u, 0, 0);
--- a/stru314.h	Fri Oct 26 23:20:39 2012 +0600
+++ b/stru314.h	Fri Oct 26 23:22:41 2012 +0600
@@ -29,6 +29,6 @@
   Vec3_float_ field_4;
   Vec3_float_ field_10;
   Vec3_float_ field_1C;
-  int field_28;
+  float dist;
 };
 #pragma pack(pop)
--- a/stru6.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/stru6.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -123,15 +123,15 @@
 
     sr_42620A(v);
 
-    pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v, 2, 0);
+    pGame->pIndoorCameraD3D->Project(v, 2, 0);
 
     if (p->uTextureID != -1)
       v12 = pBitmaps_LOD->pHardwareTextures[p->uTextureID];
     else
       v12 = 0;
 
-    v10 = pGame->pIndoorCameraD3D->flt_D0 / v[1].vWorldViewPosition.x * 20.0;
-    v11 = pGame->pIndoorCameraD3D->flt_D0 / v[0].vWorldViewPosition.x * 20.0;
+    v10 = pGame->pIndoorCameraD3D->fov_x / v[1].vWorldViewPosition.x * 20.0;
+    v11 = pGame->pIndoorCameraD3D->fov_x / v[0].vWorldViewPosition.x * 20.0;
     pRenderer->DrawProjectile(
         v[0].vWorldViewProjX,
         v[0].vWorldViewProjY,
@@ -412,10 +412,10 @@
            a1->vPosition.z,
            a1->uSectorID,
            uRadius,
-           uDiffuse >> 16,
-           BYTE1(uDiffuse),
-           uDiffuse != 0,
-           (int *)byte_4E94D3);
+           (uDiffuse & 0x00FF0000) >> 16,
+           (uDiffuse & 0x0000FF00) >> 8,
+           uDiffuse & 0x000000FF,
+           byte_4E94D3);
 }
 // 4E94D3: using guessed type char byte_4E94D3;
 
--- a/stru9.cpp	Fri Oct 26 23:20:39 2012 +0600
+++ b/stru9.cpp	Fri Oct 26 23:22:41 2012 +0600
@@ -408,6 +408,7 @@
   int v27; // [sp+1Ch] [bp-8h]@25
   stru9 *thisa; // [sp+20h] [bp-4h]@1
 
+  __debugbreak();
   thisa = this;
 
   static RenderVertexSoft stru_AE4BFC;