changeset 59:5159d2e6f559

BLV render
author Nomad
date Fri, 26 Oct 2012 02:38:26 +0200
parents 41cbaabde2cb
children 30ec77bbd018
files Actor.cpp DecalBuilder.cpp DecalBuilder.h GUIWindow.cpp Game.cpp GameUIs.cpp Indoor.cpp Indoor.h IndoorCamera.cpp IndoorCameraD3D.cpp IndoorCameraD3D.h Indoor_stuff.h LightmapBuilder.cpp LightmapBuilder.h Lights.h LightsStack.cpp Outdoor.cpp Outdoor.h ParticleEngine.cpp Player.cpp Render.cpp Render.h TurnEngine.h VideoPlayer.cpp Vis.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h stru314.h stru6.cpp stru9.cpp
diffstat 36 files changed, 1302 insertions(+), 1498 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/Actor.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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 )
--- a/DecalBuilder.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/DecalBuilder.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/DecalBuilder.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/GUIWindow.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Game.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/GameUIs.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Indoor.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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,7 +97,7 @@
       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(
@@ -108,7 +109,7 @@
       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
@@ -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;
@@ -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
@@ -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;
@@ -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;
   }
 
@@ -4489,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,
--- a/Indoor.h	Thu Oct 25 02:05:16 2012 +0200
+++ b/Indoor.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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;
@@ -360,7 +373,7 @@
   unsigned __int16 *pMarkers;
   __int16 uNumLights;
   __int16 field_56;
-  BLVLightMM7 *pLights;
+  unsigned __int16 *pLights;
   __int16 uWaterLevel;
   __int16 uMistLevel;
   __int16 uLightDistanceMultiplier;
@@ -510,7 +523,7 @@
 #pragma pack(push, 1)
 struct BLVRenderParams
 {
-  int Set(struct IndoorLocation_drawstru *a2);
+  int Reset(struct IndoorLocation_drawstru *a2);
 
   int field_0_timer_;
   int uFlags;
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/IndoorCamera.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/IndoorCameraD3D.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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,16 +95,12 @@
 
 
 //----- (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) --------------------------------------------------------
@@ -348,64 +331,81 @@
 
 
 //----- (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) --------------------------------------------------------
@@ -606,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;
@@ -859,7 +859,7 @@
       || (signed int)uOutNumVertices >= 2 )
     {
       ViewTransform(pVertices, 2u);
-      _436BB7_project_and_stuff(pVertices, 2u, 0);
+      Project(pVertices, 2u, 0);
       goto LABEL_11;
     }
   }
@@ -974,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
@@ -985,7 +985,7 @@
   double v10; // st7@3
   double v11; // st6@3
 
-  v4 = (float *)a3;
+  v4 = (float *)out;
   v5 = &a1->_12;
   v6 = 3;
   do
@@ -1014,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);
 }
 
@@ -1199,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])),
@@ -1293,7 +1256,7 @@
   v11 = 2 * (a6 == 0) + 1;
   //a6a = 0;
   v18 = v11;
-  if ( uNumVertices <= 0 )
+  if (uNumVertices <= 0)
     return false;
 
     //v12 = *pOutNumVertices;
@@ -1301,7 +1264,7 @@
   uint i = 0;
     while ( 1 )
     {
-      if (i % 2 )
+      if (i % 2)
       {
         v14 = a1;
         v15 = sr_vertices_50D9D8;
@@ -1311,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;
@@ -1429,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
@@ -1532,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
@@ -1628,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
@@ -1643,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 );
   }
 }
 
@@ -1720,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	Thu Oct 25 02:05:16 2012 +0200
+++ b/IndoorCameraD3D.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Indoor_stuff.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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/LightmapBuilder.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/LightmapBuilder.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/LightmapBuilder.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Lights.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/LightsStack.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Outdoor.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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();
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Outdoor.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/ParticleEngine.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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/Player.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/Player.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Render.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Render.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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/TurnEngine.h	Thu Oct 25 02:05:16 2012 +0200
+++ b/TurnEngine.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/VideoPlayer.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/Vis.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_1.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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 )
     {
@@ -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);
 }
@@ -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;
 }
 
@@ -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;
       }
--- a/mm7_2.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_2.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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);
@@ -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);
   }
 }
@@ -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;
@@ -13164,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) )
           {
@@ -13206,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);
@@ -13248,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) )
   {
@@ -13299,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);
@@ -15640,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;
@@ -15661,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;
@@ -15945,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:
--- a/mm7_3.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_3.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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;
@@ -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;
         }
@@ -2679,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;
@@ -2689,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:
@@ -3857,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;
@@ -3902,7 +3903,7 @@
     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;
@@ -3931,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;
@@ -6798,7 +6799,7 @@
     }
     while ( 1 )
     {
-      if ( pFace->uFaceAttributes & 0x2000 )
+      if (pFace->Invisible())
         goto LABEL_85;
       v5 = (int)*(v2 - 1);
       v6 = pFace->pVertexIDs[0];
@@ -6808,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 )
       {
@@ -6820,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;
@@ -6837,7 +6838,7 @@
         if ( v13 & 0x20 )
           HIBYTE(v7->flags) |= 8u;
       }
-      v14 = pFace->uFaceAttributes;
+      v14 = pFace->uAttributes;
       if ( BYTE1(v14) & 8 )
       {
         *(int *)&v7->flags |= 0x2000u;
@@ -6927,7 +6928,7 @@
           }
           else
           {
-            v47->_436BB7_project_and_stuff((RenderVertexSoft *)(v23 - 12), 1u, 0);
+            v47->Project((RenderVertexSoft *)(v23 - 12), 1u, 0);
           }
           v23 += 48;
           --v51;
@@ -7006,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);
@@ -7028,7 +7029,7 @@
               -1);
           }
         }
-        if ( stru_F8AD28.field_AC > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 )
           pLightmapBuilder->ApplyLights(
             &stru_F8AD28,
             &static_RenderBuildingsD3D_stru_73C834,
@@ -7242,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;
@@ -7374,7 +7375,7 @@
         }*/
 
         pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
-        if ( stru_F8AD28.field_AC <= 0 )
+        if ( stru_F8AD28.uNumLightsApplied <= 0 )
         {
           v12->field_108 = 0;
         }
@@ -7384,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 )
@@ -13064,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;
@@ -13076,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);
@@ -13218,7 +13219,7 @@
                 v1->uParticleTrailColorR,
                 v1->uParticleTrailColorG,
                 v1->uParticleTrailColorB,
-                v11);
+                byte_4E94D3);
             }
             if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
                    a1,
@@ -13248,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;
               }
@@ -13767,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
@@ -13914,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;
 
@@ -13959,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
@@ -14046,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 )
@@ -14207,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();
 }
 
@@ -15666,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;
                 }
               }
@@ -15767,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;
                 }
               }
@@ -15865,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;
@@ -16082,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);
   }
 }
 
@@ -16409,7 +16409,7 @@
         v24 = (&dword_721660)[8 * v23];
         if ( !v24 )
         {
-          v24 = nullstring;
+          v24 = "";
           v15->uControlParam = 0;
         }
         goto LABEL_79;
@@ -16453,7 +16453,7 @@
           goto LABEL_63;
         }
 LABEL_71:
-        v24 = nullstring;
+        v24 = "";
         goto LABEL_79;
       }
       if ( v0->uFlags & 0x80 )
@@ -17163,7 +17163,7 @@
   {
     //v5 = pSomeEVT;
     //v6 = v123;
-    //v7 = nullstring;
+    //v7 = "";
     //while ( 1 )
     //{
       if ( dword_5B65C4 )
@@ -17528,7 +17528,7 @@
             //v4 = v124;
             //v5 = pSomeEVT;
             //v6 = v123;
-            //v7 = nullstring;
+            //v7 = "";
             break;
           case EVENT_CharacterAnimation:
             v54 = _evt->v5;
@@ -18299,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);
@@ -18466,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;
@@ -21221,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	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_4.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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
@@ -5885,7 +5885,7 @@
   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;
   }
@@ -5900,7 +5900,7 @@
                                   0xABu,
                                   0,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5913,7 +5913,7 @@
                                   0xABu,
                                   1u,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5926,7 +5926,7 @@
                                   0xABu,
                                   2u,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5939,7 +5939,7 @@
                                   0xABu,
                                   3u,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5952,7 +5952,7 @@
                                    0xACu,
                                    0,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5965,7 +5965,7 @@
                                    0xACu,
                                    1u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5978,7 +5978,7 @@
                                    0xACu,
                                    2u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5991,7 +5991,7 @@
                                    0xACu,
                                    3u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6004,7 +6004,7 @@
                                    0x90u,
                                    0,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6017,7 +6017,7 @@
                                    0x90u,
                                    1u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6030,7 +6030,7 @@
                                    0x90u,
                                    2u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6043,7 +6043,7 @@
                                    0x90u,
                                    3u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6056,7 +6056,7 @@
                                     0x91u,
                                     0,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6069,7 +6069,7 @@
                                     0x91u,
                                     1u,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6082,7 +6082,7 @@
                                     0x91u,
                                     2u,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6095,14 +6095,14 @@
                                     0x91u,
                                     3u,
                                     0,
-                                    nullstring,
+                                    "",
                                     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, 308u, 150u, v0, 1, 0, 0x48u, uControlParamb, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXb,
       v0 + 308,
@@ -6113,7 +6113,7 @@
       0x49u,
       uControlParamb,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXb,
@@ -6125,7 +6125,7 @@
       0x4Au,
       uControlParamb,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXb,
@@ -6137,21 +6137,21 @@
       0x4Bu,
       uControlParamb,
       0,
-      nullstring,
+      "",
       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, 169u, 120u, 20u, 1, 0, 0, uControlParamc - 2, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
       v0 + 169,
@@ -6162,7 +6162,7 @@
       0,
       uControlParamc - 1,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6174,7 +6174,7 @@
       0,
       uControlParamc,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6186,7 +6186,7 @@
       0,
       uControlParamc + 1,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6198,7 +6198,7 @@
       0,
       uControlParamc + 2,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6210,7 +6210,7 @@
       0,
       uControlParamc + 3,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6222,22 +6222,22 @@
       0,
       uControlParamc + 4,
       0,
-      nullstring,
+      "",
       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
   {
@@ -6254,7 +6254,7 @@
       0x40u,
       uControlParamd,
       0,
-      nullstring,
+      "",
       0);
     ++uControlParamd;
   }
@@ -6269,7 +6269,7 @@
                               0x42u,
                               0,
                               0xDu,
-                              nullstring,
+                              "",
                               (Texture *)(uTextureID_BUTTMAKE != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE] : 0),
                               0);
   pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(
@@ -6282,7 +6282,7 @@
                                  0x43u,
                                  0,
                                  0x43u,
-                                 nullstring,
+                                 "",
                                  (Texture *)(uTextureID_BUTTMAKE2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0),
                                  0);
   pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(
@@ -6295,7 +6295,7 @@
                                  0x3Fu,
                                  0,
                                  0x2Du,
-                                 nullstring,
+                                 "",
                                  pTexture_buttminu,
                                  0);
   pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(
@@ -6308,7 +6308,7 @@
                                 0x3Eu,
                                 1u,
                                 0x2Bu,
-                                nullstring,
+                                "",
                                 pTexture_buttplus,
                                 0);
   pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0);
@@ -6714,7 +6714,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();
@@ -6855,16 +6855,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
@@ -6898,11 +6898,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;
 }
 
@@ -7979,7 +7979,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;
@@ -8478,7 +8478,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;
@@ -8744,11 +8744,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
     {
@@ -8781,7 +8781,7 @@
       ++v16;
       v2 = v15;
     }
-    while ( v16 < stru_F8AD28.field_AC );
+    while ( v16 < stru_F8AD28.uNumLightsApplied );
     v4 = 0;
   }
   if ( stru_F8AD28.field_3E4 != v4 )
@@ -8925,7 +8925,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;
@@ -9046,11 +9046,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 )
@@ -9099,7 +9099,7 @@
                     v28 = v74;
                     v29 = v18[9];
                     ++v74;
-                    stru_F8AD28._blv_lights_smthngs[v28] = v29;
+                    stru_F8AD28._blv_lights_types[v28] = v29;
                   }
                 }
               }
@@ -9167,7 +9167,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;
                       }
                     }
                   }
@@ -9184,9 +9184,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 )
@@ -9235,7 +9235,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;
                     }
                   }
                 }
@@ -9247,9 +9247,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 )
   {
@@ -9352,7 +9352,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)
@@ -9450,8 +9450,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;
 }
@@ -10812,7 +10812,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 )
@@ -10828,7 +10828,7 @@
           if ( !v15 )
           {
             v16->uControlParam = 0;
-            v15 = nullstring;
+            v15 = "";
           }
           goto LABEL_49;
         }
@@ -10848,7 +10848,7 @@
             if ( !v15 )
             {
               v16->uControlParam = 0;
-              v15 = nullstring;
+              v15 = "";
             }
             if ( uDialogueType != 84 )
               goto LABEL_49;
@@ -10875,7 +10875,7 @@
             goto LABEL_33;
           }
 LABEL_41:
-          v15 = nullstring;
+          v15 = "";
           goto LABEL_49;
         }
         v15 = pGlobalTXT_LocalizationStrings[122];
@@ -10981,7 +10981,7 @@
            0x195u,
            a2,
            0,
-           nullstring,
+           "",
            0);
 }
 
@@ -11701,7 +11701,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,
@@ -11731,7 +11731,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,
@@ -11745,7 +11745,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);
@@ -11778,7 +11778,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(
@@ -11907,7 +11907,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);
@@ -11917,7 +11917,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 )
@@ -11936,7 +11936,7 @@
               0xAFu,
               0x13u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11957,7 +11957,7 @@
               0xAFu,
               0x14u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11978,7 +11978,7 @@
               0xAFu,
               0x15u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -11999,7 +11999,7 @@
               0xAFu,
               0x16u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12020,7 +12020,7 @@
               0xAFu,
               0x17u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12041,7 +12041,7 @@
               0xAFu,
               0x18u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -13560,11 +13560,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 )
@@ -14151,7 +14151,7 @@
   }
   v63 = 1;
   v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem);
-  strcpy(a1, nullstring);
+  strcpy(a1, "");
   v41->uHeight = 0;
   v41->uY = 0;
   if ( v1->_4B6FF9() )
@@ -14612,7 +14612,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;
@@ -14708,7 +14708,7 @@
           ++v62;
           ++s1;
           a1 += 100;
-          strcpy(v31, nullstring);
+          strcpy(v31, "");
           if ( v24 )
           {
             v24->uW = 0;
@@ -15113,7 +15113,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
@@ -15193,19 +15193,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,
@@ -15215,7 +15215,7 @@
         0xFFu,
         0xFFu,
         0xFFu,
-        v11);
+        byte_4E94D3);
     }
     v12 = 0;
     if ( pStru170->uNumVisibleNotEmptySectors <= 0 )
@@ -15252,10 +15252,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);
@@ -15631,7 +15631,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	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_5.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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);
@@ -1687,8 +1690,6 @@
           }
           sub_41426F();
 _continue:
-          if ( !pMessageQueue_50CBD0->uNumMessages )
-            break;
           continue;
         case UIMSG_BC:
           if ( uMessageParam )
@@ -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;
@@ -2351,7 +2352,7 @@
             if ( v70 <= 0 || v70 >= 77 )
             {
 LABEL_90:
-              v1 = nullstring;
+              v1 = "";
 LABEL_91:
               v0 = 1;
               goto _continue;
@@ -2673,7 +2674,7 @@
             v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->field_1A4E].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 )
@@ -3947,17 +3948,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) --------------------------------------------------------
@@ -9057,9 +9054,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)
@@ -9105,8 +9102,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 )
@@ -9149,9 +9146,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)
       {
@@ -10906,7 +10903,7 @@
   signed int a5a; // [sp+2Ch] [bp+10h]@14
 
   v5 = a4;
-  v6 = a4->uFaceAttributes;
+  v6 = a4->uAttributes;
   v7 = 0;
   if ( v6 & 0x100 )
   {
@@ -15818,7 +15815,7 @@
         {
           lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
           if ( !lpsz )
-            lpsz = nullstring;
+            lpsz = "";
         }
         a1.Hint = 0;
         a1.uFrameX = 38;
@@ -17542,7 +17539,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);
@@ -17556,7 +17553,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);
@@ -17570,7 +17567,7 @@
                    0xC0u,
                    0,
                    0,
-                   nullstring,
+                   "",
                    0);
   }
 }
@@ -17673,7 +17670,7 @@
         0x79u,
         *v14,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17701,7 +17698,7 @@
         0x79u,
         *v15,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17729,7 +17726,7 @@
         0x79u,
         *v16,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17757,7 +17754,7 @@
         0x79u,
         *v17,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
--- a/mm7_6.cpp	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_6.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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);
       }
     }
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_data.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/mm7_data.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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/stru314.h	Thu Oct 25 02:05:16 2012 +0200
+++ b/stru314.h	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/stru6.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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	Thu Oct 25 02:05:16 2012 +0200
+++ b/stru9.cpp	Fri Oct 26 02:38:26 2012 +0200
@@ -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;