changeset 65:65c940aa7bf9

Слияние
author Ritor1
date Thu, 25 Oct 2012 18:02:42 +0600
parents 38025d9ab757 (current diff) 6b3a5283b107 (diff)
children 5ec98919c8fd
files mm7_5.cpp
diffstat 30 files changed, 1445 insertions(+), 2009 deletions(-) [+]
line wrap: on
line diff
--- a/DecalBuilder.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/DecalBuilder.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -107,7 +107,7 @@
 }
 
 //----- (0049B540) --------------------------------------------------------
-char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, int a7, char a8, int a9)
+char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID)
 {
   char *v9; // eax@3
   signed int v10; // ecx@3
@@ -146,6 +146,8 @@
   DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
   RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
 
+  auto a9 = uSectorID;
+
   thisa = this;
   if ( !a5 )
     return 0;
@@ -217,7 +219,7 @@
   {
       MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
   }
-  a7 = 0;
+  int _a7 = 0;
   if ( thisa->uNumDecals > 0 )
   {
     a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
@@ -266,10 +268,10 @@
       {
       MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
       }
-      ++a7;
+      ++_a7;
       a6 = (RenderVertexSoft *)((char *)a6 + 4);
     }
-    while ( a7 < v31->uNumDecals );
+    while ( _a7 < v31->uNumDecals );
   }
   return 1;
 }
--- a/DecalBuilder.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/DecalBuilder.h	Thu Oct 25 18:02:42 2012 +0600
@@ -91,7 +91,7 @@
 
   bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
   void Reset(unsigned int bPreserveBloodsplats);
-  char ApplyDecals(int a2, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, int a7, char a8, int a9);
+  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);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
--- a/GUIProgressBar.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/GUIProgressBar.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -179,13 +179,12 @@
       v3 = pIconsFrameTable->GetFrame(uIconID_TurnHour, 0);
       pRenderer->DrawTextureTransparent(0x64u, 0x92u, &pIcons_LOD->pTextures[v3->uTextureID]);
       v4 = (double)(113 * uProgressCurrent) / (double)uProgressMax;
-      pRenderer->FillRect2(
-        0,
+      pRenderer->FillRectFast(
         174,
         164,
-        COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
+        floorf(v4 + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
         16,
-        LOWORD(pRenderer->uTargetRMask));
+        pRenderer->uTargetRMask);
       goto LABEL_11;
     }
 LABEL_6:
--- a/GUIWindow.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/GUIWindow.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -1238,15 +1238,15 @@
 
   v1 = pPlayers[uActiveCharacter];
   v2 = this;
-  LoadSpellbook(v1->field_1A4E);
+  LoadSpellbook(v1->pNumSpellBookPage);
   v3 = 0;
   a2 = 0;
-  v7 = (int)(&v1->spellbook.pFireSpellbook + v1->field_1A4E);
+  v7 = (int)(&v1->spellbook.pFireSpellbook + v1->pNumSpellBookPage);
   do
   {
     if ( *(char *)(v7 + v3) )
     {
-      v4 = 2 * (12 * v1->field_1A4E + (unsigned __int8)*(&byte_4E2431[12 * v1->field_1A4E] + v3));
+      v4 = 2 * (12 * v1->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2431[12 * v1->pNumSpellBookPage] + v3));
       v2->CreateButton(
         pViewport->uViewportX + dword_4E20D0[v4],
         pViewport->uViewportY + dword_4E20D0[v4 + 1],
--- a/GUIWindow.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/GUIWindow.h	Thu Oct 25 18:02:42 2012 +0600
@@ -116,6 +116,16 @@
   UIMSG_MainMenu_ShowLoadWindow = 0x37,
   UIMSG_ShowCredits = 0x38,
   UIMSG_ExitToWindows = 0x39,
+  UIMSG_3C = 0x3C,
+  UIMSG_PlayerCreationClickPlus = 0x3E,
+  UIMSG_PlayerCreationClickMinus = 0x3F,
+  UIMSG_PlayerCreationSelectActiveSkill = 0x40,
+  UIMSG_41 = 0x41,
+  UIMSG_PlayerCreationClickOK = 0x42,
+  UIMSG_PlayerCreationClickReset = 0x43,
+  UIMSG_PlayerCreationRemoveUpSkill = 0x4A,
+  UIMSG_PlayerCreationRemoveDownSkill = 0x4B,
+  UIMSG_4B = 0x4B,
   UIMSG_LoadGame = 0x52,
   UIMSG_SaveGame = 0x53,
   UIMSG_ShowStatus_DateTime = 0x5C,
@@ -123,16 +133,20 @@
   UIMSG_ShowStatus_Player = 0x5E,
   UIMSG_ShowStatus_Food = 0x64,
   UIMSG_ShowStatus_Funds = 0x65,
+  UIMSG_6B = 0x6B,
   UIMSG_SelectCharacter = 0x6E,
   UIMSG_ChangeSoundVolume = 0x6F,
   UIMSG_ChangeMusicVolume = 0x70,
   UIMSG_CloseBook = 0x71,
+  UIMSG_PlayerCreationSelectQuality = 0x76,
   UIMSG_SkillUp = 0x79,
   UIMSG_StartNewGame = 0x7C,
   UIMSG_Game_OpenLoadGameDialog = 0x7D,
   UIMSG_Game_OpenOptionsDialog = 0x7F,
   UIMSG_SetGraphicsMode = 0x83,
   UIMSG_Quit = 0x84,
+  UIMSG_PlayerCreationVoiceBack = 0x90,
+  UIMSG_PlayerCreationVoiceForward = 0x91,
   UIMSG_StartNPCDialogue = 0xA1,
   UIMSG_A2 = 0xA2,
   UIMSG_A3 = 0xA3,
@@ -143,8 +157,8 @@
   UIMSG_A8 = 0xA8,
   UIMSG_A9 = 0xA9,
   UIMSG_AA = 0xAA,
-  UIMSG_AB = 0xAB,
-  UIMSG_AC = 0xAC,
+  UIMSG_SelectFacePlayerBack = 0xAB,
+  UIMSG_SelectFacePlayerForward = 0xAC,
   UIMSG_AD = 0xAD,
   UIMSG_AE = 0xAE,
   UIMSG_AF = 0xAF,
--- a/Game.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/Game.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -136,17 +136,16 @@
   }
   if (!pVideoPlayer->pSmackerMovie)
   {
-    GameUI_DrawMinimap(0x1E8u, 0x10u, 0x271u, 0x85u, viewparams->uMinimapZoom, pParty->uFlags & 2);
+    GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2);
     if (v4)
     {
       if ( !sub_4226C2() && pRenderer->pRenderD3D)
-        pRenderer->FillRect2(
-          0,
+        pRenderer->FillRectFast(
           pViewport->uViewportX,
           pViewport->uViewportY,
           pViewport->uViewportZ - pViewport->uViewportX,
           pViewport->uViewportW - pViewport->uViewportY + 1,
-          LOWORD(pRenderer->uTargetGMask) | LOWORD(pRenderer->uTargetBMask));
+          pRenderer->uTargetGMask | pRenderer->uTargetBMask);
       viewparams->field_48 = 0;
     }
   }
@@ -827,11 +826,11 @@
 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4)
 {
   double v4; // st7@3
-  double v5; // ST00_8@3
+  //double v5; // ST00_8@3
   signed int v6; // eax@4
   //double v7; // ST00_8@5
   signed int result; // eax@7
-  double v9; // ST00_8@8
+  //double v9; // ST00_8@8
   //double v10; // ST00_8@10
   float v11; // [sp+14h] [bp+8h]@3
   float v12; // [sp+18h] [bp+Ch]@3
@@ -845,8 +844,8 @@
     v11 = v4;
     *a3 |= 2u;
     v12 = (1.0 - this->_E28_timed_gamma_strength) * v4;
-    v5 = v12 + 6.7553994e15;
-    if ( SLODWORD(v5) >= 0 )
+    //v5 = v12 + 6.7553994e15;
+    if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 )
     {
       v13 = (1.0 - this->_E28_timed_gamma_strength) * v11;
       //v7 = v13 + 6.7553994e15;
@@ -860,8 +859,8 @@
     if ( a4 >= v6 )
     {
       v14 = (1.0 - _E28_timed_gamma_strength) * v11;
-      v9 = v14 + 6.7553994e15;
-      if ( SLODWORD(v9) >= 0 )
+      //v9 = v14 + 6.7553994e15;
+      if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 )
       {
         v15 = (1.0 - _E28_timed_gamma_strength) * v11;
         //v10 = v15 + 6.7553994e15;
--- a/Indoor.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/Indoor.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -114,11 +114,11 @@
   PrepareItemsRenderList_BLV();
   PrepareActorRenderList_BLV();
   v6 = 0;
-  for ( i = 0; i < pStru170->field_53730; ++i )
+  for ( i = 0; i < pStru170->uNumVisibleNotEmptySectors; ++i )
   {
-    v7 = pStru170->pSectorIDs_toDrawDecorationsFrom[v6];
+    v7 = pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6];
     v12 = 0;
-    v8 = &pIndoor->pSectors[pStru170->pSectorIDs_toDrawDecorationsFrom[v6]];
+    v8 = &pIndoor->pSectors[pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6]];
     v9 = v8->pDecorationIDs;
     if ( v8->uNumDecorations > 0 )
     {
@@ -261,19 +261,17 @@
 }
 
 //----- (00440B44) --------------------------------------------------------
-void IndoorLocation::ExecDraw(char a1)
+void IndoorLocation::ExecDraw(bool bD3D)
 {
-  signed int i; // esi@2
   int v2; // eax@3
   IndoorCameraD3D_Vec4 *v3; // edx@4
-  signed int j; // esi@8
   unsigned int v5; // ecx@9
   RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4
 
-  if ( a1 )
+  if (bD3D)
   {
     pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
-    for ( i = 0; i < (signed int)pStru170->uNumFaceIDs; ++i )
+    for (uint i = 0; i < pStru170->uNumFaceIDs; ++i)
     {
       v2 = pStru170->pFaceIDs[2 * i + 1];
       if ( pStru170->field_FA8[v2].std__vector_0007A8 == -1 )
@@ -286,16 +284,16 @@
         v3 = pStru170->field_FA8[v2].std__vector_0007AC;
         v6 = pStru170->field_FA8[v2].pVertices;
       }
-      IndoorLocation::ExecDraw_sub0(pStru170->pFaceIDs[2 * i], v3, 4u, v6);
+      IndoorLocation::ExecDraw_d3d(pStru170->pFaceIDs[2 * i], v3, 4u, v6);
     }
   }
   else
   {
-    for ( j = 0; j < (signed int)pStru170->uNumFaceIDs; ++j )
+    for (uint j = 0; j < pStru170->uNumFaceIDs; ++j )
     {
       v5 = pStru170->pFaceIDs[2 * j];
       pBLVRenderParams->field_7C = &pStru170->field_FA8[pStru170->pFaceIDs[2 * j + 1]].field_C;
-      IndoorLocation::ExecDraw_sub1(v5);
+      IndoorLocation::ExecDraw_sw(v5);
     }
   }
 }
@@ -432,21 +430,21 @@
 }
 
 //----- (004B0A25) --------------------------------------------------------
-void IndoorLocation::ExecDraw_sub0(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *a4)
+void IndoorLocation::ExecDraw_d3d(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *a4)
 {
-  unsigned int v4; // esi@1
+  //unsigned int v4; // esi@1
   char *v5; // eax@4
   signed int v6; // ecx@4
   char *v7; // eax@8
   signed int v8; // ecx@8
-  BLVFace *v9; // esi@13
-  IndoorCameraD3D *v10; // edi@16
-  int v11; // ebx@17
-  Vec3_short_ *v12; // ecx@18
-  char *v13; // edx@18
-  int v14; // eax@19
-  unsigned __int8 v15; // sf@19
-  unsigned __int8 v16; // of@19
+  //BLVFace *v9; // esi@13
+  //IndoorCameraD3D *v10; // edi@16
+  //int v11; // ebx@17
+  //Vec3_short_ *v12; // ecx@18
+  //char *v13; // edx@18
+  //int v14; // eax@19
+  //unsigned __int8 v15; // sf@19
+  //unsigned __int8 v16; // of@19
   int v17; // ebx@25
   double v18; // st7@27
   double v19; // st6@27
@@ -460,93 +458,73 @@
   IDirect3DTexture2 *v27; // eax@42
   Texture *v28; // [sp+Ch] [bp-1Ch]@15
   int i; // [sp+10h] [bp-18h]@38
-  LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16
-  IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16
-  IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1
-  unsigned int uFaceID_; // [sp+20h] [bp-8h]@1
+  //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16
+  //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16
+  //IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1
+  //unsigned int uFaceID_; // [sp+20h] [bp-8h]@1
   unsigned int uNumVerticesa; // [sp+24h] [bp-4h]@17
   int a4a; // [sp+34h] [bp+Ch]@25
   unsigned int a4b; // [sp+34h] [bp+Ch]@38
 
-  v4 = uFaceID;
-  a7 = pVertices;
-  uFaceID_ = uFaceID;
-  if ( (uFaceID & 0x80000000u) == 0 && (signed int)uFaceID < (signed int)pIndoor->uNumFaces )
-  {
-
-    static RenderVertexSoft static_vertices_F7C228[64];
-    static bool __init_flag1 = false;
-    if (!__init_flag1)
-    {
-      __init_flag1 = true;
-
-      for (uint i = 0; i < 64; ++i)
-        static_vertices_F7C228[i].flt_2C = 0.0f;
-    }
-
-    static RenderVertexSoft static_vertices_F7B628[64];
-    static bool __init_flag2 = false;
-    if (!__init_flag2)
-    {
-      __init_flag2 = true;
-
-      for (uint i = 0; i < 64; ++i)
-        static_vertices_F7B628[i].flt_2C = 0.0f;
-    }
-
-    static stru154 stru_F7B60C; // idb
-    /*static bool __init_flag3 = false;
-    if (!__init_flag3)
-    {
-      __init_flag3 = true;
-
-      stru154::stru154(&stru_F7B60C);
-    }*/
-
-    v9 = &pIndoor->pFaces[v4];
-    if ( v9->uNumVertices >= 3u )
-    {
-      if ( !(BYTE1(v9->uAttributes) & 0x20) )
+  //v4 = uFaceID;
+  //a7 = pVertices;
+  //uFaceID_ = uFaceID;
+  if (uFaceID >= pIndoor->uNumFaces)
+    return;
+
+  static RenderVertexSoft static_vertices_F7C228[64];
+  static RenderVertexSoft static_vertices_F7B628[64];
+  static stru154 stru_F7B60C; // idb
+
+    //v9 = &pIndoor->pFaces[uFaceID];
+  auto pFace = &pIndoor->pFaces[uFaceID];
+  if (pFace->uNumVertices < 3)
+    return;
+
+
+      if ( !(pFace->uAttributes & 0x2000) )
       {
         ++pBLVRenderParams->field_80;
-        LOBYTE(v9->uAttributes) |= 0x80u;
-        v28 = v9->GetTexture();
+        LOBYTE(pFace->uAttributes) |= 0x80u;
+        v28 = pFace->GetTexture();
         if ( v28 )
         {
-          v10 = pGame->pIndoorCameraD3D;
-          v31 = pGame->pIndoorCameraD3D;
-          pStru4 = pGame->pLightmapBuilder;
-          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(v9) )
+          //v10 = pGame->pIndoorCameraD3D;
+          //v31 = pGame->pIndoorCameraD3D;
+          //pStru4 = pGame->pLightmapBuilder;
+          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(pFace) )
           {
-            v11 = 0;
-            uNumVerticesa = v9->uNumVertices;
-            if ( (signed int)uNumVerticesa > 0 )
+            //v11 = 0;
+            //uNumVerticesa = pFace->uNumVertices;
+              //v12 = pIndoor->pVertices;
+              //v13 = (char *)&static_vertices_F7C228[0].vWorldPosition.z;
+            for (uint i = 0; i < pFace->uNumVertices; ++i)
             {
-              v12 = pIndoor->pVertices;
-              v13 = (char *)&static_vertices_F7C228[0].vWorldPosition.z;
-              do
-              {
-                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;
+              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 ( !a7
-              || (pGame->pStru9Instance->_498377(a4, 4u, a7, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
+            if ( !pVertices
+              || (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
             {
-              if ( v10->_437285_prolly_colide_vertices_against_frustrum(
+              if ( pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(
                      static_vertices_F7C228,
                      &uNumVerticesa,
                      static_vertices_F7B628,
-                     v10->std__vector_000034_prolly_frustrum,
+                     pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum,
                      4,
                      0,
                      0) != 1
@@ -554,31 +532,31 @@
               {
                 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);
-                sub_4B0E07(uFaceID_);
-                pStru4->ApplyLights_IndoorFace(uFaceID_);
-                pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID_);
-                v31->_4364C5(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
-                v31->_436BB7_project_and_stuff(array_507D30, uNumVerticesa, 0);
-                pStru4->std__vector_000004_size = 0;
+                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->pLightmapBuilder->std__vector_000004_size = 0;
                 if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
                 {
-                  v18 = v9->pFacePlane.dist;
-                  v19 = v9->pFacePlane.vNormal.z;
-                  v20 = v9->pFacePlane.vNormal.y;
-                  v21 = v9->uPolygonType;
-                  stru_F7B60C.vNormal.x = v9->pFacePlane.vNormal.x;
+                  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;
                 }
-                if ( stru_F8AD28.field_AC > 0 && !(BYTE2(v9->uAttributes) & 0x40) )
-                  pStru4->ApplyLights(
+                if ( stru_F8AD28.field_AC > 0 && !(BYTE2(pFace->uAttributes) & 0x40) )
+                  pGame->pLightmapBuilder->ApplyLights(
                     &stru_F8AD28,
                     &stru_F7B60C,
                     uNumVerticesa,
                     array_507D30,
-                    *(float *)&a7,
+                    pVertices,
                     0);
                 if ( pDecalBuilder->uNumDecals > 0 )
                   pDecalBuilder->ApplyDecals(
@@ -587,15 +565,16 @@
                     &stru_F7B60C,
                     uNumVerticesa,
                     array_507D30,
-                    (int)a7,
+                    pVertices,
                     0,
-                    v9->uSectorID);
-                if ( v9->uAttributes & 0x10 && v9->uBitmapID == pRenderer->field_1036AC_bitmapid )
+                    pFace->uSectorID);
+                if (pFace->uAttributes & 0x10 &&
+                    pFace->uBitmapID == pRenderer->field_1036AC_bitmapid )
                 {
                   v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
                   goto LABEL_42;
                 }
-                if ( v9->uAttributes & 0x10 )
+                if ( pFace->uAttributes & 0x10 )
                 {
                   v24 = GetTickCount() >> 2;
                   if ( (signed int)uNumVerticesa > 0 )
@@ -605,7 +584,7 @@
                     a4b = uNumVerticesa;
                     for ( i = v25; ; v25 = i )
                     {
-                      *(float *)v26 = (double)(pBitmaps_LOD->pTextures[v9->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8))
+                      *(float *)v26 = (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8))
                                     + *(float *)v26;
                       v26 += 48;
                       --a4b;
@@ -616,37 +595,32 @@
                 }
                 else
                 {
-                  v22 = v9->uAttributes;
+                  v22 = pFace->uAttributes;
                   if ( BYTE1(v22) & 0x40 )
                   {
                     v23 = pTextureFrameTable->GetFrameTexture(
-                            v9->uBitmapID,
+                            pFace->uBitmapID,
                             pBLVRenderParams->field_0_timer_);
 LABEL_42:
                     v27 = pBitmaps_LOD->pHardwareTextures[v23];
-                    if ( BYTE2(v9->uAttributes) & 0x40 )
-                      sub_479A53(uNumVerticesa, uFaceID_);
+                    if ( BYTE2(pFace->uAttributes) & 0x40 )
+                      sub_479A53(uNumVerticesa, uFaceID);
                     else
-                      pRenderer->DrawIndoorPolygon(uNumVerticesa, v9, v27, v28, 8 * uFaceID_ | 6, v17, 0);
+                      pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0);
                     return;
                   }
                 }
-                v23 = v9->uBitmapID;
+                v23 = pFace->uBitmapID;
                 goto LABEL_42;
               }
             }
           }
         }
       }
-    }
-  }
 }
-// F7CE28: using guessed type char static_init_flag__F7C228_bit1__F7B628_bit2__F7B60C_bit3;
-
-
 
 //----- (004AFF79) --------------------------------------------------------
-void IndoorLocation::ExecDraw_sub1(unsigned int uFaceID)
+void IndoorLocation::ExecDraw_sw(unsigned int uFaceID)
 {
   unsigned int v1; // ebx@1
   BLVFace *v2; // esi@3
@@ -1306,12 +1280,12 @@
 
 
 //----- (004B0EA8) --------------------------------------------------------
-void stru170::_4B0EA8(signed int a2, unsigned int uFaceID)
+void stru170::PrepareFaceRenderList_d3d(int a2, unsigned int uFaceID)
 {
-  unsigned int v3; // edx@1
-  stru170 *v4; // ebx@1
-  BLVFace *v5; // eax@1
-  int v6; // ecx@2
+  //unsigned int v3; // edx@1
+  //stru170 *v4; // ebx@1
+  //BLVFace *v5; // eax@1
+  //int v6; // ecx@2
   unsigned __int16 v7; // ax@11
   Vec3_short_ *v8; // esi@15
   int v9; // edx@15
@@ -1321,79 +1295,83 @@
   signed int v13; // esi@19
   signed int v14; // edx@20
   int v15; // edx@24
-  int v16; // esi@29
-  BLVFace *v17; // edi@34
+  //int v16; // esi@29
+  //BLVFace *v17; // edi@34
   unsigned __int16 v18; // ax@34
   char *v19; // eax@38
   signed int v20; // ecx@38
   char *v21; // eax@42
   signed int v22; // ecx@42
-  signed int v23; // edx@45
-  char *v24; // ecx@46
-  int v25; // eax@47
-  Vec3_short_ *v26; // eax@47
-  double v27; // st7@47
-  signed int v28; // ST28_4@47
+  //signed int v23; // edx@45
+  //char *v24; // ecx@46
+  //int v25; // eax@47
+  //Vec3_short_ *v26; // eax@47
+  //double v27; // st7@47
+  //signed int v28; // ST28_4@47
   char v29; // al@48
   signed int v30; // eax@51
   int v31; // eax@52
-  unsigned int v32; // eax@55
-  __int16 v33; // cx@56
+  //unsigned int v32; // eax@55
+  //__int16 v33; // cx@56
   signed int v34; // [sp+Ch] [bp-14h]@18
-  int a0; // [sp+14h] [bp-Ch]@2
-  IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36
+  //int a0; // [sp+14h] [bp-Ch]@2
+  //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36
   signed int v37; // [sp+18h] [bp-8h]@19
-  stru10 *v38; // [sp+18h] [bp-8h]@36
-  BLVFace *v39; // [sp+1Ch] [bp-4h]@1
-
-  v3 = uFaceID;
-  v4 = this;
-  v5 = &pIndoor->pFaces[uFaceID];
-  this->field_FA8[this->std__vector_000FA8].std__vector_0007A8 = -1;
-  v39 = v5;
-  if ( v5->uAttributes & 1 )
+  //stru10 *v38; // [sp+18h] [bp-8h]@36
+  //BLVFace *v39; // [sp+1Ch] [bp-4h]@1
+
+  //v3 = uFaceID;
+  //v4 = this;
+  //v5 = &pIndoor->pFaces[uFaceID];
+  field_FA8[std__vector_000FA8].std__vector_0007A8 = -1;
+  //v39 = &pIndoor->pFaces[uFaceID];
+
+  auto pFace = &pIndoor->pFaces[uFaceID];
+
+  if (pFace->uAttributes & 1)
   {
-    v6 = (int)((char *)this + 2252 * a2);
-    a0 = v6;
-    if ( v3 == *(short *)(v6 + 5964) )          // stru170_stru0[a2]::uFaceID
+    auto p = &field_FA8[a2];
+    //v6 = (int)((char *)this + 2252 * a2);
+    //a0 = v6;
+    if (p->uFaceID == uFaceID)
       return;
-    if ( !a2
-      && pBLVRenderParams->vPartyPos.x >= v5->pBounding.x1 - 16
-      && pBLVRenderParams->vPartyPos.x <= v5->pBounding.x2 + 16
-      && pBLVRenderParams->vPartyPos.y >= v5->pBounding.y1 - 16
-      && pBLVRenderParams->vPartyPos.y <= v5->pBounding.y2 + 16
-      && pBLVRenderParams->vPartyPos.z >= v5->pBounding.z1 - 16
-      && pBLVRenderParams->vPartyPos.z <= v5->pBounding.z2 + 16 )
+    if (!a2 &&
+        pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 &&
+        pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 &&
+        pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 &&
+        pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 &&
+        pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 &&
+        pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 )
     {
-      if ( abs(v5->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v5->pFacePlane_old.vNormal.x
-                                       + pBLVRenderParams->vPartyPos.y * v5->pFacePlane_old.vNormal.y
-                                       + pBLVRenderParams->vPartyPos.z * v5->pFacePlane_old.vNormal.z) <= 589824 )
+      if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x
+                                       + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
+                                       + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 )
       {
-        v7 = v39->uSectorID;
-        if ( v4->field_FA8[0].uSectorID == v7 )
-          v7 = v39->uBackSectorID;
-        v4->field_FA8[v4->std__vector_000FA8].uSectorID = v7;
-        v4->field_FA8[v4->std__vector_000FA8].uFaceID = uFaceID;
-        v4->field_FA8[v4->std__vector_000FA8].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-        v4->field_FA8[v4->std__vector_000FA8].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-        v4->field_FA8[v4->std__vector_000FA8].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-        v4->field_FA8[v4->std__vector_000FA8].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-        v4->field_FA8[v4->std__vector_000FA8++].field_C._43F9E1(
-          SLOWORD(pBLVRenderParams->uViewportX),
+        v7 = pFace->uSectorID;
+        if ( field_FA8[0].uSectorID == v7 )
+          v7 = pFace->uBackSectorID;
+        field_FA8[std__vector_000FA8].uSectorID = v7;
+        field_FA8[std__vector_000FA8].uFaceID = uFaceID;
+        field_FA8[std__vector_000FA8].uViewportX = pBLVRenderParams->uViewportX;
+        field_FA8[std__vector_000FA8].uViewportZ = pBLVRenderParams->uViewportZ;
+        field_FA8[std__vector_000FA8].uViewportY = pBLVRenderParams->uViewportY;
+        field_FA8[std__vector_000FA8].uViewportW = pBLVRenderParams->uViewportW;
+        field_FA8[std__vector_000FA8++].field_C._43F9E1(
+          pBLVRenderParams->uViewportX,
           pBLVRenderParams->uViewportY,
-          SLOWORD(pBLVRenderParams->uViewportZ),
+          pBLVRenderParams->uViewportZ,
           pBLVRenderParams->uViewportW);
-        sub_440639(v4->std__vector_000FA8 - 1);
+        sub_440639(std__vector_000FA8 - 1);
         return;
       }
-      v5 = v39;
-      v6 = a0;
+      //v5 = v39;
+      //v6 = a0;
     }
-    v8 = &pIndoor->pVertices[*v5->pVertexIDs];
-    v9 = v5->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v8->x - pBLVRenderParams->vPartyPos.x)
-       + v5->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v8->x >> 16) - pBLVRenderParams->vPartyPos.y)
-       + v5->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z);
-    if ( *(short *)(v6 + 4008) != v5->uSectorID )// stru170_stru0[a2]::uSectorID
+    v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
+    v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x)
+       + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y)
+       + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z);
+    if (p->uSectorID != pFace->uSectorID)
       v9 = -v9;
     if ( v9 < 0 )
     {
@@ -1425,122 +1403,102 @@
           }
           while ( v13 < v34 );
         }
-        v16 = a0;
-        if ( v11 >= *(short *)(a0 + 4010)       // stru170_stru0[a2]::uViewportX
-          && a2 <= *(short *)(a0 + 4014)        // stru170_stru0[a2]::uViewportZ
-          && v12 >= *(short *)(a0 + 4012)       // stru170_stru0[a2]::uViewportY
-          && v37 <= *(short *)(a0 + 4016)       // stru170_stru0[a2]::uViewportW
-          && sub_424829(v10, &v4->field_FA8[v4->std__vector_000FA8].field_C, (stru170_stru2 *)(a0 + 4020), uFaceID) )
+        //v16 = a0;
+        if (v11 >= p->uViewportX &&
+            a2 <= p->uViewportZ &&
+            v12 >= p->uViewportY &&
+            v37 <= p->uViewportW &&
+            sub_424829(v10, &field_FA8[std__vector_000FA8].field_C, &p->field_C, uFaceID))
         {
-          v17 = v39;
-          v18 = v39->uSectorID;
-          if ( *(short *)(a0 + 4008) == v18 )
-            v18 = v39->uBackSectorID;
-          v4->field_FA8[v4->std__vector_000FA8].uSectorID = v18;
-          v4->field_FA8[v4->std__vector_000FA8].uFaceID = uFaceID;
-          v4->field_FA8[v4->std__vector_000FA8].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-          v4->field_FA8[v4->std__vector_000FA8].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-          v4->field_FA8[v4->std__vector_000FA8].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-          v4->field_FA8[v4->std__vector_000FA8].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-          v38 = pGame->pStru10Instance;
-          a0a = pGame->pIndoorCameraD3D;
-          if ( *(int *)(v16 + 5968) == -1 )  // [a2]::std__vector_0007A8
+          //v17 = v39;
+          v18 = pFace->uSectorID;
+          if (p->uSectorID == v18 )
+            v18 = pFace->uBackSectorID;
+          field_FA8[std__vector_000FA8].uSectorID = v18;
+          field_FA8[std__vector_000FA8].uFaceID = uFaceID;
+          field_FA8[std__vector_000FA8].uViewportX = pBLVRenderParams->uViewportX;
+          field_FA8[std__vector_000FA8].uViewportZ = pBLVRenderParams->uViewportZ;
+          field_FA8[std__vector_000FA8].uViewportY = pBLVRenderParams->uViewportY;
+          field_FA8[std__vector_000FA8].uViewportW = pBLVRenderParams->uViewportW;
+          //v38 = pGame->pStru10Instance;
+          //a0a = pGame->pIndoorCameraD3D;
+          if (p->std__vector_0007A8 == -1 )
           {
-            v29 = pGame->pStru10Instance->_49C681(
-                    v39,
-                    v4->field_FA8[v4->std__vector_000FA8].std__vector_0007AC,
-                    v4->field_FA8[v4->std__vector_000FA8].pVertices);
+            v29 = pGame->pStru10Instance->_49C681_DrawDebugStuff(
+                    pFace,
+                    field_FA8[std__vector_000FA8].std__vector_0007AC,
+                    field_FA8[std__vector_000FA8].pVertices);
           }
           else
           {
-
-            static RenderVertexSoft static_sub_4B0EA8_stru_F7AA08[64];
-            static bool __init_flag1 = false;
-            if (!__init_flag1)
+            static RenderVertexSoft static_subPrepareFaceRenderList_d3d_stru_F7AA08[64];
+            static RenderVertexSoft static_subPrepareFaceRenderList_d3d_stru_F79E08[64];
+
+            //v23 = 0;
+            a2 = pFace->uNumVertices;
+            for (uint k = 0; k < pFace->uNumVertices; ++k)
             {
-              __init_flag1 = true;
-
-              for (uint i = 0; i < 64; ++i)
-                static_sub_4B0EA8_stru_F7AA08[i].flt_2C = 0.0f;
-            }
-            
-            static RenderVertexSoft static_sub_4B0EA8_stru_F79E08[64];
-            static bool __init_flag2 = false;
-            if (!__init_flag2)
-            {
-              __init_flag2 = true;
-
-              for (uint i = 0; i < 64; ++i)
-                static_sub_4B0EA8_stru_F79E08[i].flt_2C = 0.0f;
+              //v24 = (char *)&static_subPrepareFaceRenderList_d3d_stru_F7AA08[0].vWorldPosition.z;
+              //do
+              //{
+                //v25 = pFace->pVertexIDs[k];
+                //v26 = &pIndoor->pVertices[pFace->pVertexIDs[k]];
+                auto pVertex = &pIndoor->pVertices[pFace->pVertexIDs[k]];
+                //v27 = (double)v26->z;
+                //v28 = v26->y;
+                //v17 = v39;
+                static_subPrepareFaceRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pVertex->x;
+                static_subPrepareFaceRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pVertex->y;
+                static_subPrepareFaceRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pVertex->z;
+                //v24 += 48;
+              //}
+              //while ( v23 < a2 );
             }
-
-            v23 = 0;
-            a2 = v39->uNumVertices;
-            if ( a2 > 0 )
-            {
-              v24 = (char *)&static_sub_4B0EA8_stru_F7AA08[0].vWorldPosition.z;
-              do
-              {
-                v25 = v17->pVertexIDs[v23++];
-                v26 = &pIndoor->pVertices[v25];
-                v27 = (double)v26->z;
-                v28 = v26->y;
-                v17 = v39;
-                *((float *)v24 - 2) = (double)v26->x;
-                *((float *)v24 - 1) = (double)v28;
-                *(float *)v24 = v27;
-                v24 += 48;
-              }
-              while ( v23 < a2 );
-            }
-            a0a->_437285_prolly_colide_vertices_against_frustrum(
-              static_sub_4B0EA8_stru_F7AA08,
+            pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(
+              static_subPrepareFaceRenderList_d3d_stru_F7AA08,
               (unsigned int *)&a2,
-              static_sub_4B0EA8_stru_F79E08,
-              (IndoorCameraD3D_Vec4 *)(v16 + 5972),
+              static_subPrepareFaceRenderList_d3d_stru_F79E08,
+              p->std__vector_0007AC,
               4,
               0,
               0);
-            v29 = v38->_49C5DA(
-                    v17,
-                    static_sub_4B0EA8_stru_F79E08,
+            v29 = pGame->pStru10Instance->_49C5DA(
+                    pFace,
+                    static_subPrepareFaceRenderList_d3d_stru_F79E08,
                     &a2,
-                    v4->field_FA8[v4->std__vector_000FA8].std__vector_0007AC,
-                    v4->field_FA8[v4->std__vector_000FA8].pVertices);
+                    field_FA8[std__vector_000FA8].std__vector_0007AC,
+                    field_FA8[std__vector_000FA8].pVertices);
           }
           if ( v29 )
           {
-            v4->field_FA8[v4->std__vector_000FA8].std__vector_0007A8 = uFaceID;
-            v30 = v4->std__vector_000FA8;
+            field_FA8[std__vector_000FA8].std__vector_0007A8 = uFaceID;
+            v30 = std__vector_000FA8;
             if ( v30 < 150 )
             {
               v31 = v30 + 1;
-              v4->std__vector_000FA8 = v31;
+              std__vector_000FA8 = v31;
               sub_440639(v31 - 1);
             }
           }
           if ( pBLVRenderParams->uFlags & 1 )
-            a0a->PrepareAndDrawDebugOutline(v17, 0x1E1EFFu);
+            pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF);
         }
       }
     }
   }
   else
   {
-    v32 = this->uNumFaceIDs;
-    if ( (signed int)this->uNumFaceIDs < 1000 )
+    if (uNumFaceIDs < 1000 )
     {
-      v33 = a2;
-      v4->pFaceIDs[2 * v32] = v3;
-      v4->pFaceIDs[2 * v4->uNumFaceIDs++ + 1] = v33;
+      pFaceIDs[2 * uNumFaceIDs] = uFaceID;
+      pFaceIDs[2 * uNumFaceIDs++ + 1] = a2;
     }
   }
 }
-// F7B608: using guessed type char static_sub_4B0EA8_byte_F7B608_init_flags;
 
 
 //----- (004AFB86) --------------------------------------------------------
-void stru170::_4AFB86(int a2, unsigned int uFaceID)
+void stru170::PrepareFaceRenderList_sw(int a2, unsigned int uFaceID)
 {
   stru170 *v3; // ebx@1
   BLVFace *v4; // eax@1
@@ -1775,7 +1733,7 @@
   pAllocator->FreeChunk(v1->pLights);
   pAllocator->FreeChunk(v1->pDoors);
   pAllocator->FreeChunk(v1->pNodes);
-  pAllocator->FreeChunk(v1->pMapVertices);
+  pAllocator->FreeChunk(v1->pMapOutlines);
   v1->pVertices = 0;
   v1->pFaces = 0;
   v1->pFaceExtras = 0;
@@ -1783,7 +1741,7 @@
   v1->pLights = 0;
   v1->pDoors = 0;
   v1->pNodes = 0;
-  v1->pMapVertices = 0;
+  v1->pMapOutlines = 0;
   v1->bLoaded = 0;
 }
 
@@ -1829,11 +1787,11 @@
   v13 = v1->pNodes;
   v1->pDoors = (BLVDoor *)v12;
   v14 = pAllocator->AllocNamedChunk(v13, 0x9C40u, "L.BSP");
-  v15 = v1->pMapVertices;
+  v15 = v1->pMapOutlines;
   v1->pNodes = (BSPNode *)v14;
   v16 = pAllocator->AllocNamedChunk(v15, 0x14824u, "L.Map");
   v17 = v1->pVertices;
-  v1->pMapVertices = (BLVMapVertices *)v16;
+  v1->pMapOutlines = (BLVMapOutlines *)v16;
   if ( v17 && v1->pFaces && v1->pFaceExtras && v1->pSectors && v1->pLights && v1->pDoors && v1->pNodes && v16 )
   {
     memset(v17, 90000, 0);
@@ -1843,7 +1801,7 @@
     memset(v1->pLights, 6400, 0);
     memset(v1->pDoors, 16000, 0);
     memset(v1->pNodes, 40000, 0);
-    memset(v1->pMapVertices, 84004, 0);
+    memset(v1->pMapOutlines, 84004, 0);
     result = 1;
   }
   else
@@ -2503,7 +2461,7 @@
       fseek(v7, v234, 0);
       fread(&uLastVisitDay, 1u, 0x38u, v7);
       fseek(v7, v223, 0);
-      v80 = (void **)&pMapVertices;
+      v80 = (void **)&pMapOutlines;
       fread(*v80, 4u, 1u, v7);
       fread((char *)*v80 + 4, 0xCu, *(int *)*v80, v7);
       fclose(v7);
@@ -2592,6 +2550,7 @@
   assert(sizeof(LayingItem) == 112);
   assert(sizeof(Chest) == 5324);
   assert(sizeof(stru123) == 0xC8);
+  assert(sizeof(BLVMapOutline) == 12);
   
   bLoaded = true;
 
@@ -2877,10 +2836,10 @@
   pGameLoadingUI_ProgressBar->Progress();
 
   //v201 = (const char *)v148;
-  //v200 = (size_t)pMapVertices;
-  memcpy(&pMapVertices->uNumVertices, pData, 4);
-  memcpy(pMapVertices->pVertices, pData + 4, pMapVertices->uNumVertices * sizeof(Vec3_int_));
-  //v149 = pMapVertices;
+  //v200 = (size_t)pMapOutlines;
+  memcpy(&pMapOutlines->uNumOutlines, pData, 4);
+  memcpy(pMapOutlines->pOutlines, pData + 4, pMapOutlines->uNumOutlines * sizeof(BLVMapOutline));
+  //v149 = pMapOutlines;
   //v199 = 12 * *v149;
   //memcpy(v149 + 1, (const void *)(v148 + 4), v199);
   free(pRawBLV);
@@ -3001,9 +2960,9 @@
   if ( *(int *)pDest )
     memcpy(_visible_outlines, v203, 875);
 
-  for (uint i = 0; i < pMapVertices->uNumVertices; ++i)
+  for (uint i = 0; i < pMapOutlines->uNumOutlines; ++i)
   {
-    auto pVertex = pMapVertices->pVertices + i;
+    auto pVertex = pMapOutlines->pOutlines + i;
     if ((unsigned __int8)(1 << (7 - i % 8)) & _visible_outlines[i / 8])
       pVertex->uFlags |= 1;
   }
@@ -3218,9 +3177,9 @@
 int IndoorLocation::GetSector(int sX, int sY, int sZ)
 {
   int v4; // esi@1
-  unsigned __int8 v5; // zf@1
-  unsigned __int8 v6; // sf@1
-  unsigned __int8 v7; // of@1
+  //unsigned __int8 v5; // zf@1
+  //unsigned __int8 v6; // sf@1
+  //unsigned __int8 v7; // of@1
   BLVSector *v8; // eax@3
   int v9; // edi@9
   int v10; // eax@9
@@ -3274,14 +3233,15 @@
   int v59; // [sp+110h] [bp-4h]@16
 
   v4 = 0;
-  v7 = __OFSUB__(this->uNumSectors, 1);
-  v5 = this->uNumSectors == 1;
-  v6 = this->uNumSectors - 1 < 0;
+  //v7 = __OFSUB__(this->uNumSectors, 1);
+  //v5 = this->uNumSectors == 1;
+  //v6 = this->uNumSectors - 1 < 0;
   v55 = 0;
   v43[0] = 0;
   v56 = 1;
-  if ( (unsigned __int8)(v6 ^ v7) | v5 )
+  if (uNumSectors < 2)
     return 0;
+
   v52 = 116;
   do
   {
@@ -3328,9 +3288,9 @@
                       v20 = v19[*pVertexIDs].y;
                       v54 = 0;
                       v57 = 0;
-                      v5 = v16->uNumVertices == 0;
+                      //v5 = v16->uNumVertices == 0;
                       v59 = v20 >= sY;
-                      if ( !v5 )
+                      if (v16->uNumVertices)
                       {
                         v21 = pVertexIDs + 1;
                         do
@@ -3395,11 +3355,11 @@
                     }
                     v11 = v48 + 1;
                     v12 = v53 + 2;
-                    v7 = __OFSUB__(v48 + 1, v51);
-                    v6 = v48++ + 1 - v51 < 0;
+                    //v7 = __OFSUB__(v48 + 1, v51);
+                    //v6 = v48++ + 1 - v51 < 0;
                     v53 += 2;
                   }
-                  while ( v6 ^ v7 );
+                  while ( ++v48 < v51 );
                   v4 = v43[0];
                 }
               }
--- a/Indoor.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/Indoor.h	Thu Oct 25 18:02:42 2012 +0600
@@ -238,7 +238,7 @@
 
 /*  101 */
 #pragma pack(push, 1)
-struct BLVMapVertex
+struct BLVMapOutline
 {
   unsigned __int16 uVertex1ID;
   unsigned __int16 uVertex2ID;
@@ -373,10 +373,10 @@
 
 
 #pragma pack(push, 1)
-struct BLVMapVertices
+struct BLVMapOutlines
 {
-  uint         uNumVertices;
-  BLVMapVertex pVertices[1];
+  uint          uNumOutlines;
+  BLVMapOutline pOutlines[1];
 };
 #pragma pack(pop)
 
@@ -411,7 +411,7 @@
     pLights = 0;
     pDoors = 0;
     pNodes = 0;
-    pMapVertices = 0;
+    pMapOutlines = 0;
     uNumSpawnPoints = 0;
     pSpawnPoints = 0;
   }
@@ -424,9 +424,9 @@
   void ToggleLight(unsigned int uLightID, unsigned int bToggle);
 
   static unsigned int GetLocationIndex(const char *Str1);
-  static void ExecDraw(char a1);
-  static void ExecDraw_sub1(unsigned int uFaceID);
-  static void ExecDraw_sub0(unsigned int uFaceID, struct IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *a4);
+  static void ExecDraw(bool bD3D);
+  static void ExecDraw_sw(unsigned int uFaceID);
+  static void ExecDraw_d3d(unsigned int uFaceID, struct IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *a4);
 
   char pFilename[32];
   char field_20[48];
@@ -447,7 +447,7 @@
   struct BLVDoor *pDoors;
   unsigned int uNumNodes;
   struct BSPNode *pNodes;
-  BLVMapVertices *pMapVertices;
+  BLVMapOutlines *pMapOutlines;
   unsigned __int16 *ptr_2AC;
   unsigned __int16 *ptr_0002B0_sector_rdata;
   unsigned __int16 *ptr_0002B4_doors_ddata;
--- a/IndoorCameraD3D.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/IndoorCameraD3D.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -1225,50 +1225,39 @@
 {
   char *v8; // eax@2
   signed int v9; // ecx@2
-  bool result; // eax@5
+  //bool result; // eax@5
   int v11; // ecx@5
-  signed int v12; // ecx@6
-  char *v13; // esi@6
+  //signed int v12; // ecx@6
+  //char *v13; // esi@6
   RenderVertexSoft *v14; // eax@8
   RenderVertexSoft *v15; // edx@8
   Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12
   float v17; // [sp+44h] [bp-10h]@1
   int v18; // [sp+48h] [bp-Ch]@5
-  stru9 *thisa; // [sp+4Ch] [bp-8h]@1
+  //stru9 *thisa; // [sp+4Ch] [bp-8h]@1
   int a7a; // [sp+53h] [bp-1h]@5
-  bool a6a; // [sp+70h] [bp+1Ch]@5
+  //bool a6a; // [sp+70h] [bp+1Ch]@5
 
   v17 = 0.0;
-  thisa = pGame->pStru9Instance;
+  //thisa = pGame->pStru9Instance;
 
   
   static RenderVertexSoft sr_vertices_50D9D8[64];
-  static bool __init_flag1 = false;
-  if (!__init_flag1)
-  {
-    __init_flag1 = true;
 
-    for (uint i = 0; i < 64; ++i)
-      sr_vertices_50D9D8[i].flt_2C = 0.0f;
-  }
-
-  result = 0;
-  LOBYTE(a7a) = 0;
+  //result = 0;
+  a7a = 0;
   v11 = 2 * (a6 == 0) + 1;
-  a6a = 0;
+  //a6a = 0;
   v18 = v11;
   if ( uNumVertices <= 0 )
-  {
-LABEL_14:
-    LOBYTE(result) = a7a;
-  }
-  else
-  {
-    v12 = *pOutNumVertices;
-    v13 = (char *)&a4->y;
+    return false;
+
+    //v12 = *pOutNumVertices;
+    //v13 = (char *)&a4->y;
+  uint i = 0;
     while ( 1 )
     {
-      if ( result % 2 )
+      if (i % 2 )
       {
         v14 = a1;
         v15 = sr_vertices_50D9D8;
@@ -1278,27 +1267,24 @@
         v15 = a1;
         v14 = sr_vertices_50D9D8;
       }
-      ++a6a;
-      if ( a6a == uNumVertices )
+      ++i;
+      if (i == uNumVertices )
         v14 = pVertices;
-      a5.x = *((float *)v13 - 1);
-      a5.y = *(float *)v13;
-      a5.z = *((float *)v13 + 1);
-      result = thisa->_4985FB(v15, v12, v14, pOutNumVertices, &a5, *((float *)v13 + 2), (char *)&a7a, _unused);
-      v12 = *pOutNumVertices;
+      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 )
         break;
-      result = a6a;
-      v13 += 24;
-      if ( a6a >= uNumVertices )
-        goto LABEL_14;
+      //result = a6a;
+      //v13 += 24;
+      if (i >= uNumVertices)
+        return a7a;
     }
     *pOutNumVertices = 0;
-    LOBYTE(result) = 1;
-  }
-  return result;
+  return true;
 }
-// 50E5D8: using guessed type char static_50D9D8_init_flag_bit1;
 
 //----- (004371C3) --------------------------------------------------------
 bool IndoorCameraD3D::_4371C3(RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused)
@@ -1680,8 +1666,8 @@
 void IndoorCameraD3D::Project(signed int x, signed int y, signed int z, int *a5, int *a6)
 {
   double v6; // ST00_8@2
-  double v7; // ST08_8@2
-  double v8; // ST00_8@2
+  //double v7; // ST08_8@2
+  //double v8; // ST00_8@2
   signed __int64 v9; // qtt@3
   int v10; // ST04_4@3
   float a2a; // [sp+18h] [bp+8h]@2
@@ -1690,12 +1676,12 @@
   if ( pRenderer->pRenderD3D )
   {
     v6 = 1.0 / (double)x;
-    a2a = (double)y * this->flt_fov * v6 + this->field_C8;
-    v7 = a2a + 6.7553994e15;
-    *a5 = LODWORD(v7);
-    a2b = (double)z * this->flt_fov * v6 + this->field_CC;
-    v8 = a2b + 6.7553994e15;
-    *a6 = pViewport->uViewportW - LODWORD(v8);
+    a2a = (double)y * flt_fov * v6 + field_C8;
+    //v7 = a2a + 6.7553994e15;
+    *a5 = floorf(a2a + 0.5f);
+    a2b = (double)z * flt_fov * v6 + field_CC;
+    //v8 = a2b + 6.7553994e15;
+    *a6 = pViewport->uViewportW - floorf(a2b + 0.5f);
   }
   else
   {
--- a/Indoor_stuff.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/Indoor_stuff.h	Thu Oct 25 18:02:42 2012 +0600
@@ -76,20 +76,20 @@
    //    (void (__thiscall *)(void *))stru170_stru0::dtor);
     uNumFaceIDs = 0;
     std__vector_000FA8 = 0;
-    field_53730 = 0;
+    uNumVisibleNotEmptySectors = 0;
   }
 
-  void _4AFB86(int a2, unsigned int uFaceID);
-  void _4B0EA8(signed int a2, unsigned int uFaceID);
-  void RenderWalls();
+  void PrepareFaceRenderList_sw(int a2, unsigned int uFaceID);
+  void PrepareFaceRenderList_d3d(signed int a2, unsigned int uFaceID);
+  void MakeVisibleSectorList();
 
   unsigned int uNumFaceIDs;
   __int16 pFaceIDs[150];
   char field_130[3700];
   unsigned int std__vector_000FA8;
   stru170_stru0 field_FA8[150];
-  int field_53730;
-  unsigned __int16 pSectorIDs_toDrawDecorationsFrom[6];
+  unsigned int uNumVisibleNotEmptySectors;
+  unsigned __int16 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[6];
 };
 #pragma pack(pop)
 
--- a/LightmapBuilder.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/LightmapBuilder.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -48,7 +48,7 @@
 
 
 //----- (0045BC07) --------------------------------------------------------
-char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char a7)
+char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char a7)
 {
   char *v7; // eax@3
   signed int v8; // ecx@3
@@ -97,7 +97,7 @@
   }
 
   a9 = (int)a5;
-  if ( a6 == 0.0 )
+  if ( !a6)
   {
     v14 = a3;
   }
@@ -161,18 +161,19 @@
       v29 = *v19;
       v30 = v19[60];
       v21 = *(v19 - 60);
-      a6 = v20;
+      //a6 = v20;
       v36 = v21;
       v37 = v19[20];
+      auto _a6_1 = floorf(v20 + 0.5f);
       //v33 = a6 + 6.7553994e15;
-      a6 = *((float *)v19 + 100) * 255.0;
+      auto _a6_2 = *((float *)v19 + 100) * 255.0;
       //v32 = a6 + 6.7553994e15;
-      a6 = *((float *)v19 + 120) * 255.0;
+      auto _a6_3 = *((float *)v19 + 120) * 255.0;
       //v31 = a6 + 6.7553994e15;
       //v38 = __PAIR__(LODWORD(v32), LODWORD(v31));
-      v38 = __PAIR__((int)floorf(a6 + 0.5f), (int)floorf(a6 + 0.5f));
+      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 + 0.5f) | (((int)floorf(a6 + 0.5f) | ((int)floorf(a6 + 0.5f) << 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;
--- a/LightmapBuilder.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/LightmapBuilder.h	Thu Oct 25 18:02:42 2012 +0600
@@ -54,7 +54,7 @@
   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, float a6, char a7);
+  char ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char a7);
 
 
   void (__thiscall ***vdestructor_ptr)(LightmapBuilder *, bool);
--- a/Monsters.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/Monsters.h	Thu Oct 25 18:02:42 2012 +0600
@@ -177,7 +177,7 @@
   unsigned __int16 uMonsterRadius;
   unsigned __int16 uMovementSpeed;
   __int16 uToHitRadius;
-  int uTintColor;
+  unsigned int uTintColor;
   unsigned __int16 pSoundSampleIDs[4];
   char pMonsterName[32];
   char pSpriteNames[10][10];
--- a/OSAPI.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/OSAPI.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -9,8 +9,9 @@
 int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE, wchar_t *lpCmdLine, int nShowCmd)
 {
   Log::Initialize();
-
-  if (HWND hMM7Window = FindWindowW(L"MM7", 0))
+  
+  //if (HWND hMM7Window = FindWindowW(L"MM7", 0))
+  if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))
   {
     if (IsIconic(hMM7Window))
       ShowWindow(hMM7Window, SW_RESTORE);
--- a/Party.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/Party.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -280,11 +280,11 @@
 //----- (0049137D) --------------------------------------------------------
 void Party::CreateDefaultParty(char bGiveItems)
 {
-  Party *v2; // esi@1
+  Party *pParty; // esi@1
   signed __int16 v3; // ax@1
-  int v4; // ecx@1
-  Player *v5; // esi@3
-  signed int v6; // edx@5
+  int pResMagicBase; // ecx@1
+  Player *pCharacter; // esi@3
+  signed int uSpellBookPageCount; // edx@5
   int v7; // eax@5
   int uSkillIdx; // eax@11
   unsigned __int8 v9; // zf@37
@@ -292,110 +292,109 @@
   unsigned __int8 v11; // of@37
   char *v12; // eax@38
   signed int v13; // ecx@38
-  int v14; // eax@42
+  int uMaxSP; // eax@42
   unsigned int v15; // [sp-4h] [bp-44h]@14
   unsigned int v16; // [sp-4h] [bp-44h]@26
   int v17; // [sp+10h] [bp-30h]@1
   int v18; // [sp+14h] [bp-2Ch]@11
-  signed int v19; // [sp+18h] [bp-28h]@1
+  signed int uNumPlayers; // [sp+18h] [bp-28h]@1
   ItemGen Dst; // [sp+1Ch] [bp-24h]@10
 
-  v2 = this;
-  strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]);
-  v2->pPlayers[0].field_1928 = 17;
-  v2->pPlayers[0].uFace = 17;
-  v2->pPlayers[0].field_1924 = 17;
-  v2->pPlayers[0].uVoiceID = 17;
-  v2->pPlayers[0].uMight = 30;
-  v2->pPlayers[0].uIntelligence = 5;
-  v2->pPlayers[0].uWillpower = 5;
-  v2->pPlayers[0].uEndurance = 13;
-  v2->pPlayers[0].uAccuracy = 13;
-  v2->pPlayers[0].uSpeed = 14;
-  v2->pPlayers[0].uLuck = 7;
-  v2->pPlayers[0].pActiveSkills[9] = 1;         // leather
-  v2->pPlayers[0].pActiveSkills[33] = 1;        // armsmaster
-  v2->pPlayers[0].pActiveSkills[5] = 1;         // bow
-  v2->pPlayers[0].pActiveSkills[1] = 1;         // sword
-  v2->pPlayers[1].field_1928 = 3;
-  v2->pPlayers[1].uFace = 3;
-  v2->pPlayers[1].field_1924 = 3;
-  v2->pPlayers[1].uVoiceID = 3;
-  strcpy(v2->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]);
-  v2->pPlayers[1].uMight = 13;
-  v2->pPlayers[1].uIntelligence = 9;
-  v2->pPlayers[1].uWillpower = 9;
-  v2->pPlayers[1].uEndurance = 13;
-  v2->pPlayers[1].uAccuracy = 13;
-  v2->pPlayers[1].uSpeed = 13;
-  v2->pPlayers[1].uLuck = 13;
-  v2->pPlayers[1].pActiveSkills[9] = 1;         // leather
-  v2->pPlayers[1].pActiveSkills[34] = 1;        // stealing
-  v2->pPlayers[1].pActiveSkills[2] = 1;         // dagger
-  v2->pPlayers[1].pActiveSkills[29] = 1;        // disarm trap
-  v2->pPlayers[2].field_1928 = 14;
-  v2->pPlayers[2].uFace = 14;
-  v2->pPlayers[2].field_1924 = 14;
-  v2->pPlayers[2].uVoiceID = 14;
-  strcpy(v2->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]);
-  v2->pPlayers[2].uMight = 12;
-  v2->pPlayers[2].uIntelligence = 9;
-  v2->pPlayers[2].uWillpower = 20;
-  v2->pPlayers[2].uEndurance = 22;
-  v2->pPlayers[2].uAccuracy = 7;
-  v2->pPlayers[2].uSpeed = 13;
-  v2->pPlayers[2].uLuck = 7;
-  v2->pPlayers[2].pActiveSkills[35] = 1;        // alchemy
-  v2->pPlayers[2].pActiveSkills[9] = 1;         // leather
-  v2->pPlayers[2].pActiveSkills[18] = 1;        // body
-  v2->pPlayers[2].pActiveSkills[6] = 1;         // mace
-  strcpy(v2->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]);
+  pParty = this;
+  strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan
+  pParty->pPlayers[0].field_1928 = 17;
+  pParty->pPlayers[0].uFace = 17;
+  pParty->pPlayers[0].field_1924 = 17;
+  pParty->pPlayers[0].uVoiceID = 17;
+  pParty->pPlayers[0].uMight = 30;
+  pParty->pPlayers[0].uIntelligence = 5;
+  pParty->pPlayers[0].uWillpower = 5;
+  pParty->pPlayers[0].uEndurance = 13;
+  pParty->pPlayers[0].uAccuracy = 13;
+  pParty->pPlayers[0].uSpeed = 14;
+  pParty->pPlayers[0].uLuck = 7;
+  pParty->pPlayers[0].pActiveSkills[9] = 1;         // leather
+  pParty->pPlayers[0].pActiveSkills[33] = 1;        // armsmaster
+  pParty->pPlayers[0].pActiveSkills[5] = 1;         // bow
+  pParty->pPlayers[0].pActiveSkills[1] = 1;         // sword
+  pParty->pPlayers[1].field_1928 = 3;
+  pParty->pPlayers[1].uFace = 3;
+  pParty->pPlayers[1].field_1924 = 3;
+  pParty->pPlayers[1].uVoiceID = 3;
+  strcpy(pParty->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic
+  pParty->pPlayers[1].uMight = 13;
+  pParty->pPlayers[1].uIntelligence = 9;
+  pParty->pPlayers[1].uWillpower = 9;
+  pParty->pPlayers[1].uEndurance = 13;
+  pParty->pPlayers[1].uAccuracy = 13;
+  pParty->pPlayers[1].uSpeed = 13;
+  pParty->pPlayers[1].uLuck = 13;
+  pParty->pPlayers[1].pActiveSkills[9] = 1;         // leather
+  pParty->pPlayers[1].pActiveSkills[34] = 1;        // stealing
+  pParty->pPlayers[1].pActiveSkills[2] = 1;         // dagger
+  pParty->pPlayers[1].pActiveSkills[29] = 1;        // disarm trap
+  pParty->pPlayers[2].field_1928 = 14;
+  pParty->pPlayers[2].uFace = 14;
+  pParty->pPlayers[2].field_1924 = 14;
+  pParty->pPlayers[2].uVoiceID = 14;
+  strcpy(pParty->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena
+  pParty->pPlayers[2].uMight = 12;
+  pParty->pPlayers[2].uIntelligence = 9;
+  pParty->pPlayers[2].uWillpower = 20;
+  pParty->pPlayers[2].uEndurance = 22;
+  pParty->pPlayers[2].uAccuracy = 7;
+  pParty->pPlayers[2].uSpeed = 13;
+  pParty->pPlayers[2].uLuck = 7;
+  pParty->pPlayers[2].pActiveSkills[35] = 1;        // alchemy
+  pParty->pPlayers[2].pActiveSkills[9] = 1;         // leather
+  pParty->pPlayers[2].pActiveSkills[18] = 1;        // body
+  pParty->pPlayers[2].pActiveSkills[6] = 1;         // mace
+  strcpy(pParty->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis
   v3 = 10;
-  v2->pPlayers[3].field_1928 = 10;
-  v2->pPlayers[3].uFace = 10;
-  v4 = (int)&v2->pPlayers[0].sResMagicBase;
-  v2->pPlayers[3].uEndurance = 13;
-  v2->pPlayers[3].uAccuracy = 13;
-  v2->pPlayers[3].uSpeed = 13;
-  v2->pPlayers[3].field_1924 = 10;
-  v2->pPlayers[3].uVoiceID = 10;
-  v2->pPlayers[3].uMight = 5;
-  v2->pPlayers[3].uIntelligence = 30;
-  v2->pPlayers[3].uWillpower = 9;
-  v2->pPlayers[3].uLuck = 7;
-  v2->pPlayers[3].pActiveSkills[9] = 1;         // leather
-  v2->pPlayers[3].pActiveSkills[13] = 1;        // air
-  v2->pPlayers[3].pActiveSkills[12] = 1;        // fire
-  v2->pPlayers[3].pActiveSkills[0] = 1;         // staff
-  v17 = (int)&v2->pPlayers[0].sResMagicBase;
-  v19 = 4;
+  pParty->pPlayers[3].field_1928 = 10;
+  pParty->pPlayers[3].uFace = 10;
+  pResMagicBase = (int)&pParty->pPlayers[0].sResMagicBase;
+  pParty->pPlayers[3].uEndurance = 13;
+  pParty->pPlayers[3].uAccuracy = 13;
+  pParty->pPlayers[3].uSpeed = 13;
+  pParty->pPlayers[3].field_1924 = 10;
+  pParty->pPlayers[3].uVoiceID = 10;
+  pParty->pPlayers[3].uMight = 5;
+  pParty->pPlayers[3].uIntelligence = 30;
+  pParty->pPlayers[3].uWillpower = 9;
+  pParty->pPlayers[3].uLuck = 7;
+  pParty->pPlayers[3].pActiveSkills[9] = 1;         // leather
+  pParty->pPlayers[3].pActiveSkills[13] = 1;        // air
+  pParty->pPlayers[3].pActiveSkills[12] = 1;        // fire
+  pParty->pPlayers[3].pActiveSkills[0] = 1;         // staff
+  pCharacter = &pParty->pPlayers[0];
+  uNumPlayers = 4;
   while ( 1 )
   {
-    v5 = (Player *)(v4 - 6014);
-    if ( !*(char *)(v4 - 5829) )
-      *(short *)v4 = v3;
-    v6 = 0;
-    v7 = v4 - 5726;
+    if ( !pCharacter->uClass )
+      *(short *)pResMagicBase = v3;
+    uSpellBookPageCount = 0;
+    v7 = pResMagicBase - 5726;// Skills
     while ( !*(short *)v7 )
     {
-      ++v6;
+      ++uSpellBookPageCount;
       v7 += 2;
-      if ( v6 >= 9 )
+      if ( uSpellBookPageCount >= 9 )
         goto LABEL_10;
     }
-    v5->field_1A4E = v6;
+    pCharacter->pNumSpellBookPage = uSpellBookPageCount;
 LABEL_10:
-    v5->uExpressionTimePassed = 0;
+    pCharacter->uExpressionTimePassed = 0;
     Dst.Reset();
     if ( bGiveItems )
     {
       pItemsTable->GenerateItem(2, 40, &Dst);
-      v5->AddItem2(0xFFFFFFFFu, &Dst);
+      pCharacter->AddItem2(-1, &Dst);
       uSkillIdx = 0;
       v18 = 0;
       do
       {
-        if ( v5->pActiveSkills[uSkillIdx] )
+        if ( pCharacter->pActiveSkills[uSkillIdx] )
         {
           switch ( uSkillIdx )
           {
@@ -432,7 +431,7 @@
             case PLAYER_SKILL_PLATE:
               v15 = ITEM_PLATE_1;
 wear_item:
-              v5->WearItem(v15);
+              pCharacter->WearItem(v15);
               break;
             case PLAYER_SKILL_FIRE:
               v16 = ITEM_SPELLBOOK_FIRE_STRIKE;
@@ -462,7 +461,7 @@
             case PLAYER_SKILL_DIPLOMACY:
             case PLAYER_SKILL_TRAP_DISARM:
             case PLAYER_SKILL_LEARNING:
-              v5->AddItem(0xFFFFFFFFu, ITEM_POTION_BOTTLE);
+              pCharacter->AddItem(-1, ITEM_POTION_BOTTLE);
               v16 = 5 * (rand() % 3 + 40);      // simple reagent
               goto add_item;
             case PLAYER_SKILL_DODGE:
@@ -471,7 +470,7 @@
             case PLAYER_SKILL_UNARMED:
               v16 = ITEM_GAUNTLETS_1;
 add_item:
-              v5->AddItem(0xFFFFFFFFu, v16);
+              pCharacter->AddItem(-1, v16);
               break;
             default:
               break;
@@ -483,7 +482,7 @@
         v10 = v18++ - 35 < 0;
       }
       while ( (unsigned __int8)(v10 ^ v11) | v9 );
-      v12 = (char *)&v5->pInventoryItems[0].uAttributes;
+      v12 = (char *)&pCharacter->pInventoryItems[0].uAttributes;
       v13 = 138;
       do
       {
@@ -494,14 +493,13 @@
       }
       while ( v13 );
     }
-    v5->sHealth = v5->GetMaxHealth();
-    v14 = v5->GetMaxMana();
-    v17 += 6972;
-    v9 = v19-- == 1;
-    v5->sMana = v14;
+    pCharacter->sHealth = pCharacter->GetMaxHealth();
+    pCharacter->sMana = pCharacter->GetMaxMana();
+    pCharacter++;
+    v9 = uNumPlayers-- == 1;
     if ( v9 )
       break;
-    v4 = v17;
+    pResMagicBase = (int)pCharacter;
     v3 = 10;
   }
 }
--- a/Party.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/Party.h	Thu Oct 25 18:02:42 2012 +0600
@@ -148,6 +148,9 @@
   static void TakeFood(unsigned int uNumFood);
   static __int16 GiveFood(unsigned int _this);
 
+  inline bool WizardEyeActive()     {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;}
+  inline int  WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;}
+
 
   int field_0;
   unsigned int uPartyHeight;
--- a/Player.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/Player.h	Thu Oct 25 18:02:42 2012 +0600
@@ -93,7 +93,12 @@
 {
   PLAYER_CLASS_KNIGHT = 0x0,
   PLAYER_CLASS_THEIF = 0x4,
+  PLAYER_CLASS_MONK = 0x8,
+  PLAYER_CLASS_PALADIN = 0xC,
+  PLAYER_CLASS_SHOOTER = 0x10,
+  PLAYER_CLASS_DRUID = 0x14,
   PLAYER_CLASS_CLERIC = 0x18,
+  PLAYER_CLASS_RANGER = 0x1C,
   PLAYER_CLASS_SORCERER = 0x20,
 };
 
@@ -424,7 +429,7 @@
   int field_1988[49];
   char field_1A4C;
   char field_1A4D;
-  char field_1A4E;
+  char pNumSpellBookPage;
   unsigned __int8 uQuickSpell;
   char field_1A50[64];
   char _some_attack_bonus;
--- a/Render.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/Render.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -2020,7 +2020,7 @@
               -1);
         }
         if ( stru_F8AD28.field_AC > 0 )
-          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0.0, v33);
+          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
         v34 = a5;
         v35 = byte_4D864C == 0;
         v16->uNumVertices = a5;
@@ -2170,7 +2170,7 @@
         &static_sub_0048034E_stru_76D590,
         uNumVertices,
         array_50AC10,
-        0.0,
+        0,
         (char)a8);
     v55 = uNumVertices;
     v35 = byte_4D864C == 0;
@@ -2307,7 +2307,7 @@
           -1);
     }
     if ( stru_F8AD28.field_AC > 0 )
-      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0.0, v70);
+      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
     v71 = a8;
     v72 = v100;
     v35 = byte_4D864C == 0;
@@ -6139,7 +6139,7 @@
 
 
 //----- (004A0BEE) --------------------------------------------------------
-char Render::FillRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor)
+char Render::Line2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor)
 {
   int v6; // edi@1
   int v7; // edx@5
@@ -9618,52 +9618,20 @@
 
 
 //----- (004A6D87) --------------------------------------------------------
-void Render::FillRect2(int uX, int uY, int a4, unsigned int a5, int a6, unsigned __int16 a7)
-{
-  Render *v7; // esi@1
-  void *v8; // edx@2
-  unsigned int v9; // ecx@3
-  unsigned __int8 v10; // cf@5
-  unsigned int v11; // ecx@5
-  unsigned __int16 *v12; // edi@5
-  int i; // ecx@5
-  char v14; // zf@9
-  int v15; // [sp+10h] [bp+Ch]@3
-
-  auto a1 = this;
-  v7 = a1;
-  if ( a1->uNumSceneBegins )
-  {
-    v8 = &a1->pTargetSurface[uY + a4 * a1->uTargetSurfacePitch];
-    if ( a6 > 0 )
-    {
-      v9 = a5;
-      v15 = a6;
-      do
-      {
-        if ( (signed int)v9 > 0 )
-        {
-          LOWORD(uX) = a7;
-          uX <<= 16;
-          LOWORD(uX) = a7;
-          v10 = v9 & 1;
-          v11 = v9 >> 1;
-          memset32(v8, uX, v11);
-          v12 = (unsigned __int16 *)((char *)v8 + 4 * v11);
-          for ( i = v10; i; --i )
-          {
-            *v12 = a7;
-            ++v12;
-          }
-          v9 = a5;
-          v8 = (char *)v8 + 2 * a5;
-        }
-        v14 = v15-- == 1;
-        v8 = (char *)v8 + 2 * (v7->uTargetSurfacePitch - v9);
-      }
-      while ( !v14 );
-    }
-  }
+void Render::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16)
+{
+  if (!uNumSceneBegins)
+    return;
+
+  unsigned __int32 twoColors = (uColor16 << 16) | uColor16;
+  for (uint y = 0; y < uHeight; ++y)
+  {
+    auto pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch];
+
+    memset32(pDst, twoColors, uWidth / 2);
+    if (uWidth & 1)
+      pDst[uWidth - 1] = uColor16;
+    }
 }
 
 
--- a/Render.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/Render.h	Thu Oct 25 18:02:42 2012 +0600
@@ -277,7 +277,7 @@
   void CreateSomeTexture();
   bool InitializeFullscreen(HWND hWnd);
   bool SwitchToWindow(HWND hWnd);
-  char FillRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor);
+  char Line2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor);
   void ClearZBuffer(int a2, int a3);
   void Clip_v2(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   void ParseTargetPixelFormat();
@@ -339,7 +339,7 @@
   void _4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height);
   void DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8);
   void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor);
-  void FillRect2(int uX, int uY, int a4, unsigned int a5, int a6, unsigned __int16 a7);
+  void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16);
   int _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7);
   void _4A6E7E(unsigned int a2, unsigned int a3, Texture *a4);
   char DrawBuildingsD3D();
--- a/Vis.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/Vis.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -361,7 +361,6 @@
   v17 = 0;
   for ( a1.flt_2C = 0.0; v17 < (signed int)pStru170->uNumFaceIDs; ++v17 )
   {
-    __debugbreak();
     v6 = pStru170->pFaceIDs[2 * v5];
     if ( v6 >= 0 )
     {
--- a/mm7_1.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_1.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -3101,15 +3101,15 @@
   v106.sZValue = 0;
   v106.uFlags = 0;
   pRenderer->Clip_v2(0, 0, 0x27Fu, 0x1DFu);
-  pRenderer->FillRect(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, a5);
-  pRenderer->FillRect(
+  pRenderer->Line2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, a5);
+  pRenderer->Line2D(
     v106.uViewportX + 129,
     v106.uViewportY - 1,
     v106.uViewportX + 129,
     v106.uViewportW + 1,
     a5);
-  pRenderer->FillRect(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, a5);
-  pRenderer->FillRect(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, a5);
+  pRenderer->Line2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, a5);
+  pRenderer->Line2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, a5);
   if ( pRenderer->pRenderD3D )
   {
     v13 = &pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]];
@@ -3150,20 +3150,18 @@
       v116 = v106.uViewportZ;
     if ( v119 > (signed int)v106.uViewportW )
       v119 = v106.uViewportW;
-    pRenderer->FillRect2(
-      0,
+    pRenderer->FillRectFast(
       v106.uViewportX,
       v106.uViewportY,
       v106.uViewportZ - v106.uViewportX,
       v106.uViewportW - v106.uViewportY,
-      LOWORD(pRenderer->uTargetBMask) | LOWORD(pRenderer->uTargetGMask));
-    pRenderer->FillRect2(
-      0,
+      pRenderer->uTargetBMask | pRenderer->uTargetGMask);
+    pRenderer->FillRectFast(
       v106.uViewportX,
       v106.uViewportY,
       v106.uViewportZ - v106.uViewportX,
       v106.uViewportW - v106.uViewportY,
-      LOWORD(pRenderer->uTargetBMask) | LOWORD(pRenderer->uTargetGMask));
+      pRenderer->uTargetBMask | pRenderer->uTargetGMask);
     v84.left = v106.uViewportX;
     v84.top = v106.uViewportY;
     v84.right = v106.uViewportZ;
@@ -3269,8 +3267,7 @@
   }
   else
   {
-    pRenderer->FillRect2(
-      0,
+    pRenderer->FillRectFast(
       v106.uViewportX,
       v106.uViewportY,
       v106.uViewportZ - v106.uViewportX,
@@ -6394,13 +6391,13 @@
 {
   BLVFace *v1; // ebx@1
   Vec3_short_ *v2; // esi@1
-  int v3; // ST28_4@1
+  //int v3; // ST28_4@1
   __int16 v4; // ST2C_2@1
-  signed int v5; // esi@1
-  Vec3_short_ *v6; // eax@4
-  signed int v7; // edi@5
-  signed int v8; // eax@5
-  signed int i_; // ecx@10
+  //signed int v5; // esi@1
+  //Vec3_short_ *v6; // eax@4
+  //signed int v7; // edi@5
+  //signed int v8; // eax@5
+  //signed int i_; // ecx@10
   int v10; // eax@10
   int v11; // edx@11
   int v12; // ST28_4@12
@@ -6417,64 +6414,65 @@
   int v23; // edi@21
   int v24; // eax@21
   int v25; // eax@22
-  signed int v26; // ST30_4@24
-  signed __int64 v27; // qtt@24
-  int v28; // ST18_4@25
-  int v29; // eax@26
-  int v30; // eax@27
-  signed int v31; // ST30_4@29
-  signed __int64 v32; // qtt@29
-  int v33; // ST30_4@30
-  signed int v34; // edi@31
-  unsigned int v35; // eax@31
-  bool v36; // edx@31
-  int v37; // ecx@31
-  int v38; // ecx@32
-  int v39; // esi@32
-  int v40; // eax@34
-  signed int v41; // ebx@41
-  unsigned int v42; // eax@41
-  signed int v43; // ecx@42
-  int v44; // esi@42
-  int v45; // eax@44
-  signed int v46; // edi@51
-  unsigned int v47; // eax@51
-  bool v48; // edx@51
-  int v49; // ecx@51
-  int v50; // ecx@52
-  signed int v51; // esi@52
-  int v52; // eax@54
-  int v53; // ebx@61
-  unsigned int v54; // eax@61
-  signed int v55; // ecx@62
-  int v56; // esi@62
-  int v57; // eax@64
-  char v59; // zf@72
-  signed int v60; // edx@75
-  int v61; // ecx@76
-  int v62; // esi@76
-  int v63; // ecx@83
-  signed int v64; // [sp+14h] [bp-14h]@3
-  int v65; // [sp+14h] [bp-14h]@34
-  int v66; // [sp+14h] [bp-14h]@44
-  int v67; // [sp+14h] [bp-14h]@54
-  int v68; // [sp+14h] [bp-14h]@64
-  signed int v69; // [sp+14h] [bp-14h]@75
-  IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1
+  int v26; // eax@22
+  signed int v27; // ST30_4@24
+  signed __int64 v28; // qtt@24
+  int v29; // ST18_4@25
+  int v30; // eax@26
+  int v31; // eax@27
+  int v32; // eax@27
+  signed int v33; // ST30_4@29
+  signed __int64 v34; // qtt@29
+  int v35; // ST30_4@30
+  signed int v36; // edi@31
+  unsigned int v37; // eax@31
+  bool v38; // edx@31
+  int v39; // ecx@31
+  int v40; // ecx@32
+  int v41; // esi@32
+  int v42; // eax@34
+  signed int v43; // ebx@41
+  unsigned int v44; // eax@41
+  signed int v45; // ecx@42
+  int v46; // esi@42
+  int v47; // eax@44
+  signed int v48; // edi@51
+  unsigned int v49; // eax@51
+  bool v50; // edx@51
+  int v51; // ecx@51
+  int v52; // ecx@52
+  signed int v53; // esi@52
+  int v54; // eax@54
+  int v55; // ebx@61
+  unsigned int v56; // eax@61
+  signed int v57; // ecx@62
+  int v58; // esi@62
+  int v59; // eax@64
+  char v61; // zf@72
+  signed int v62; // edx@75
+  int v63; // ecx@76
+  int v64; // esi@76
+  int v65; // ecx@83
+  //signed int v66; // [sp+14h] [bp-14h]@3
+  int v67; // [sp+14h] [bp-14h]@34
+  int v68; // [sp+14h] [bp-14h]@44
+  int v69; // [sp+14h] [bp-14h]@54
+  int v70; // [sp+14h] [bp-14h]@64
+  signed int v71; // [sp+14h] [bp-14h]@75
   bool thisa; // [sp+18h] [bp-10h]@9
   int thisb; // [sp+18h] [bp-10h]@12
   int thisc; // [sp+18h] [bp-10h]@20
   bool thisd; // [sp+18h] [bp-10h]@41
   bool thise; // [sp+18h] [bp-10h]@61
   int thisf; // [sp+18h] [bp-10h]@74
-  signed int v77; // [sp+1Ch] [bp-Ch]@9
-  int v78; // [sp+1Ch] [bp-Ch]@76
-  bool v79; // [sp+20h] [bp-8h]@10
-  bool v80; // [sp+20h] [bp-8h]@32
-  bool v81; // [sp+20h] [bp-8h]@42
-  bool v82; // [sp+20h] [bp-8h]@52
-  bool v83; // [sp+20h] [bp-8h]@62
-  signed int i; // [sp+24h] [bp-4h]@9
+  signed int v79; // [sp+1Ch] [bp-Ch]@9
+  int v80; // [sp+1Ch] [bp-Ch]@76
+  bool v81; // [sp+20h] [bp-8h]@10
+  bool v82; // [sp+20h] [bp-8h]@32
+  bool v83; // [sp+20h] [bp-8h]@42
+  bool v84; // [sp+20h] [bp-8h]@52
+  bool v85; // [sp+20h] [bp-8h]@62
+  //signed int i; // [sp+24h] [bp-4h]@9
   signed int ia; // [sp+24h] [bp-4h]@19
   signed int ib; // [sp+24h] [bp-4h]@31
   signed int ic; // [sp+24h] [bp-4h]@41
@@ -6482,13 +6480,13 @@
   signed int ie; // [sp+24h] [bp-4h]@61
 
   v1 = &pIndoor->pFaces[uFaceID];
-  _this = pGame->pIndoorCameraD3D;
+  //this = pGame->pIndoorCameraD3D;
   v2 = &pIndoor->pVertices[*v1->pVertexIDs];
-  v3 = *(int *)&v2->x;
+  //v3 = *(_DWORD *)&v2->x;
   v4 = v2->z;
-  v5 = 0;
-  if ( v1->pFacePlane_old.vNormal.x * ((signed __int16)v3 - pBLVRenderParams->vPartyPos.x)
-     + v1->pFacePlane_old.vNormal.y * (SHIWORD(v3) - pBLVRenderParams->vPartyPos.y)
+  //v5 = 0;
+  if ( v1->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
+     + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
      + v1->pFacePlane_old.vNormal.z * (v4 - pBLVRenderParams->vPartyPos.z) < 0 )
   {
     dword_50B700 = 1;
@@ -6499,110 +6497,103 @@
     if ( !(v1->uAttributes & 1) )
       return 0;
   }
-  v64 = v1->uNumVertices;
-  if ( (signed int)v1->uNumVertices > 0 )
-  {
-    do
-    {
-      v6 = &pIndoor->pVertices[v1->pVertexIDs[v5]];
-      _this->ApplyViewTransform_TrueIfStillVisible(
+  //v66 = v1->uNumVertices;
+  for (uint i = 0; i < v1->uNumVertices; ++i)
+  {
+      auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
+      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
         v6->x,
         v6->y,
         v6->z,
-        &_50B924_view_transformed_xs[v5],
-        &_50B834_view_transformed_zs[v5],
-        &_50B744_view_transformed_ys[v5],
+        &_50B924_view_transformed_xs[i],
+        &_50B834_view_transformed_zs[i],
+        &_50B744_view_transformed_ys[i],
         0);
-      ++v5;
-    }
-    while ( v5 < v64 );
-  }
-  v7 = v64;
-  v8 = 0;
-  if ( v64 <= 0 )
+  }
+
+  //v7 = v1->uNumVertices;
+  //v8 = 0;
+  if (v1->uNumVertices <= 0)
     return 0;
-  do
-  {
-    if ( _50B924_view_transformed_xs[v8] >= 524288 )
+
+  bool bFound = false;
+  for (uint i = 0; i < v1->uNumVertices; ++i)
+    if (_50B924_view_transformed_xs[i] >= 0x80000u)
+    {
+      bFound = true;
       break;
-    ++v8;
-  }
-  while ( v8 < v64 );
-  if ( v8 >= v64 )
+    }
+  if (!bFound)
     return 0;
-  v77 = 0;
-  _50B924_view_transformed_xs[v64] = _50B924_view_transformed_xs[0];
-  _50B834_view_transformed_zs[v64] = _50B834_view_transformed_zs[0];
-  _50B744_view_transformed_ys[v64] = _50B744_view_transformed_ys[0];
-  thisa = _50B924_view_transformed_xs[0] >= 524288;
-  i = 1;
-  if ( v64 >= 1 )
-  {
-    do
-    {
-      i_ = i;
+
+  v79 = 0;
+  _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
+  _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
+  _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
+  thisa = _50B924_view_transformed_xs[0] >= 0x80000u;
+  //int i = 1;
+  for (uint i = 1; i < v1->uNumVertices; ++i)
+  {
       v10 = _50B924_view_transformed_xs[i];
-      v79 = v10 >= 524288;
-      if ( thisa ^ v79 )
-      {
-        v11 = _50B924_view_transformed_xs_minus1[i_];
-        if ( v10 >= 524288 )
+      v81 = v10 >= (signed int)0x80000u;
+      if ( thisa ^ v81 )
+      {
+        v11 = _50B924_view_transformed_xs[i - 1];
+        if ( v10 >= (signed int)0x80000u )
         {
           v12 = v10 - v11;
-          v13 = 524288 - v11;
+          v13 = 0x80000 - v11;
           LODWORD(v14) = v13 << 16;
           HIDWORD(v14) = v13 >> 16;
-          v15 = &_50B744_view_transformed_ys_minus1[i_];
-          dword_50B828[v77] = ((unsigned __int64)((_50B834_view_transformed_zs[i_] - _50B834_view_transformed_zs_minus1[i_])
+          v15 = &_50B744_view_transformed_ys[i - 1];
+          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i] - _50B834_view_transformed_zs[i - 1])
                                                 * v14
                                                 / v12) >> 16)
-                            + _50B834_view_transformed_zs_minus1[i_];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i_] - _50B744_view_transformed_ys_minus1[i_]) * v14 / v12) >> 16;
+                            + _50B834_view_transformed_zs[i - 1];
+          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
         }
         else
         {
           v16 = v11 - v10;
-          v17 = 524288 - v10;
+          v17 = 0x80000 - v10;
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
-          v15 = &_50B744_view_transformed_ys[i_];
-          dword_50B828[v77] = ((unsigned __int64)((_50B834_view_transformed_zs_minus1[i_] - _50B834_view_transformed_zs[i_])
+          v15 = &_50B744_view_transformed_ys[i];
+          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i])
                                                 * v18
                                                 / v16) >> 16)
-                            + _50B834_view_transformed_zs[i_];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys_minus1[i_] - _50B744_view_transformed_ys[i_]) * v18 / v16) >> 16;
+                            + _50B834_view_transformed_zs[i];
+          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
         }
-        v19 = v77++;
-        v7 = v64;
+        v19 = v79++;
+        //v7 = v66;
         dword_50B738[v19] = thisb + *v15;
-        dword_50B918[v19] = 524288;
-      }
-      if ( v79 )
-      {
-        v20 = v77++;
-        dword_50B918[v20] = _50B924_view_transformed_xs[i_];
-        dword_50B828[v20] = _50B834_view_transformed_zs[i_];
-        dword_50B738[v20] = _50B744_view_transformed_ys[i_];
-      }
-      ++i;
-      thisa = v79;
-    }
-    while ( i <= v7 );
+        dword_50B918[v19] = 0x80000u;
+      }
+      if ( v81 )
+      {
+        v20 = v79++;
+        dword_50B918[v20] = _50B924_view_transformed_xs[i];
+        dword_50B828[v20] = _50B834_view_transformed_zs[i];
+        dword_50B738[v20] = _50B744_view_transformed_ys[i];
+      }
+      //++i;
+      thisa = v81;
   }
   ia = 0;
-  v21 = v77;
-  dword_50B918[v77] = dword_50B918[0];
-  dword_50B828[v77] = dword_50B828[0];
-  for ( dword_50B738[v77] = dword_50B738[0]; ia < v77; dword_50BA08[v22] = pBLVRenderParams->uViewportCenterY - v33 )
+  v21 = v79;
+  dword_50B918[v79] = dword_50B918[0];
+  dword_50B828[v79] = dword_50B828[0];
+  for ( dword_50B738[v79] = dword_50B738[0]; ia < v79; dword_50BA08[v22] = pBLVRenderParams->uViewportCenterY - v35 )
   {
     v22 = ia;
     thisc = abs(dword_50B918[ia]);
     if ( abs(dword_50B828[ia]) >> 13 <= thisc )
     {
-      v26 = dword_50B828[v22];
-      LODWORD(v27) = v26 << 16;
-      HIDWORD(v27) = v26 >> 16;
-      v25 = v27 / dword_50B918[v22];
+      v27 = dword_50B828[v22];
+      LODWORD(v28) = v27 << 16;
+      HIDWORD(v28) = v27 >> 16;
+      v26 = v28 / dword_50B918[v22];
       v23 = 0;
     }
     else
@@ -6612,272 +6603,277 @@
       if ( dword_50B828[v22] >= 0 )
       {
         LOBYTE(v24) = dword_50B918[v22] >= 0;
-        v25 = ((v24 - 1) & 0xFF800000) + 0x400000;
+        v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
         LOBYTE(v24) = dword_50B918[v22] >= 0;
-        v25 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & (v24 - 1)) - 4194304;
-      }
-    }
-    v28 = dword_50B738[v22];
-    dword_50BAF8_xs[v22] = v25;
-    if ( abs(v28) >> 13 <= thisc )
-    {
-      v31 = dword_50B738[v22];
-      LODWORD(v32) = v31 << 16;
-      HIDWORD(v32) = v31 >> 16;
-      v30 = v32 / dword_50B918[v22];
+        v25 = v24 - 1;
+        v26 = (v25 & 0x800000) - 0x400000;
+      }
+    }
+    v29 = dword_50B738[v22];
+    dword_50BAF4_xs[v22 + 1] = v26;
+    if ( abs(v29) >> 13 <= thisc )
+    {
+      v33 = dword_50B738[v22];
+      LODWORD(v34) = v33 << 16;
+      HIDWORD(v34) = v33 >> 16;
+      v32 = v34 / dword_50B918[v22];
     }
     else
     {
-      v29 = 0;
+      v30 = 0;
       if ( dword_50B738[v22] >= v23 )
       {
-        LOBYTE(v29) = dword_50B918[v22] >= v23;
-        v30 = ((v29 - 1) & 0xFF800000) + 4194304;
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v29) = dword_50B918[v22] >= v23;
-        v30 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & (v29 - 1)) - 4194304;
-      }
-    }
-    dword_50BA08[v22] = v30;
-    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
-    v33 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08[v22]) >> 16;
-    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        v31 = v30 - 1;
+        v32 = (v31 & 0x800000) - 0x400000;
+      }
+    }
+    dword_50BA08[v22] = v32;
+    dword_50BAF4_xs[v22 + 1] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
+                                                * (signed __int64)dword_50BAF4_xs[v22 + 1]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08[v22]) >> 16;
+    dword_50BAF4_xs[v22 + 1] = pBLVRenderParams->uViewportCenterX - dword_50BAF4_xs[v22 + 1];
     ++ia;
   }
-  v34 = 0;
-  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
+  v36 = 0;
+  dword_50BAF4_xs[v21 + 1] = dword_50BAF4_xs[1];
   dword_50BA08[v21] = dword_50BA08[0];
-  v35 = pBLVRenderParams->uViewportX;
-  v36 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v36) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
-  v37 = 1;
+  v37 = pBLVRenderParams->uViewportX;
+  v38 = dword_50BAF4_xs[1] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = dword_50BAF4_xs[1] >= (signed int)pBLVRenderParams->uViewportX;
+  v39 = 1;
   ib = 1;
-  if ( v77 < 1 )
+  if ( v79 < 1 )
     return 0;
   do
   {
-    v38 = v37;
-    v39 = dword_50BAF8_xs[v38];
-    v80 = v39 >= (signed int)v35;
-    if ( v36 ^ v80 )
-    {
-      if ( v39 >= (signed int)v35 )
-      {
-        v65 = (signed int)(v35 - dword_50BAF4[v38])
-            * (signed __int64)(dword_50BA08[v38] - dword_50B9F8[v38 + 3])
-            / (v39 - dword_50BAF4[v38]);
-        v40 = dword_50B9F8[v38 + 3];
+    v40 = v39;
+    v41 = dword_50BAF4_xs[v40 + 1];
+    v82 = v41 >= (signed int)v37;
+    if ( v38 ^ v82 )
+    {
+      if ( v41 >= (signed int)v37 )
+      {
+        v67 = (signed int)(v37 - dword_50BAF4_xs[v40])
+            * (signed __int64)(dword_50BA08[v40] - dword_50B9F8[v40 + 3])
+            / (v41 - dword_50BAF4_xs[v40]);
+        v42 = dword_50B9F8[v40 + 3];
       }
       else
       {
-        v65 = (signed int)(v35 - v39)
-            * (signed __int64)(dword_50B9F8[v38 + 3] - dword_50BA08[v38])
-            / (dword_50BAF4[v38] - v39);
-        v40 = dword_50BA08[v38];
-      }
-      ++v34;
-      dword_50B9F8[v34] = v65 + v40;
-      v35 = pBLVRenderParams->uViewportX;
-      dword_50BAE8[v34] = pBLVRenderParams->uViewportX;
-    }
-    v36 = v80;
-    if ( v80 )
-    {
-      dword_50BAEC_xs[v34] = dword_50BAF8_xs[v38];
-      dword_50B9F8[v34++ + 1] = dword_50BA08[v38];
-    }
-    v37 = ib++ + 1;
-  }
-  while ( ib <= v77 );
-  if ( !v34
-    || (v41 = 0,
-        dword_50BAEC_xs[v34] = dword_50BAEC_xs[0],
-        dword_50B9F8[v34 + 1] = dword_50B9F8[1],
-        v42 = pBLVRenderParams->uViewportZ,
-        thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ,
+        v67 = (signed int)(v37 - v41)
+            * (signed __int64)(dword_50B9F8[v40 + 3] - dword_50BA08[v40])
+            / (dword_50BAF4_xs[v40] - v41);
+        v42 = dword_50BA08[v40];
+      }
+      ++v36;
+      dword_50B9F8[v36] = v67 + v42;
+      v37 = pBLVRenderParams->uViewportX;
+      dword_50BAE8_xs[v36] = pBLVRenderParams->uViewportX;
+    }
+    v38 = v82;
+    if ( v82 )
+    {
+      dword_50BAE8_xs[v36 + 1] = dword_50BAF4_xs[v40 + 1];
+      dword_50B9F8[v36++ + 1] = dword_50BA08[v40];
+    }
+    v39 = ib++ + 1;
+  }
+  while ( ib <= v79 );
+
+  if ( !v36
+    || (v43 = 0,
+        dword_50BAE8_xs[v36 + 1] = dword_50BAE8_xs[1],
+        dword_50B9F8[v36 + 1] = dword_50B9F8[1],
+        v44 = pBLVRenderParams->uViewportZ,
+        thisd = dword_50BAE8_xs[1] <= (signed int)pBLVRenderParams->uViewportZ,
         ic = 1,
-        v34 < 1) )
+        v36 < 1) )
     return 0;
+
   do
   {
-    v43 = ic;
-    v44 = dword_50BAEC_xs[ic];
-    v81 = v44 <= (signed int)v42;
-    if ( thisd ^ v81 )
-    {
-      if ( v44 <= (signed int)v42 )
-      {
-        v66 = (signed int)(v42 - dword_50BAE8[v43])
-            * (signed __int64)(dword_50B9F8[v43 + 1] - dword_50B9F8[v43])
-            / (v44 - dword_50BAE8[v43]);
-        v45 = dword_50B9F8[v43];
+    v45 = ic;
+    v46 = dword_50BAE8_xs[ic + 1];
+    v83 = v46 <= (signed int)v44;
+    if ( thisd ^ v83 )
+    {
+      if ( v46 <= (signed int)v44 )
+      {
+        v68 = (signed int)(v44 - dword_50BAE8_xs[v45])
+            * (signed __int64)(dword_50B9F8[v45 + 1] - dword_50B9F8[v45])
+            / (v46 - dword_50BAE8_xs[v45]);
+        v47 = dword_50B9F8[v45];
       }
       else
       {
-        v66 = (signed int)(v42 - v44)
-            * (signed __int64)(dword_50B9F8[v43] - dword_50B9F8[v43 + 1])
-            / (dword_50BAE8[v43] - v44);
-        v45 = dword_50B9F8[v43 + 1];
-      }
-      ++v41;
-      dword_50B9EC[v41] = v66 + v45;
-      v42 = pBLVRenderParams->uViewportZ;
-      dword_50BADC_xs[v41] = pBLVRenderParams->uViewportZ;
-    }
-    if ( v81 )
-    {
-      dword_50BAE0[v41] = dword_50BAEC_xs[v43];
-      dword_50B9F0[v41++] = dword_50B9F8[v43 + 1];
+        v68 = (signed int)(v44 - v46)
+            * (signed __int64)(dword_50B9F8[v45] - dword_50B9F8[v45 + 1])
+            / (dword_50BAE8_xs[v45] - v46);
+        v47 = dword_50B9F8[v45 + 1];
+      }
+      ++v43;
+      dword_50B9EC[v43] = v68 + v47;
+      v44 = pBLVRenderParams->uViewportZ;
+      dword_50BADC_xs[v43] = pBLVRenderParams->uViewportZ;
+    }
+    if ( v83 )
+    {
+      dword_50BAE0[v43] = dword_50BAE8_xs[v45 + 1];
+      dword_50B9F0[v43++] = dword_50B9F8[v45 + 1];
     }
     ++ic;
-    thisd = v81;
-  }
-  while ( ic <= v34 );
-  if ( !v41
-    || (v46 = 0,
-        dword_50BAE0[v41] = dword_50BAE0[0],
-        dword_50B9F0[v41] = dword_50B9F0[0],
-        v47 = pBLVRenderParams->uViewportY,
-        v48 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY,
-        LOBYTE(v48) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY,
-        v49 = 1,
+    thisd = v83;
+  }
+  while ( ic <= v36 );
+  if ( !v43
+    || (v48 = 0,
+        dword_50BAE0[v43] = dword_50BAE0[0],
+        dword_50B9F0[v43] = dword_50B9F0[0],
+        v49 = pBLVRenderParams->uViewportY,
+        v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY,
+        LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY,
+        v51 = 1,
         id = 1,
-        v41 < 1) )
+        v43 < 1) )
     return 0;
   do
   {
-    v50 = v49;
-    v51 = dword_50B9F0[v50];
-    v82 = v51 >= (signed int)v47;
-    if ( v48 ^ v82 )
-    {
-      if ( v51 >= (signed int)v47 )
-      {
-        v67 = (signed int)(v47 - dword_50B9EC[v50])
-            * (signed __int64)(dword_50BAE0[v50] - dword_50BADC_xs[v50])
-            / (v51 - dword_50B9EC[v50]);
-        v52 = dword_50BADC_xs[v50];
+    v52 = v51;
+    v53 = dword_50B9F0[v52];
+    v84 = v53 >= (signed int)v49;
+    if ( v50 ^ v84 )
+    {
+      if ( v53 >= (signed int)v49 )
+      {
+        v69 = (signed int)(v49 - dword_50B9EC[v52])
+            * (signed __int64)(dword_50BAE0[v52] - dword_50BADC_xs[v52])
+            / (v53 - dword_50B9EC[v52]);
+        v54 = dword_50BADC_xs[v52];
       }
       else
       {
-        v67 = (signed int)(v47 - v51)
-            * (signed __int64)(dword_50BADC_xs[v50] - dword_50BAE0[v50])
-            / (dword_50B9EC[v50] - v51);
-        v52 = dword_50BAE0[v50];
-      }
-      ++v46;
-      dword_50BAD0[v46] = v67 + v52;
-      v47 = pBLVRenderParams->uViewportY;
-      dword_50B9E0_ys[v46] = pBLVRenderParams->uViewportY;
-    }
-    v48 = v82;
-    if ( v82 )
-    {
-      dword_50BAD4[v46] = dword_50BAE0[v50];
-      dword_50B9E0_ys[v46++ + 1] = dword_50B9F0[v50];
-    }
-    v49 = id++ + 1;
-  }
-  while ( id <= v41 );
-  if ( !v46
-    || (v53 = 0,
-        dword_50BAD4[v46] = dword_50BAD4[0],
-        dword_50B9E0_ys[v46 + 1] = dword_50B9E0_ys[1],
-        v54 = pBLVRenderParams->uViewportW,
+        v69 = (signed int)(v49 - v53)
+            * (signed __int64)(dword_50BADC_xs[v52] - dword_50BAE0[v52])
+            / (dword_50B9EC[v52] - v53);
+        v54 = dword_50BAE0[v52];
+      }
+      ++v48;
+      dword_50BAD0[v48] = v69 + v54;
+      v49 = pBLVRenderParams->uViewportY;
+      dword_50B9E0_ys[v48] = pBLVRenderParams->uViewportY;
+    }
+    v50 = v84;
+    if ( v84 )
+    {
+      dword_50BAD4[v48] = dword_50BAE0[v52];
+      dword_50B9E0_ys[v48++ + 1] = dword_50B9F0[v52];
+    }
+    v51 = id++ + 1;
+  }
+  while ( id <= v43 );
+  if ( !v48
+    || (v55 = 0,
+        dword_50BAD4[v48] = dword_50BAD4[0],
+        dword_50B9E0_ys[v48 + 1] = dword_50B9E0_ys[1],
+        v56 = pBLVRenderParams->uViewportW,
         thise = dword_50B9E0_ys[1] <= (signed int)pBLVRenderParams->uViewportW,
         ie = 1,
-        v46 < 1) )
+        v48 < 1) )
     return 0;
   do
   {
-    v55 = ie;
-    v56 = dword_50B9E0_ys[ie + 1];
-    v83 = v56 <= (signed int)v54;
-    if ( thise ^ v83 )
-    {
-      if ( v56 <= (signed int)v54 )
-      {
-        v68 = (signed int)(v54 - dword_50B9E0_ys[v55])
-            * (signed __int64)(dword_50BAD4[v55] - dword_50BAD0[v55])
-            / (v56 - dword_50B9E0_ys[v55]);
-        v57 = dword_50BAD0[v55];
+    v57 = ie;
+    v58 = dword_50B9E0_ys[ie + 1];
+    v85 = v58 <= (signed int)v56;
+    if ( thise ^ v85 )
+    {
+      if ( v58 <= (signed int)v56 )
+      {
+        v70 = (signed int)(v56 - dword_50B9E0_ys[v57])
+            * (signed __int64)(dword_50BAD4[v57] - dword_50BAD0[v57])
+            / (v58 - dword_50B9E0_ys[v57]);
+        v59 = dword_50BAD0[v57];
       }
       else
       {
-        v68 = (signed int)(v54 - v56)
-            * (signed __int64)(dword_50BAD0[v55] - dword_50BAD4[v55])
-            / (dword_50B9E0_ys[v55] - v56);
-        v57 = dword_50BAD4[v55];
-      }
-      ++v53;
-      dword_50BAC4[v53] = v68 + v57;
-      v54 = pBLVRenderParams->uViewportW;
-      unk_50B9D4[v53] = pBLVRenderParams->uViewportW;
-    }
-    if ( v83 )
-    {
-      dword_50BAC8[v53] = dword_50BAD4[v55];
-      dword_50B9D8_ys[v53++] = dword_50B9E0_ys[v55 + 1];
+        v70 = (signed int)(v56 - v58)
+            * (signed __int64)(dword_50BAD0[v57] - dword_50BAD4[v57])
+            / (dword_50B9E0_ys[v57] - v58);
+        v59 = dword_50BAD4[v57];
+      }
+      ++v55;
+      dword_50BAC4[v55] = v70 + v59;
+      v56 = pBLVRenderParams->uViewportW;
+      unk_50B9D4[v55] = pBLVRenderParams->uViewportW;
+    }
+    if ( v85 )
+    {
+      dword_50BAC8[v55] = dword_50BAD4[v57];
+      dword_50B9D8_ys[v55++] = dword_50B9E0_ys[v57 + 1];
     }
     ++ie;
-    thise = v83;
-  }
-  while ( ie <= v46 );
-  if ( !v53 )
+    thise = v85;
+  }
+  while ( ie <= v48 );
+  if ( !v55 )
     return 0;
-  v59 = pRenderer->pRenderD3D == 0;
-  dword_50BAC8[v53] = dword_50BAC8[0];
-  dword_50B9D8_ys[v53] = dword_50B9D8_ys[0];
-  if ( v59 && v53 > 3 )
-  {
-    dword_50BAC8[v53 + 1] = dword_50BAC8[1];
-    dword_50B9D8_ys[v53 + 1] = dword_50B9D8_ys[1];
+  v61 = pRenderer->pRenderD3D == 0;
+  dword_50BAC8[v55] = dword_50BAC8[0];
+  dword_50B9D8_ys[v55] = dword_50B9D8_ys[0];
+  if ( v61 && v55 > 3 )
+  {
+    dword_50BAC8[v55 + 1] = dword_50BAC8[1];
+    dword_50B9D8_ys[v55 + 1] = dword_50B9D8_ys[1];
     thisf = 2 * (dword_50B700 != 0) - 1;
-    if ( v53 > 0 )
-    {
-      v60 = 1;
-      v69 = 1;
+    if ( v55 > 0 )
+    {
+      v62 = 1;
+      v71 = 1;
       do
       {
-        v61 = v60 - 1;
-        v62 = v60 + 1;
-        v78 = v60 + 1;
-        if ( v60 - 1 >= v53 )
-          v61 -= v53;
-        if ( v60 >= v53 )
-          v60 -= v53;
-        if ( v62 >= v53 )
-          v62 -= v53;
+        v63 = v62 - 1;
+        v64 = v62 + 1;
+        v80 = v62 + 1;
+        if ( v62 - 1 >= v55 )
+          v63 -= v55;
+        if ( v62 >= v55 )
+          v62 -= v55;
+        if ( v64 >= v55 )
+          v64 -= v55;
         if ( thisf
-           * ((dword_50B9D8_ys[v62] - dword_50B9D8_ys[v61]) * (dword_50BAC8[v60] - dword_50BAC8[v61])
-            - (dword_50B9D8_ys[v60] - dword_50B9D8_ys[v61]) * (dword_50BAC8[v62] - dword_50BAC8[v61])) < 0 )
+           * ((dword_50B9D8_ys[v64] - dword_50B9D8_ys[v63]) * (dword_50BAC8[v62] - dword_50BAC8[v63])
+            - (dword_50B9D8_ys[v62] - dword_50B9D8_ys[v63]) * (dword_50BAC8[v64] - dword_50BAC8[v63])) < 0 )
         {
-          v60 = v78;
-          v69 = v78;
+          v62 = v80;
+          v71 = v80;
         }
         else
         {
-          v60 = v69;
-          v63 = v69;
-          if ( v69 < v53 || (v63 = v69 - v53, v69 - v53 < v53) )
+          v62 = v71;
+          v65 = v71;
+          if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
           {
-            memcpy(&dword_50B9D8_ys[v63], &dword_50B9D8_ys[v63 + 1], 4 * ((unsigned int)(4 * (v53 - v63)) >> 2));
-            memcpy(&dword_50BAC8[v63], &dword_50BAC8[v63 + 1], 4 * ((unsigned int)(4 * (v53 - v63)) >> 2));
+            memcpy(&dword_50B9D8_ys[v65], &dword_50B9D8_ys[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&dword_50BAC8[v65], &dword_50BAC8[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
           }
-          --v53;
+          --v55;
         }
       }
-      while ( v60 - 1 < v53 );
-    }
-    dword_50BAC8[v53] = dword_50BAC8[0];
-    dword_50B9D8_ys[v53] = dword_50B9D8_ys[0];
-  }
-  return v53;
+      while ( v62 - 1 < v55 );
+    }
+    dword_50BAC8[v55] = dword_50BAC8[0];
+    dword_50B9D8_ys[v55] = dword_50B9D8_ys[0];
+  }
+  return v55;
 }
 
 
--- a/mm7_2.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_2.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -3450,13 +3450,12 @@
   pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
   pRenderer->BeginScene();
   if ( pRenderer->pRenderD3D )
-    pRenderer->FillRect2(
-      1,
+    pRenderer->FillRectFast(
       pViewport->uViewportX,
       pViewport->uViewportY,
       pViewport->uViewportZ - pViewport->uViewportX,
       pViewport->uViewportW - pViewport->uViewportY + 1,
-      LOWORD(pRenderer->uTargetGMask) | LOWORD(pRenderer->uTargetBMask));
+      pRenderer->uTargetGMask | pRenderer->uTargetBMask);
 
   auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
   pRenderer->_4A6A68(
@@ -13087,8 +13086,8 @@
   char *v3; // eax@1
   //char *v4; // eax@1
   unsigned int v5; // eax@3
-  size_t v6; // ecx@10
-  char *v7; // eax@11
+  //size_t v6; // ecx@10
+  //char *v7; // eax@11
   char Str1[20]; // [sp+Ch] [bp-18h]@1
   unsigned int v9; // [sp+20h] [bp-4h]@1
 
@@ -13128,20 +13127,13 @@
   sub_461103();
   if ( !_strcmpi(pCurrentMapName, "d11.blv") || !_strcmpi(pCurrentMapName, "d10.blv") )
   {
-    __debugbreak();
-    v6 = uNumActors;
-    if ( (signed int)uNumActors > 0 )
-    {
-      v7 = (char *)&pActors[0].pMonsterInfo.uTreasureType;
-      do
-      {
-        *v7 = 0;
-        *(v7 - 3) = 0;
-        *(int *)(v7 + 59) = 0;
-        v7 += 836;
-        --v6;
-      }
-      while ( v6 );
+    //spawning grounds & good analogue - no loot & exp from monsters
+
+    for (uint i = 0; i < uNumActors; ++i)
+    {
+      pActors[i].pMonsterInfo.uTreasureType = 0;
+      pActors[i].pMonsterInfo.uTreasureDiceRolls = 0;
+      pActors[i].pMonsterInfo.uExp = 0;
     }
   }
   bDialogueUI_InitializeActor_NPC_ID = 0;
--- a/mm7_3.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_3.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -4733,6 +4733,7 @@
 }
 
 //----- (00476395) --------------------------------------------------------
+//0x26 Wizard eye at skill level 2
 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
 {
   bool result; // eax@2
@@ -7032,7 +7033,7 @@
             &static_RenderBuildingsD3D_stru_73C834,
             uNumVertices,
             array_50AC10,
-            0.0,
+            0,
             (char)v31);
         if ( v50 )
         {
@@ -12921,7 +12922,7 @@
     pStru170->std__vector_000FA8 = 1;
     sub_440639(0);
   }
-  pStru170->RenderWalls();
+  pStru170->MakeVisibleSectorList();
 }
 
 //----- (0043F9E1) --------------------------------------------------------
@@ -13297,7 +13298,10 @@
     if ( v3->uNumNonBSPFaces > 0 )
     {
       do
-        pStru170->_4B0EA8(v1, v3->pFaceIDs[v2++]);
+      {
+        Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]);
+        pStru170->PrepareFaceRenderList_d3d(v1, v3->pFaceIDs[v2++]);
+      }
       while ( v2 < v3->uNumNonBSPFaces );
     }
   }
@@ -13306,7 +13310,7 @@
     if ( v3->uNumNonBSPFaces > 0 )
     {
       do
-        pStru170->_4AFB86(v1, v3->pFaceIDs[v2++]);
+        pStru170->PrepareFaceRenderList_sw(v1, v3->pFaceIDs[v2++]);
       while ( v2 < v3->uNumNonBSPFaces );
     }
   }
@@ -13329,6 +13333,8 @@
   bool v11; // [sp+14h] [bp-8h]@5
   stru170_stru0 *v12; // [sp+18h] [bp-4h]@1
 
+  Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode);
+
   v10 = a1;
   v12 = &pStru170->field_FA8[a1];
   while ( 1 )
@@ -13351,15 +13357,18 @@
       sub_4406BC(v10, v6);
     v7 = v3->uCoplanarOffset;
     v8 = v7 + v3->uCoplanarSize;
+
+    Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]);
+    
     if ( pRenderer->pRenderD3D )
     {
       while ( v7 < v8 )
-        pStru170->_4B0EA8(v10, v2->pFaceIDs[v7++]);
+        pStru170->PrepareFaceRenderList_d3d(v10, v2->pFaceIDs[v7++]);
     }
     else
     {
       while ( v7 < v8 )
-        pStru170->_4AFB86(v10, v2->pFaceIDs[v7++]);
+        pStru170->PrepareFaceRenderList_sw(v10, v2->pFaceIDs[v7++]);
     }
     v9 = v11 ? v3->uFront : v3->uBack;
     if ( v9 == -1 )
@@ -13481,12 +13490,11 @@
 {
   if ( uActiveCharacter )
     pRenderer->DrawTextureTransparent(
-      pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[uActiveCharacter] - 9,
+      pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9,
       0x17Cu,
       &pIcons_LOD->pTextures[dword_50C98C]);
 }
-// 4ED746: using guessed type __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[];
-// 50C98C: using guessed type int dword_50C98C;
+
 
 //----- (004415C5) --------------------------------------------------------
 void __cdecl Load_isn_spells_21_27()
@@ -13683,28 +13691,23 @@
 
 
 //----- (00441D38) --------------------------------------------------------
-void __fastcall GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags)
-{
-  int v6; // ebx@6
-  BLVFace *v7; // eax@8
-  unsigned int *v8; // edi@9
-  unsigned int v9; // edx@9
-  unsigned int v10; // ebx@10
+void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags)
+{
+  int uHeight; // ebx@6
+  //unsigned int v9; // edx@9
+  //unsigned int v10; // ebx@10
   __int16 v11; // cx@11
-  int v12; // ecx@17
-  unsigned int v13; // ecx@21
+  //BLVFace *v12; // ecx@17
+  //unsigned int v13; // ecx@21
   unsigned int v14; // ebx@23
   int v15; // eax@23
-  unsigned int *v16; // ecx@28
+  //unsigned int *v16; // ecx@28
   __int16 v17; // di@30
   double v18; // st7@30
   float v19; // ST38_4@30
   double v20; // st7@30
   double v21; // st6@30
   double v22; // st5@33
-  float v23; // ST3C_4@37
-  double v24; // ST20_8@37
-  double v25; // ST20_8@37
   unsigned __int16 *v26; // edx@37
   signed int v27; // eax@37
   unsigned __int16 *v28; // ecx@37
@@ -13754,30 +13757,23 @@
   signed int uBluea; // [sp+28h] [bp-2Ch]@37
   int v73; // [sp+2Ch] [bp-28h]@30
   unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
-  signed int v75; // [sp+34h] [bp-20h]@4
   int v76; // [sp+34h] [bp-20h]@91
   int v77; // [sp+34h] [bp-20h]@108
   signed int v78; // [sp+38h] [bp-1Ch]@37
   int v79; // [sp+38h] [bp-1Ch]@72
-  bool v80; // [sp+3Ch] [bp-18h]@2
-  unsigned int a2; // [sp+40h] [bp-14h]@1
-  int a2a; // [sp+40h] [bp-14h]@8
   signed int a2b; // [sp+40h] [bp-14h]@41
   char *a2c; // [sp+40h] [bp-14h]@68
-  unsigned int a3; // [sp+44h] [bp-10h]@1
   int a3a; // [sp+44h] [bp-10h]@40
-  signed int uHeight; // [sp+48h] [bp-Ch]@1
-  signed int uWidth; // [sp+4Ch] [bp-8h]@1
-  signed int uZa; // [sp+5Ch] [bp+8h]@7
+  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 uZc; // [sp+5Ch] [bp+8h]@30
+  signed int uWidth; // [sp+5Ch] [bp+8h]@30
   signed int uZd; // [sp+5Ch] [bp+8h]@45
   signed int uZe; // [sp+5Ch] [bp+8h]@67
   signed int uZf; // [sp+5Ch] [bp+8h]@85
   signed int uZg; // [sp+5Ch] [bp+8h]@105
   unsigned int uWa; // [sp+60h] [bp+Ch]@23
   float uWb; // [sp+60h] [bp+Ch]@30
-  float uWe; // [sp+60h] [bp+Ch]@37
   unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
   unsigned int uWd; // [sp+60h] [bp+Ch]@95
   float uZooma; // [sp+64h] [bp+10h]@117
@@ -13786,25 +13782,26 @@
   char *flagsc; // [sp+68h] [bp+14h]@86
   unsigned int flagsd; // [sp+68h] [bp+14h]@105
 
-  a3 = uY;
-  a2 = uX;
-  uWidth = (signed int)(uX + uZ) >> 1;
-  uHeight = (signed int)(uY + uW) >> 1;
+  //a3 = uY;
+  //a2 = uX;
+  uCenterX = (uX + uZ) / 2;
+  uCenterY = (uY + uW) / 2;
   lPitch = pRenderer->uTargetSurfacePitch;
   GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
   uBlue = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
-  v80 = (signed __int64)pParty->pPartyBuffs[19].uExpireTime > 0;
-  v75 = pParty->pPartyBuffs[19].uSkill;
-  if ( CheckHiredNPCSpeciality(0x26u) )
-  {
-    v80 = 1;
-    v75 = 2;
-  }
-  pRenderer->Clip_v2(a2, a3, uZ - 1, uW - 1);
-  v6 = uW - a3;
+  auto bWizardEyeActive = pParty->WizardEyeActive();
+  auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel();
+  if (CheckHiredNPCSpeciality(0x26u))
+  {
+    bWizardEyeActive = true;
+    uWizardEyeSkillLevel = 2;
+  }
+  pRenderer->Clip_v2(uX, uY, uZ - 1, uW - 1);
+  uHeight = uW - uY;
+  uWidth = uZ - uX;
+
   if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
   {
-    uZc = uZ - a2;
     v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
     v74 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
     v62 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
@@ -13816,54 +13813,54 @@
     uWb = v21;
     if ( uZoom == 512 )
     {
-      v20 = v20 - (double)(uZc / 2);
-      v22 = (double)(v6 / 2);
+      v20 = v20 - (double)(uWidth / 2);
+      v22 = (double)(uHeight / 2);
     }
     else
     {
       if ( uZoom == 1024 )
       {
-        v20 = v20 - (double)(uZc / 4);
-        v22 = (double)(v6 / 4);
+        v20 = v20 - (double)(uWidth / 4);
+        v22 = (double)(uHeight / 4);
       }
       else
       {
         if ( uZoom != 2048 )
           goto LABEL_37;
-        v20 = v20 - (double)(uZc / 8);
-        v22 = (double)(v6 / 8);
+        v20 = v20 - (double)(uWidth / 8);
+        v22 = (double)(uHeight / 8);
       }
     }
     uWb = v21 - v22;
 LABEL_37:
-    v23 = v20 * 65536.0;
-    v24 = v23 + 6.7553994e15;
-    v70 = LODWORD(v24);
-    uWe = uWb * 65536.0;
-    v25 = uWe + 6.7553994e15;
+    //v23 = v20 * 65536.0;
+    //v24 = v23 + 6.7553994e15;
+    v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
+    //uWe = uWb * 65536.0;
+    //v25 = uWe + 6.7553994e15;
     v78 = v70;
-    uBluea = LODWORD(v25);
+    uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
     v26 = (unsigned __int16 *)_56EFD8_minimap;
-    v27 = SLODWORD(v25) >> 16;
+    v27 = uBluea >> 16;
     uWc = (unsigned __int16 *)_56EFD8_minimap;
-    v28 = &pRenderer->pTargetSurface[a2 + a3 * lPitch];
+    v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
     if ( flags )
     {
       if ( v74 )
       {
         v64 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-        if ( v6 > 0 )
-        {
-          a3a = v6;
+        if ( uHeight > 0 )
+        {
+          a3a = uHeight;
           v29 = v70 >> 16;
           do
           {
             a2b = 0;
-            if ( uZc > 0 )
+            if ( uWidth > 0 )
             {
               v30 = (int)&v74[v27 * v64];
-              flagsa = uZc;
-              a2b = uZc;
+              flagsa = uWidth;
+              a2b = uWidth;
               do
               {
                 v31 = uWc;
@@ -13903,102 +13900,91 @@
     }
     while ( uZd );
     uNumBlueFacesInBLVMinimap = 0;
-    goto LABEL_50;
-  }
-  pRenderer->FillRect2(v6, a2, a3, uZ - a2, v6, 0xFu);
-  uNumBlueFacesInBLVMinimap = 0;
-  uZa = 0;
-  if ( (signed int)pIndoor->pMapVertices->uNumVertices > 0 )
-  {
-    a2a = 0;
-    v7 = pIndoor->pFaces;
-    while ( 1 )
-    {
-      v8 = (uint *)&pIndoor->pMapVertices->pVertices[a2a];
-      v9 = v7[LOWORD(pIndoor->pMapVertices[a2a + 2])].uAttributes;
-      if ( !(BYTE1(v9) & 0x20) )
-      {
-        v10 = v7[HIWORD(pIndoor->pMapVertices[a2a + 2])].uAttributes;
-        if ( !(BYTE1(v10) & 0x20) )
-        {
-          v11 = HIWORD(pIndoor->pMapVertices[a2a + 3]);
+  }
+  else
+  {
+    pRenderer->FillRectFast(uX, uY, uZ - uX, uHeight, 0xF);
+    uNumBlueFacesInBLVMinimap = 0;
+
+    for (uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i)
+    {
+      auto pOutline = &pIndoor->pMapOutlines->pOutlines[i];
+
+      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 ( (v9 & 0x80u) != 0 || (v10 & 0x80u) != 0 )
-            break;
-        }
-      }
-LABEL_26:
-      ++uZa;
-      a2a += 3;
-      if ( uZa >= (signed int)pIndoor->pMapVertices->uNumVertices )
-        goto LABEL_27;
-    }
-    HIWORD(pIndoor->pMapVertices[a2a + 3]) = v11 | 1;
-    pIndoor->_visible_outlines[uZa >> 3] |= 1 << (7 - uZa % 8);
-    v7 = pIndoor->pFaces;
+          if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
+            goto LABEL_ABC;
+        }
+      }
+      continue;
+
+LABEL_ABC:
+    pOutline->uFlags = v11 | 1;
+    pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);
+
 LABEL_15:
-    if ( v80
-      && v75 >= 3
-      && ((v12 = (int)&v7[*((short *)v8 + 2)], *(int *)(v12 + 44) & 0x2000000)
-       || v7[*((short *)v8 + 3)].uAttributes & 0x2000000)
-      && (pIndoor->pFaceExtras[*(short *)(v12 + 72)].uEventID
-       || pIndoor->pFaceExtras[v7[*((short *)v8 + 3)].uFaceExtraID].uEventID)
-      && (v13 = uNumBlueFacesInBLVMinimap, (signed int)uNumBlueFacesInBLVMinimap < 49) )
-    {
-      pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap] = uZa;
-      uNumBlueFacesInBLVMinimap = v13 + 1;
-    }
-    else
-    {
-      v69 = uWidth
-          + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                           * (signed __int64)pIndoor->pVertices[*(short *)v8].x) >> 16) << 16)
+    //v12 = &pIndoor->pFaces[pOutline->uFace1ID];
+    if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 &&
+        (pFace1->uAttributes & 0x2000000 || pFace2->uAttributes & 0x2000000) &&
+        (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID))
+    {
+      if (uNumBlueFacesInBLVMinimap < 49)
+        pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap++] = i;
+    }
+    else
+    {
+      v69 = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16)
                         - uZoom * pParty->vPosition.x) >> 16);
-      lPitcha = uHeight
-              - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                               * (signed __int64)pIndoor->pVertices[*(short *)v8].y) >> 16) << 16)
+      lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
                             - uZoom * pParty->vPosition.z) >> 16);
-      uWa = uWidth
-          + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                           * (signed __int64)pIndoor->pVertices[*((short *)v8 + 1)].x) >> 16) << 16)
+      uWa = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16)
                         - uZoom * pParty->vPosition.x) >> 16);
-      v14 = uHeight
-          - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                           * (signed __int64)pIndoor->pVertices[*((short *)v8 + 1)].y) >> 16) << 16)
+      v14 = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
                         - uZoom * pParty->vPosition.z) >> 16);
-      v15 = abs(*((short *)v8 + 4) - pParty->vPosition.y) / 8;
+      v15 = abs(pOutline->sZ - pParty->vPosition.y) / 8;
       if ( v15 > 100 )
         v15 = 100;
-      pRenderer->FillRect(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
-      v7 = pIndoor->pFaces;
-    }
-    goto LABEL_26;
-  }
-LABEL_27:
+      pRenderer->Line2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
+    }
+  }
+
+
   for ( uZb = 0; uZb < (signed int)uNumBlueFacesInBLVMinimap; ++uZb )
   {
-    v16 = (uint *)&pIndoor->pMapVertices->pVertices[3 * pBlueFacesInBLVMinimapIDs[uZb]];
-    pRenderer->FillRect(
-      uWidth
+    //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
+    auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
+    pRenderer->Line2D(
+      uCenterX
     + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                     * (signed __int64)pIndoor->pVertices[*(short *)v16].x) >> 16) << 16)
+                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16)
                   - uZoom * pParty->vPosition.x) >> 16),
-      uHeight
+      uCenterY
     - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                     * (signed __int64)pIndoor->pVertices[*(short *)v16].y) >> 16) << 16)
+                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
                   - uZoom * pParty->vPosition.z) >> 16),
-      uWidth
+      uCenterX
     + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                     * (signed __int64)pIndoor->pVertices[HIWORD(pIndoor->pMapVertices[3 * pBlueFacesInBLVMinimapIDs[uZb] + 1])].x) >> 16) << 16)
+                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16)
                   - uZoom * pParty->vPosition.x) >> 16),
-      uHeight
+      uCenterY
     - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom
-                                                     * (signed __int64)pIndoor->pVertices[HIWORD(pIndoor->pMapVertices[3 * pBlueFacesInBLVMinimapIDs[uZb] + 1])].y) >> 16) << 16)
+                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
                   - uZoom * pParty->vPosition.z) >> 16),
       uBlue);
   }
-LABEL_50:
+  }
+
+
+//_draw_party_arrow:
   v33 = 0;
   v34 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
   v35 = 0;
@@ -14050,13 +14036,13 @@
   v35 = v57;
 LABEL_66:
   pRenderer->DrawTextureTransparent(
-    uWidth - 3,
-    uHeight - 3,
+    uCenterX - 3,
+    uCenterY - 3,
     (Texture *)(pTextureIDs_pMapDirs[v35] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v35]] : 0));
   v36 = 255;
   flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
   v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-  if ( v80 )
+  if ( bWizardEyeActive )
   {
     uZe = 0;
     if ( (signed int)uNumLayingItems > 0 )
@@ -14066,11 +14052,11 @@
       {
         if ( !*((short *)a2c - 1)
           || !*(short *)a2c
-          || v75 == 1
+          || uWizardEyeSkillLevel == 1
           || (v37 = ((unsigned __int64)((*(int *)(a2c + 2) - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
-                  + uWidth,
+                  + uCenterX,
               v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16,
-              v38 = uHeight - v79,
+              v38 = uCenterY - v79,
               v37 < pRenderer->field_1C_clipx)
           || v37 > pRenderer->field_24_clipz
           || v38 < pRenderer->field_20_clipy
@@ -14080,22 +14066,22 @@
           break;
         if ( (signed int)uZoom > 512 )
         {
-          pRenderer->FillRect(v37 - 1, v38 - 1, v37 - 1, v38 + 1, flagsb);
-          pRenderer->FillRect(v37, v38 - 2, v37, v38 + 1, flagsb);
-          pRenderer->FillRect(v37 + 1, v38 - 1, v37 + 1, v38 + 1, flagsb);
-          pRenderer->FillRect(v37 - 2, v38, v37 - 2, v38 + 1, flagsb);
+          pRenderer->Line2D(v37 - 1, v38 - 1, v37 - 1, v38 + 1, flagsb);
+          pRenderer->Line2D(v37, v38 - 2, v37, v38 + 1, flagsb);
+          pRenderer->Line2D(v37 + 1, v38 - 1, v37 + 1, v38 + 1, flagsb);
+          pRenderer->Line2D(v37 - 2, v38, v37 - 2, v38 + 1, flagsb);
           v37 += 2;
           v58 = flagsb;
           v55 = v38 + 1;
           goto LABEL_81;
         }
-        pRenderer->FillRect(v37 - 1, v38 - 1, v37 - 1, uHeight - v79, flagsb);
+        pRenderer->Line2D(v37 - 1, v38 - 1, v37 - 1, uCenterY - v79, flagsb);
         v58 = flagsb;
-        v55 = uHeight - v79;
+        v55 = uCenterY - v79;
         v53 = v37;
         v51 = v38 - 1;
 LABEL_82:
-        pRenderer->FillRect(v37, v51, v53, v55, v58);
+        pRenderer->Line2D(v37, v51, v53, v55, v58);
 LABEL_83:
         ++uZe;
         a2c += 112;
@@ -14107,10 +14093,10 @@
         }
       }
       v58 = v60;
-      v55 = uHeight - v79;
+      v55 = uCenterY - v79;
 LABEL_81:
       v53 = v37;
-      v51 = uHeight - v79;
+      v51 = uCenterY - v79;
       goto LABEL_82;
     }
 LABEL_85:
@@ -14128,10 +14114,10 @@
         {
           v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
                                   * (signed __int64)(signed int)uZoom) >> 16)
-              + uWidth;
+              + uCenterX;
           v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.z)
                                  * (signed __int64)(signed int)uZoom) >> 16;
-          v41 = uHeight - v76;
+          v41 = uCenterY - v76;
           if ( v40 >= pRenderer->field_1C_clipx )
           {
             if ( v40 <= pRenderer->field_24_clipz && v41 >= pRenderer->field_20_clipy && v41 <= pRenderer->field_28_clipw )
@@ -14143,13 +14129,13 @@
                 uWd = v65;
               if ( (signed int)uZoom > 1024 )
               {
-                pRenderer->FillRect(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd);
-                pRenderer->FillRect(v40, v41 - 2, v40, v41 + 2, uWd);
-                pRenderer->FillRect(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd);
+                pRenderer->Line2D(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd);
+                pRenderer->Line2D(v40, v41 - 2, v40, v41 + 2, uWd);
+                pRenderer->Line2D(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd);
                 v42 = v41 + 1;
                 v43 = v41 - 1;
                 v44 = v42;
-                pRenderer->FillRect(v40 - 2, v43, v40 - 2, v42, uWd);
+                pRenderer->Line2D(v40 - 2, v43, v40 - 2, v42, uWd);
                 v40 += 2;
                 v59 = uWd;
                 v56 = v44;
@@ -14158,13 +14144,13 @@
               }
               else
               {
-                pRenderer->FillRect(v40 - 1, v41 - 1, v40 - 1, uHeight - v76, uWd);
+                pRenderer->Line2D(v40 - 1, v41 - 1, v40 - 1, uCenterY - v76, uWd);
                 v59 = uWd;
-                v56 = uHeight - v76;
+                v56 = uCenterY - v76;
                 v54 = v40;
                 v52 = v41 - 1;
               }
-              pRenderer->FillRect(v40, v52, v54, v56, v59);
+              pRenderer->Line2D(v40, v52, v54, v56, v59);
             }
           }
         }
@@ -14187,9 +14173,9 @@
       if ( *(v45 - 2) & 8 )
       {
         v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
-            + uWidth;
+            + uCenterX;
         v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16;
-        v47 = uHeight - v77;
+        v47 = uCenterY - v77;
         if ( v46 >= pRenderer->field_1C_clipx )
         {
           if ( v46 <= pRenderer->field_24_clipz && v47 >= pRenderer->field_20_clipy && v47 <= pRenderer->field_28_clipw )
@@ -14198,14 +14184,14 @@
             {
               v48 = v47 + 1;
               v49 = v47 - 1;
-              pRenderer->FillRect(v46 - 1, v47 - 1, v46 - 1, v47 + 1, flagsd);
-              pRenderer->FillRect(v46, v49, v46, v48, flagsd);
-              pRenderer->FillRect(v46 + 1, v49, v46 + 1, v48, flagsd);
+              pRenderer->Line2D(v46 - 1, v47 - 1, v46 - 1, v47 + 1, flagsd);
+              pRenderer->Line2D(v46, v49, v46, v48, flagsd);
+              pRenderer->Line2D(v46 + 1, v49, v46 + 1, v48, flagsd);
               v45 = lPitchb;
             }
             else
             {
-              pRenderer->FillRect(v46, uHeight - v77, v46, uHeight - v77, flagsd);
+              pRenderer->Line2D(v46, uCenterY - v77, v46, uCenterY - v77, flagsd);
             }
           }
         }
@@ -14449,10 +14435,10 @@
 LABEL_8:
   black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
   teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
-  v7 = (uint *)pIndoor->pMapVertices;
+  v7 = (uint *)pIndoor->pMapOutlines;
   uNumBlueFacesInBLVMinimap = 0;
-  v8 = pIndoor->pMapVertices->uNumVertices == 0;
-  v9 = (pIndoor->pMapVertices->uNumVertices & 0x80000000u) != 0;
+  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
+  v9 = (pIndoor->pMapOutlines->uNumOutlines & 0x80000000u) != 0;
   v94 = 0;
   if ( !(v9 | v8) )
   {
@@ -14489,13 +14475,13 @@
       v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
       v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
       v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
-      pRenderer->FillRect(
+      pRenderer->Line2D(
         v85 + v88,
         v90 - v87,
         v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
         v90 - v92,
         black);
-      v7 = (uint *)pIndoor->pMapVertices;
+      v7 = (uint *)pIndoor->pMapOutlines;
 LABEL_17:
       ++v94;
       i += 12;
@@ -14523,7 +14509,7 @@
       v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
       i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
       v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
-      pRenderer->FillRect(
+      pRenderer->Line2D(
         v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
         v90 - v88,
         v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
@@ -14532,7 +14518,7 @@
       ++v21;
       if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
         break;
-      v7 = (uint *)pIndoor->pMapVertices;
+      v7 = (uint *)pIndoor->pMapOutlines;
     }
     v6 = v86;
   }
@@ -14654,8 +14640,8 @@
             {
               v96 = v55 + 1;
               black = v55 - 1;
-              pRenderer->FillRect(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
-              pRenderer->FillRect(v54, black, v54, v96, v86);
+              pRenderer->Line2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
+              pRenderer->Line2D(v54, black, v54, v96, v86);
               ++v54;
               v74 = v86;
               v72 = v96;
@@ -14668,7 +14654,7 @@
               v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
               v70 = v90 - (int)v97;
             }
-            pRenderer->FillRect(v54, v70, v71, v72, v74);
+            pRenderer->Line2D(v54, v70, v71, v72, v74);
           }
         }
       }
@@ -14905,11 +14891,11 @@
     v14 = 0x40000000u;
     v17 = 0xC0000000u;
     v15 = 0xC0000000u;
-    if ( (signed int)pIndoor->pMapVertices->uNumVertices > 0 )
-    {
-      v2 = (__int16 *)(pIndoor->pMapVertices->pVertices);
-      v11 = pIndoor->pMapVertices->uNumVertices;
-      v12 = (uint *)pIndoor->pMapVertices->pVertices;
+    if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
+    {
+      v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
+      v11 = pIndoor->pMapOutlines->uNumOutlines;
+      v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
       do
       {
         v3 = &pIndoor->pVertices[*v2];
--- a/mm7_4.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_4.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -5333,63 +5333,41 @@
   int v51; // eax@49
   char *v52; // edi@52
   char v53; // al@52
-  int v54; // edi@53
+  int uClassType; // edi@53
   int v55; // ST0C_4@53
   int v56; // eax@53
   int v57; // eax@53
-  const char *v58; // ST10_4@55
-  unsigned int v59; // ST0C_4@55
   int v60; // eax@55
   int v61; // ecx@55
-  const char *v62; // ST10_4@57
-  unsigned int v63; // ST0C_4@57
   int v64; // ST08_4@57
   int v65; // eax@57
   int v66; // ecx@57
-  const char *v67; // ST10_4@59
-  unsigned int v68; // ST0C_4@59
   int v69; // ST08_4@59
   int v70; // eax@59
   int v71; // eax@59
-  const char *v72; // ST10_4@61
-  unsigned int v73; // ST0C_4@61
   int v74; // eax@61
   int v75; // eax@61
-  const char *v76; // ST10_4@63
-  unsigned int v77; // ST0C_4@63
   int v78; // ST08_4@63
   int v79; // eax@63
   int v80; // eax@63
-  const char *v81; // ST10_4@65
-  unsigned int v82; // ST0C_4@65
   int v83; // ST08_4@65
   int v84; // eax@65
   int v85; // eax@65
-  const char *v86; // ST10_4@67
-  unsigned int v87; // ST0C_4@67
   int v88; // eax@67
   int v89; // eax@67
-  const char *v90; // ST10_4@69
-  unsigned int v91; // ST0C_4@69
   int v92; // ST08_4@69
   int v93; // eax@69
   int v94; // eax@69
-  const char *v95; // ST10_4@71
-  unsigned int v96; // ST0C_4@71
   int v97; // ST08_4@71
   int v98; // eax@71
-  const char *v99; // ST10_4@71
-  int v100; // ST0C_4@71
   int v101; // eax@71
   enum PLAYER_SKILL_TYPE v102; // edi@72
   size_t v103; // eax@72
   signed int v104; // ecx@72
   int v105; // ecx@79
-  int v106; // edi@81
   unsigned int v107; // ST0C_4@81
   int pTextY; // ST08_4@81
   int v109; // eax@81
-  const char *v110; // ST10_4@82
   int v111; // ST0C_4@82
   int v112; // eax@82
   signed int v113; // edi@82
@@ -5661,86 +5639,65 @@
       v51 = v134;
     }
   }
-  v54 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].uClass;
+  uClassType = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].uClass;
   v55 = uColor1;
-  v133 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].uClass;
   v56 = pFontCreate->AlignText_Center(193u, Str1);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, v56 + 324, 395, v55, Str1, 0, 0, 0);
   v57 = uColorTeal;
-  if ( v54 )
+  if ( uClassType )
     v57 = uColorWhite;
-  v58 = pClassNames[0];
-  v59 = v57;
   v60 = pFontCreate->AlignText_Center(65u, pClassNames[0]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v60 + 323, 417, v59, v58, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v60 + 323, 417, v57, pClassNames[0], 0, 0, 0);
   v61 = uColorTeal;
-  if ( v133 != 12 )
+  if ( uClassType != PLAYER_CLASS_PALADIN )
     v61 = uColorWhite;
-  v62 = pClassNames[12];
-  v63 = v61;
   v64 = v128 + 417;
   uColorGreen = v128 + 417;
   v65 = pFontCreate->AlignText_Center(65u, pClassNames[12]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v65 + 323, v64, v63, v62, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v65 + 323, v64, v61, pClassNames[12], 0, 0, 0);
   v66 = uColorTeal;
-  if ( v133 != 20 )
+  if ( uClassType != PLAYER_CLASS_DRUID )
     v66 = uColorWhite;
-  v67 = pClassNames[20];
-  v68 = v66;
   v69 = 2 * v128 + 417;
   v126 = 2 * v128 + 417;
   v70 = pFontCreate->AlignText_Center(65u, pClassNames[20]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v70 + 323, v69, v68, v67, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v70 + 323, v69, v66, pClassNames[20], 0, 0, 0);
   v71 = uColorTeal;
-  if ( v133 != PLAYER_CLASS_CLERIC )
+  if ( uClassType != PLAYER_CLASS_CLERIC )
     v71 = uColorWhite;
-  v72 = pClassNames[24];
-  v73 = v71;
   v74 = pFontCreate->AlignText_Center(65u, pClassNames[24]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v74 + 388, 417, v73, v72, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v74 + 388, 417, v71, pClassNames[24], 0, 0, 0);
   v75 = uColorTeal;
-  if ( v133 != 28 )
+  if ( uClassType != 28 )
     v75 = uColorWhite;
-  v76 = pClassNames[28];
-  v77 = v75;
   v78 = uColorGreen;
   v79 = pFontCreate->AlignText_Center(65u, pClassNames[28]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v79 + 388, v78, v77, v76, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v79 + 388, v78, v75, pClassNames[28], 0, 0, 0);
   v80 = uColorTeal;
-  if ( v133 != PLAYER_CLASS_SORCERER )
+  if ( uClassType != PLAYER_CLASS_SORCERER )
     v80 = uColorWhite;
-  v81 = pClassNames[32];
-  v82 = v80;
   v83 = v126;
   v84 = pFontCreate->AlignText_Center(65u, pClassNames[32]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v84 + 388, v83, v82, v81, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v84 + 388, v83, v80, pClassNames[32], 0, 0, 0);
   v85 = uColorTeal;
-  if ( v133 != 16 )
+  if ( uClassType != PLAYER_CLASS_SHOOTER )
     v85 = uColorWhite;
-  v86 = pClassNames[16];
-  v87 = v85;
   v88 = pFontCreate->AlignText_Center(65u, pClassNames[16]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v88 + 453, 417, v87, v86, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v88 + 453, 417, v85, pClassNames[16], 0, 0, 0);
   v89 = uColorTeal;
-  if ( v133 != 8 )
+  if ( uClassType != PLAYER_CLASS_MONK )
     v89 = uColorWhite;
-  v90 = pClassNames[8];
-  v91 = v89;
   v92 = uColorGreen;
   v93 = pFontCreate->AlignText_Center(65u, pClassNames[8]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v93 + 453, v92, v91, v90, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v93 + 453, v92, v89, pClassNames[8], 0, 0, 0);
   v94 = uColorTeal;
-  if ( v133 != 4 )
+  if ( uClassType != PLAYER_CLASS_THEIF )
     v94 = uColorWhite;
-  v95 = pClassNames[4];
-  v96 = v94;
   v97 = v126;
   v98 = pFontCreate->AlignText_Center(65u, pClassNames[4]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v98 + 453, v97, v96, v95, 0, 0, 0);
-  v99 = pGlobalTXT_LocalizationStrings[20];     // "Available Skills"
-  v100 = uColor1;
-  v101 = pFontCreate->AlignText_Center(0xECu, pGlobalTXT_LocalizationStrings[20]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v101 + 37, 395, v100, v99, 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v98 + 453, v97, v94, pClassNames[4], 0, 0, 0);
+  v101 = pFontCreate->AlignText_Center(0xECu, pGlobalTXT_LocalizationStrings[20]); // "Available Skills"
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v101 + 37, 395, uColor1, pGlobalTXT_LocalizationStrings[20], 0, 0, 0);
   v134 = 0;
   do
   {
@@ -5770,12 +5727,11 @@
     v105 = uColorTeal;
     if ( !pParty->pPlayers[0].pActiveSkills[v102 + 3486 * uPlayerCreationUI_SelectedCharacter] )
       v105 = uColorWhite;
-    v106 = v134 / 3;
-	v107 = v105;
+    v107 = v105;
 	v109 = pFontCreate->AlignText_Center(100u, Str1);
     pGUIWindow_CurrentMenu->DrawText(
       pFontCreate,
-      100 * v106 + v109 + uColorGreen + 17,
+      100 * (v134 / 3) + v109 + uColorGreen + 17,
       v128 * (v134 % 3) + 417,
       v107,
       Str1,
@@ -5785,10 +5741,9 @@
     ++v134;
   }
   while ( v134 < 9 );
-  v110 = pGlobalTXT_LocalizationStrings[30];    // "Bonus"
   v111 = uColor1;
-  v112 = pFontCreate->AlignText_Center(0x5Cu, pGlobalTXT_LocalizationStrings[30]);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v112 + 533, 394, v111, v110, 0, 0, 0);
+  v112 = pFontCreate->AlignText_Center(0x5Cu, pGlobalTXT_LocalizationStrings[30]);// "Bonus"
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, v112 + 533, 394, v111, pGlobalTXT_LocalizationStrings[30], 0, 0, 0);
   v113 = PlayerCreation_ComputeAttributeBonus();
   sprintf(pTmpBuf, "%d", v113);
   v114 = uColorWhite;
@@ -7333,11 +7288,12 @@
         v1 = pRenderer->pTargetSurface;
         v2 = Dst.lpSurface;
 
+
         for (uint y = 0; y < 480; ++y)
         {
           auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
           for (uint x = 0; x < 640; ++x)
-            pDst[x] = pRenderer->uTargetGMask | pRenderer->uTargetBMask;
+            pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
         }
         
         auto pSrc = pRenderer->pTargetSurface;
@@ -15111,10 +15067,10 @@
   SpriteFrame *v10; // ebx@18
   int *v11; // eax@18
   int v12; // ecx@28
-  IndoorCameraD3D **v14; // eax@36
+  //IndoorCameraD3D **v14; // eax@36
   double v15; // st7@36
   float v16; // eax@36
-  double v17; // ST30_8@36
+  //double v17; // ST30_8@36
   signed __int64 v18; // qtt@36
   int v19; // ST5C_4@36
   signed __int64 v20; // qtt@37
@@ -15124,8 +15080,8 @@
   signed int v24; // ecx@40
   int v25; // edx@44
   __int16 v26; // ax@44
-  MonsterDesc *v27; // edx@44
-  int v28; // ecx@44
+  //MonsterDesc *v27; // edx@44
+  //int v28; // ecx@44
   unsigned __int8 v29; // zf@44
   unsigned __int8 v30; // sf@44
   unsigned int v31; // [sp-8h] [bp-5Ch]@15
@@ -15183,7 +15139,7 @@
     if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
       v8 = 0;
     v31 = p->pSpriteIDs[v5];
-    if (p->uAIState == 16 )
+    if (p->uAIState == Resurrected)
       v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
     else
       v9 = pSpriteFrameTable->GetFrame(v31, v8);
@@ -15214,13 +15170,13 @@
         v11);
     }
     v12 = 0;
-    if ( pStru170->field_53730 <= 0 )
+    if ( pStru170->uNumVisibleNotEmptySectors <= 0 )
       continue;
-    while (pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != p->uSectorID)
+    while (pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID)
     {
       ++v12;
-      if ( v12 >= pStru170->field_53730 )
-        continue;
+      if ( v12 >= pStru170->uNumVisibleNotEmptySectors )
+        goto _continue;
     }
     if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1)
       || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
@@ -15247,14 +15203,14 @@
     }
     else
     {
-      v14 = &pGame->pIndoorCameraD3D;
+      //v14 = &pGame->pIndoorCameraD3D;
       v0->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-      v15 = (*v14)->flt_D4;
+      v15 = pGame->pIndoorCameraD3D->flt_D4;
       v16 = v0->flt_8;
       v0->flt_C = v15;
-      v17 = v16 + 6.7553994e15;
+      //v17 = v16 + 6.7553994e15;
       LODWORD(v18) = 0;
-      HIDWORD(v18) = SLOWORD(v17);
+      HIDWORD(v18) = floorf(v16 + 0.5f);
       v19 = v18 / x;
       v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16;
       a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16;
@@ -15292,18 +15248,21 @@
     LOWORD(v25) = 0;
     LOBYTE(v26) = v41;
     v0->sZValue = v25 + (8 * i | 3);
-    v27 = pMonsterList->pMonsters;
-    v28 = p->pMonsterInfo.uID;
+    //v27 = pMonsterList->pMonsters;
+    //v28 = p->pMonsterInfo.uID;
     v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
     v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
     v0->field_1E = v41;
     v0->pSpriteFrame = v10;
-    v0->uTintColor = *((_DWORD *)&v27[v28] - 36);
+    v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor;
     if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) )
     {
       HIBYTE(v26) = HIBYTE(v41) | 1;
       v0->field_1E = v26;
     }
+    
+_continue:
+    ;
   }
 }
 
--- a/mm7_5.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_5.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -2670,7 +2670,7 @@
         case 0x4E:
           if ( dword_50654C && byte_506550 )
           {
-            v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->field_1A4E].pName;
+            v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName;
             v157 = pGlobalTXT_LocalizationStrings[483];
 _sprintex_2args_draw_status_and_continue:
             sprintfex(pTmpBuf, v157, v173);
@@ -2726,7 +2726,7 @@
             v127 = 203;
             goto _play_sound_and_continue;
           }
-          v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->field_1A4E;
+          v99 = dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage;
           pPlayers[uActiveCharacter]->uQuickSpell = v99;
           stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
           if ( uActiveCharacter )
@@ -2745,7 +2745,7 @@
           {
             if ( *(short *)thisl )
             {
-              if ( v100->field_1A4E == v101 )
+              if ( v100->pNumSpellBookPage == v101 )
                 uAction = (int)v195;
               v102 = (int)v195;
               v195 = (NPCData *)((char *)v195 + 1);
@@ -2770,13 +2770,13 @@
               uAction = 0;
           }
           sub_41140B();
-          pPlayers[uActiveCharacter]->field_1A4E = LOBYTE(v217[uAction]);
+          pPlayers[uActiveCharacter]->pNumSpellBookPage = LOBYTE(v217[uAction]);
           goto LABEL_661;
         case UIMSG_SaveGame|0x4:
-          if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->field_1A4E )
+          if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage )
             goto _continue;
           sub_41140B();
-          pPlayers[uActiveCharacter]->field_1A4E = uMessageParam;
+          pPlayers[uActiveCharacter]->pNumSpellBookPage = uMessageParam;
 LABEL_661:
           pGUIWindow_CurrentMenu->_411621();
 LABEL_662:
@@ -3416,7 +3416,7 @@
   int v42; // [sp-10h] [bp-20h]@36
   int v43; // [sp-10h] [bp-20h]@56
   int uNum; // [sp+4h] [bp-Ch]@3
-  UIMessageType v45; // [sp+8h] [bp-8h]@3
+  UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
   int v46; // [sp+Ch] [bp-4h]@3
   Player *pPlayer;
 
@@ -3427,8 +3427,8 @@
 	pPlayer = pParty->pPlayers;
     do
     {
-      pMessageQueue_50CBD0->PopMessage(&v45, &uNum, &v46);
-      switch (v45)
+      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &v46);
+      switch (pUIMessageType)
       {
         case UIMSG_MainMenu_ShowPartyCreationWnd:
         {
@@ -3469,15 +3469,14 @@
       }
 
 
-      switch (v45)
+      switch (pUIMessageType)
       {
         case UIMSG_A5:   // WINDOW_5A
         {
             //main menu save/load wnd   clicking on savegame lines
           if (pGUIWindow_CurrentMenu->field_40 == 1)
             pKeyActionMap->_459ED1(0);
-          if ( pCurrentScreen != 11
-              || uLoadGameUI_SelectedSlot != uNum + dword_6A0C9C )
+          if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != uNum + dword_6A0C9C )
           {
             //load clicked line
               v26 = uNum + dword_6A0C9C;
@@ -3504,18 +3503,17 @@
 
         case UIMSG_A4:
         {
-          GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241,
-                            pGUIWindow_CurrentMenu->uFrameY + 302,
+          GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302,
                             61, 28, WINDOW_5E, (int)ptr_69BD64, 0);
         }
         continue;
       }
 
-      if ( (signed int)v45 > 75 )
-      {
-        if ( v45 > UIMSG_A3 )
-        {
-          if ( v45 == UIMSG_A6 )
+      if ( (signed int)pUIMessageType > 75 )
+      {
+        if ( pUIMessageType > UIMSG_A3 )
+        {
+          if ( pUIMessageType == UIMSG_A6 )
           {
             v43 = 0;
             v39 = (int)ptr_69BD60;
@@ -3527,7 +3525,7 @@
             GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43);
             continue;
           }
-          if ( v45 == UIMSG_AB ) // sellect face -1
+          if ( pUIMessageType == UIMSG_SelectFacePlayerBack )
           {
             pPlayer = &pParty->pPlayers[uNum];
             v12 = (char)((int)pPlayer->uFace - 1) < 0;
@@ -3539,26 +3537,19 @@
             pPlayer->SetSexByVoice();
             pPlayer->RandomizeName();
             v25 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem
-                                                       - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7
-                                                      + pGUIWindow_CurrentMenu->pStartingPosActiveItem
-                                                      + 7 * uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
             uPlayerCreationUI_SelectedCharacter = v25;
-            GUIWindow::Create(
-              pCreationUI_BtnPressLeft[v25]->uX,
-              pCreationUI_BtnPressLeft[v25]->uY,
-              0,
-              0,
-              (enum WindowType)92,
-              (int)pCreationUI_BtnPressLeft[v25],
-              1);
+            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0,
+              (enum WindowType)92, (int)pCreationUI_BtnPressLeft[v25], 1);
             //v0 = pAudioPlayer;
             pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0.0, 0);
             v22 = pPlayer;
-            goto LABEL_117;
-          }
-          if ( v45 == UIMSG_AC ) //sellect face +1
+            v22->PlaySound(102, 0);
+            v1 = (char *)pParty->pPlayers;
+            continue;
+          }
+          if ( pUIMessageType == UIMSG_SelectFacePlayerForward )
           {
             pPlayer = &pParty->pPlayers[uNum];
 			v20 = (char)((int)pPlayer->uFace + 1) % 20;
@@ -3568,60 +3559,35 @@
             pPlayer->SetSexByVoice();
             pPlayer->RandomizeName();
             v21 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem
-                                                       - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7
-                                                      + pGUIWindow_CurrentMenu->pStartingPosActiveItem
-                                                      + 7 * uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
             uPlayerCreationUI_SelectedCharacter = v21;
-            GUIWindow::Create(
-              pCreationUI_BtnPressRight[v21]->uX,
-              pCreationUI_BtnPressRight[v21]->uY,
-              0,
-              0,
-              (enum WindowType)92,
-              (int)pCreationUI_BtnPressRight[v21],
-              1);
+            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (enum WindowType)92,
+			  (int)pCreationUI_BtnPressRight[v21], 1);
             //v0 = pAudioPlayer;
             pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
             v22 = pPlayer;
-LABEL_117:
             v22->PlaySound(102, 0);
             v1 = (char *)pParty->pPlayers;
             continue;
           }
-          if ( v45 == UIMSG_AD )
-          {
-            GUIWindow::Create(
-              pMainMenu_BtnNew->uX,
-              pMainMenu_BtnNew->uY,
-              0,
-              0,
-              (enum WindowType)90,
-              (int)pMainMenu_BtnNew,
-              0);
+          if ( pUIMessageType == UIMSG_AD )
+          {
+            GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnNew, 0);
           SetCurrentMenuID(MENU_LOAD);
           continue;
           }
-          if ( v45 != 174 )
+          if ( pUIMessageType != UIMSG_AE )
             continue;
-          GUIWindow::Create(
-            pMainMenu_BtnExit->uX,
-            pMainMenu_BtnExit->uY,
-            0,
-            0,
-            (enum WindowType)90,
-            (int)pMainMenu_BtnExit,
-            0);
+          GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnExit, 0);
 LABEL_114:
           v40 = 10;
 LABEL_89:
           v2 = v40;
-LABEL_90:
           SetCurrentMenuID((MENU_STATE)v2);
           continue;
         }
-        if ( v45 == UIMSG_A3 )
+        if ( pUIMessageType == UIMSG_A3 )
         {
           ++dword_6A0C9C;
           if ( dword_6A0C9C >= uNum )
@@ -3634,7 +3600,7 @@
           v8 = pGUIWindow_CurrentMenu->uFrameY + 323;
           goto LABEL_105;
         }
-        if ( v45 == 107 )
+        if ( pUIMessageType == UIMSG_6B )
         {
           if ( pCurrentScreen )
           {
@@ -3649,7 +3615,7 @@
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
           goto LABEL_93;
         }
-        if ( v45 == UIMSG_CloseBook )
+        if ( pUIMessageType == UIMSG_CloseBook )
         {
           if ( ptr_507BDC )
           {
@@ -3691,8 +3657,7 @@
           }
           v16 = GetCurrentMenuID() == 8;
           v17 = pCurrentScreen;
-          if ( v16
-            && !pCurrentScreen )
+          if ( v16 && !pCurrentScreen )
             goto LABEL_83;
           if ( pCurrentScreen == 12 )
           {
@@ -3724,15 +3689,11 @@
         }
         else
         {
-          if ( v45 == 118 )
-          {
-            v14 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem
-                                                       - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7
-                                                      + pGUIWindow_CurrentMenu->pStartingPosActiveItem
-                                                      + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v14;
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectQuality )
+          {
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = uNum;
 LABEL_36:
             v42 = 0;
             v38 = 0;
@@ -3746,7 +3707,7 @@
             pAudioPlayer->PlaySound(pSoundID, v30, v31, v32, v34, v36, v38, v42);
             continue;
           }
-          if ( v45 == 144 ) //select voise -1
+          if ( pUIMessageType == UIMSG_PlayerCreationVoiceBack )
           {
             v9 = &pPlayer[uNum];
             v46 = v9->GetSexByVoice();
@@ -3761,7 +3722,7 @@
             v11 = pCreationUI_BtnPressLeft2[uNum];
             goto LABEL_60;
           }
-          if ( v45 == 145 )
+          if ( pUIMessageType == UIMSG_PlayerCreationVoiceForward )
           {
             v9 = &pPlayer[uNum];
             v46 = v9->GetSexByVoice();
@@ -3778,7 +3739,7 @@
             v9->PlaySound(102, 0);
             continue;
           }
-          if ( v45 == UIMSG_A2 )
+          if ( pUIMessageType == UIMSG_A2 )
           {
             --dword_6A0C9C;
             if ( dword_6A0C9C < 0 )
@@ -3788,30 +3749,25 @@
             v39 = (int)ptr_69BD5C;
             v8 = pGUIWindow_CurrentMenu->uFrameY + 197;
 LABEL_105:
-            v37 = (WindowType)90;
-            v35 = 0;
-            v33 = 0;
-            v18 = v7->uFrameX + 215;
-            GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43);
+            GUIWindow::Create(v7->uFrameX + 215, v8, 0, 0, (WindowType)90, v39, v43);
             continue;
           }
         }
       }
       else
       {
-        if ( v45 == 75 )
+        if ( pUIMessageType == UIMSG_PlayerCreationRemoveDownSkill )
         {
           uPlayerCreationUI_SelectedCharacter = uNum;
           v41 = 3;
           v1 = (char *)pParty->pPlayers;
           v5 = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7
-             + pGUIWindow_CurrentMenu->pStartingPosActiveItem
-             + 7 * uNum;
+             + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
           goto LABEL_44;
         }
-        if ( (signed int)v45 > 60 )
-        {
-          if ( v45 == 62 ) //click +
+        if ( (signed int)pUIMessageType > UIMSG_3C )
+        {
+          if ( pUIMessageType == UIMSG_PlayerCreationClickPlus )
           {
             GUIWindow::Create(613, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnPlus, 1);
             (&pPlayer[uPlayerCreationUI_SelectedCharacter])->IncreaseAttribute(
@@ -3826,7 +3782,7 @@
             pSoundID = (SoundID)20;
             goto LABEL_40;
           }
-          if ( v45 == 63 ) // click -
+          if ( pUIMessageType == UIMSG_PlayerCreationClickMinus )
           {
             GUIWindow::Create(523, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
             (&pPlayer[uPlayerCreationUI_SelectedCharacter])->DecreaseAttribute(
@@ -3841,7 +3797,7 @@
             pSoundID = (SoundID)23;
             goto LABEL_40;
           }
-          if ( v45 == 64 ) // sellect active skill
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectActiveSkill )
           {
             auto _t = &pPlayer[uPlayerCreationUI_SelectedCharacter];
             v6 = _t->GetSkillIdxByOrder(uNum + 4);
@@ -3857,34 +3813,34 @@
             pSoundID = (SoundID)24;
             goto LABEL_40;
           }
-          if ( v45 == 65 )
+          if ( pUIMessageType == UIMSG_41 )
           {
             (&pPlayer[uPlayerCreationUI_SelectedCharacter])->Reset(0);
             goto LABEL_36;
           }
-          if ( v45 == 66 ) // click ok
-          {
-            GUIWindow::Create(0x244u, 0x1AFu, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnOK, 0);
+          if ( pUIMessageType == UIMSG_PlayerCreationClickOK )
+          {
+            GUIWindow::Create(580, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnOK, 0);
             if ( PlayerCreation_ComputeAttributeBonus() || !sub_4908DE() )
               GameUI_StatusBar_TimedStringTimeLeft = GetTickCount() + 4000;
             else
               uGameState = 6;
             continue;
           }
-          if ( v45 == 67 ) // click reset
-          {
-            GUIWindow::Create(0x20Fu, 0x1AFu, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnReset, 0);
+          if ( pUIMessageType == UIMSG_PlayerCreationClickReset ) 
+          {
+            GUIWindow::Create(527, 431, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnReset, 0);
             pParty->Reset();
           }
           else
           {
-            if ( v45 == 74 )
+            if ( pUIMessageType == UIMSG_PlayerCreationRemoveUpSkill )
             {
               uPlayerCreationUI_SelectedCharacter = uNum;
               v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
               v46 = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
               v41 = 2;
-              v5 = (v4 % 7) + v46 + 7 * uNum;
+              v5 = v4 % 7 + v46 + 7 * uNum;
 LABEL_44:
               pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
               pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
@@ -3895,7 +3851,7 @@
         }
         else
         {
-          switch ( v45 )
+          switch ( pUIMessageType )
           {
             case 60:
               pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
@@ -3911,7 +3867,7 @@
               pMouse->SetCursorBitmap("MICON2");
               break;
             default:
-              if ( v45 == 58 )
+              if ( pUIMessageType == 58 )
                 goto LABEL_114;
               break;
           }
@@ -8957,27 +8913,27 @@
 
 
 //----- (0043F333) --------------------------------------------------------
-void stru170::RenderWalls()
+void stru170::MakeVisibleSectorList()
 {
   int v6; // ebx@3
 
-  field_53730 = 0;
+  uNumVisibleNotEmptySectors = 0;
   for (uint i = 0; i < std__vector_000FA8; ++i)
   {
       v6 = 0;
-      if (!field_53730)
+      if (!uNumVisibleNotEmptySectors)
       {
 LABEL_7:
-        pSectorIDs_toDrawDecorationsFrom[field_53730++] = field_FA8[i].uSectorID;
+        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
       }
       else
       {
-        while (pSectorIDs_toDrawDecorationsFrom[v6] != field_FA8[i].uSectorID )
+        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != field_FA8[i].uSectorID )
         {
           ++v6;
-          if ( v6 >= field_53730)
-          {
-            pSectorIDs_toDrawDecorationsFrom[field_53730++] = field_FA8[i].uSectorID;
+          if ( v6 >= uNumVisibleNotEmptySectors)
+          {
+            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
             continue;
           }
         }
@@ -12110,14 +12066,14 @@
   if ( bSolidFill )
   {
     for ( i = v3->y; (signed int)i <= v3->w; ++i )
-      pRenderer->FillRect(v3->x, i, v3->z, i, v4);
-  }
-  else
-  {
-    pRenderer->FillRect(v3->x, v3->y, v3->z, v3->y, v4);
-    pRenderer->FillRect(v3->z, v3->y, v3->z, v3->w, v4);
-    pRenderer->FillRect(v3->z, v3->w, v3->x, v3->w, v4);
-    pRenderer->FillRect(v3->x, v3->w, v3->x, v3->y, v4);
+      pRenderer->Line2D(v3->x, i, v3->z, i, v4);
+  }
+  else
+  {
+    pRenderer->Line2D(v3->x, v3->y, v3->z, v3->y, v4);
+    pRenderer->Line2D(v3->z, v3->y, v3->z, v3->w, v4);
+    pRenderer->Line2D(v3->z, v3->w, v3->x, v3->w, v4);
+    pRenderer->Line2D(v3->x, v3->w, v3->x, v3->y, v4);
   }
   pRenderer->EndScene();
 }
@@ -12566,7 +12522,7 @@
 
   v1 = pPlayers[uActiveCharacter];
   v10 = _this;
-  v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->field_1A4E) + 1];
+  v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->pNumSpellBookPage) + 1];
   if ( pMouse->GetCursorPos(&a2)->y <= 250 )
     v3 = pMouse->GetCursorPos(&a2)->y + 30;
   else
@@ -12625,14 +12581,14 @@
   a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
   a1.uFrameWidth = 108;
   a1.uFrameZ = a1.uFrameX + 107;
-  a1.DrawText2(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->field_1A4E + 12], 3u);
+  a1.DrawText2(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->pNumSpellBookPage + 12], 3u);
   sprintfex(
     pTmpBuf,
     "%s\n%d",
     pGlobalTXT_LocalizationStrings[522],
     *(&pSpellDatas[0].field_14
-    + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->field_1A4E + 12]) >> 6)
-    + 10 * (int)((char *)v10 + 11 * v1->field_1A4E)));
+    + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->pNumSpellBookPage + 12]) >> 6)
+    + 10 * (int)((char *)v10 + 11 * v1->pNumSpellBookPage)));
   a1.DrawText2(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u);
   dword_507B00_spell_info_to_draw_in_popup = 0;
 }
@@ -13144,7 +13100,7 @@
 
   sub_412AF9();
   v0 = pPlayers[uActiveCharacter];
-  v1 = 11 * v0->field_1A4E;
+  v1 = 11 * v0->pNumSpellBookPage;
   v2 = pIcons_LOD->FindTextureByName("Pending");
   v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
   pRenderer->ClearZBuffer(0, 479);
@@ -13170,14 +13126,14 @@
           }
           if ( v6->pLevelOfDetail0 )
           {
-            v7 = 2 * (12 * v0->field_1A4E + (unsigned __int8)*(&byte_4E2430[12 * v0->field_1A4E] + v4));
+            v7 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage + v4]));
             v19 = pViewport->uViewportY + dword_4E20D0[v7 + 1];
             v17 = pViewport->uViewportX + dword_4E20D0[v7];
             if ( BYTE1(v6->pBits) & 2 )
               pRenderer->DrawTextureTransparent(v17, v19, v6);
             else
               pRenderer->DrawTextureIndexed(v17, v19, v6);
-            v8 = 2 * (12 * v0->field_1A4E + (unsigned __int8)*(&byte_4E2430[12 * v0->field_1A4E] + v4));
+            v8 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v4));
             pRenderer->_4A612A(dword_4E20D0[v8], dword_4E20D0[v8 + 1], (Texture *)v23[0], v4);
           }
         }
@@ -13194,7 +13150,7 @@
     if ( v11->pLevelOfDetail0 )
     {
       v21 = dword_5063D8[v10];
-      v12 = 2 * (12 * v0->field_1A4E + (unsigned __int8)*(&byte_4E2430[12 * v0->field_1A4E] + v10));
+      v12 = 2 * (12 * v0->pNumSpellBookPage + (unsigned __int8)*(&byte_4E2430[12 * v0->pNumSpellBookPage] + v10));
       v20 = pViewport->uViewportY + dword_4E20D0[v12 + 1];
       v18 = pViewport->uViewportX + dword_4E20D0[v12];
       if ( BYTE1(v11->pBits) & 2 )
@@ -13212,7 +13168,7 @@
   {
     if ( *(short *)a2.x )
     {
-      if ( v0->field_1A4E == v13 )
+      if ( v0->pNumSpellBookPage == v13 )
       {
         v16 = *(Texture **)&pTextures_tabs[0][0].pName[8 * v13 + 4];
         switch ( v13 )
--- a/mm7_data.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_data.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -350,6 +350,7 @@
 int amuint_4E1870; // weak
 int dword_4E1874; // weak
 int dword_4E1878; // weak
+float flt_4D84E8 = 0.0f;
 int dword_4E187C; // weak
 int dword_4E1880; // weak
 int dword_4E1884; // weak
@@ -481,8 +482,8 @@
 int dword_4E2A50[12];
 int _4E2A80_skills[9];
 unsigned __int8 pAwardsTextColors[20];
-unsigned int pHealthBarPos[4];
-unsigned int pManaBarPos[4];
+unsigned int pHealthBarPos[4] = {22, 137, 251, 366};
+unsigned int pManaBarPos[4] = {102, 217, 331, 447};
 char _4E2AD8_ui_colors[72];
 char _4E2B21_buff_spell_tooltip_colors[80];
 char byte_4E2B70[777]; // weak
@@ -1692,8 +1693,7 @@
 const char *dlhu_texnames_by_face[25];
 _UNKNOWN unk_4ED3D8; // weak
 unsigned char byte_4ED498 = 15; // weak
-__int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[777]; // weak
-__int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
+__int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4] = {34, 149, 264, 379};
 char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 int dword_4EDEA0[777]; // weak
 int dword_4EDEB4[777]; // weak
@@ -1701,8 +1701,8 @@
 __int16 word_4EDED8[777]; // weak
 __int16 word_4EDEDC; // weak
 _UNKNOWN unk_4EDF40; // weak
-unsigned int pHiredNPCsIconsOffsetsX[2];
-unsigned int pHiredNPCsIconsOffsetsY[2];
+unsigned int pHiredNPCsIconsOffsetsX[2] = {489, 559};
+unsigned int pHiredNPCsIconsOffsetsY[2] = {152, 152};
 int dword_4EE07C[2]; // weak
 _UNKNOWN unk_4EE084; // weak
 __int16 word_4EE088_sound_ids[100] =
@@ -2073,19 +2073,18 @@
 int dword_50B638[777]; // weak
 int dword_50B700; // weak
 int dword_50B738[777]; // idb
-int _50B744_view_transformed_ys_minus1[777]; // weak
 int _50B744_view_transformed_ys[43];
 int dword_50B828[777];
-int _50B834_view_transformed_zs_minus1[777]; // weak
 int _50B834_view_transformed_zs[43];
 int dword_50B918[777];
-int _50B924_view_transformed_xs_minus1[777]; // idb
 int _50B924_view_transformed_xs[43];
 int unk_50B9D4[777]; // idb
 int dword_50B9D8_ys[777];
 int dword_50B9E0_ys[777]; // idb
 int dword_50B9EC[777]; // idb
 int dword_50B9F0[2]; // idb
+int dword_50BAE8_xs[777];
+int dword_50BAF4_xs[777];
 int dword_50B9F8[777]; // idb
 int dword_50BA08[777]; // idb
 int dword_50BAC4[777]; // weak
--- a/mm7_data.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/mm7_data.h	Thu Oct 25 18:02:42 2012 +0600
@@ -337,6 +337,7 @@
 extern int amuint_4E1870; // weak
 extern int dword_4E1874; // weak
 extern int dword_4E1878; // weak
+extern float flt_4D84E8;
 extern int dword_4E187C; // weak
 extern int dword_4E1880; // weak
 extern int dword_4E1884; // weak
@@ -1661,7 +1662,6 @@
 extern const char *dlhu_texnames_by_face[25];
 extern _UNKNOWN unk_4ED3D8; // weak
 extern unsigned char byte_4ED498; // weak
-extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[]; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
 extern char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 extern int dword_4EDEA0[]; // weak
@@ -2026,19 +2026,18 @@
 extern int dword_50B638[]; // weak
 extern int dword_50B700; // weak
 extern int dword_50B738[]; // idb
-extern int _50B744_view_transformed_ys_minus1[]; // weak
 extern int _50B744_view_transformed_ys[43];
 extern int dword_50B828[];
-extern int _50B834_view_transformed_zs_minus1[]; // weak
 extern int _50B834_view_transformed_zs[43];
 extern int dword_50B918[];
-extern int _50B924_view_transformed_xs_minus1[]; // idb
 extern int _50B924_view_transformed_xs[43];
 extern int unk_50B9D4[]; // idb
 extern int dword_50B9D8_ys[];
 extern int dword_50B9E0_ys[]; // idb
 extern int dword_50B9EC[]; // idb
 extern int dword_50B9F0[2]; // idb
+extern int dword_50BAE8_xs[];
+extern int dword_50BAF4_xs[];
 extern int dword_50B9F8[]; // idb
 extern int dword_50BA08[]; // idb
 extern int dword_50BAC4[]; // weak
@@ -2788,7 +2787,7 @@
 void Load_isn_spells_21_27();
 void GameUI_DrawPartySpells();
 __int16 __fastcall sub_441A4E(int a1);
-void __fastcall GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags);
+void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags);
 int __fastcall DrawSpellbook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
 int __cdecl Initialize2DA();
 unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize);
--- a/stru10.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/stru10.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -94,7 +94,7 @@
     --v6;
   }
   while ( v6 );
-  stru10::_49D379(pFace, a2a);
+  stru10::CalcPolygonBoundingBox(pFace, a2a);
   v7 = pFace->uAttributes;
   if ( v7 & 0x100 )
   {
@@ -417,674 +417,312 @@
 }
 
 //----- (0049D379) --------------------------------------------------------
-int stru10::_49D379(BLVFace *pFace, RenderVertexSoft *pVertices)
+void stru10::CalcPolygonBoundingBox(BLVFace *pFace, RenderVertexSoft *pOutVertices)
 {
-  BLVFace *v3; // edx@1
-  Vec3_short_ *v4; // ecx@1
-  int v5; // eax@2
-  unsigned __int16 *v6; // esi@3
-  char *v7; // eax@3
-  int v8; // ebx@4
-  int v9; // edi@4
-  int v10; // ebx@4
-  int v11; // edi@4
-  double v12; // st7@4
-  int v13; // edi@4
-  unsigned __int16 *v14; // esi@7
-  char *v15; // eax@7
-  int v16; // ebx@8
-  int v17; // edi@8
-  int v18; // ebx@8
-  int v19; // edi@8
-  double v20; // st7@8
-  int v21; // edi@8
-  unsigned __int16 *v22; // esi@11
-  char *v23; // eax@11
-  int v24; // ebx@12
-  int v25; // edi@12
-  int v26; // ebx@12
-  int v27; // edi@12
-  double v28; // st7@12
-  int v29; // edi@12
-  int v30; // eax@13
-  double v31; // st7@13
-  char *v32; // esi@14
-  int v33; // edi@14
-  int v34; // eax@24
-  Vec3_short_ *v35; // eax@24
-  signed int v36; // ecx@24
-  signed int v37; // eax@24
-  Vec3_short_ *v38; // eax@24
-  signed int v39; // ecx@24
-  signed int v40; // eax@24
-  Vec3_short_ *v41; // eax@24
-  signed int v42; // ecx@24
-  signed int v43; // eax@24
-  Vec3_short_ *v44; // eax@24
-  signed int v45; // ecx@24
-  signed int result; // eax@24
-  char v47; // [sp+10h] [bp-350h]@3
-  RenderVertexSoft v48; // [sp+30Ch] [bp-54h]@24
-  int v49; // [sp+33Ch] [bp-24h]@16
-  int v50; // [sp+340h] [bp-20h]@20
-  int v51; // [sp+344h] [bp-1Ch]@18
-  int v52; // [sp+348h] [bp-18h]@22
-  unsigned __int16 *v53; // [sp+34Ch] [bp-14h]@3
-  Vec3_short_ *v54; // [sp+350h] [bp-10h]@3
-  float v55; // [sp+354h] [bp-Ch]@1
-  float v56; // [sp+358h] [bp-8h]@4
-  Vec3_short_ *v57; // [sp+35Ch] [bp-4h]@4
-  int pFacea; // [sp+368h] [bp+8h]@2
-  int pFaceb; // [sp+368h] [bp+8h]@6
-  int pFacec; // [sp+368h] [bp+8h]@10
-  float pFaced; // [sp+368h] [bp+8h]@13
-  signed int pFacee; // [sp+368h] [bp+8h]@24
-  signed int pFacef; // [sp+368h] [bp+8h]@24
-  signed int pFaceg; // [sp+368h] [bp+8h]@24
-  signed int pFaceh; // [sp+368h] [bp+8h]@24
+  struct
+  {
+    float x;
+    float y;
+    int c;
+  } v46[40]; //[sp+0C];
 
-  v3 = pFace;
-  v4 = pIndoor->pVertices;
-  LODWORD(v55) = pFace->uAttributes;
-  if ( BYTE1(v55) & 1 )
+  if (pFace->uAttributes & 0x0100)
   {
-    v5 = pFace->uNumVertices;
-    pFacea = 0;
-    if ( v5 > 0 )
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
+    {
+      v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
+      v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pYInterceptDisplacements[i];
+      v46[i].c = i;
+    }
+  }
+  if (pFace->uAttributes & 0x0200)
+  {
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
     {
-      v6 = v3->pVertexIDs;
-      v7 = &v47;
-      v53 = (unsigned short *)((char *)v3->pXInterceptDisplacements - (char *)v6);
-      v54 = (Vec3_short_ *)((char *)v3->pYInterceptDisplacements - (char *)v6);
-      do
-      {
-        v8 = *(unsigned __int16 *)((char *)v53 + (int)v6);
-        v57 = &v4[*v6];
-        LODWORD(v56) = v57->x + v8;
-        v9 = *(__int16 *)((char *)&v54->x + (int)v6);
-        v10 = v57->y;
-        *((float *)v7 - 1) = (double)SLODWORD(v56);
-        v57 = (Vec3_short_ *)(v10 + v9);
-        v11 = pFacea;
-        v12 = (double)(signed int)v57;
-        ++pFacea;
-        *((int *)v7 + 1) = v11;
-        v13 = v3->uNumVertices;
-        *(float *)v7 = v12;
-        v7 += 12;
-        ++v6;
-      }
-      while ( pFacea < v13 );
+      v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
+      v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pZInterceptDisplacements[i];
+      v46[i].c = i;
+    }
+  }
+  if (pFace->uAttributes & 0x0400)
+  {
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
+    {
+      v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pYInterceptDisplacements[i];
+      v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pZInterceptDisplacements[i];
+      v46[i].c = i;
     }
   }
-  if ( BYTE1(v55) & 2 )
+
+  float x_min = FLT_MAX;
+  uint  x_min_idx = 0;
+
+  float x_max = FLT_MIN;
+  uint  x_max_idx = 0;
+
+  float y_min = FLT_MAX;
+  uint  y_min_idx = 0;
+
+  float y_max = FLT_MIN;
+  uint  y_max_idx = 0;
+
+  for (uint i = 0; i < pFace->uNumVertices; ++i)
   {
-    pFaceb = 0;
-    if ( (signed int)v3->uNumVertices > 0 )
+    if (v46[i].x < x_min)
     {
-      v14 = v3->pVertexIDs;
-      v15 = &v47;
-      v53 = (unsigned short *)((char *)v3->pXInterceptDisplacements - (char *)v14);
-      LODWORD(v56) = (char *)v3->pZInterceptDisplacements - (char *)v14;
-      do
-      {
-        v16 = *(unsigned __int16 *)((char *)v53 + (int)v14);
-        v54 = &v4[*v14];
-        v57 = (Vec3_short_ *)(v54->x + v16);
-        v17 = *(signed __int16 *)((char *)v14 + LODWORD(v56));
-        v18 = v54->z;
-        *((float *)v15 - 1) = (double)(signed int)v57;
-        v57 = (Vec3_short_ *)(v18 + v17);
-        v19 = pFaceb;
-        v20 = (double)(signed int)v57;
-        ++pFaceb;
-        *((int *)v15 + 1) = v19;
-        v21 = v3->uNumVertices;
-        *(float *)v15 = v20;
-        v15 += 12;
-        ++v14;
-      }
-      while ( pFaceb < v21 );
+      x_min = v46[i].x;
+      x_min_idx = v46[i].c;
     }
-  }
-  if ( BYTE1(v55) & 4 )
-  {
-    pFacec = 0;
-    if ( (signed int)v3->uNumVertices > 0 )
+    if (v46[i].x > x_max)
+    {
+      x_max = v46[i].x;
+      x_max_idx = v46[i].c;
+    }
+
+    if (v46[i].y < y_min)
     {
-      v22 = v3->pVertexIDs;
-      v23 = &v47;
-      v54 = (Vec3_short_ *)((char *)v3->pYInterceptDisplacements - (char *)v22);
-      LODWORD(v56) = (char *)v3->pZInterceptDisplacements - (char *)v22;
-      do
-      {
-        v24 = *(__int16 *)((char *)&v54->x + (int)v22);
-        LODWORD(v55) = (unsigned int)&v4[*v22];
-        v57 = (Vec3_short_ *)(*(short *)(LODWORD(v55) + 2) + v24);
-        v25 = *(signed __int16 *)((char *)v22 + LODWORD(v56));
-        v26 = *(short *)(LODWORD(v55) + 4);
-        *((float *)v23 - 1) = (double)(signed int)v57;
-        v57 = (Vec3_short_ *)(v26 + v25);
-        v27 = pFacec;
-        v28 = (double)(signed int)v57;
-        ++pFacec;
-        *((int *)v23 + 1) = v27;
-        v29 = v3->uNumVertices;
-        *(float *)v23 = v28;
-        v23 += 12;
-        ++v22;
-      }
-      while ( pFacec < v29 );
+      y_min = v46[i].y;
+      y_min_idx = v46[i].c;
+    }
+    if (v46[i].y > y_max)
+    {
+      y_max = v46[i].y;
+      y_max_idx = v46[i].c;
     }
   }
-  v30 = v3->uNumVertices;
-  pFaced = 3.4028235e38;
-  v56 = 3.4028235e38;
-  v31 = -3.4028235e38;
-  v55 = -3.4028235e38;
-  if ( v30 > 0 )
-  {
-    v32 = &v47;
-    v33 = v30;
-    do
-    {
-      if ( *((float *)v32 - 1) < (double)pFaced )
-      {
-        LODWORD(pFaced) = *((int *)v32 - 1);
-        v49 = *((int *)v32 + 1);
-      }
-      if ( *((float *)v32 - 1) > (double)v55 )
-      {
-        LODWORD(v55) = *((int *)v32 - 1);
-        v51 = *((int *)v32 + 1);
-      }
-      if ( *(float *)v32 < (double)v56 )
-      {
-        LODWORD(v56) = *(int *)v32;
-        v50 = *((int *)v32 + 1);
-      }
-      if ( v31 < *(float *)v32 )
-      {
-        v31 = *(float *)v32;
-        v52 = *((int *)v32 + 1);
-      }
-      v32 += 12;
-      --v33;
-    }
-    while ( v33 );
-  }
-  v34 = v3->pVertexIDs[v49];
-  v48.flt_2C = 0.0;
-  v35 = &v4[v34];
-  pFacee = v35->x;
-  v36 = v35->y;
-  v37 = v35->z;
-  v48.vWorldPosition.x = (double)pFacee;
-  v48.vWorldPosition.y = (double)v36;
-  v48.vWorldPosition.z = (double)v37;
-  memcpy(pVertices, &v48, 0x30u);
-  v48.flt_2C = 0.0;
-  v38 = &pIndoor->pVertices[v3->pVertexIDs[v50]];
-  pFacef = v38->x;
-  v39 = v38->y;
-  v40 = v38->z;
-  v48.vWorldPosition.x = (double)pFacef;
-  v48.vWorldPosition.y = (double)v39;
-  v48.vWorldPosition.z = (double)v40;
-  memcpy(&pVertices[1], &v48, sizeof(pVertices[1]));
-  v48.flt_2C = 0.0;
-  v41 = &pIndoor->pVertices[v3->pVertexIDs[v51]];
-  pFaceg = v41->x;
-  v42 = v41->y;
-  v43 = v41->z;
-  v48.vWorldPosition.x = (double)pFaceg;
-  v48.vWorldPosition.y = (double)v42;
-  v48.vWorldPosition.z = (double)v43;
-  memcpy(&pVertices[2], &v48, sizeof(pVertices[2]));
-  v48.flt_2C = 0.0;
-  v44 = &pIndoor->pVertices[v3->pVertexIDs[v52]];
-  pFaceh = v44->x;
-  v45 = v44->y;
-  result = v44->z;
-  v48.vWorldPosition.x = (double)pFaceh;
-  v48.vWorldPosition.y = (double)v45;
-  v48.vWorldPosition.z = (double)result;
-  memcpy(&pVertices[3], &v48, sizeof(pVertices[3]));
-  return result;
+
+
+
+  auto p1 = &pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]];
+  RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24
+  v1.vWorldPosition.x = (float)p1->x;
+  v1.vWorldPosition.y = (float)p1->y;
+  v1.vWorldPosition.z = (float)p1->z;
+  memcpy(pOutVertices + 0, &v1, sizeof(RenderVertexSoft));
+
+  auto p2 = &pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]];
+  RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24
+  v2.vWorldPosition.x = (float)p2->x;
+  v2.vWorldPosition.y = (float)p2->y;
+  v2.vWorldPosition.z = (float)p2->z;
+  memcpy(pOutVertices + 1, &v2, sizeof(RenderVertexSoft));
+
+  auto p3 = &pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]];
+  RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24
+  v3.vWorldPosition.x = (float)p3->x;
+  v3.vWorldPosition.y = (float)p3->y;
+  v3.vWorldPosition.z = (float)p3->z;
+  memcpy(pOutVertices + 2, &v3, sizeof(RenderVertexSoft));
+
+  auto p4 = &pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]];
+  RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24
+  v4.vWorldPosition.x = (double)p4->x;
+  v4.vWorldPosition.y = (double)p4->y;
+  v4.vWorldPosition.z = (double)p4->z;
+  memcpy(pOutVertices + 3, &v4, sizeof(RenderVertexSoft));
 }
 
 
 //----- (0049C9E3) --------------------------------------------------------
-bool stru10::_49C9E3(BLVFace *a3, RenderVertexSoft *arg4, unsigned int uNumVertices, RenderVertexSoft *arg0)
+bool stru10::_49C9E3(BLVFace *pFace, RenderVertexSoft *pFaceBounding, unsigned int uNumVertices, RenderVertexSoft *arg0)
 {
-  __debugbreak();
-  return 0;
-  /*IndoorCameraD3D *v6; // edi@1
-  PolygonType v7; // al@1
-  unsigned int v8; // edx@7
-  char v10; // zf@10
-  float v13; // ST14_4@20
-  stru10 *v15; // ecx@21
-  RenderVertexSoft *v16; // ST0C_4@21
-  bool result; // eax@21
-  float v18; // ST14_4@24
-  stru10 *v19; // edi@29
-  float v20; // ST14_4@30
-  float v21; // ST14_4@30
-  float v22; // ST14_4@30
-  float v23; // ST14_4@30
-  float v24; // ST14_4@31
-  RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
-  RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
-  IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
-  stru10 *v31; // [sp+84h] [bp-1Ch]@1
+  //IndoorCameraD3D *v6; // edi@1
+  //PolygonType v7; // al@1
+  //unsigned int v8; // edx@7
+  //char v10; // zf@10
+  //float v13; // ST14_4@20
+  //stru10 *v15; // ecx@21
+  //RenderVertexSoft *v16; // ST0C_4@21
+  //bool result; // eax@21
+  //float v18; // ST14_4@24
+  //stru10 *v19; // edi@29
+  //float v20; // ST14_4@30
+  //float v21; // ST14_4@30
+  //float v22; // ST14_4@30
+  //float v23; // ST14_4@30
+  //float v24; // ST14_4@31
+  //RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
+  //RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+  //IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
+  //stru10 *v31; // [sp+84h] [bp-1Ch]@1
   float v32; // [sp+88h] [bp-18h]@8
   Vec3_float_ a1; // [sp+8Ch] [bp-14h]@1
   float v35; // [sp+9Ch] [bp-4h]@8
 
-  _ESI = a3;
-  v31 = this;
-  __asm
-  {
-    fld     dword ptr [esi]
-    fld     dword ptr [esi+4]
-    fldz
-  }
-  v6 = pGame->pIndoorCameraD3D;
-  v7 = a3->uPolygonType;
-  __asm
-  {
-    fstp    [ebp+var_28]
-    fldz
-  }
-  thisa = v6;
-  __asm
+  //auto a3 = pFace;
+  //auto arg4 = pFaceBounding;
+
+  //_ESI = a3;
+  //v31 = this;
+  //v6 = pGame->pIndoorCameraD3D;
+  //v7 = a3->uPolygonType;
+
+  a1.x = 0.0f;
+  a1.y = 0.0f;
+  a1.z = 0.0f;
+
+  float var_28;
+  float var_24;
+  if (pFace->uPolygonType == POLYGON_VerticalWall)
   {
-    fstp    [ebp+var_24]
-    fldz
-    fstp    [ebp+a1.x]
-    fldz
-    fstp    [ebp+a1.y]
-    fldz
-    fstp    [ebp+a1.z]
+    a1.x = -pFace->pFacePlane.vNormal.y;
+    a1.y = pFace->pFacePlane.vNormal.x;
+    a1.z = 0.0f;
+    a1.Normalize();
+
+    var_28 = 0;
+    var_24 = 1;
   }
-  if ( v7 == 1 )
+  else if (pFace->uPolygonType == POLYGON_Floor ||
+           pFace->uPolygonType == POLYGON_Ceiling)
   {
-    __asm
-    {
-      fchs
-      fstp    [ebp+a1.x]
-      fstp    [ebp+a1.y]
-      fldz
-      fstp    [ebp+a1.z]
-    }
-    a1.Normalize();
-    __asm
-    {
-      fldz
-      fstp    [ebp+var_28]
-      fld1
-    }
-LABEL_6:
-    __asm { fstp    [ebp+var_24] }
-    goto LABEL_7;
+    a1.x = 1;
+    a1.y = 0;
+    a1.z = 0.0f;
+
+    var_28 = 1;
+    var_24 = 0;
   }
-  __asm
-  {
-    fstp    st
-    fstp    st
-  }
-  if ( v7 == 3 || v7 == 5 )
+
+
+  float arg_4;
+  float var_18;
+  float var_4;
+  float a3;
+  float var_8;
+  //v8 = _ESI->uAttributes;
+  //_ECX = pFaceBounding;
+  //__asm { fld     0.5 }
+  if (pFace->uAttributes & 0x0100)
   {
-    __asm
-    {
-      fld1
-      fstp    [ebp+a1.x]
-      fldz
-      fstp    [ebp+a1.y]
-      fldz
-      fstp    [ebp+a1.z]
-      fld1
-      fstp    [ebp+var_28]
-      fldz
-    }
-    goto LABEL_6;
+    arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
+    var_18 = (pFaceBounding[3].vWorldPosition.y + pFaceBounding[1].vWorldPosition.y) / 2;
+    var_4 = (pFaceBounding[0].vWorldPosition.z + pFaceBounding[2].vWorldPosition.z) / 2;
+
+    a3 = arg_4 - pFaceBounding[0].vWorldPosition.x;
+    var_8 = var_18 - pFaceBounding[1].vWorldPosition.y;
   }
-LABEL_7:
-  v8 = _ESI->uAttributes;
-  _ECX = arg4;
-  __asm { fld     ds:flt_4D84F0 }
-  if ( BYTE1(v8) & 1 )
+  if (pFace->uAttributes & 0x0200)
   {
-    __asm
+    arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
+    var_18 = (pFaceBounding[0].vWorldPosition.y + pFaceBounding[2].vWorldPosition.y) / 2;
+    var_4 = (pFaceBounding[1].vWorldPosition.z + pFaceBounding[3].vWorldPosition.z) / 2;
+
+    a3 = arg_4 - pFaceBounding[0].vWorldPosition.x;
+    var_8 = var_4 - pFaceBounding[1].vWorldPosition.z;
+
+    if (pFace->uPolygonType == POLYGON_VerticalWall)
+      a3 /= a1.x;
+  }
+  if (pFace->uAttributes & 0x0400)
+  {
+    arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
+    var_18 = (pFaceBounding[0].vWorldPosition.y + pFaceBounding[2].vWorldPosition.y) / 2;
+    var_4 = (pFaceBounding[1].vWorldPosition.z + pFaceBounding[3].vWorldPosition.z) / 2;
+
+    a3 = var_18 - pFaceBounding[0].vWorldPosition.y;
+    var_8 = var_4 - pFaceBounding[1].vWorldPosition.z;
+                                       // [0.5]
+    if (pFace->uPolygonType == POLYGON_VerticalWall)
     {
-      fld     dword ptr [ecx+60h]
-      fadd    dword ptr [ecx]
-      fmul    st, st(1)
-      fstp    [ebp+arg4]
-      fld     dword ptr [ecx+94h]
-      fadd    dword ptr [ecx+34h]
-      fmul    st, st(1)
-      fstp    [ebp+var_18]
-      fld     dword ptr [ecx+68h]
-      fadd    dword ptr [ecx+8]
-      fmul    st, st(1)
-      fstp    [ebp+var_4]
-      fld     [ebp+arg4]
-      fsub    dword ptr [ecx]
-      fstp    [ebp+a3]
-      fld     [ebp+var_18]
-      fsub    dword ptr [ecx+34h]
-      fstp    [ebp+var_8]
+      if (a1.x != 1.0f)
+        a3 /= a1.y;
     }
   }
-  if ( BYTE1(v8) & 2 )
-  {
-    __asm
-    {
-      fld     dword ptr [ecx+60h]
-      fadd    dword ptr [ecx]
-    }
-    v10 = _ESI->uPolygonType == 1;
-    __asm
-    {
-      fmul    st, st(1)
-      fstp    [ebp+arg4]
-      fld     dword ptr [ecx+64h]
-      fadd    dword ptr [ecx+4]
-      fmul    st, st(1)
-      fstp    [ebp+var_18]
-      fld     dword ptr [ecx+98h]
-      fadd    dword ptr [ecx+38h]
-      fmul    st, st(1)
-      fstp    [ebp+var_4]
-      fld     [ebp+arg4]
-      fsub    dword ptr [ecx]
-      fstp    [ebp+a3]
-      fld     [ebp+var_4]
-      fsub    dword ptr [ecx+38h]
-      fstp    [ebp+var_8]
-    }
-    if ( v10 )
-    {
-      __asm
-      {
-        fld     [ebp+a1.x]
-        fcomp   ds:dword_4D84A8
-        fnstsw  ax
-      }
-      if ( __SETP__(HIBYTE(_AX) & 0x44, 0) )
-      {
-        __asm
-        {
-          fld     [ebp+a3]
-          fdiv    [ebp+a1.x]
-          fstp    [ebp+a3]
-        }
-      }
-    }
-  }
-  if ( BYTE1(v8) & 4 )
-  {
-    __asm
-    {
-      fld     dword ptr [ecx+60h]
-      fadd    dword ptr [ecx]
-    }
-    v10 = _ESI->uPolygonType == 1;
-    __asm
-    {
-      fmul    st, st(1)
-      fstp    [ebp+arg4]
-      fld     dword ptr [ecx+64h]
-      fadd    dword ptr [ecx+4]
-      fmul    st, st(1)
-      fstp    [ebp+var_18]
-      fld     dword ptr [ecx+98h]
-      fadd    dword ptr [ecx+38h]
-      fmul    st, st(1)
-      fstp    [ebp+var_4]
-      fstp    st
-      fld     [ebp+var_18]
-      fsub    dword ptr [ecx+4]
-      fstp    [ebp+a3]
-      fld     [ebp+var_4]
-      fsub    dword ptr [ecx+38h]
-      fstp    [ebp+var_8]
-    }
-    if ( v10 )
-    {
-      __asm
-      {
-        fld     [ebp+a1.x]
-        fcomp   ds:dword_4D84A8
-        fnstsw  ax
-      }
-      if ( __SETP__(HIBYTE(_AX) & 0x44, 0) )
-      {
-        __asm
-        {
-          fld     [ebp+a3]
-          fdiv    [ebp+a1.y]
-          fstp    [ebp+a3]
-        }
-      }
-    }
-  }
-  else
-  {
-    __asm { fstp    st }
-  }
+
+
   if ( byte_4D864C && pGame->uFlags & 8 )
   {
-    __asm { fldz }
-    LODWORD(v26.vWorldPosition.x) = arg4;
-    __asm { fstp    [ebp+var_60.flt_2C] }
+    RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+    v26.vWorldPosition.x = arg_4;
     v26.vWorldPosition.y = v32;
-    __asm { fldz }
     v26.vWorldPosition.z = v35;
-    __asm { fstp    [esp+0A0h+var_A0] }
-    v6->do_draw_debug_line_sw(_ECX, 0xFF00u, &v26, 0xFF0000u, 0, v13);
+
+    pGame->pIndoorCameraD3D->do_draw_debug_line_sw(pFaceBounding, 0xFF00u, &v26, 0xFF0000u, 0, 0);
   }
-  __asm
-  {
-    fld     [ebp+var_8]
-    fmul    ds:flt_4D84E8
-    fld     [ebp+var_8]
-    fmul    [ebp+var_28]
-    fld     [ebp+var_8]
-    fmul    [ebp+var_24]
-  }
-  _EBX = arg0;
-  v15 = v31;
-  __asm
-  {
-    fst     [ebp+var_20]
-    fld     [ebp+a3]
-    fmul    [ebp+a1.x]
-    fld     [ebp+a3]
-    fmul    [ebp+a1.y]
-    fld     [ebp+a3]
-    fmul    [ebp+a1.z]
-  }
-  v16 = arg0;
-  __asm
+
+  //_EBX = arg0;
+  //v15 = v31;
+  //v16 = arg0;
+  float var_20 = var_8 * var_24;
+  var_8 = a3 * a1.z;
+  float arg_0 = var_8 + var_4;
+
+  arg0[0].vWorldPosition.x = arg_4 - a3 * a1.x + var_8 * flt_4D84E8;
+  arg0[0].vWorldPosition.y = var_18 - a3 * a1.y + var_8 * var_28;
+  arg0[0].vWorldPosition.z = var_4 - var_8 + var_8 * var_24;
+  arg0[1].vWorldPosition.x = arg_4 - a3 * a1.x - var_8 * flt_4D84E8;
+  arg0[1].vWorldPosition.y = var_18 - a3 * a1.y - var_8 * var_28;
+  arg0[1].vWorldPosition.z = (var_4 - var_8) - var_8 * var_24;
+  arg0[2].vWorldPosition.x = a3 * a1.x + arg_4 - var_8 * flt_4D84E8;
+  arg0[2].vWorldPosition.y = a3 * a1.y + var_18 - var_8 * var_28;
+  arg0[2].vWorldPosition.z = var_8 + var_4 - var_20;
+  arg0[3].vWorldPosition.x = (a3 * a1.x + arg_4) + var_8 * flt_4D84E8;
+  arg0[3].vWorldPosition.y = a3 * a1.y + var_18 + var_8 * var_28;
+  arg0[3].vWorldPosition.z = arg_0 + var_20;
+
+  a3 = (var_4 - var_8);
+  a3 = (a3 * a1.x + arg_4);
+
+  a1.x = 0.0f;
+  a1.y = 0.0f;
+  a1.z = 0.0f;
+
+  if (!_49C8DC(arg0, &a1, &a3))
+    return false;
+
+
+  if ( byte_4D864C )
   {
-    fstp    [ebp+var_8]
-    fld     [ebp+arg4]
-    fsub    st, st(2)
-    fld     st
-    fadd    st, st(6)
-    fstp    dword ptr [ebx]
-    fld     [ebp+var_18]
-    fsub    st, st(2)
-    fld     st
-    fadd    st, st(6)
-    fstp    dword ptr [ebx+4]
-    fld     [ebp+var_4]
-    fsub    [ebp+var_8]
-    fst     [ebp+a3]
-    fadd    st, st(5)
-    fstp    dword ptr [ebx+8]
-    fld     st(1)
-    fsub    st, st(7)
-    fstp    dword ptr [ebx+30h]
-    fsub    st, st(5)
-    fstp    dword ptr [ebx+34h]
-    fstp    st
-    fld     [ebp+a3]
-    fsub    st, st(3)
-    fstp    dword ptr [ebx+38h]
-    fld     st(1)
-    fadd    [ebp+arg4]
-    fst     [ebp+a3]
-    fsub    st, st(5)
-    fstp    dword ptr [ebx+60h]
-    fadd    [ebp+var_18]
-    fstp    st(2)
-    fstp    st
-    fld     st
-    fsub    st, st(2)
-    fstp    dword ptr [ebx+64h]
-    fld     [ebp+var_8]
-    fadd    [ebp+var_4]
-    fst     [ebp+arg0]
-    fsub    [ebp+var_20]
-    fstp    dword ptr [ebx+68h]
-    fld     [ebp+a3]
-    fadd    st, st(3)
-    fstp    dword ptr [ebx+90h]
-    fadd    st, st(1)
-    fstp    dword ptr [ebx+94h]
-    fstp    st
-    fstp    st
-    fld     [ebp+arg0]
-    fadd    [ebp+var_20]
-    fstp    dword ptr [ebx+98h]
-    fldz
-    fstp    [ebp+a1.x]
-    fldz
-    fstp    [ebp+a1.y]
-    fldz
-    fstp    [ebp+a1.z]
-  }
-  result = this->_49C8DC(v16, &a1, (float *)&a3);
-  if ( result )
-  {
-    if ( byte_4D864C )
-    {
-      HIWORD(result) = HIWORD(pGame);
       if ( pGame->uFlags & 8 )
       {
-        __asm
-        {
-          fldz
-          fstp    [ebp+var_60.flt_2C]
-          fld     ds:flt_4D8770
-          fld     [ebp+a1.x]
-          fmul    st, st(1)
-        }
-        LODWORD(v25.vWorldPosition.x) = (uint)arg4;
+        RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
+        RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+
+        v25.vWorldPosition.x = arg_4;
         v25.vWorldPosition.y = v32;
-        __asm
-        {
-          fstp    [ebp+var_60.vWorldPosition.x]
-          fld     [ebp+a1.y]
-          fmul    st, st(1)
-        }
         v25.vWorldPosition.z = v35;
-        __asm
-        {
-          fstp    [ebp+var_60.vWorldPosition.y]
-          fld     [ebp+a1.z]
-          fmul    st, st(1)
-          fstp    [ebp+var_60.vWorldPosition.z]
-          fstp    st
-          fldz
-          fstp    [ebp+var_90.flt_2C]
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, v18);
+
+        v26.vWorldPosition.x = a1.x * 30.0f;
+        v26.vWorldPosition.y = a1.y * 30.0f;
+        v26.vWorldPosition.z = a1.z * 30.0f;
+
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, 0);
       }
-    }
-    __asm { fild    pBLVRenderParams->vPartyPos.z }
-    memcpy(&v25, _EBX, sizeof(v25));
-    __asm
-    {
-      fsubr   [ebp+var_90.vWorldPosition.z]
-      fmul    [ebp+a1.z]
-      fild    pBLVRenderParams->vPartyPos.y
-      fsubr   [ebp+var_90.vWorldPosition.y]
-      fmul    [ebp+a1.y]
-      faddp   st(1), st
-      fild    pBLVRenderParams->vPartyPos.x
-      fsubr   [ebp+var_90.vWorldPosition.x]
-      fmul    [ebp+a1.x]
-      faddp   st(1), st
-      fcomp   ds:flt_4D84E8
-      fnstsw  ax
-    }
-    if ( !__SETP__(BYTE1(result) & 5, 0) )
-    {
-      result = (bool)&_EBX[1];
-      memcpy(&v25, &_EBX[1], sizeof(v25));
-      memcpy(&_EBX[1], &_EBX[3], sizeof(_EBX[1]));
-      memcpy(&_EBX[3], &v25, sizeof(_EBX[3]));
-    }
+  }
+
+
+  RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
+  memcpy(&v25, arg0, sizeof(RenderVertexSoft));
+
+  float _dp = (v25.vWorldPosition.x - pBLVRenderParams->vPartyPos.x) * a1.x +
+              (v25.vWorldPosition.y - pBLVRenderParams->vPartyPos.y) * a1.y +
+              (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z;
+  if (fabs(_dp) < 1e-6f)
+  {
+    memcpy(&v25, arg0 + 1, sizeof(RenderVertexSoft));
+    memcpy(arg0 + 1, arg0 + 3, sizeof(RenderVertexSoft));
+    memcpy(arg0 + 3, &v25, sizeof(RenderVertexSoft));
+  }
+
     if ( byte_4D864C && pGame->uFlags & 8 )
     {
-      v19 = v31;
-      if ( !LOBYTE(v31->field_4) )
+      RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+      if ( !LOBYTE(field_4) )
       {
-        __asm
-        {
-          fldz
-          fstp    [ebp+var_60.flt_2C]
-          fild    pParty->vPosition.x
-        }
-        a3 = (BLVFace *)(pParty->vPosition.y + pParty->sEyelevel);
-        __asm
-        {
-          fstp    [ebp+var_60.vWorldPosition.x]
-          fild    pParty->vPosition.z
-          fstp    [ebp+var_60.vWorldPosition.y]
-          fild    [ebp+a3]
-          fstp    [ebp+var_60.vWorldPosition.z]
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFF0000u, _EBX, 0xFF0000u, 0, v20);
-        __asm
-        {
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFF00u, _EBX + 1, 0xFF00u, 0, v21);
-        __asm
-        {
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFFu, _EBX + 2, 0xFFu, 0, v22);
-        __asm
-        {
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFFFFFFu, _EBX + 3, 0xFFFFFFu, 0, v23);
-        LOBYTE(v19->field_4) = 1;
+        v26.vWorldPosition.x = pParty->vPosition.x;
+        v26.vWorldPosition.y = pParty->vPosition.z;
+        v26.vWorldPosition.z = pParty->vPosition.y + pParty->sEyelevel;
+
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, arg0, 0xFF0000u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, arg0 + 1, 0xFF00u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, arg0 + 2, 0xFFu, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, arg0 + 3, 0xFFFFFFu, 0, 0);
+        LOBYTE(field_4) = 1;
       }
-      __asm
-      {
-        fld     ds:flt_4D86E8
-        fstp    [esp+0A0h+var_A0]
-      }
-      IndoorCameraD3D::debug_outline_sw(thisa, _EBX, uNumVertices, 0x1EFF1Eu, v24);
+      pGame->pIndoorCameraD3D->debug_outline_sw(arg0, uNumVertices, 0x1EFF1Eu, 0.00019999999);
     }
-    LOBYTE(result) = 1;
-  }
-  return result;*/
+  return true;
 }
 
 
@@ -1132,33 +770,16 @@
 // 4D864C: using guessed type char byte_4D864C;
 
 //----- (0049C681) --------------------------------------------------------
-char stru10::_49C681(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pArrayOf4)
+char stru10::_49C681_DrawDebugStuff(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pArrayOf4)
 {
-  stru10 *v4; // edi@1
-  char *v5; // eax@1
-  signed int v6; // ecx@1
-  IndoorCameraD3D *v7; // esi@3
-  char result; // al@6
-  RenderVertexSoft a2a[4]; // [sp+Ch] [bp-C0h]@1
+  RenderVertexSoft pBounding[4]; // [sp+Ch] [bp-C0h]@1
 
-  v4 = this;
-  v5 = (char *)&a2a[0].flt_2C;
-  v6 = 4;
-  do
-  {
-    *(float *)v5 = 0.0;
-    v5 += 48;
-    --v6;
-  }
-  while ( v6 );
-  v7 = pGame->pIndoorCameraD3D;
-  _49D379(pFace, a2a);
+  CalcPolygonBoundingBox(pFace, pBounding);
   if ( byte_4D864C && pGame->uFlags & 8 )
-    pGame->pIndoorCameraD3D->debug_outline_sw(a2a, 4u, 0xFF1E1Eu, 0.000099999997);
-  result = _49C9E3(pFace, a2a, 4u, pArrayOf4);
-  if ( result )
-    result = _49C720(pArrayOf4, a3);
-  return result;
+    pGame->pIndoorCameraD3D->debug_outline_sw(pBounding, 4, 0xFF1E1E, 0.000099999997);
+  if (_49C9E3(pFace, pBounding, 4, pArrayOf4))
+    return _49C720(pArrayOf4, a3);
+  return false;
 }
 // 4D864C: using guessed type char byte_4D864C;
 
@@ -1300,7 +921,7 @@
   a1.z = result->z;
   if ( a1.x != 0.0
     || a1.y != 0.0
-    || (/*UNDEF(v8),*/ v9 = a1.z < 0.0, v10 = 0, v11 = a1.z == 0.0, BYTE1(result) = HIBYTE(v8), a1.z != 0.0) )
+    || (/*UNDEF(v8),*/ v9 = a1.z < 0.0, v10 = 0, v11 = a1.z == 0.0, /*BYTE1(result) = HIBYTE(v8),*/ a1.z != 0.0) )
   {
     a1.Normalize();
     v12 = a1.y;
@@ -1311,11 +932,7 @@
     a2->z = a1.z;
     result = (Vec3_float_ *)a3;
     *a3 = -(v13 + v14 + v19 * a1.x);
-    LOBYTE(result) = 1;
+    return true;
   }
-  else
-  {
-    LOBYTE(result) = 0;
-  }
-  return (bool)result;
+  return false;
 }
--- a/stru10.h	Thu Oct 25 18:01:39 2012 +0600
+++ b/stru10.h	Thu Oct 25 18:02:42 2012 +0600
@@ -8,12 +8,12 @@
   stru10();
   virtual ~stru10();
   char _49C5DA(struct BLVFace *a2, struct RenderVertexSoft *a3, int *a4, struct IndoorCameraD3D_Vec4 *a5, struct RenderVertexSoft *a6);
-  char _49C681(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pArrayOf4);
+  char _49C681_DrawDebugStuff(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pArrayOf4);
   char _49C720(struct RenderVertexSoft *a2, struct IndoorCameraD3D_Vec4 *a4);
   bool _49C7C5(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct Vec3_float_ *a3, struct IndoorCameraD3D_Vec4 *a4);
   bool _49C8DC(struct RenderVertexSoft *arg0, struct Vec3_float_ *a2, float *a3);
   bool _49C9E3(struct BLVFace *a3, struct RenderVertexSoft *arg4, unsigned int uNumVertices, struct RenderVertexSoft *arg0);
-  int _49D379(struct BLVFace *pFace, struct RenderVertexSoft *pVertices);
+  void CalcPolygonBoundingBox(struct BLVFace *pFace, struct RenderVertexSoft pOutVertices[4]);
   void _49CE9E(struct BLVFace *pFace, struct RenderVertexSoft *a2, signed int a3, RenderVertexSoft *a4);
 
 
--- a/stru9.cpp	Thu Oct 25 18:01:39 2012 +0600
+++ b/stru9.cpp	Thu Oct 25 18:02:42 2012 +0600
@@ -155,10 +155,10 @@
 {
   RenderVertexSoft *v9; // ecx@1
   Vec3_float_ *v10; // esi@1
-  char *v11; // ebx@1
+  //char *v11; // ebx@1
   RenderVertexSoft *v12; // edi@1
   double v13; // st7@1
-  bool result; // eax@4
+  //bool result; // eax@4
   signed int v15; // edx@9
   RenderVertexSoft *v16; // ecx@9
   double v17; // st7@9
@@ -169,60 +169,57 @@
 
   v9 = a1;
   v10 = a5;
-  v11 = (char *)&a1->vWorldPosition.z;
+  //v11 = (char *)&a1->vWorldPosition.z;
+  auto v11 = a1;
   v12 = a3;
   v13 = a1->vWorldPosition.y * a5->y + a5->x * a1->vWorldPosition.x + a1->vWorldPosition.z * a5->z;
   v20 = v13;
   v21 = v13 >= a6;
-  result = 0;
+
   *pOutNumVertices = 0;
   if ( a2 <= 0 )
-    goto LABEL_19;
+    return false;
+  v19 = 1;
   while ( 1 )
   {
-    v19 = result + 1;
     if ( v21 )
     {
       ++a3;
-      memcpy(v12, v11 - 8, 0x30u);
+      memcpy(v12, v11, sizeof(RenderVertexSoft));
       ++*pOutNumVertices;
       v10 = a5;
       v12 = a3;
       v9 = a1;
     }
     v15 = 0;
-    v16 = &v9[(result + 1) % a2];
+    v16 = &v9[v19 % a2];
     v17 = v16->vWorldPosition.z * v10->z + v16->vWorldPosition.y * v10->y + v10->x * v16->vWorldPosition.x;
     if ( v17 >= a6 )
       v15 = 1;
     if ( v21 != v15 )
     {
       v18 = (a6 - v20) / (v17 - v20);
-      v12->vWorldPosition.x = (v16->vWorldPosition.x - *((float *)v11 - 2)) * v18 + *((float *)v11 - 2);
+      v12->vWorldPosition.x = (v16->vWorldPosition.x - v11->vWorldPosition.x) * v18 + v11->vWorldPosition.x;
+      v12->vWorldPosition.y = (v16->vWorldPosition.y - v11->vWorldPosition.y) * v18 + v11->vWorldPosition.y;
+      v12->vWorldPosition.z = (v16->vWorldPosition.z - v11->vWorldPosition.z) * v18 + v11->vWorldPosition.z;
+      v12->u = (v16->u - v11->u) * v18 + v11->u;
+      v12->v = (v16->v - v11->v) * v18 + v11->v;
       ++v12;
       a3 = v12;
-      *((float *)v12 - 11) = (v16->vWorldPosition.y - *((float *)v11 - 1)) * v18 + *((float *)v11 - 1);
-      *((float *)v12 - 10) = (v16->vWorldPosition.z - *(float *)v11) * v18 + *(float *)v11;
-      *((float *)v12 - 3) = (v16->u - *((float *)v11 + 7)) * v18 + *((float *)v11 + 7);
-      *((float *)v12 - 2) = (v16->v - *((float *)v11 + 8)) * v18 + *((float *)v11 + 8);
       ++*pOutNumVertices;
       *a7 = 1;
     }
-    ++result;
-    v11 += 48;
+
+    v11++;
     v21 = v15;
     v20 = v17;
     if ( v19 >= a2 )
       break;
     v9 = a1;
+    v19++;
   }
-  result = (bool)pOutNumVertices;
-  if ( (signed int)*pOutNumVertices >= 3 )
-    LOBYTE(result) = 1;
-  else
-LABEL_19:
-    LOBYTE(result) = 0;
-  return result;
+
+  return *pOutNumVertices >= 3;
 }
 
 //----- (00498737) --------------------------------------------------------