changeset 87:c0cf9393af64

Слияние
author Ritor1
date Mon, 29 Oct 2012 09:28:08 +0600
parents c83d06692295 (current diff) b39bdc150e90 (diff)
children 2d3f4e0379ce c97dfd4b9600 62bfa3ffe7db
files mm7_4.cpp stru346.h
diffstat 67 files changed, 6782 insertions(+), 9291 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Actor.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -180,7 +180,7 @@
   if ( (v6 & 3) != 2 )
     v5->uFlags = v6 + 1;
   v7 = const_2();
-  sprintfex(pContainer, "evt%02d", v7);
+  sprintf(pContainer, "evt%02d", v7);
   if ( !pParty->uAlignment )
   {
     v14 = "-b";
@@ -198,7 +198,7 @@
   array_5913D8[6] = 0;
   uNumDialogueNPCPortraits = 1;
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v8];
-  sprintfex(pContainer, "npc%03u", v5->uPortraitID);
+  sprintf(pContainer, "npc%03u", v5->uPortraitID);
   v9 = 0;
   pDialogueNPCPortraits[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
   dword_591084 = areWeLoadingTexture;
@@ -258,17 +258,17 @@
             0x88u,
             9u,
             0,
-            nullstring,
+            "",
             0);
           pDialogueWindow->_41D08F(4, 1, 0, 1);
         }
       }
     }
   }
-  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   if ( v17 && uActiveCharacter && !(v5->uFlags & 0x80) )
   {
     if ( pParty->uCurrentHour < 5 || pParty->uCurrentHour > 0x15 )
@@ -729,10 +729,10 @@
           }
           if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
             return;
-          v118 = pParty->vPosition.y;
+          v118 = pParty->vPosition.z;
           v111 = pParty->vPosition.x;
-          v114 = pParty->vPosition.y + 2500;
-          v113 = pParty->vPosition.z;
+          v114 = pParty->vPosition.z + 2500;
+          v113 = pParty->vPosition.y;
           v23 = 8;
           if ( uSkillLevel & 0x0100 )
           {
@@ -1786,8 +1786,8 @@
     if ( !v4 )
     {
       outx = pParty->vPosition.x;
-      outy = pParty->vPosition.z;
-      v14 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+      outy = pParty->vPosition.y;
+      v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
 LABEL_27:
       outz = v14;
       goto LABEL_28;
@@ -1807,21 +1807,21 @@
           v39 = &outy;
           v38 = &outx;
           v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
-          v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+          v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
           goto LABEL_20;
         }
         v40 = &outz;
         v39 = &outy;
         v38 = &outx;
         v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi;
-        v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
       }
       else
       {
         v40 = &outz;
         v39 = &outy;
         v38 = &outx;
-        v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
       }
       *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x;
@@ -1834,7 +1834,7 @@
     v40 = &outz;
     v39 = &outy;
     v38 = &outx;
-    v37.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+    v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
     v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY;
 LABEL_20:
     *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x;
@@ -1891,11 +1891,11 @@
   if ( v21 == 4 )
   {
     LODWORD(v45) = pParty->vPosition.x;
-    LODWORD(v44) = pParty->vPosition.z;
+    LODWORD(v44) = pParty->vPosition.y;
     v29 = a4;
     if ( !a4 )
       v29 = pParty->sEyelevel;
-    v28 = pParty->vPosition.y + v29;
+    v28 = pParty->vPosition.z + v29;
     goto LABEL_44;
   }
   if ( v21 == 5 )
@@ -2046,7 +2046,7 @@
     else
       v8->uCurrentActionLength = uActionLength;
     v8->uCurrentActionTime = v7;
-    v8->uAIState = v7;
+    v8->uAIState = Standing;
     v8->vVelocity.z = v7;
     v8->vVelocity.y = v7;
     v8->vVelocity.x = v7;
@@ -2083,7 +2083,7 @@
   else
     v6->uCurrentActionLength = uActionLength;
   v6->uCurrentActionTime = v5;
-  v6->uAIState = v5;
+  v6->uAIState = Standing;
   v6->vVelocity.z = v5;
   v6->vVelocity.y = v5;
   v6->vVelocity.x = v5;
@@ -2099,7 +2099,7 @@
   v1 = &pActors[uActorID];
   v1->uCurrentActionLength = rand() % 128 + 128;
   v1->uCurrentActionTime = 0;
-  v1->uAIState = 0;
+  v1->uAIState = Standing;
   v1->vVelocity.z = 0;
   v1->vVelocity.y = 0;
   v1->vVelocity.x = 0;
@@ -2155,8 +2155,8 @@
       if ( (edx0 & 7) == 4 )
       {
         v6 = (AIDirection *)pParty->vPosition.x;
-        v7 = (AIDirection *)pParty->vPosition.z;
-        v23 = pParty->vPosition.y + pParty->sEyelevel;
+        v7 = (AIDirection *)pParty->vPosition.y;
+        v23 = pParty->vPosition.z + pParty->sEyelevel;
       }
       else
       {
@@ -2187,7 +2187,7 @@
       v17 = v24;
       v3->uCurrentActionLength = 8 * v16;
       v3->uCurrentActionTime = v13;
-      v3->uAIState = 2;
+      v3->uAIState = AttackingMelee;
       Actor::PlaySound(v17, 0);
       LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
       v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
@@ -2554,8 +2554,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.z;
-      v21 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v21 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2584,7 +2584,7 @@
     v14 = v22;
     v3->uCurrentActionLength = 8 * v13;
     v3->uCurrentActionTime = v10;
-    v3->uAIState = 18;
+    v3->uAIState = AttackingRanged4;
     Actor::PlaySound(v14, 0);
     v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
     pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
@@ -2609,9 +2609,9 @@
     {
       v3->uCurrentActionLength = 64;
       v3->uCurrentActionTime = v10;
-      v3->uAIState = 9;
+      v3->uAIState = Fidgeting;
       result = v3->UpdateAnimation();
-      v3->uAIState = 18;
+      v3->uAIState = AttackingRanged4;
     }
     else
     {
@@ -2666,8 +2666,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.z;
-      v21 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v21 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2696,7 +2696,7 @@
     v14 = v22;
     v3->uCurrentActionLength = 8 * v13;
     v3->uCurrentActionTime = v10;
-    v3->uAIState = 13;
+    v3->uAIState = AttackingRanged3;
     Actor::PlaySound(v14, 0);
     v15 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
     pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
@@ -2721,9 +2721,9 @@
     {
       v3->uCurrentActionLength = 64;
       v3->uCurrentActionTime = v10;
-      v3->uAIState = 9;
+      v3->uAIState = Fidgeting;
       result = v3->UpdateAnimation();
-      v3->uAIState = 13;
+      v3->uAIState = AttackingRanged3;
     }
     else
     {
@@ -2777,8 +2777,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = (AIDirection *)pParty->vPosition.x;
-      v5 = (AIDirection *)pParty->vPosition.z;
-      v20 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = (AIDirection *)pParty->vPosition.y;
+      v20 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2807,7 +2807,7 @@
     v14 = v21;
     v3->uCurrentActionLength = 8 * v13;
     v3->uCurrentActionTime = v10;
-    v3->uAIState = 12;
+    v3->uAIState = AttackingRanged2;
     Actor::PlaySound(v14, 0);
     LODWORD(v15) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
     pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
@@ -2873,8 +2873,8 @@
     if ( (edx0 & 7) == 4 )
     {
       v4 = pParty->vPosition.x;
-      v5 = pParty->vPosition.z;
-      v22 = pParty->vPosition.y + pParty->sEyelevel;
+      v5 = pParty->vPosition.y;
+      v22 = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -2911,7 +2911,7 @@
     v15 = v21;
     v3->uCurrentActionLength = 8 * v14;
     v3->uCurrentActionTime = v11;
-    v3->uAIState = 3;
+    v3->uAIState = AttackingRanged1;
     Actor::PlaySound(v15, 0);
     v16 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
     pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime;
@@ -3010,7 +3010,7 @@
   else
     v5->uCurrentActionLength = 0;
   v5->uCurrentActionTime = 0;
-  v5->uAIState = 1;
+  v5->uAIState = Tethered;
   if ( rand() % 100 < 2 )
     Actor::PlaySound(uActorID, 3u);
   v5->UpdateAnimation();
@@ -3119,7 +3119,7 @@
     v7 = v6[v4->pSpriteIDs[4]].uAnimLength;
     v8 = v11;
     v4->uCurrentActionTime = 0;
-    v4->uAIState = 8;
+    v4->uAIState = Stunned;
     v4->uCurrentActionLength = 8 * v7;
     Actor::PlaySound(v8, 2u);
     result = v4->UpdateAnimation();
@@ -3220,7 +3220,7 @@
   v2 = pSpriteFrameTable->pSpriteSFrames;
   v3 = 60 * v1->pSpriteIDs[5];
   v1->uCurrentActionTime = 0;
-  v1->uAIState = 4;
+  v1->uAIState = Dying;
   v1->uCurrentActionAnimation = 5;
   LOWORD(v3) = *(__int16 *)((char *)&v2->uAnimLength + v3);
   v1->sCurrentHP = 0;
@@ -3436,7 +3436,7 @@
   v19 = stru_5C6E00->SinCos(v18 + v13 - stru_5C6E00->uIntegerHalfPi);
   v7->uYawAngle = stru_5C6E00->Atan2(
                     v17 - v7->vPosition.x,
-                    pParty->vPosition.z
+                    pParty->vPosition.y
                   + ((unsigned __int64)(v19 * (signed __int64)v10->uDistanceXZ) >> 16)
                   - v7->vPosition.y);
   if ( uActionLength )
@@ -3444,7 +3444,7 @@
   else
     v7->uCurrentActionLength = 128;
   v7->uPitchAngle = LOWORD(v10->uPitchAngle);
-  v7->uAIState = 6;
+  v7->uAIState = Pursuing;
   return v7->UpdateAnimation();
 }
 
@@ -3503,7 +3503,7 @@
       v9 = LOWORD(a4->uPitchAngle);
       v5->uCurrentActionTime = 0;
       v5->uPitchAngle = v9;
-      v5->uAIState = 7;
+      v5->uAIState = Fleeing;
       result = v5->UpdateAnimation();
     }
   }
@@ -3588,7 +3588,7 @@
   v14 = LOWORD(v10->uPitchAngle);
   v7->uCurrentActionTime = 0;
   v7->uPitchAngle = v14;
-  v7->uAIState = 6;
+  v7->uAIState = Pursuing;
   return v7->UpdateAnimation();
 }
 
@@ -3679,7 +3679,7 @@
   v16 = LOWORD(v9->uPitchAngle);
   v6->uCurrentActionTime = 0;
   v6->uPitchAngle = v16;
-  v6->uAIState = 6;
+  v6->uAIState = Pursuing;
   if ( rand() % 100 < 2 )
     Actor::PlaySound(v4, 2u);
   return v6->UpdateAnimation();
@@ -3800,8 +3800,8 @@
       if ( !v3->pMonsterInfo.uHostilityType )
         v15 = dword_4DF380[v14];
       v16 = abs(v3->vPosition.x - pParty->vPosition.x);
-      v28 = abs(v3->vPosition.y - pParty->vPosition.z);
-      v17 = abs(v3->vPosition.z - pParty->vPosition.y);
+      v28 = abs(v3->vPosition.y - pParty->vPosition.y);
+      v17 = abs(v3->vPosition.z - pParty->vPosition.z);
       if ( v16 <= v15 && v28 <= v15 && v17 <= v15 )
       {
         if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 )
@@ -3949,7 +3949,7 @@
 //----- (0045976D) --------------------------------------------------------
 unsigned int Actor::UpdateAnimation()
 {
-  enum AIState state; // edx@1
+  AIState state; // edx@1
   unsigned int result; // eax@1
 
   state = (AIState)this->uAIState;
@@ -4030,7 +4030,7 @@
   this->uTetherDistance = 256;
   this->uActorRadius = 32;
   this->uActorHeight = 128;
-  this->uAIState = 0;
+  this->uAIState = Standing;
   this->uCurrentActionAnimation = 0;
   this->uMovementSpeed = 200;
   this->uCarriedItemID = 0;
@@ -4129,7 +4129,7 @@
   int result; // eax@13
   Actor *v23; // eax@16
   int v24; // [sp+Ch] [bp-1Ch]@1
-  int v25; // [sp+10h] [bp-18h]@8
+  unsigned int uFaceID; // [sp+10h] [bp-18h]@8
   int v26; // [sp+14h] [bp-14h]@10
   int v27; // [sp+18h] [bp-10h]@10
   int v28; // [sp+1Ch] [bp-Ch]@8
@@ -4158,7 +4158,7 @@
   }
   v6 = v2->vPosition.z;
   v28 = 0;
-  v25 = v6;
+  uFaceID = v6;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
     v28 = pIndoor->GetSector(v2->vPosition.x, v2->vPosition.y, v6);
   v7 = v4 - 1;
@@ -4187,9 +4187,9 @@
   v16 = stru_5C6E00->SinCos(v13 - stru_5C6E00->uIntegerHalfPi);
   v26 = v16;
   v29 = (unsigned __int64)(v16 * (signed __int64)v27) >> 16;
-  LOWORD(v16) = v25;
+  LOWORD(v16) = uFaceID;
   v17 = v29 + v30->vPosition.y;
-  v8->vInitialPosition.z = v25;
+  v8->vInitialPosition.z = uFaceID;
   v8->vPosition.z = v16;
   LOWORD(v16) = v28;
   v8->vInitialPosition.x = v15;
@@ -4204,15 +4204,15 @@
   LODWORD(v19) = v18->uAlly;
   if ( !(uint)v19 )
   {
-    v25 = v18->pMonsterInfo.uID - 1;
-    v19 = (signed __int64)((double)v25 * 0.33333334);
+    uFaceID = v18->pMonsterInfo.uID - 1;
+    v19 = (signed __int64)((double)uFaceID * 0.33333334);
     v18 = v30;
   }
   v8->uAlly = v19;
   v20 = v18->uGroup;
   v8->uCurrentActionTime = 0;
   v8->uGroup = v20;
-  v8->uAIState = 17;
+  v8->uAIState = Summoned;
   v8->uCurrentActionLength = 256;
   v8->UpdateAnimation();
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
@@ -4220,7 +4220,7 @@
         v27 = v30->vPosition.z,
         result = pIndoor->GetSector(v15, v17, v21),
         result == v28)
-    && (result = _46CEC3_get_floor_level(v15, v17, v27, result, &v25), result != -30000)
+    && (result = _46CEC3_get_floor_level(v15, v17, v27, result, &uFaceID), result != -30000)
     && (result = abs(result - v27), result <= 1024) )
   {
     v23 = v30;
--- a/Actor.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Actor.h	Mon Oct 29 09:28:08 2012 +0600
@@ -76,7 +76,7 @@
 };
 
 /*  264 */
-enum AIState : __int32
+enum AIState : unsigned __int16
 {
   Standing = 0x0,
   Tethered = 0x1,
@@ -256,7 +256,7 @@
   struct Vec3_short_ vInitialPosition;
   struct Vec3_short_ vGuardingPosition;
   unsigned __int16 uTetherDistance;
-  unsigned __int16 uAIState;
+  AIState uAIState;
   unsigned __int16 uCurrentActionAnimation;
   unsigned __int16 uCarriedItemID;
   char field_B6;
--- a/Allocator.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Allocator.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -231,7 +231,7 @@
   v2 = this;
   v3 = this->uDumpsCount;
   this->uDumpsCount = v3 + 1;
-  sprintfex(Filename, "Mem%03i.txt", v3);
+  sprintf(Filename, "Mem%03i.txt", v3);
   v4 = fopen(Filename, "w");
   v5 = v4;
   if ( v4 )
--- a/AudioPlayer.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/AudioPlayer.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -468,7 +468,7 @@
     memcpy(&v19, texture_frame_table_txt_parser(&Buf, &v18), sizeof(v19));
     if ( v19.field_0 && *v19.pProperties[0] != 47 )
     {
-      sprintfex(v2->pSounds[v2->uNumSounds].pSoundName, "%s", v19.pProperties[0]);
+      sprintf(v2->pSounds[v2->uNumSounds].pSoundName, "%s", v19.pProperties[0]);
       v9 = atoi(v19.pProperties[1]);
       v10 = v19.pProperties[2];
       v2->pSounds[v2->uNumSounds].uSoundID = v9;
@@ -825,12 +825,12 @@
           if ( !a5 )
             v75 = pParty->vPosition.x;
           if ( !a6 )
-            a6 = pParty->vPosition.z;
+            a6 = pParty->vPosition.y;
           if ( uNumRepeats )
             AIL_set_sample_loop_count(v73->hSample, uNumRepeats - 1);
           v83 = sub_4AB66C(v75, a6);
           AIL_set_sample_pan(v73->hSample, v83);
-          v84 = GetSoundStrengthByDistanceFromParty(v75, a6, pParty->vPosition.y);
+          v84 = GetSoundStrengthByDistanceFromParty(v75, a6, pParty->vPosition.z);
           AIL_set_sample_volume(v73->hSample, v84);
           v76 = a3;
           goto LABEL_184;
@@ -1049,8 +1049,8 @@
           v12 = 10;
 LABEL_46:
           a1.vWorldPosition.x = (double)pParty->vPosition.x;
-          a1.vWorldPosition.y = (double)pParty->vPosition.z;
-          v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.y;
+          a1.vWorldPosition.y = (double)pParty->vPosition.y;
+          v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
           goto LABEL_47;
         }
         v12 = 10 * v13 / 16;
@@ -1259,10 +1259,10 @@
           if ( (a3 & 7) != 5 )
           {
             a1.vWorldPosition.x = (double)pParty->vPosition.x;
-            v43 = (double)pParty->vPosition.z;
+            v43 = (double)pParty->vPosition.y;
 LABEL_100:
             a1.vWorldPosition.y = v43;
-            v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.y;
+            v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
             goto LABEL_101;
           }
           v44 = (LayingItem *)&pLevelDecorations[a3 >> 3];
@@ -1427,8 +1427,8 @@
             if ( v10 != 2 )
             {
               a1.vWorldPosition.x = (double)pParty->vPosition.x;
-              a1.vWorldPosition.y = (double)pParty->vPosition.z;
-              v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.y;
+              a1.vWorldPosition.y = (double)pParty->vPosition.y;
+              v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
               goto LABEL_21;
             }
             v12 = (LayingItem *)&pLevelDecorations[v6->field_4 >> 3];
@@ -1451,8 +1451,8 @@
             if ( pBLVRenderParams->sPartyRotX )
             {
               v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
-              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.z;
-              v18 = a1.vWorldPosition.z - (double)pParty->vPosition.y;
+              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
+              v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
               if ( pRenderer->pRenderD3D )
               {
                 v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
@@ -1470,7 +1470,7 @@
             else
             {
               v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
-              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.z;
+              *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
               if ( pRenderer->pRenderD3D )
               {
                 a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
@@ -1482,7 +1482,7 @@
                 v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
               }
               a1.vWorldViewPosition.y = v21;
-              a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.y;
+              a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
             }
           }
           else
@@ -1608,7 +1608,7 @@
           }
         }
       }
-      if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != v2 )
+      if ( pCurrentScreen != v2 )
       {
         v42 = &v1->pMixerChannels[4];
         if ( AIL_sample_status(v42->hSample) == 4 )
@@ -1623,8 +1623,8 @@
         LODWORD(v56) = 1;
         v43 = 4 * v59 + 6817720;
         v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]];
-        v45 = abs(v44->vPosition.z - pParty->vPosition.y);
-        v46 = abs(v44->vPosition.y - pParty->vPosition.z);
+        v45 = abs(v44->vPosition.z - pParty->vPosition.z);
+        v46 = abs(v44->vPosition.y - pParty->vPosition.y);
         v47 = abs(v44->vPosition.x - pParty->vPosition.x);
         if ( sub_4621DA(v47, v46, v45) <= 8192 )
           break;
@@ -1692,7 +1692,7 @@
 {
   signed int v2; // eax@1
 
-  v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.z)
+  v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y)
                                   - stru_5C6E00->uIntegerHalfPi
                                   - pParty->sRotationY);
   if ( v2 > (signed int)stru_5C6E00->uIntegerPi )
@@ -1714,8 +1714,8 @@
 
   v3 = a2;
   v4 = a1;
-  v5 = abs(a3 - pParty->vPosition.y);
-  v6 = abs(v3 - pParty->vPosition.z);
+  v5 = abs(a3 - pParty->vPosition.z);
+  v6 = abs(v3 - pParty->vPosition.y);
   v7 = abs(v4 - pParty->vPosition.x);
   v9 = sub_4621DA(v7, v6, v5);
   if ( v9 <= 8192 )
@@ -2201,8 +2201,8 @@
   if ( pBLVRenderParams->sPartyRotX )
   {
     v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
-    v11 = a1->vWorldPosition.y - (double)pParty->vPosition.z;
-    v4 = a1->vWorldPosition.z - (double)pParty->vPosition.y;
+    v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
+    v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
     if ( pRenderer->pRenderD3D )
     {
       v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY;
@@ -2220,8 +2220,8 @@
   else
   {
     v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x;
-    v12 = a1->vWorldPosition.y - (double)pParty->vPosition.z;
-    v7 = a1->vWorldPosition.z - (double)pParty->vPosition.y;
+    v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y;
+    v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z;
     if ( pRenderer->pRenderD3D )
     {
       a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY;
--- a/Bink_Smacker.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Bink_Smacker.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -22,6 +22,7 @@
 void (__stdcall *smackw32_SmackBufferClose)(HSMACKBUF) = 0;
 void (__stdcall *smackw32_SmackBlitClose)(HSMACKBLIT) = 0;
 int  (__stdcall *smackw32_SmackBlitClear)(HSMACKBLIT, unsigned short *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int) = 0;
+int  (__stdcall *smackw32_SmackGoto)(_SMACK *, long) = 0;
 void SMACKW32_DLL_Initialize()
 {
  HMODULE pDll = LoadLibraryW(L"SmackW32.dll");
@@ -42,6 +43,7 @@
  smackw32_SmackBufferClose = (void (__stdcall *)(HSMACKBUF))GetProcAddress(pDll, "_SmackBufferClose@4");
  smackw32_SmackBlitClose = (void (__stdcall *)(HSMACKBLIT))GetProcAddress(pDll, "_SmackBlitClose@4");
  smackw32_SmackBlitClear = (int (__stdcall *)(HSMACKBLIT, unsigned short *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, int))GetProcAddress(pDll, "_SmackBlitClear@32");
+ smackw32_SmackGoto = (int  (__stdcall *)(_SMACK *, long))GetProcAddress(pDll, "_SmackGoto@8");
 }
 
 
@@ -129,6 +131,10 @@
  return (smackw32_SmackBlitClear)(a1, pFrameData, uTargetSurfacePitch, uOutX, uOutY, uOutZ, uOutW, a8);
 }
 
+int __stdcall SmackGoto(_SMACK *a1, long a2)
+{
+ return (smackw32_SmackGoto)(a1, a2);
+}
 
 
 int __stdcall SmackBufferOpen(HWND a1, long a2, long a3, long a4, long a5, long a6)
@@ -144,12 +150,6 @@
 }
 
 
-int __stdcall SmackGoto(_SMACK *a1, long a2)
-{
- __asm int 3
- return 0;
-}
-
 // sub_4D83D0: using guessed type int __stdcall SmackBufferNewPalette(_DWORD, _DWORD, _DWORD);
 int __stdcall SmackBufferNewPalette(long a1, long a2, long a3)
 {
--- a/DecalBuilder.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/DecalBuilder.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -3,9 +3,9 @@
 #include "Time.h"
 #include "stru314.h"
 #include "Outdoor.h"
+#include "Log.h"
 
 #include "mm7_data.h"
-//#include "MM7.h"
 
 
 
@@ -16,16 +16,14 @@
 
 
 //----- (0043B570) --------------------------------------------------------
-double DecalBuilder_stru0::_43B570()
+double DecalBuilder_stru0::_43B570_get_color_mult_by_time()
 {
-  DecalBuilder_stru0 *v1; // esi@1
   double result; // st7@3
-
-  v1 = this;
-  if ( this->field_1C_flags & 1 )
+  
+  if (field_1C_flags & 1)
   {
-    if ( (double)(signed __int64)(this->field_20_time - pEventTimer->Time() + 384) * 0.0026041667 >= 0.0 )
-      result = (double)(signed __int64)(v1->field_20_time - pEventTimer->Time() + 384) * 0.0026041667;
+    if ((field_20_time - pEventTimer->Time() + 384) / 384.0 >= 0.0)
+      result = (field_20_time - pEventTimer->Time() + 384) / 384.0;
     else
       result = 0.0;
   }
@@ -109,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
@@ -148,6 +146,10 @@
   DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
   RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
 
+  __debugbreak();
+
+  auto a9 = uSectorID;
+
   thisa = this;
   if ( !a5 )
     return 0;
@@ -202,24 +204,24 @@
   {
     v16 = a4;
   }
-  v18 = v16->vNormal.z;
-  v19 = v16->vNormal.y;
-  v20 = v16->vNormal.x;
-  v37 = (int)&stru_AE4F7C;
-  stru_AE4F64.y = v19;
-  stru_AE4F64.x = v20;
-  LODWORD(v36) = (DWORD)&stru_AE4F70;
-  stru_AE4F64.z = v18;
-  dword_AE4F88 = LODWORD(v16->field_10);
+  v18 = v16->face_plane.vNormal.z;
+  v19 = v16->face_plane.vNormal.y;
+  v20 = v16->face_plane.vNormal.x;
+  v37 = (int)&static_AE4F60.field_1C;
+  static_AE4F60.field_4.y = v19;
+  static_AE4F60.field_4.x = v20;
+  LODWORD(v36) = (DWORD)&static_AE4F60.field_10;
+  static_AE4F60.field_4.z = v18;
+  static_AE4F60.dist = v16->face_plane.dist;
   if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
-          v16->field_14,
-          &stru_AE4F64,
-          &stru_AE4F70,
-          &stru_AE4F7C) )
+          v16->polygonType,
+          &static_AE4F60.field_4,
+          &static_AE4F60.field_10,
+          &static_AE4F60.field_1C) )
   {
       MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
   }
-  a7 = 0;
+  int _a7 = 0;
   if ( thisa->uNumDecals > 0 )
   {
     a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
@@ -229,7 +231,7 @@
       *(float *)&v37 = v21->z;
       v36 = v21->y;
       v35 = v21->x;
-      v22 = sub_43F5C8(a2, a9, v35, v36, *(float *)&v37);
+      v22 = _43F5C8_get_point_light_level_with_respect_to_lights(a2, a9, v35, v36, *(float *)&v37);
       v23 = v21->b;
       v24 = v21->x;
       v42 = v22;
@@ -242,7 +244,7 @@
       v27 = (signed __int64)v21->y;
       v37 = a8;
       v40 = (signed __int64)v26;
-      v28 = *(float *)&v21->field_14;
+      v28 = v21->dot_dist;
       LODWORD(v36) = (uint32)a11;
       a5a = v25;
       v39 = v27;
@@ -268,18 +270,16 @@
       {
       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;
 }
-// AE4F88: using guessed type int dword_AE4F88;
-// AE5B90: using guessed type char static_init_flag__AE4F90_bit1__AE4F60_bit2;
 
 //----- (0049B790) --------------------------------------------------------
-char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, int a7, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
+char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, RenderVertexSoft *a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
 {
   DecalBuilder *v12; // esi@1
   Decal *v13; // edi@2
@@ -376,7 +376,7 @@
     v28 = v18->field_4.y * *(float *)v25
         + *((float *)v25 - 1) * v18->field_4.x
         + *((float *)v25 + 1) * v18->field_4.z
-        + *(float *)&v18->field_28;
+        + v18->dist;
     *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
     *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
     v25 += 48;
@@ -384,7 +384,7 @@
     *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z;
   }
   while ( v26 );
-  v13->field_C10 = a7;
+  v13->uColorMultiplier = uColorMultiplier;
   v40 = (unsigned int *)&v13->uNumVertices;
   v39 = v13->pVertices;
   v13->uNumVertices = 4;
@@ -403,7 +403,7 @@
     v39 = a8;
     pGame->pIndoorCameraD3D->ViewTransform(a8, (unsigned int)v40);
     v40 = 0;
-    pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v32, *v31, 0);
+    pGame->pIndoorCameraD3D->Project(v32, *v31, 0);
     if ( !(uClipFlags & 1) )
     {
 LABEL_19:
@@ -422,7 +422,7 @@
       {
         v40 = (unsigned int *)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436CDC(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, (unsigned int *)&a8);
 LABEL_14:
         v40 = v31;
         v39 = v12->pVertices;
@@ -433,7 +433,7 @@
       {
         v40 = (unsigned int *)&a8;
         v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09(v32, *v31, v12->pVertices, (unsigned int *)&a8);
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, (unsigned int *)&a8);
         goto LABEL_14;
       }
       v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
@@ -455,64 +455,43 @@
 }
 
 //----- (0049BBBD) --------------------------------------------------------
-char DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
+bool DecalBuilder::ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID)
 {
-  int v2; // edi@1
-  unsigned int v3; // ebx@1
-  BLVFace *v4; // esi@2
-  unsigned int v5; // eax@2
-  char *v6; // edx@5
   double v7; // st7@12
 
-  v2 = 0;
-  this->uNumDecals = 0;
-  v3 = pBloodsplatContainer->std__vector_pBloodsplats_size;
-  if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
+  if (!pBloodsplatContainer->std__vector_pBloodsplats_size)
+    return true;
+  
+  auto pFace = &pIndoor->pFaces[uFaceID];
+
+  if (pFace->uAttributes & 0x400000)
+    return true;
+  if (pFace->Animated())
+    return true;
+
+  for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
   {
-    v4 = &pIndoor->pFaces[uFaceID];
-    v5 = v4->uAttributes;
-    if ( !(v5 & 0x400000) )
+    auto pBloodsplat = pBloodsplatContainer->std__vector_pBloodsplats + i;
+    if (pFace->pBounding.x1 - pBloodsplat->radius < pBloodsplat->x &&
+        pFace->pBounding.x2 + pBloodsplat->radius > pBloodsplat->x &&
+        pFace->pBounding.y1 - pBloodsplat->radius < pBloodsplat->y &&
+        pFace->pBounding.y2 + pBloodsplat->radius > pBloodsplat->y &&
+        pFace->pBounding.z1 - pBloodsplat->radius < pBloodsplat->z &&
+        pFace->pBounding.z2 + pBloodsplat->radius > pBloodsplat->z)
     {
-      if ( !(v5 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
+      v7 = pFace->pFacePlane.vNormal.z * pBloodsplat->z +
+           pFace->pFacePlane.vNormal.y * pBloodsplat->y +
+           pFace->pFacePlane.vNormal.x * pBloodsplat->x +
+           pFace->pFacePlane.dist;
+      if (v7 <= pBloodsplat->radius)
       {
-        v6 = (char *)&pBloodsplatContainer->std__vector_pBloodsplats[0].y;
-        do
-        {
-          if ( (double)v4->pBounding.x1 - *((float *)v6 + 2) < *((float *)v6 - 1) )
-          {
-            if ( (double)v4->pBounding.x2 + *((float *)v6 + 2) > *((float *)v6 - 1) )
-            {
-              if ( (double)v4->pBounding.y1 - *((float *)v6 + 2) < *(float *)v6 )
-              {
-                if ( (double)v4->pBounding.y2 + *((float *)v6 + 2) > *(float *)v6 )
-                {
-                  if ( (double)v4->pBounding.z1 - *((float *)v6 + 2) < *((float *)v6 + 1) )
-                  {
-                    if ( (double)v4->pBounding.z2 + *((float *)v6 + 2) > *((float *)v6 + 1) )
-                    {
-                      v7 = v4->pFacePlane.vNormal.z * *((float *)v6 + 1)
-                         + v4->pFacePlane.vNormal.y * *(float *)v6
-                         + v4->pFacePlane.vNormal.x * *((float *)v6 - 1)
-                         + v4->pFacePlane.dist;
-                      if ( v7 <= *((float *)v6 + 2) )
-                      {
-                        *((float *)v6 + 3) = v7;
-                        this->std__vector_30B00C[this->uNumDecals++] = v2;
-                      }
-                    }
-                  }
-                }
-              }
-            }
-          }
-          ++v2;
-          v6 += 40;
-        }
-        while ( v2 < (signed int)v3 );
+        pBloodsplat->dot_dist = v7;
+        std__vector_30B00C[uNumDecals++] = i;
       }
     }
   }
-  return 1;
+
+  return true;
 }
 
 //----- (0049BCEB) --------------------------------------------------------
@@ -532,7 +511,7 @@
   v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
   if ( pBloodsplatContainer->std__vector_pBloodsplats_size )
   {
-    v3 = pFace->uFaceAttributes;
+    v3 = pFace->uAttributes;
     if ( !(v3 & 0x400000) )
     {
       if ( !(v3 & 0x10) && (signed int)pBloodsplatContainer->std__vector_pBloodsplats_size > 0 )
@@ -714,214 +693,109 @@
 }
 
 //----- (0049C095) --------------------------------------------------------
-void DecalBuilder::DrawDecal(Decal *pDecal, float a2)
+void DecalBuilder::DrawDecal(Decal *pDecal, float z_bias)
 {
-  Decal *v3; // edi@1
-  double v4; // st7@3
-  double v5; // st7@5
-  int v6; // eax@5
-  unsigned __int8 v7; // zf@5
-  unsigned __int8 v8; // sf@5
-  char *v9; // esi@6
-  int v10; // ebx@6
-  int v11; // eax@8
-  int v12; // edx@8
-  int v13; // eax@8
-  int v14; // ecx@8
-  double v15; // st7@9
-  int v16; // eax@12
-  double v17; // st7@12
-  int v18; // eax@12
-  unsigned __int8 v19; // of@12
-  HRESULT v20; // eax@17
   signed int v21; // [sp+Ch] [bp-864h]@15
-  const char *v22; // [sp+10h] [bp-860h]@15
-  int v23; // [sp+14h] [bp-85Ch]@15
-  unsigned int v24; // [sp+18h] [bp-858h]@14
-  RenderVertexD3D3 hr[64]; // [sp+20h] [bp-850h]@6
-  double v26; // [sp+820h] [bp-50h]@8
-  double v27; // [sp+828h] [bp-48h]@8
-  double v28; // [sp+830h] [bp-40h]@8
-  int v29; // [sp+838h] [bp-38h]@8
-  int v30; // [sp+83Ch] [bp-34h]@8
-  __int64 v31; // [sp+840h] [bp-30h]@8
-  __int64 v32; // [sp+848h] [bp-28h]@8
-  __int64 v33; // [sp+850h] [bp-20h]@8
-  int v34; // [sp+858h] [bp-18h]@8
-  unsigned __int64 v35; // [sp+85Ch] [bp-14h]@8
-  float v36; // [sp+864h] [bp-Ch]@6
-  int v37; // [sp+868h] [bp-8h]@5
-  float v38; // [sp+86Ch] [bp-4h]@8
-  float thisa; // [sp+878h] [bp+8h]@5
+  RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
+
+  if (pDecal->uNumVertices < 3)
+  {
+    Log::Warning(L"Decal has < 3 vertices");
+    return;
+  }
 
-  v3 = pDecal;
-  if ( pDecal->uNumVertices >= 3 )
+  float color_mult;
+  if ( pDecal->field_C1C & 1 )
+    color_mult = 1.0;
+  else
+    color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
+
+  for (uint i = 0; i < pDecal->uNumVertices; ++i)
   {
-    if ( pDecal->field_C1C & 1 )
-      v4 = 1.0;
-    else
-      v4 = pDecal->field_C18->_43B570();
-    thisa = v4;
-    v5 = get_shading_dist_mist();
-    v6 = 0;
-    v7 = v3->uNumVertices == 0;
-    v8 = v3->uNumVertices < 0;
-    v37 = 0;
-    if ( !(v8 | v7) )
-    {
-      v9 = (char *)&hr[0].pos.y;
-      v10 = (int)&v3->pVertices[0].vWorldViewPosition;
-      v36 = 1.0 / v5;
-      while ( 1 )
-      {
-        v11 = pRenderer->GetActorTintColor(*(float *)v10, v3->field_C14, v6, v6, (RenderBillboard *)v6);
-        LOBYTE(v12) = v11;
-        v33 = ((unsigned int)v11 >> 16) & 0xFFi64;
-        LOBYTE(v38) = BYTE2(v3->field_C10);
-        v38 = (double)v33 * 0.0039215689 * thisa * (double)LOBYTE(v38);
-        v28 = v38 + 6.7553994e15;
-        v31 = (unsigned __int16)v11 >> 8;
-        LODWORD(v38) = BYTE1(v3->field_C10);
-        v38 = (double)v31 * 0.0039215689 * thisa * (double)SLODWORD(v38);
-        v26 = v38 + 6.7553994e15;
-        v35 = __PAIR__(LODWORD(v28), LODWORD(v26));
-        v13 = v3->field_C10;
-        v32 = v12 & 0xFFi64;
-        v29 = (unsigned __int8)v13;
-        v30 = 0;
-        v38 = (double)v32 * 0.0039215689 * thisa * (double)(unsigned __int8)v13;
-        v27 = v38 + 6.7553994e15;
-        v34 = LODWORD(v27);
-        v14 = LODWORD(v27) | ((LODWORD(v26) | (LODWORD(v28) << 8)) << 8);
-        if ( a2 == 0.0 )
-        {
-          v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0);
-        }
-        else
-        {
-          v15 = 1.0 - 1.0 / (v36 * *(float *)v10 * 1000.0) - a2;
-          if ( v15 < 0.000099999997 )
-            v15 = 0.000099999997;
-        }
-        *((float *)v9 + 1) = v15;
-        v16 = *(int *)(v10 + 12);
-        ++v37;
-        v17 = 1.0 / *(float *)v10;
-        *((int *)v9 - 1) = v16;
-        *(int *)v9 = *(int *)(v10 + 16);
-        *((int *)v9 + 5) = *(int *)(v10 + 24);
-        *((int *)v9 + 6) = *(int *)(v10 + 28);
-        v18 = v37;
-        *((int *)v9 + 3) = v14;
-        *((int *)v9 + 4) = 0;
-        v10 += 48;
-        v9 += 32;
-        v19 = __OFSUB__(v18, v3->uNumVertices);
-        v8 = v18 - v3->uNumVertices < 0;
-        *((float *)v9 - 6) = v17;
-        if ( !(v8 ^ v19) )
-          break;
-        v6 = 0;
-      }
-      v6 = 0;
-    }
-    v24 = v6;
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    {
-      v21 = 28;
-    }
-    else
-    {
-      v21 = 16;
-    }
-    ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
-            D3DPT_TRIANGLEFAN,
-            452,
-            hr,
-            v3->uNumVertices,
+    uint uTint = pRenderer->GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
+
+    uint uTintR = (uTint >> 16) & 0xFF,
+         uTintG = (uTint >> 8) & 0xFF,
+         uTintB = uTint & 0xFF;
+
+    uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
+         uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
+         uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
+
+    uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
+         uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
+         uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
+
+
+    float v15;
+    if (fabs(z_bias) < 1e-5)
+      v15 = 1.0 - 1.0 / ((1.0f / get_shading_dist_mist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
+     else
+     {
+      v15 = 1.0 - 1.0 / ((1.0f / get_shading_dist_mist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
+      if (v15 < 0.000099999997)
+        v15 = 0.000099999997;
+     }
+
+    pVerticesD3D[i].pos.z = v15;
+
+    pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
+    pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
+    pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
+    pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
+    pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
+    pVerticesD3D[i].specular = 0;
+    pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
+  }
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
+  else
+    v21 = D3DDP_DONOTLIGHT;
+
+  ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+            pVerticesD3D,
+            pDecal->uNumVertices,
             v21));
-  }
 }
 
 //----- (0049C2CD) --------------------------------------------------------
-void DecalBuilder::DrawDecals(float a2)
+void DecalBuilder::DrawDecals(float z_bias)
 {
-  DecalBuilder *v2; // esi@1
-  signed int v3; // edi@1
-  Decal *v4; // ebx@2
-
-  v2 = this;
-  v3 = 0;
-  if ( (signed int)this->std__vector_pDecals_size > 0 )
-  {
-    v4 = this->std__vector_pDecals;
-    do
-    {
-      DrawDecal(v4, a2);
-      ++v3;
-      ++v4;
-    }
-    while ( v3 < (signed int)v2->std__vector_pDecals_size );
-  }
+  for (uint i = 0; i < std__vector_pDecals_size; ++i)
+    DrawDecal(std__vector_pDecals + i, z_bias);
 }
 
 //----- (0049C304) --------------------------------------------------------
 void DecalBuilder::DrawBloodsplats()
 {
-  unsigned int v1; // ebx@0
-  int v2; // esi@0
-  char v3; // zf@1
-  HRESULT v4; // eax@4
-  HRESULT v5; // eax@4
-  HRESULT v6; // eax@4
-  HRESULT v7; // eax@4
-  HRESULT v8; // eax@4
-  HRESULT v9; // eax@4
-  HRESULT v10; // eax@4
-  char *v11; // eax@4
-  //IDirect3DDevice3Vtbl *v12; // ebx@6
-  int v13; // ST6C_4@6
-  HRESULT v14; // eax@6
-  HRESULT v15; // eax@6
-  HRESULT v16; // eax@6
-  HRESULT v17; // eax@6
-  HRESULT v18; // eax@6
-  HRESULT v19; // eax@6
-  char thisa; // [sp+80h] [bp-8h]@4
-  DecalBuilder *v21; // [sp+84h] [bp-4h]@1
+  if (!std__vector_pDecals_size)
+    return;
+
+  if (pRenderer->bUsingSpecular)
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
 
-  v3 = this->std__vector_pDecals_size == 0;
-  v21 = this;
-  if ( !v3 )
-  {
-    if ( pRenderer->bUsingSpecular )
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3));
-
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
 
-    v11 = (char *)std__string_AE5B94.c_str();
-    if ( !std__string_AE5B94.size() )
-      v11 = (char *)&dword_4D86F0;
-    //v12 = pRenderer->pRenderD3D->pDevice->lpVtbl;
-    v13 = (int)pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v11);
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, (IDirect3DTexture2 *)v13));
+  auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04");
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
+ 
+  DrawDecals(0.00039999999);
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
 
-    v21->DrawDecals(0.00039999999);
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-
-    if ( pRenderer->bUsingSpecular )
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
-  }
+  if (pRenderer->bUsingSpecular)
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
 }
 
 //----- (0049C550) --------------------------------------------------------
--- a/DecalBuilder.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/DecalBuilder.h	Mon Oct 29 09:28:08 2012 +0600
@@ -5,7 +5,7 @@
 #pragma pack(push, 1)
 struct DecalBuilder_stru0
 {
-  double _43B570();
+  double _43B570_get_color_mult_by_time();
 
   int field_0;
   int field_4;
@@ -47,7 +47,7 @@
   __int16 field_C0A;
   __int16 field_C0C;
   __int16 field_C0E;
-  int field_C10;
+  uint uColorMultiplier;
   int field_C14;
   DecalBuilder_stru0 *field_C18;
   int field_C1C;
@@ -91,13 +91,13 @@
 
   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 _49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, int a7, struct RenderVertexSoft *a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
-  char ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
+  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);
+  bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
   bool _49BE8A(struct stru148 *a2, float a3, int a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
-  void DrawDecal(Decal *pDecal, float a2);
-  void DrawDecals(float a2);
+  void DrawDecal(Decal *pDecal, float z_bias);
+  void DrawDecals(float z_bias);
   void DrawBloodsplats();
   void DrawDecalDebugOutlines();
 
@@ -155,7 +155,7 @@
   float y;
   float z;
   float radius;
-  int field_14;
+  float dot_dist;
   char r;
   char g;
   char b;
--- a/GUIProgressBar.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/GUIProgressBar.cpp	Mon Oct 29 09:28:08 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	Mon Oct 22 09:20:49 2012 +0600
+++ b/GUIWindow.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -108,7 +108,7 @@
   v7 = v2->uFrameHeight;
   v2->uFrameZ = v6 + v2->uFrameX - 1;
   v2->uFrameW = v2->uFrameY + v7 - 1;
-  v2->_415551(0);
+  v2->DrawMessageBox(0);
   v2->DrawText2(pFontArrus, 0, 0xCu, 0, pGlobalTXT_LocalizationStrings[451], 3u);
   if ( !v19 )
     v2->DrawText2(v1, 0, 0x28u, 0, pGlobalTXT_LocalizationStrings[153], 3u);
@@ -145,13 +145,9 @@
 
 
 //----- (0041D3B7) --------------------------------------------------------
-char GUIWindow::_41D3B7()
+char GUIWindow::DrawQuickCharRecord()
 {
-  GUIWindow *v1; // edi@1
   Player *pPlayer; // esi@1
-  int v3; // ecx@1
-  SpellBuff *v4; // eax@1
-  signed int v5; // ebx@1
   int v6; // eax@5
   int v7; // ebx@5
   unsigned int v8; // ecx@5
@@ -163,76 +159,44 @@
   unsigned int v14; // eax@12
   PlayerFrame *v15; // eax@12
   unsigned int v16; // eax@15
-  signed int v17; // ST28_4@15
-  int v18; // ST24_4@15
-  signed int v19; // eax@15
   unsigned int v20; // eax@15
-  int v21; // ST28_4@15
-  int v22; // ST24_4@15
-  int v23; // eax@15
   unsigned int v24; // eax@15
   unsigned int v25; // eax@15
-  char *v26; // ST28_4@15
-  signed int v27; // eax@15
   unsigned __int8 v28; // al@15
   char *v29; // eax@16
-  unsigned int v30; // esi@18
-  SpellBuff *v31; // edx@18
-  char *v32; // edi@18
-  signed int v33; // ecx@19
-  unsigned int v34; // eax@19
   __int64 v35; // ST38_8@22
   int v36; // esi@22
-  const char *v37; // ST1C_4@22
   unsigned int v38; // eax@22
   char *v39; // eax@24
-  SpellBuff *v41; // [sp+14h] [bp-14h]@1
-  GUIFont *a2; // [sp+18h] [bp-10h]@1
-  GUIWindow *a1; // [sp+1Ch] [bp-Ch]@1
   signed int uFramesetID; // [sp+20h] [bp-8h]@9
   int uFramesetIDa; // [sp+20h] [bp-8h]@18
-  const char **v46; // [sp+24h] [bp-4h]@18
+
+  pPlayer = &pParty->pPlayers[(unsigned int)ptr_1C];
+
+  uint numActivePlayerBuffs = 0;
+
+  for (uint i = 0; i < 24; ++i)
+    if (pPlayer->pPlayerBuffs[i].uExpireTime > 0)
+      ++numActivePlayerBuffs;
 
-  v1 = this;
-  a2 = pFontComic;
-  pPlayer = &pParty->pPlayers[(unsigned int)this->ptr_1C];
-  a1 = this;
-  v3 = 0;
-  v4 = pPlayer->pPlayerBuffs;
-  v5 = 24;
-  v41 = pPlayer->pPlayerBuffs;
-  do
-  {
-    if ( (signed __int64)v4->uExpireTime > 0 )
-      ++v3;
-    ++v4;
-    --v5;
-  }
-  while ( v5 );
-  v6 = LOBYTE(pFontArrus->uFontHeight) + 162;
-  v1->uFrameHeight = v6;
-  v7 = (v3 - 1) * LOBYTE(pFontArrus->uFontHeight);
-  v8 = v1->uFrameX;
+  v6 = pFontArrus->uFontHeight + 162;
+  uFrameHeight = v6;
+  v7 = (numActivePlayerBuffs - 1) * pFontArrus->uFontHeight;
+  v8 = uFrameX;
   v9 = v6 + v7;
-  v10 = v1->uFrameWidth;
-  v1->uFrameHeight = v9;
+  v10 = uFrameWidth;
+  uFrameHeight = v9;
   v11 = v10 + v8 - 1;
-  v12 = v1->uFrameY;
-  v1->uFrameZ = v11;
-  v1->uFrameW = v9 + v12 - 1;
-  v1->_415551(0);
-  if ( pPlayer->pConditions[16] )
-  {
+  v12 = uFrameY;
+  uFrameZ = v11;
+  uFrameW = v9 + v12 - 1;
+  DrawMessageBox(0);
+  if (pPlayer->Eradicated())
     v13 = pTexture_PlayerFaceEradicated;
-  }
+  else if (pPlayer->Dead())
+    v13 = pTexture_PlayerFaceDead;
   else
   {
-    if ( pPlayer->pConditions[14] )
-    {
-      v13 = pTexture_PlayerFaceDead;
-    }
-    else
-    {
       uFramesetID = pPlayerFrameTable->GetFrameIdBy_field0(pPlayer->uExpressionID);
       if ( !uFramesetID )
         uFramesetID = 1;
@@ -249,74 +213,58 @@
         v15 = pPlayerFrameTable->GetFrameBy_x(uFramesetID, v14);
       }
       pPlayer->field_1AA2 = v15->uTextureID - 1;
-      v13 = (Texture *)A74CEC_player_faces_minus1_indexing[v15->uTextureID + 56 * (unsigned int)v1->ptr_1C];
-    }
+      v13 = pTextures_PlayerFaces[(unsigned int)ptr_1C][v15->uTextureID];
   }
-  pRenderer->DrawTextureTransparent(v1->uFrameX + 24, v1->uFrameY + 24, v13);
+
+  pRenderer->DrawTextureTransparent(uFrameX + 24, uFrameY + 24, v13);
   v16 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  sprintfex(pTmpBuf, format_4E2DC8, v16);
-  sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->uClass]);
+  sprintf(pTmpBuf, "\xC%05d", v16);
+  sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->uClass]);
   strcat(pTmpBuf, pTmpBuf2);
-  strcat(pTmpBuf, string_4E3294);
-  v17 = pPlayer->GetMaxHealth();
-  v18 = pPlayer->sHealth;
-  v19 = pPlayer->GetMaxHealth();
-  v20 = sub_4178FE(pPlayer->sHealth, v19);
-  sprintfex(pTmpBuf2, "%s : ", pGlobalTXT_LocalizationStrings[108], v20, v18, v17);
+  strcat(pTmpBuf, "\xC" "00000\n");
+  v20 = UI_GetHealthManaStringColor(pPlayer->sHealth, pPlayer->GetMaxHealth());
+  sprintf(pTmpBuf2, "%s : \x0C" "%05u%d\x0C" "00000 / %d\n", pGlobalTXT_LocalizationStrings[108],
+          v20, pPlayer->sHealth, pPlayer->GetMaxHealth());
   strcat(pTmpBuf, pTmpBuf2);
-  v21 = pPlayer->GetMaxMana();
-  v22 = pPlayer->sMana;
-  v23 = pPlayer->GetMaxMana();
-  v24 = sub_4178FE(pPlayer->sMana, v23);
-  sprintfex(pTmpBuf2, "%s : ", pGlobalTXT_LocalizationStrings[212], v24, v22, v21);
+  v24 = UI_GetHealthManaStringColor(pPlayer->sMana, pPlayer->GetMaxMana());
+  sprintf(pTmpBuf2, "%s : \x0C" "%05u%d\x0C" "00000 / %d\n", pGlobalTXT_LocalizationStrings[212],
+          v24, pPlayer->sMana, pPlayer->GetMaxMana());
   strcat(pTmpBuf, pTmpBuf2);
   v25 = pPlayer->GetMajorConditionIdx();
-  v26 = aCharacterConditionNames[v25];
-  v27 = GetConditionDrawColor(v25);
-  sprintfex(pTmpBuf2, "%s: ", pGlobalTXT_LocalizationStrings[47], v27, v26);
+  sprintf(pTmpBuf2, "%s: \x0C" "%05d%s\x0C" "00000\n", pGlobalTXT_LocalizationStrings[47],
+          GetConditionDrawColor(v25), aCharacterConditionNames[v25]);
   strcat(pTmpBuf, pTmpBuf2);
   v28 = pPlayer->uQuickSpell;
   if ( v28 )
     v29 = pSpellStats->pInfos[v28].pShortName;
   else
     v29 = pGlobalTXT_LocalizationStrings[153];
-  sprintfex(pTmpBuf2, "%s: %s", pGlobalTXT_LocalizationStrings[172], v29);
+  sprintf(pTmpBuf2, "%s: %s", pGlobalTXT_LocalizationStrings[172], v29);
   strcat(pTmpBuf, pTmpBuf2);
-  v30 = 0;
-  a1->DrawText(pFontArrus, 120, 22, 0, pTmpBuf, 0, 0, 0);
-  v31 = v41;
+  DrawText(pFontArrus, 120, 22, 0, pTmpBuf, 0, 0, 0);
+
   uFramesetIDa = 0;
-  v32 = &_4E2AD8_ui_colors[1];
-  v46 = (const char **)&aSpellNames[20];
-  do
+  for (uint i = 0; i < 24; ++i)
   {
-    v33 = HIDWORD(v31->uExpireTime);
-    v34 = LODWORD(v31->uExpireTime);
-    if ( v33 >= (signed int)v30 && (v33 > (signed int)v30 || v34 > v30) )
+    auto buff = pPlayer->pPlayerBuffs + i;
+    if (buff->uExpireTime > 0)
     {
-      v35 = __PAIR__(v33, v34) - pParty->uTimePlayed;
-      v36 = uFramesetIDa++ * LOBYTE(a2->uFontHeight) + 134;
-      v37 = *v46;
+      v35 = buff->uExpireTime - pParty->uTimePlayed;
+      v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134;
       v38 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
-              (unsigned __int8)*(v32 - 1),
-              (unsigned __int8)*v32,
-              (unsigned __int8)v32[1]);
-      a1->DrawText(a2, 52, v36, v38, v37, 0, 0, 0);
-      sub_41D20D_buff_remaining_time_string(v36, a1, v35, a2);
-      v31 = v41;
-      v30 = 0;
+              _4E2AD8_ui_colors[i * 3],
+              _4E2AD8_ui_colors[i * 3 + 1],
+              _4E2AD8_ui_colors[i * 3 + 2]);
+      DrawText(pFontComic, 52, v36, v38, aSpellNames[20 + i], 0, 0, 0);
+      sub_41D20D_buff_remaining_time_string(v36, this, v35, pFontComic);
     }
-    ++v46;
-    ++v31;
-    v32 += 3;
-    v41 = v31;
   }
-  while ( (signed int)v46 < (signed int)&dword_506978 );
-  v39 = nullstring;
-  if ( uFramesetIDa == v30 )
+
+  v39 = "";
+  if ( uFramesetIDa == 0 )
     v39 = pGlobalTXT_LocalizationStrings[153];
-  sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[450], v39);
-  return a1->DrawText(pFontArrus, 14, 114, v30, pTmpBuf, v30, v30, v30);
+  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[450], v39);
+  return DrawText(pFontArrus, 14, 114, 0, pTmpBuf, 0, 0, 0);
 }
 
 //----- (0041D08F) --------------------------------------------------------
@@ -324,20 +272,20 @@
 {
   if ( a2 )
   {
-    this->field_28 = a2;
+    this->pNumPresenceButton = a2;
     this->field_30 = a3;
     this->field_34 = a4;
-    this->field_2C_focus_id = a5;
-    this->field_38 = a5;
+    this->pCurrentPosActiveItem = a5;
+    this->pStartingPosActiveItem = a5;
     this->field_44 = 1;
   }
   else
   {
-    this->field_28 = 0;
+    this->pNumPresenceButton = 0;
     this->field_30 = a3;
     this->field_34 = a4;
-    this->field_2C_focus_id = 0;
-    this->field_38 = 0;
+    this->pCurrentPosActiveItem = 0;
+    this->pStartingPosActiveItem = 0;
     this->field_44 = 0;
   }
 }
@@ -369,7 +317,7 @@
     if ( !v5 )
     {
       pIcons_LOD->_40F9C5();
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = dword_506978;
+      pCurrentScreen = dword_506978;
       pKeyActionMap->_459ED1(3);
       goto LABEL_26;
     }
@@ -431,7 +379,7 @@
         pTexture_Dialogue_Background->Release();
         pIcons_LOD->_40F9C5();
 LABEL_19:
-        uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = dword_506978;
+        pCurrentScreen = dword_506978;
         goto LABEL_26;
       }
       OnCloseSpellook();
@@ -459,7 +407,7 @@
   {
     v12 = pVisibleWindowsIdxs[v10 + 1];
     pVisibleWindowsIdxs[v10] = v12;
-    --*((int *)&stru_506F20.field_18 + 21 * v12);
+    --*((int *)&pTexture_PCX.field_18 + 21 * v12);
     ++v10;
   }
   pVisibleWindowsIdxs[v11] = 0;
@@ -525,7 +473,7 @@
   pAudioPlayer->StopChannels(-1, -1);
   InitializeBookFonts();
   v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 3;
+  pCurrentScreen = 3;
   dword_506524 = 0;
   dword_506528 = 0;
   dword_50651C = 0;
@@ -589,7 +537,7 @@
           0xB3u,
           v19,
           0,
-          nullstring,
+          "",
           0);
         ++v19;
       }
@@ -632,7 +580,7 @@
           0xB7u,
           v16,
           0,
-          nullstring,
+          "",
           0);
         ++v16;
       }
@@ -887,7 +835,7 @@
                             2u,
                             0,
                             pGlobalTXT_LocalizationStrings[192],// Scroll Up
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             pBtn_Book_4 = v1->CreateButton(
                             pViewport->uViewportX + 397,
@@ -900,7 +848,7 @@
                             3u,
                             0,
                             pGlobalTXT_LocalizationStrings[193],// Scroll Down
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             pBtn_Book_5 = v1->CreateButton(
                             pViewport->uViewportX + 397,
@@ -913,7 +861,7 @@
                             4u,
                             0,
                             pGlobalTXT_LocalizationStrings[573],// "Scroll Right"
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             pBtn_Book_6 = v1->CreateButton(
                             pViewport->uViewportX + 397,
@@ -926,7 +874,7 @@
                             5u,
                             0,
                             pGlobalTXT_LocalizationStrings[572],// "Scroll Left"
-                            (Texture *)nullstring,
+                            (Texture *)"",
                             0);
             return;
           }
@@ -1033,7 +981,7 @@
 
 
 //----- (00415551) --------------------------------------------------------
-void GUIWindow::_415551(int arg0)
+void GUIWindow::DrawMessageBox(int arg0)
 {
   unsigned int v2; // edi@1
   GUIWindow *v3; // ebx@1
@@ -1120,7 +1068,7 @@
   v19.uFrameZ = v19.uFrameWidth + v19.uFrameX - 1;
   v23 = v12;
   v19.uFrameW = v19.uFrameHeight + v19.uFrameY - 1;
-  v14 = v3->str_48;
+  v14 = v3->Hint;
   if ( v14 )
   {
     v15 = pFontLucida->CalcTextHeight(v14, &v19, 0, 0);
@@ -1136,7 +1084,7 @@
   if ( (signed int)(v16 + v12) > 479 )
     v16 = 479 - v12;
   DrawPopupWindow(a2.y, v12, v21, v16);
-  v17 = v3->str_48;
+  v17 = v3->Hint;
   if ( v17 )
   {
     v18 = pFontLucida->CalcTextHeight(v17, &v19, 0, 0);
@@ -1148,8 +1096,8 @@
 //----- (0041192C) --------------------------------------------------------
 void __cdecl InitializeBookTextures()
 {
-  signed int v0; // ebp@3
-  Texture **v1; // ebx@3
+  //signed int v0; // ebp@3
+  //Texture **v1; // ebx@3
 
   pAudioPlayer->StopChannels(-1, -1);
   ++pIcons_LOD->uTexturePacksCount;
@@ -1161,21 +1109,24 @@
   pTexture_506448   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-u", TEXTURE_16BIT_PALETTE)];
   ptr_506440        = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-d", TEXTURE_16BIT_PALETTE)];
   pTexture_50643C   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m6-u",TEXTURE_16BIT_PALETTE)];
-  v0 = 1;
-  v1 = (Texture **)&pTextures_tabs[0][0].pName[4];
-  pTexture_506444 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m6-d",TEXTURE_16BIT_PALETTE)];
-  do
+  //v0 = 1;
+
+  static const char *texNames[9] =
   {
-    *(&pTexture_pagemask + v0) = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(
-                                                         (const char *)pLloydsBeacons_SomeYs[v0 + 4],
-                                                         TEXTURE_16BIT_PALETTE)];
-    sprintfex(pTmpBuf, "tab%da", v0);
-    *(v1 - 1) = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
-    sprintfex(pTmpBuf, "tab%db", v0++);
-    *v1 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
-    v1 += 2;
+    "SBFB00", "SBAB00", "SBWB00", "SBEB00",
+    "SBSB00", "SBMB00", "SBBB00", "SBLB00",
+  };
+
+  pTexture_506444 = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE);
+  for (uint i = 0; i < 8; ++i)
+  {
+    pTextures_5064A0[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE);
+
+    sprintf(pTmpBuf, "tab%da", i);
+    pTextures_tabs[i][0] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
+    sprintf(pTmpBuf, "tab%db", i);
+    pTextures_tabs[i][1] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
   }
-  while ( (signed int)v1 <= (signed int)&unk_506494 );
 }
 
 //----- (00411AAA) --------------------------------------------------------
@@ -1206,7 +1157,7 @@
   v2 = uSlot;
   v7 = uPlayer;
   v3 = uSlot + 1;
-  sprintfex(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1);
+  sprintf(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1);
   v4 = fopen(pContainerName, "rb");
   if ( v4 )
   {
@@ -1215,7 +1166,7 @@
   }
   else
   {
-    sprintfex(pContainerName, "lloyd%d%d.pcx", v7, v3);
+    sprintf(pContainerName, "lloyd%d%d.pcx", v7, v3);
     v5 = pNew_LOD->FindContainer(pContainerName, 1);
     if ( v5 )
       pSavegameThumbnails[v2].LoadFromFILE(v5, 0, 0);
@@ -1236,17 +1187,19 @@
   int a2; // [sp+10h] [bp-8h]@1
   int v7; // [sp+14h] [bp-4h]@1
 
+  __debugbreak();
+
   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],
@@ -1257,14 +1210,14 @@
         0x56u,
         v3,
         0,
-        nullstring,
+        "",
         0);
       ++a2;
     }
     ++v3;
   }
   while ( (signed int)v3 < 11 );
-  v2->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, nullstring, 0);
+  v2->CreateButton(0, 0, 0, 0, 1, 0, 0x33u, 0, 9u, "", 0);
   if ( a2 )
     v2->_41D08F(a2, 0, 0, 0);
   if ( v1->pActiveSkills[12] )
@@ -1295,7 +1248,7 @@
     0x58u,
     0,
     0,
-    nullstring,
+    "",
     0);
   ptr_5064F8 = v2->CreateButton(
                  0x1DCu,
@@ -1307,7 +1260,7 @@
                  0x58u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  pTexture_506444,
                  0);
   v2->CreateButton(
@@ -1477,7 +1430,7 @@
     _4E5EE0_transui_y - 4,
     (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
   pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pDialogueNPCPortraits[(signed int)v4]);
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 14 )
+  if ( pCurrentScreen == 14 )
   {
     CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
     goto LABEL_58;
@@ -1488,7 +1441,7 @@
   }
   else
   {
-    sprintfex(
+    sprintf(
       pTmpBuf,
       pGlobalTXT_LocalizationStrings[429],
       //p2DEvents_minus1_::08[13 * (unsigned int)ptr_507BC0->ptr_1C],
@@ -1620,7 +1573,7 @@
     v8 = pGlobalTXT_LocalizationStrings[57];
     if ( v18 <= 1 )
       v8 = pGlobalTXT_LocalizationStrings[56];
-    sprintfex(pTmpBuf2, "%d %s ", v18, v8);
+    sprintf(pTmpBuf2, "%d %s ", v18, v8);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v7 )
@@ -1629,7 +1582,7 @@
       v9 = pGlobalTXT_LocalizationStrings[109];
     else
       v9 = pGlobalTXT_LocalizationStrings[110];
-    sprintfex(pTmpBuf2, "%d %s ", v7, v9);
+    sprintf(pTmpBuf2, "%d %s ", v7, v9);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v16 && !v18 )
@@ -1638,7 +1591,7 @@
       v10 = pGlobalTXT_LocalizationStrings[437];
     else
       v10 = pGlobalTXT_LocalizationStrings[436];
-    sprintfex(pTmpBuf2, "%d %s ", v16, v10);
+    sprintf(pTmpBuf2, "%d %s ", v16, v10);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v17 && !v7 )
@@ -1647,7 +1600,7 @@
       v11 = pGlobalTXT_LocalizationStrings[439];
     else
       v11 = pGlobalTXT_LocalizationStrings[438];
-    sprintfex(pTmpBuf2, "%d %s ", v17, v11);
+    sprintf(pTmpBuf2, "%d %s ", v17, v11);
     strcat(pTmpBuf, pTmpBuf2);
   }
   v12 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
@@ -2164,7 +2117,7 @@
   pWindow->uFrameZ = uX + uWidth - 1;
   pWindow->uFrameW = uY + uHeight - 1;
   pWindow->ptr_1C = (void *)a4;
-  pWindow->str_48 = (char *)a5;
+  pWindow->Hint = (char *)a5;
   v10 = uNumVisibleWindows;
   pWindow->uFrameX = uX;
   ++v10;
@@ -2185,8 +2138,8 @@
           pWindow->InitializeBookView();
           break;
         case WINDOW_A:
-          dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 4;
+          dword_506978 = pCurrentScreen;
+          pCurrentScreen = 4;
           ptr_5076F4 = pWindow->CreateButton(
                          0x1D7u,
                          0x1BDu,
@@ -2229,7 +2182,7 @@
                       0x88u,
                       0x13u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2250,7 +2203,7 @@
                       0x88u,
                       0x14u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2271,7 +2224,7 @@
                       0x88u,
                       0x15u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2292,7 +2245,7 @@
                       0x88u,
                       0x16u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2313,7 +2266,7 @@
                       0x88u,
                       0x17u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2334,7 +2287,7 @@
                       0x88u,
                       0x18u,
                       0,
-                      nullstring,
+                      "",
                       0);
                 }
               }
@@ -2357,7 +2310,7 @@
                   0);
                 if ( v12->uFlags & 0x80 )
                 {
-                  sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName);
+                  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName);
                   pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pTmpBuf, 0);
                 }
                 else
@@ -2382,8 +2335,8 @@
           }
           break;
         case WINDOW_11:
-          dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 17;
+          dword_506978 = pCurrentScreen;
+          pCurrentScreen = 17;
           ptr_5076F4 = pWindow->CreateButton(
                          0x236u,
                          0x1BDu,
@@ -2407,7 +2360,7 @@
                          0x5Au,
                          0,
                          0x59u,
-                         pWindow->str_48,
+                         pWindow->Hint,
                          (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
                          0);
           pWindow->CreateButton(
@@ -2420,35 +2373,35 @@
             0x5Au,
             1u,
             0x20u,
-            pWindow->str_48,
+            pWindow->Hint,
             0,
             0,
             0);
-          pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x5Au, 1u, 0, pWindow->str_48, 0);
+          pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x5Au, 1u, 0, pWindow->Hint, 0);
           break;
         case WINDOW_12:
           InitializeBookTextures();
           pWindow->_411621();
           break;
         case WINDOW_13:
-          dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+          dword_506978 = pCurrentScreen;
           pKeyActionMap->_459E5A(0, 15, pWindow);
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 19;
+          pCurrentScreen = 19;
           break;
       }
       return pWindow;
     }
 LABEL_62:
-    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
-    pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, nullstring, 0);
+    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+    pWindow->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
     return pWindow;
   }
   if (eWindowType == WINDOW_HouseInterior)
   {
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 13;
+    pCurrentScreen = 13;
     ptr_5076F4 = pWindow->CreateButton(
                    0x1D7u,
                    0x1BDu,
@@ -2484,7 +2437,7 @@
           v30 = v27;
           v29 = pGlobalTXT_LocalizationStrings[435];
         }
-        sprintfex(&byte_591180[100 * v26], v29, v30);
+        sprintf(&byte_591180[100 * v26], v29, v30);
         array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(
                                              *(&_4E5E50_transui_x + v26 + 6 * uNumDialogueNPCPortraits - 6),
                                              *(&_4E5EE0_transui_y + v26 + 6 * uNumDialogueNPCPortraits - 6),
@@ -2514,8 +2467,8 @@
   {
     if (eWindowType == WINDOW_1A)
     {
-      dword_506978 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 18;
+      dword_506978 = pCurrentScreen;
+      pCurrentScreen = 18;
       ptr_5076F4 = pWindow->CreateButton(
                      0x236u,
                      0x1BDu,
@@ -2539,7 +2492,7 @@
                      0x19Bu,
                      0,
                      0x59u,
-                     pWindow->str_48,
+                     pWindow->Hint,
                      (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0),
                      0);
       pWindow->CreateButton(
@@ -2552,9 +2505,9 @@
         0x19Bu,
         1u,
         0x20u,
-        pWindow->str_48,
+        pWindow->Hint,
         0);
-      pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x19Bu, 1u, 0, pWindow->str_48, 0);
+      pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x19Bu, 1u, 0, pWindow->Hint, 0);
       return pWindow;
     }
     if (eWindowType == WINDOW_1B)
@@ -2586,7 +2539,7 @@
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2u);
       ++pIcons_LOD->uTexturePacksCount;
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 23;
+      pCurrentScreen = 23;
       if ( !pIcons_LOD->uNumPrevLoadedFiles )
         pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
     }
--- a/GUIWindow.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/GUIWindow.h	Mon Oct 29 09:28:08 2012 +0600
@@ -68,11 +68,11 @@
   void _4B3157();
   GUIButton *_411621();
   void InitializeBookView();
-  void _415551(int arg0);
+  void DrawMessageBox(int arg0);
   GUIButton *GetControl(unsigned int uID);
   void Release();
   void _41D08F(int a2, int a3, int a4, int a5);
-  char _41D3B7();
+  char DrawQuickCharRecord();
   char _41D73D_draw_buff_tooltip();
 
   static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eType, int a4, int a5);
@@ -87,15 +87,15 @@
   void *ptr_1C;
   unsigned int uNumControls;
   int field_24;
-  int field_28;
-  int field_2C_focus_id;
+  int pNumPresenceButton; 
+  int pCurrentPosActiveItem;
   int field_30;
   int field_34;
-  int field_38;
+  int pStartingPosActiveItem;
   int field_3C;
   int field_40;
   int field_44;
-  char *str_48;
+  char *Hint;
   GUIButton *pControlsHead;
   GUIButton *pControlsTail;
 };
@@ -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_PlayerCreationSelectClass = 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	Mon Oct 22 09:20:49 2012 +0600
+++ b/Game.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -48,8 +48,6 @@
 //----- (0044103C) --------------------------------------------------------
 void Game::Draw()
 {
-  Render *v0; // esi@3
-  int _null; // ebx@6
   float v2; // ST24_4@11
   //double v3; // ST28_8@11
   int v4; // edi@26
@@ -63,38 +61,37 @@
   pIndoorCamera->pos.x = pParty->vPosition.x
                       - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
                                           * (signed __int64)pParty->field_18) >> 16);
-  pIndoorCamera->pos.y = pParty->vPosition.z
+  pIndoorCamera->pos.y = pParty->vPosition.y
                       - ((unsigned __int64)(stru_5C6E00->SinCos(
                                               pParty->sRotationY - stru_5C6E00->uIntegerHalfPi)
                                           * (signed __int64)pParty->field_18) >> 16);
-  pIndoorCamera->pos.z = pParty->vPosition.y + pParty->sEyelevel;
+  pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   pIndoorCamera->Initialize2();
   pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
   pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum();
-  //v0 = &pRenderer;
+
   if ( pVideoPlayer->AnyMovieLoaded() )
   {
-    _null = 0;
     if ( pRenderer->pRenderD3D )
       goto LABEL_22;
-    pRenderer->SetGameRenderStates();
-    pMouse->_469E3B();
+    pRenderer->BeginSceneD3D();
+    pMouse->DrawCursorToTarget();
   }
   else
   {
-    if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.z != pParty->vPrevPosition.z | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.y != pParty->vPrevPosition.y | pParty->sEyelevel != pParty->sPrevEyelevel )
+    if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.z | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.z != pParty->vPrevPosition.y | pParty->sEyelevel != pParty->sPrevEyelevel )
       pParty->uFlags |= 2u;
     pParty->vPrevPosition.x = pParty->vPosition.x;
-    pParty->vPrevPosition.y = pParty->vPosition.y;
+    pParty->vPrevPosition.y = pParty->vPosition.z;
     //v0 = &pRenderer;
     pParty->sPrevRotationY = pParty->sRotationY;
-    pParty->vPrevPosition.z = pParty->vPosition.z;
+    pParty->vPrevPosition.z = pParty->vPosition.y;
     pParty->sPrevRotationX = pParty->sRotationX;
     pParty->sPrevEyelevel = pParty->sEyelevel;
-    pRenderer->SetGameRenderStates();
-    _null = 0;
+    pRenderer->BeginSceneD3D();
+
     if ( !pRenderer->pRenderD3D )
-      pMouse->_469E3B();
+      pMouse->DrawCursorToTarget();
     if ( !sub_4226C2() || viewparams->field_48 == 1 )
     {
       if ( pRenderer->pRenderD3D )
@@ -105,15 +102,15 @@
         pRenderer->field_1036A8_bitmapid = floorf(v2 + 0.5f);
       }
 
-      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
         pIndoor->Draw();
-      else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-          pOutdoor->Draw();
+      else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+        pOutdoor->Draw();
 
-      if ( pRenderer->pRenderD3D )
+      if (pRenderer->pRenderD3D)
       {
         pDecalBuilder->DrawBloodsplats();
-        if ( pRenderer->pRenderD3D )
+        if (pRenderer->pRenderD3D)
           pGame->pLightmapBuilder->DrawLightmaps(2);
       }
     }
@@ -121,44 +118,42 @@
   pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
 LABEL_22:
   pRenderer->BeginScene();
-  if ( pRenderer->pRenderD3D != (RenderD3D *)_null )
-    pMouse->_469E3B();
-  if ( pOtherOverlayList->field_3EC != _null )
+  if (pRenderer->pRenderD3D)
+    pMouse->DrawCursorToTarget();
+  if (pOtherOverlayList->field_3EC)
     viewparams->bRedrawGameUI = 1;
   v4 = viewparams->bRedrawGameUI;
   GameUI_DrawStatusBar();
-  if ( viewparams->bRedrawGameUI == _null )
+  if (!viewparams->bRedrawGameUI)
   {
-    //nullsub_1();
     GameUI_DrawRightPanelItems();
   }
   else
   {
     GameUI_DrawRightPanelFrames();
     GameUI_DrawStatusBar_2();
-    viewparams->bRedrawGameUI = _null;
+    viewparams->bRedrawGameUI = false;
   }
-  if ( pVideoPlayer->pSmackerMovie == (_SMACK *)_null )
+  if (!pVideoPlayer->pSmackerMovie)
   {
-    GameUI_DrawMinimap(0x1E8u, 0x10u, 0x271u, 0x85u, viewparams->uMinimapZoom, pParty->uFlags & 2);
-    if ( v4 != _null )
+    GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2);
+    if (v4)
     {
-      if ( !sub_4226C2() && pRenderer->pRenderD3D != (RenderD3D *)_null )
-        pRenderer->FillRect2(
-          _null,
+      if ( !sub_4226C2() && pRenderer->pRenderD3D)
+        pRenderer->FillRectFast(
           pViewport->uViewportX,
           pViewport->uViewportY,
           pViewport->uViewportZ - pViewport->uViewportX,
           pViewport->uViewportW - pViewport->uViewportY + 1,
-          LOWORD(pRenderer->uTargetGMask) | LOWORD(pRenderer->uTargetBMask));
-      viewparams->field_48 = _null;
+          pRenderer->uTargetGMask | pRenderer->uTargetBMask);
+      viewparams->field_48 = 0;
     }
   }
   v5 = pOtherOverlayList->field_3EC;
-  pOtherOverlayList->field_3EC = _null;
+  pOtherOverlayList->field_3EC = 0;
   viewparams->bRedrawGameUI = v5;
   GameUI_DrawPartySpells();
-  if ( v4 != _null || pParty->pHirelings[0].evtc != _null || pParty->pHirelings[1].evtc != _null )
+  if (v4 || pParty->pHirelings[0].evtc || pParty->pHirelings[1].evtc )
     DrawHiredNPCs();
   GameUI_DrawPortraits(v4);
   GameUI_DrawLifeManaBars();
@@ -174,8 +169,8 @@
   GUI_UpdateWindows();
   pParty->_4909F4();
   ++stru_51076C.field_8;
-  dword_5B5924 = _null;
-  if ( v4 != _null )
+  dword_5B5924 = 0;
+  if (v4)
     pMouse->field_14 = 1;
   pMouse->_469EA4();
   pMouse->DrawCursor();
@@ -184,7 +179,6 @@
   pRenderer->Present();
   pParty->uFlags &= 0xFFFFFFFDu;
 }
-// 5B5924: using guessed type int dword_5B5924;
 
 
 //----- (0047A815) --------------------------------------------------------
@@ -254,7 +248,8 @@
     pEventTimer->Resume();
     dword_6BE364_game_settings_1 |= 0x80;
     dword_6BE340 = 2;
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+    // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+	pCurrentScreen = 0;
     if (pAsyncMouse)
       pAsyncMouse->Resume();
     if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard )
@@ -292,7 +287,7 @@
       if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) )
       {
         pRenderer->BeginScene();
-        pMouse->_469E3B();
+        pMouse->DrawCursorToTarget();
         pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow);
         pMouse->_469EA4();
         pRenderer->EndScene();
@@ -300,7 +295,7 @@
       if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) )
       {
         pRenderer->BeginScene();
-        pMouse->_469E3B();
+        pMouse->DrawCursorToTarget();
         pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow);
         pMouse->_469EA4();
         pRenderer->EndScene();
@@ -424,21 +419,21 @@
       if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 136) )
       {
         pParty->vPosition.x = -17331;            // respawn in harmondale
-        pParty->vPosition.z = 12547;
-        pParty->vPosition.y = 465;
+        pParty->vPosition.y = 12547;
+        pParty->vPosition.z = 465;
         pParty->sRotationY = 0;
         v13 = "out02.odm";
       }
       else
       {
         pParty->vPosition.x = 12552;             // respawn on emerald isle
-        pParty->vPosition.z = 1816;
-        pParty->vPosition.y = 0;
+        pParty->vPosition.y = 1816;
+        pParty->vPosition.z = 0;
         pParty->sRotationY = 512;
         v13 = "out01.odm";
       }
       strcpy(Source, v13);
-      pParty->uFallStartY = pParty->vPosition.y;
+      pParty->uFallStartY = pParty->vPosition.z;
       pParty->sRotationX = 0;
       pParty->uFallSpeed = 0;
       pParty->field_6E4 = 0;
@@ -447,8 +442,8 @@
       {
         strcpy(pCurrentMapName, Source);
         _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x;
-        _5B65AC_npcdata_fame_or_other = pParty->vPosition.z;
-        _5B65B0_npcdata_rep_or_other = pParty->vPosition.y;
+        _5B65AC_npcdata_fame_or_other = pParty->vPosition.y;
+        _5B65B0_npcdata_rep_or_other = pParty->vPosition.z;
         _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY;
         _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX;
         dword_5B65C0 = 1;
@@ -486,7 +481,7 @@
     }
     break;
   }
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 16;
+  pCurrentScreen = 16;
   sub_491E3A();
 }
 
@@ -494,33 +489,19 @@
 
 
 //----- (0044F192) --------------------------------------------------------
-void Game::PushStru165s()
+void Game::PrepareBloodsplats()
 {
-  Game *v1; // edi@1
-  int v2; // ebx@1
-  float *v3; // esi@2
-
-  auto a1 = this;
-  v1 = a1;
-  v2 = 0;
-  if ( a1->array_708_size > 0 )
+  for (uint i = 0; i < uNumBloodsplats; ++i)
   {
-    v3 = &a1->array_708[0].flt_10;
-    do
-    {
-      pBloodsplatContainer->AddBloodsplat(
-        *(v3 - 4),
-        *(v3 - 3),
-        *(v3 - 2),
-        v3[2],
-        (signed __int64)*(v3 - 1),
-        (signed __int64)*v3,
-        (signed __int64)v3[1]);
-      ++v2;
-      v3 += 7;
-    }
-    while ( v2 < v1->array_708_size );
-  }
+    pBloodsplatContainer->AddBloodsplat(
+        pBloodsplats[i].x,
+        pBloodsplats[i].y,
+        pBloodsplats[i].z,
+        pBloodsplats[i].radius,
+        pBloodsplats[i].r,
+        pBloodsplats[i].g,
+        pBloodsplats[i].b);
+   }
 }
 
 
@@ -561,7 +542,7 @@
 
   if ( !(uFlags & 0x40) )
   {
-    array_708_size = 0;
+    uNumBloodsplats = 0;
     field_E0C = 0;
   }
 }
@@ -592,7 +573,7 @@
 //----- (0044EEA7) --------------------------------------------------------
 bool Game::_44EEA7()
 {
-  Game *v1; // esi@1
+  //Game *v1; // esi@1
   double v2; // st7@2
   float depth; // ST00_4@9
   bool result; // eax@9
@@ -605,7 +586,7 @@
   stru157 *v11; // [sp+14h] [bp-14h]@2
   POINT a2; // [sp+20h] [bp-8h]@1
 
-  v1 = this;
+  //v1 = this;
   ++qword_5C6DF0;
   pParticleEngine->UpdateParticles();
   pMouseInstance->GetCursorPos(&a2);
@@ -620,7 +601,7 @@
   }
   else
   {
-    if ( v1->uFlags2 & 0x10 )
+    if ( uFlags2 & 0x10 )
     {
       v11 = &a5;
       v10 = &stru_F93E1C;
@@ -649,8 +630,8 @@
   depth = v2;
 
   PickMouse(depth, y, x, v9, v10, v11);
-  v1->pLightmapBuilder->std__vector_000004_size = 0;
-  v1->pLightmapBuilder->std__vector_183808_size = 0;
+  pLightmapBuilder->std__vector_000004_size = 0;
+  pLightmapBuilder->std__vector_183808_size = 0;
   pDecalBuilder->std__vector_pDecals_size = 0;
   pDecalBuilder->field_308008 = 0;
   result = _44F07B();
@@ -661,59 +642,48 @@
     if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor)
     {
       v5 = GetLevelFogColor();
-      LODWORD(pRenderer->uFogColor) = v5 & 0xFFFFFF;
+      pRenderer->uFogColor = v5 & 0xFFFFFF;
     }
     if (uFlags & 0x0400)
       uFlags2 |= 0x01;
-    if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && uNumMobileLightsApplied )
+    if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive )
     {
       uFlags2 |= 0x01;
       field_E10 = qword_5C6DF0;
     }
-    v6 = qword_5C6DF0 - v1->field_E10;
-    if ( qword_5C6DF0 - v1->field_E10 == 1 )
-      v1->uFlags2 |= v6;
-    if ( v1->uNumStationaryLights_in_pStationaryLightsStack != uNumStationaryLightsApplied )
+    v6 = qword_5C6DF0 - field_E10;
+    if ( qword_5C6DF0 - field_E10 == 1 )
+      uFlags2 |= v6;
+    if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive )
     {
-      v1->uFlags2 |= 1u;
-      v1->uNumStationaryLights_in_pStationaryLightsStack = uNumStationaryLightsApplied;
+      uFlags2 |= 1u;
+      uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive;
     }
     _44E904();
     LOBYTE(result) = 1;
   }
   return result;
 }
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
-// 5C6DEC: using guessed type char static_sub_44EEA7_byte_5C6DEC__init_flag;
-// 5C6DF0: using guessed type __int64 qword_5C6DF0;
-// F93E1C: using guessed type stru157 stru_F93E1C;
-// F93E30: using guessed type stru157 stru_F93E30;
+
 
 //----- (0044EDE4) --------------------------------------------------------
-bool Game::_44EDE4(BLVFace *pFace, int *a3)
+bool Game::AlterGamma(BLVFace *pFace, unsigned int *pColor)
 {
-  bool result; // eax@1
-
-  result = (bool)pGame;
-  if ( pGame->uFlags2 & 2 && (result = (bool)pFace, pFace->uAttributes & 2) )
+  if (pGame->uFlags2 & 2 && pFace->uAttributes & 2)
   {
-    result = sub_48A959(*a3, 1.0, this->_E28_timed_gamma_strength, -1.0);
-    *a3 = result;
-    LOBYTE(result) = 1;
+    *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0);
+    return true;
   }
   else
-  {
-    LOBYTE(result) = 0;
-  }
-  return result;
+    return false;
 }
 
 //----- (0044EE30) --------------------------------------------------------
 bool Game::_44EE30(ODMFace *a2, int a3)
 {
-  if (uFlags2 & 0x2 && a2->uFaceAttributes & 0x02)
+  if (uFlags2 & 0x2 && a2->uAttributes & 0x02)
   {
-    *(int *)a3 = sub_48A959(*(int *)a3, 1.0, _E28_timed_gamma_strength, -1.0);
+    *(int *)a3 = ReplaceHSV(*(int *)a3, 1.0, fSaturation, -1.0);
     return true;
   }
   else
@@ -781,17 +751,17 @@
   float a4a; // [sp+1Ch] [bp+10h]@9
   float a4b; // [sp+1Ch] [bp+10h]@11
 
-  if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uFaceAttributes & 2 )
+  if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 )
   {
     v4 = (double)a4;
     a2a = v4;
     *a3 |= 2u;
-    a3a = (1.0 - this->_E28_timed_gamma_strength) * v4;
+    a3a = (1.0 - this->fSaturation) * v4;
     //v5 = a3a + 6.7553994e15;
     //if ( SLODWORD(v5) >= 0 )
     if (floorf(a3a + 0.5f) >= 0 )
     {
-      a3b = (1.0 - this->_E28_timed_gamma_strength) * a2a;
+      a3b = (1.0 - this->fSaturation) * a2a;
       //v7 = a3b + 6.7553994e15;
       //v6 = LODWORD(v7);
       v6 = floorf(a3b + 0.5f);
@@ -802,12 +772,12 @@
     }
     if ( a4 >= v6 )
     {
-      a4a = (1.0 - _E28_timed_gamma_strength) * a2a;
+      a4a = (1.0 - fSaturation) * a2a;
       //v9 = a4a + 6.7553994e15;
       //if ( SLODWORD(v9) >= 0 )
       if (floorf(a4a + 0.5f) >= 0)
       {
-        a4b = (1.0 - _E28_timed_gamma_strength) * a2a;
+        a4b = (1.0 - fSaturation) * a2a;
         //v10 = a4b + 6.7553994e15;
         //result = LODWORD(v10);
         result = floorf(a4b + 0.5f);
@@ -849,11 +819,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
@@ -866,11 +836,11 @@
     v4 = (double)a4;
     v11 = v4;
     *a3 |= 2u;
-    v12 = (1.0 - this->_E28_timed_gamma_strength) * v4;
-    v5 = v12 + 6.7553994e15;
-    if ( SLODWORD(v5) >= 0 )
+    v12 = (1.0 - this->fSaturation) * v4;
+    //v5 = v12 + 6.7553994e15;
+    if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 )
     {
-      v13 = (1.0 - this->_E28_timed_gamma_strength) * v11;
+      v13 = (1.0 - this->fSaturation) * v11;
       //v7 = v13 + 6.7553994e15;
       //v6 = LODWORD(v7);
       v6 = floorf(v13 + 0.5f);
@@ -881,11 +851,11 @@
     }
     if ( a4 >= v6 )
     {
-      v14 = (1.0 - _E28_timed_gamma_strength) * v11;
-      v9 = v14 + 6.7553994e15;
-      if ( SLODWORD(v9) >= 0 )
+      v14 = (1.0 - fSaturation) * v11;
+      //v9 = v14 + 6.7553994e15;
+      if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 )
       {
-        v15 = (1.0 - _E28_timed_gamma_strength) * v11;
+        v15 = (1.0 - fSaturation) * v11;
         //v10 = v15 + 6.7553994e15;
         //result = LODWORD(v10);
         result = floorf(v15 + 0.5f);
@@ -912,7 +882,7 @@
 Game::Game()
 {
   uNumStationaryLights = 0;
-  array_708_size = 0;
+  uNumBloodsplats = 0;
   field_E0C = 0;
   field_E10 = 0;
   uNumStationaryLights_in_pStationaryLightsStack = 0;
@@ -924,7 +894,7 @@
 
   pThreadWardInstance = new ThreadWard;
   pParticleEngine = new ParticleEngine;
-  pMouseInstance = new Mouse(pThreadWardInstance);
+  pMouse = pMouseInstance = new Mouse(pThreadWardInstance);
   pLightmapBuilder = new LightmapBuilder;
   pVisInstance = new Vis;
   pStru6Instance = new stru6;
@@ -984,7 +954,7 @@
 //----- (0044E904) --------------------------------------------------------
 void Game::_44E904()
 {
-  Game *v1; // esi@1
+  //Game *v1; // esi@1
   unsigned __int64 v2; // qax@1
   unsigned int v3; // ecx@1
   int v4; // edi@1
@@ -993,13 +963,13 @@
   double v7; // st7@15
   signed __int64 v8; // [sp+Ch] [bp-8h]@1
 
-  v1 = this;
+  //v1 = this;
   v2 = pEventTimer->Time();
-  v4 = (v2 - v1->uSomeGammaStartTime) >> 32;
-  v3 = v2 - LODWORD(v1->uSomeGammaStartTime);
-  v8 = v2 - v1->uSomeGammaStartTime;
+  v4 = (v2 - uSomeGammaStartTime) >> 32;
+  v3 = v2 - LODWORD(uSomeGammaStartTime);
+  v8 = v2 - uSomeGammaStartTime;
   if ( v4 < 0
-    || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(v1->uSomeGammaStartTime)) + HIDWORD(v1->uSomeGammaStartTime) | v4 == 0
+    || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0
     && v3 <= 0x80 )
   {
     if ( v4 > 0 || v4 >= 0 )
@@ -1009,25 +979,25 @@
   }
   else
   {
-    if ( v1->uSomeGammaDeltaTime )
+    if ( uSomeGammaDeltaTime )
     {
-      LODWORD(v1->uSomeGammaDeltaTime) = 0;
-      HIDWORD(v1->uSomeGammaDeltaTime) = 0;
+      LODWORD(uSomeGammaDeltaTime) = 0;
+      HIDWORD(uSomeGammaDeltaTime) = 0;
     }
     else
     {
-      LODWORD(v1->uSomeGammaDeltaTime) = v3;
-      HIDWORD(v1->uSomeGammaDeltaTime) = v4;
+      LODWORD(uSomeGammaDeltaTime) = v3;
+      HIDWORD(uSomeGammaDeltaTime) = v4;
     }
     v5 = __CFADD__(v3, -128);
     v3 -= 128;
     v4 = v5 + v4 - 1;
   }
-  v1->uSomeGammaStartTime = v2;
+  uSomeGammaStartTime = v2;
   v8 = __PAIR__(v4, v3);
 LABEL_12:
-  if ( v1->uSomeGammaDeltaTime )
-    v6 = (double)(signed __int64)(v1->uSomeGammaDeltaTime - __PAIR__(v4, v3));
+  if ( uSomeGammaDeltaTime )
+    v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3));
   else
     v6 = (double)v8;
   v7 = v6 * 0.0078125;
@@ -1041,9 +1011,9 @@
     v7 = 1.0;
   }
   if ( pRenderer->pRenderD3D )
-    v1->_E28_timed_gamma_strength = v7;
+    fSaturation = v7;
   else
-    v1->_E28_timed_gamma_strength = (1.0 - 0.5) * v7 + 0.5;
+    fSaturation = (1.0 - 0.5) * v7 + 0.5;
 }
 
 //----- (0044EA17) --------------------------------------------------------
@@ -1071,8 +1041,7 @@
   int a3; // [sp+1Fh] [bp-1h]@5
 
   auto v7 = this;
-  if (!uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-      && pRenderer->pRenderD3D)
+  if (!pCurrentScreen && pRenderer->pRenderD3D)
   {
     if (!pVisInstance)
     {
@@ -1097,14 +1066,12 @@
   }
   return false;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0044EB12) --------------------------------------------------------
 bool Game::_44EB12(bool bOutline, stru157 *a3, stru157 *a4)
 {
-  if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-    && pVisInstance
-    && pRenderer->pRenderD3D )
+  if ( !pCurrentScreen && pVisInstance && pRenderer->pRenderD3D )
   {
     bool r = pVisInstance->_4C05CC(&pVisInstance->stru1, a3, a4);
 
@@ -1114,7 +1081,7 @@
   }
   return false;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0044EB5A) --------------------------------------------------------
 void Game::OutlineSelection()
--- a/Game.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Game.h	Mon Oct 29 09:28:08 2012 +0600
@@ -61,15 +61,16 @@
 
 /*  279 */
 #pragma pack(push, 1)
-struct Game_stru1
+//Game_stru1
+struct Game_Bloodsplat
 {
-  float flt_0;
-  float flt_4;
-  float flt_8;
-  float flt_C;
-  float flt_10;
-  float flt_14;
-  float flt_18;
+  float x;
+  float y;
+  float z;
+  float r;
+  float g;
+  float b;
+  float radius;
 };
 #pragma pack(pop)
 
@@ -91,7 +92,7 @@
   void OutlineSelection();
   signed int _44EC23(struct stru148 *a2, int *a3, signed int a4);
   signed int _44ED0A(struct BLVFace *a2, int *a3, signed int a4);
-  bool _44EDE4(struct BLVFace *pFace, int *a3);
+  bool AlterGamma(struct BLVFace *pFace, unsigned int *pColor);
   bool _44EE30(struct ODMFace *a2, int a3);
   bool draw_debug_outlines();
   bool _44EEA7();
@@ -100,7 +101,7 @@
   void ToggleFlags2(unsigned int uFlag);
   void _44F0FD();
   void PushStationaryLights(int a2);
-  void PushStru165s();
+  void PrepareBloodsplats();
   void Deinitialize();
   void Loop();
   void DrawParticles();
@@ -116,7 +117,7 @@
   Game__StationaryLight pStationaryLights[25];
   char field_2C0[1092];
   unsigned int uNumStationaryLights;
-  Game_stru1 array_708[20];
+  Game_Bloodsplat pBloodsplats[20];
   int field_938;
   int field_93C;
   int field_940;
@@ -136,14 +137,14 @@
   int field_978;
   Game_stru0 stru_97C;
   char field_98C[1148];
-  int array_708_size;
+  int uNumBloodsplats;
   int field_E0C;
   __int64 field_E10;
   int uNumStationaryLights_in_pStationaryLightsStack;
   unsigned int bGammaControlInitialized;
   unsigned int uFlags;
   unsigned int uFlags2;
-  float _E28_timed_gamma_strength;
+  float fSaturation;
   unsigned __int64 uSomeGammaStartTime;
   __int64 uSomeGammaDeltaTime;
   ThreadWard *pThreadWardInstance;
--- a/GameUIs.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/GameUIs.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -52,7 +52,7 @@
       8u,
       8u,
       (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
+    if ( pCurrentScreen == 11 )
     {
       v1 = uTextureID_save_up;
       v2 = uTextureID_LS_saveU;
@@ -71,7 +71,7 @@
   }
   else
   {
-    pRenderer->DrawTextureRGB(0, 0, &stru_506F20);
+    pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
   }
   pGUIWindow_CurrentMenu = GUIWindow::Create(
                              saveload_dlg_xs[uDialogueType_],
@@ -110,7 +110,7 @@
       v5 = v15.FindContainer("image.pcx", true);
       if ( !v5 )
       {
-        v9 = nullstring;
+        v9 = "";
 LABEL_22:
         pSavegameUsedSlots[v3] = 0;
         strcpy(Dest->pName, v9);
@@ -132,7 +132,7 @@
   }
 LABEL_24:
   v15.FreeSubIndexAndIO();
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
+  if ( pCurrentScreen == 11 )
   {
     v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
     v10 = (TEXTURE_TYPE)2;
@@ -148,13 +148,13 @@
   uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10);
   uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, "", 0);
   ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
                  241u,
                  302u,
@@ -165,7 +165,7 @@
                  0xA4u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
                  0);
   ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
@@ -178,7 +178,7 @@
                  0xA6u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
                  0);
   ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
@@ -191,7 +191,7 @@
                  0xA2u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
                  0);
   v7 = pGUIWindow_CurrentMenu->CreateButton(
@@ -204,7 +204,7 @@
          0xA3u,
          uNumSavegameFiles,
          0,
-         nullstring,
+         "",
          (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
          0);
   v16 = -1;
@@ -244,7 +244,7 @@
     8u,
     8u,
     (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
+  if ( pCurrentScreen == 11 )
   {
     v0 = uTextureID_save_up;
     v1 = uTextureID_LS_saveU;
@@ -273,7 +273,7 @@
     v3 = v8;
     if ( !*v8 )
       v3 = "1.mm7";
-    sprintfex(pTmpBuf, "saves\\%s", v3);
+    sprintf(pTmpBuf, "saves\\%s", v3);
     if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
     {
       v6 = pGlobalTXT_LocalizationStrings[72];
@@ -309,13 +309,13 @@
   uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
   pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, "", 0);
   ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
                  0xF1u,
                  0x12Eu,
@@ -326,7 +326,7 @@
                  0xA4u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
                  0);
   ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
@@ -339,7 +339,7 @@
                  0xA6u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
                  0);
   ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
@@ -352,7 +352,7 @@
                  0xA2u,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
                  0);
   v7 = pGUIWindow_CurrentMenu->CreateButton(
@@ -365,7 +365,7 @@
          0xA3u,
          0x22u,
          0,
-         nullstring,
+         "",
          (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
          0);
   v12 = -1;
--- a/Indoor.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Indoor.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -48,7 +48,7 @@
 stru337 stru_F81018;
 stru167_wrap array_5118E8;
 stru170_stru2 stru_F8A590;
-stru170 *pStru170; // idb
+stru170 *pStru170 = new stru170; // idb
 stru141 stru_721530;
 stru352 stru_F83B80[480];
 
@@ -69,7 +69,7 @@
 //----- (0043F39E) --------------------------------------------------------
 void __fastcall sub_43F39E(IndoorLocation_drawstru *_this)
 {
-  int *v1; // ecx@1
+  //int *v1; // ecx@1
   //double v2; // ST30_8@3
   //double v3; // ST30_8@6
   //double v4; // ST28_8@6
@@ -82,13 +82,14 @@
   //unsigned __int8 v11; // [sp+1Ch] [bp-4h]@3
   signed int v12; // [sp+1Ch] [bp-4h]@8
 
-  pBLVRenderParams->Set(_this);
-  uNumMobileLightsApplied = 0;
+  pBLVRenderParams->Reset(_this);
+  pMobileLightsStack->uNumLightsActive = 0;
+  //uNumMobileLightsApplied = 0;
   uNumDecorationsDrawnThisFrame = 0;
   _unused000 = 0;
   uNumSpritesDrawnThisFrame = 0;
   uNumBillboardsToDraw = 0;
-  if ( !byte_4D864C || !(BYTE1(pGame->uFlags) & 0x10) )
+  if ( !byte_4D864C || !(pGame->uFlags & 0x1000) )
   {
     //v2 = pParty->flt_TorchlightColorB + 6.7553994e15;
     //v11 = LOBYTE(v2);
@@ -96,46 +97,46 @@
       v5 = 800;
     else
       v5 = 800 * pParty->pPartyBuffs[16].uPower;
-    LOBYTE(v1) = byte_4E94D0;
+    //LOBYTE(v1) = byte_4E94D0;
     //v4 = pParty->flt_TorchlightColorR + 6.7553994e15;
     //v3 = pParty->flt_TorchlightColorG + 6.7553994e15;
     pMobileLightsStack->AddLight(
-      SLOWORD(pBLVRenderParams->vPartyPos.x),
-      SLOWORD(pBLVRenderParams->vPartyPos.y),
-      SLOWORD(pBLVRenderParams->vPartyPos.z),
-      SLOWORD(pBLVRenderParams->uRadius),
+      pBLVRenderParams->vPartyPos.x,
+      pBLVRenderParams->vPartyPos.y,
+      pBLVRenderParams->vPartyPos.z,
+      pBLVRenderParams->uPartySectorID,
       v5,
       floorf(pParty->flt_TorchlightColorR + 0.5f),
       floorf(pParty->flt_TorchlightColorG + 0.5f),
       floorf(pParty->flt_TorchlightColorB + 0.5f),
-      v1);
+      byte_4E94D0);
   }
   PrepareWallsRenderList_BLV();
   PrepareItemsRenderList_BLV();
   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 )
     {
       do
-        PrepareDecorationsRenderList_BLV((signed __int16)v9[v12++], v7);
+        PrepareDecorationsRenderList_BLV(v9[v12++], v7);
       while ( v12 < v8->uNumDecorations );
     }
     v6 = i + 1;
   }
   MessWithBillboards_BLV();
-  pGame->PushStru165s();
+  pGame->PrepareBloodsplats();
 }
 
 
 
 //----- (004407D9) --------------------------------------------------------
-int BLVRenderParams::Set(IndoorLocation_drawstru *a2)
+int BLVRenderParams::Reset(IndoorLocation_drawstru *a2)
 {
   IndoorLocation_drawstru *v2; // ebx@1
   BLVRenderParams *v3; // esi@1
@@ -179,15 +180,15 @@
   v6 = this->vPartyPos.x;
   this->sPartyRotX = a2->sRotationX;
   v7 = pIndoor->GetSector(v6, v5, v4);
-  v3->uRadius = v7;
+  v3->uPartySectorID = v7;
   if ( !v7 )
   {
     v8 = v3->vPartyPos.z;
     v3->vPartyPos.x = pParty->vPosition.x;
-    v9 = pParty->vPosition.z;
+    v9 = pParty->vPosition.y;
     v10 = v3->vPartyPos.x;
-    v3->vPartyPos.y = pParty->vPosition.z;
-    v3->uRadius = pIndoor->GetSector(v10, v9, v8);
+    v3->vPartyPos.y = pParty->vPosition.y;
+    v3->uPartySectorID = pIndoor->GetSector(v10, v9, v8);
   }
   if ( pRenderer->pRenderD3D )
   {
@@ -253,7 +254,7 @@
   result = 0;
   v3->field_8C = 0;
   v3->field_84 = 0;
-  v3->field_80 = 0;
+  v3->uNumFacesRenderedThisFrame = 0;
   v3->field_88 = 0;
   pBLVRenderParams->field_90 = 64;
   pBLVRenderParams->field_94 = 6;
@@ -261,19 +262,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 )
+    pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
+    for (uint i = 0; i < pStru170->uNumFaceIDs; ++i)
     {
       v2 = pStru170->pFaceIDs[2 * i + 1];
       if ( pStru170->field_FA8[v2].std__vector_0007A8 == -1 )
@@ -286,16 +285,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, 4, 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);
     }
   }
 }
@@ -312,7 +311,7 @@
   int v7; // [sp+Ch] [bp-4h]@8
 
   sub_43F39E(_this);
-  if ( pBLVRenderParams->uRadius )
+  if (pBLVRenderParams->uPartySectorID)
     IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0);
   pRenderer->DrawBillboardList_BLV();
   if ( !pRenderer->pRenderD3D )
@@ -364,7 +363,7 @@
   int v0; // eax@1
   IndoorLocation_drawstru _this; // [sp+0h] [bp-4Ch]@5
   int v2; // [sp+44h] [bp-8h]@5
-  float v3; // [sp+48h] [bp-4h]@5
+  int v3; // [sp+48h] [bp-4h]@5
 
   v0 = 0;
   if ( viewparams->field_50_draw_debug_outlines )
@@ -377,9 +376,9 @@
                    - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY)
                                        * (signed __int64)pParty->field_18) >> 16);
   v2 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
-  LODWORD(v3) = (unsigned __int64)(v2 * (signed __int64)pParty->field_18) >> 16;
+  v3 = (unsigned __int64)(v2 * (signed __int64)pParty->field_18) >> 16;
   _this.field_1C_mb_fov = 65;
-  _this.vPosition.y = pParty->vPosition.z - LODWORD(v3);
+  _this.vPosition.y = pParty->vPosition.y - v3;
   _this.sRotationY = pParty->sRotationY;
   _this.sRotationX = pParty->sRotationX;
   _this.pRenderTarget = pRenderer->pTargetSurface;
@@ -388,7 +387,7 @@
   _this.uViewportZ = pViewport->uScreenZ;
   _this.uViewportW = pViewport->uScreenW;
   _this.field_3C = pViewport->field_30;
-  _this.vPosition.z = pParty->vPosition.y + pParty->sEyelevel;
+  _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel;
   _this.uTargetWidth = 640;
   _this.uTargetHeight = 480;
   _this.pTargetZ = pRenderer->pActiveZBuffer;
@@ -412,7 +411,7 @@
   this->pFacePlane.vNormal.z = (double)(a2->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022
                              + (double)(a2->pFacePlane.vNormal.z >> 16);
   this->pFacePlane.dist = (double)(a2->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(a2->pFacePlane.dist >> 16);
-  this->uAttributes = a2->uFaceAttributes;
+  this->uAttributes = a2->uAttributes;
   this->pBounding.x1 = a2->pBoundingBox.x1;
   this->pBounding.y1 = a2->pBoundingBox.y1;
   this->pBounding.z1 = a2->pBoundingBox.z1;
@@ -432,221 +431,175 @@
 }
 
 //----- (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
-  double v20; // st5@27
-  char v21; // dl@27
-  unsigned int v22; // eax@44
+  //double v18; // st7@27
+  //double v19; // st6@27
+  //double v20; // st5@27
+  //char v21; // dl@27
+  //unsigned int v22; // eax@44
   unsigned int v23; // eax@35
   DWORD v24; // eax@37
   int v25; // eax@38
-  char *v26; // edi@38
+  //char *v26; // edi@38
   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
+  //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
   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 )
+  //unsigned int a4b; // [sp+34h] [bp+Ch]@38
+
+  //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->Invisible())
+    return;
+  
+  ++pBLVRenderParams->uNumFacesRenderedThisFrame;
+  pFace->uAttributes |= 0x80u;
+
+  if (!pFace->GetTexture())
+    return;
+
+  v28 = pFace->GetTexture();
+
+  if (!pGame->pIndoorCameraD3D->IsCulled(pFace))
   {
-
-    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)
+    uNumVerticesa = pFace->uNumVertices;
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
     {
-      __init_flag3 = true;
-
-      stru154::stru154(&stru_F7B60C);
-    }*/
-
-    v9 = &pIndoor->pFaces[v4];
-    if ( v9->uNumVertices >= 3u )
+      static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x;
+      static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y;
+      static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z;
+      static_vertices_F7C228[i].u = (signed short)pFace->pVertexUIDs[i];
+      static_vertices_F7C228[i].v = (signed short)pFace->pVertexUIDs[i];
+    }
+
+    if (!pVertices ||
+        (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
     {
-      if ( !(BYTE1(v9->uAttributes) & 0x20) )
-      {
-        ++pBLVRenderParams->field_80;
-        LOBYTE(v9->uAttributes) |= 0x80u;
-        v28 = v9->GetTexture();
-        if ( v28 )
-        {
-          v10 = pGame->pIndoorCameraD3D;
-          v31 = pGame->pIndoorCameraD3D;
-          pStru4 = pGame->pLightmapBuilder;
-          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(v9) )
-          {
-            v11 = 0;
-            uNumVerticesa = v9->uNumVertices;
-            if ( (signed int)uNumVerticesa > 0 )
-            {
-              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;
-            }
-            if ( !a7
-              || (pGame->pStru9Instance->_498377(a4, 4u, a7, 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,
+                     false,
                      0) != 1
                 || uNumVerticesa )
-              {
-                a4a = SHIWORD(stru_F8AD28.field_2C);
-                v17 = (248 - 8 * SHIWORD(stru_F8AD28.field_2C)) | (((248 - 8 * SHIWORD(stru_F8AD28.field_2C)) | ((248 - 8 * SHIWORD(stru_F8AD28.field_2C)) << 8)) << 8);
-                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;
-                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;
-                  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(
+      {
+        a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel);
+        v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8);
+        sub_4B0E07(uFaceID);
+        pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID);
+        pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID);
+        pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
+        pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0);
+        pGame->pLightmapBuilder->std__vector_000004_size = 0;
+        if (stru_F8AD28.uNumLightsApplied > 0 ||
+            pDecalBuilder->uNumDecals > 0)
+        {
+          stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x;
+          stru_F7B60C.polygonType = pFace->uPolygonType;
+          stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y;
+          stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z;
+          stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist;
+        }
+
+        if (stru_F8AD28.uNumLightsApplied > 0 &&
+            !(pFace->uAttributes & 0x400000))
+          pGame->pLightmapBuilder->ApplyLights(
                     &stru_F8AD28,
                     &stru_F7B60C,
                     uNumVerticesa,
                     array_507D30,
-                    *(float *)&a7,
+                    pVertices,
                     0);
-                if ( pDecalBuilder->uNumDecals > 0 )
-                  pDecalBuilder->ApplyDecals(
+
+        if (pDecalBuilder->uNumDecals > 0)
+          pDecalBuilder->ApplyDecals(
                     a4a,
                     1,
                     &stru_F7B60C,
                     uNumVerticesa,
                     array_507D30,
-                    (int)a7,
+                    pVertices,
                     0,
-                    v9->uSectorID);
-                if ( v9->uAttributes & 0x10 && v9->uBitmapID == pRenderer->field_1036AC_bitmapid )
-                {
-                  v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
-                  goto LABEL_42;
-                }
-                if ( v9->uAttributes & 0x10 )
-                {
-                  v24 = GetTickCount() >> 2;
-                  if ( (signed int)uNumVerticesa > 0 )
-                  {
-                    v25 = v24 - stru_5C6E00->uIntegerHalfPi;
-                    v26 = (char *)&array_507D30[0].v;
-                    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;
-                      v26 += 48;
-                      --a4b;
-                      if ( !a4b )
-                        break;
-                    }
-                  }
-                }
-                else
-                {
-                  v22 = v9->uAttributes;
-                  if ( BYTE1(v22) & 0x40 )
-                  {
-                    v23 = pTextureFrameTable->GetFrameTexture(
-                            v9->uBitmapID,
+                    pFace->uSectorID);
+
+        if (pFace->Animated() &&
+            pFace->uBitmapID == pRenderer->field_1036AC_bitmapid )
+        {
+          __debugbreak();
+          v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
+          goto LABEL_42;
+        }
+
+        if (pFace->Animated())
+        {
+          v24 = GetTickCount() / 4;
+          v25 = v24 - stru_5C6E00->uIntegerHalfPi;
+
+          for (uint i = 0; i < uNumVerticesa; ++i)
+            array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8));
+
+          v23 = pFace->uBitmapID;
+          goto LABEL_42;
+        }
+        else
+        {
+          if (pFace->uAttributes & 0x4000)
+          {
+            v23 = pTextureFrameTable->GetFrameTexture(
+                            pFace->uBitmapID,
                             pBLVRenderParams->field_0_timer_);
 LABEL_42:
                     v27 = pBitmaps_LOD->pHardwareTextures[v23];
-                    if ( BYTE2(v9->uAttributes) & 0x40 )
-                      sub_479A53(uNumVerticesa, uFaceID_);
+                    if (pFace->uAttributes & 0x400000)
+                      _479A53_draw_some_blv_poly(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;
-                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
@@ -803,7 +756,7 @@
         if ( !(v3 & 0x10) || (sub_4AD504(uFaceID), pRenderer->pRenderD3D) )
         {
           v4 = v2->GetTexture();
-          ++pBLVRenderParams->field_80;
+          ++pBLVRenderParams->uNumFacesRenderedThisFrame;
           v5 = v4;
           v108 = v4;
           if ( v4 )
@@ -822,7 +775,7 @@
               {
                 if ( v2->uPolygonType == 1 )
                 {
-                  for ( i = 0; i < stru_F8AD28.field_AC; stru_F8AD28._blv_lights_ys[v18] = v20 )
+                  for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 )
                   {
                     v18 = i;
                     v120 = stru_F8AD28._blv_lights_xs[i];
@@ -846,7 +799,7 @@
                     {
 LABEL_16:
                       a2 = 0;
-                      if ( stru_F8AD28.field_AC > 0 )
+                      if ( stru_F8AD28.uNumLightsApplied > 0 )
                       {
                         do
                         {
@@ -883,7 +836,7 @@
                           stru_F8AD28._blv_lights_ys[v8] += v128;
                           ++a2;
                         }
-                        while ( a2 < stru_F8AD28.field_AC );
+                        while ( a2 < stru_F8AD28.uNumLightsApplied );
                         v2 = v103;
                       }
                       goto LABEL_24;
@@ -895,7 +848,7 @@
                       goto LABEL_16;
                     }
                   }
-                  for ( j = 0; j < stru_F8AD28.field_AC; *(int *)v15 = v16 )
+                  for ( j = 0; j < stru_F8AD28.uNumLightsApplied; *(int *)v15 = v16 )
                   {
                     v14 = v128;
                     stru_F8AD28._blv_lights_xs[j] += v126;
@@ -1306,12 +1259,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 +1274,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 +1382,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 +1712,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 +1720,7 @@
   v1->pLights = 0;
   v1->pDoors = 0;
   v1->pNodes = 0;
-  v1->pMapVertices = 0;
+  v1->pMapOutlines = 0;
   v1->bLoaded = 0;
 }
 
@@ -1829,11 +1766,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 +1780,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 +2440,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 +2529,7 @@
   assert(sizeof(LayingItem) == 112);
   assert(sizeof(Chest) == 5324);
   assert(sizeof(stru123) == 0xC8);
+  assert(sizeof(BLVMapOutline) == 12);
   
   bLoaded = true;
 
@@ -2630,10 +2568,10 @@
     pFace->pZInterceptDisplacements = ptr_2AC + j;
 
     j += pFace->uNumVertices + 1;
-    pFace->pVertexUIDs = ptr_2AC + j;
+    pFace->pVertexUIDs = (__int16 *)(ptr_2AC + j);
 
     j += pFace->uNumVertices + 1;
-    pFace->pVertexVIDs = ptr_2AC + j;
+    pFace->pVertexVIDs = (__int16 *)(ptr_2AC + j);
 
     j += pFace->uNumVertices + 1;
       /*v93 = &pFaces[v92];
@@ -2747,7 +2685,7 @@
     auto pSector = pSectors + i;
 
     pSector->pFloors = ptr_0002B0_sector_rdata + j;
-    j += pSector->field_4;
+    j += pSector->uNumFloors;
 
     pSector->pWalls = ptr_0002B0_sector_rdata + j;
     j += pSector->field_C;
@@ -2829,7 +2767,7 @@
 
   for (uint i = 0, j = 0; i < uNumSectors; ++i)
   {
-    pSectors->pLights = (BLVLightMM7 *)(ptr_0002B8_sector_lrdata + j);
+    pSectors->pLights = (unsigned __int16 *)(ptr_0002B8_sector_lrdata + j);
     j += pSectors->uNumLights;
   }
 
@@ -2877,10 +2815,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 +2939,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,36 +3156,36 @@
 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
-  BLVSector *v8; // eax@3
-  int v9; // edi@9
-  int v10; // eax@9
-  int v11; // edx@9
-  int v12; // eax@10
-  unsigned __int16 v13; // ax@12
-  int v14; // edi@14
-  BLVFace *v15; // eax@14
-  BLVFace *v16; // edi@14
-  PolygonType v17; // al@14
-  unsigned __int16 *pVertexIDs; // esi@16
-  Vec3_short_ *v19; // eax@16
-  int v20; // edx@16
-  unsigned __int16 *v21; // esi@17
-  int v22; // edi@19
-  int v23; // edi@20
-  Vec3_short_ *v24; // edx@20
+  //unsigned __int8 v5; // zf@1
+  //unsigned __int8 v6; // sf@1
+  //unsigned __int8 v7; // of@1
+  //BLVSector *v8; // eax@3
+  //int v9; // edi@9
+  //int v10; // eax@9
+  //int v11; // edx@9
+  //int v12; // eax@10
+  //unsigned __int16 v13; // ax@12
+  //int v14; // edi@14
+  //BLVFace *v15; // eax@14
+  //BLVFace *v16; // edi@14
+  //PolygonType v17; // al@14
+  //unsigned __int16 *pVertexIDs; // esi@16
+  //Vec3_short_ *v19; // eax@16
+  //int v20; // edx@16
+  //unsigned __int16 *v21; // esi@17
+  //int v22; // edi@19
+  //int v23; // edi@20
+  //Vec3_short_ *v24; // edx@20
   signed int v25; // edx@21
   int v26; // ebx@23
-  int v27; // edx@26
-  signed __int64 v28; // qtt@26
-  Vec3_short_ *v29; // eax@26
-  Vec3_short_ *v30; // edx@26
-  int v31; // edx@26
+  //int v27; // edx@26
+  //signed __int64 v28; // qtt@26
+  ///Vec3_short_ *v29; // eax@26
+  //Vec3_short_ *v30; // edx@26
+  //int v31; // edx@26
   signed int v32; // edi@27
   signed __int64 v33; // qtt@27
-  Vec3_short_ *v34; // edx@27
+  //Vec3_short_ *v34; // edx@27
   int v35; // edx@32
   int v37; // edi@38
   int v38; // ebx@40
@@ -3256,162 +3194,157 @@
   PolygonType v41; // dl@42
   int v42; // edx@43
   int v43[50]; // [sp+Ch] [bp-108h]@1
-  int v44; // [sp+D4h] [bp-40h]@9
-  int v45; // [sp+D8h] [bp-3Ch]@14
-  int v46; // [sp+DCh] [bp-38h]@14
-  int v47; // [sp+E0h] [bp-34h]@19
-  int v48; // [sp+E4h] [bp-30h]@9
-  Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19
+  //int v44; // [sp+D4h] [bp-40h]@9
+  //int v45; // [sp+D8h] [bp-3Ch]@14
+  //int v46; // [sp+DCh] [bp-38h]@14
+  //int v47; // [sp+E0h] [bp-34h]@19
+  //int v48; // [sp+E4h] [bp-30h]@9
+  //Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19
   bool v50; // [sp+ECh] [bp-28h]@19
   int v51; // [sp+F0h] [bp-24h]@9
-  unsigned int v52; // [sp+F4h] [bp-20h]@2
+  //unsigned int v52; // [sp+F4h] [bp-20h]@2
   int v53; // [sp+F8h] [bp-1Ch]@10
   int v54; // [sp+FCh] [bp-18h]@16
   int v55; // [sp+100h] [bp-14h]@1
   int v56; // [sp+104h] [bp-10h]@1
   int v57; // [sp+108h] [bp-Ch]@16
-  Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20
+  //Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20
   int v59; // [sp+110h] [bp-4h]@16
 
   v4 = 0;
-  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 )
+  //v56 = 1;
+  if (uNumSectors < 2)
     return 0;
-  v52 = 116;
-  do
+
+  for (uint i = 1; i < uNumSectors; ++i)
   {
-    v8 = &this->pSectors[v52 / 0x74];
-    if ( v8->pBounding.x1 <= sX )
-    {
-      if ( v8->pBounding.x2 >= sX )
-      {
-        if ( v8->pBounding.y1 <= sY )
+    auto pSector = pSectors + i;
+
+    if (pSector->pBounding.x1 <= sX  && pSector->pBounding.x2 >= sX)
+      if (pSector->pBounding.y1 <= sY  && pSector->pBounding.y2 >= sY)
+        if (pSector->pBounding.z1 - 64 <= sZ && pSector->pBounding.z2 + 64 >= sZ)
         {
-          if ( v8->pBounding.y2 >= sY )
-          {
-            if ( v8->pBounding.z1 - 64 <= sZ )
-            {
-              if ( v8->pBounding.z2 + 64 >= sZ )
-              {
-                v9 = v8->field_4;
-                v10 = v9 + v8->uNumPortals;
-                v11 = 0;
-                v44 = v9;
-                v51 = v10;
-                v48 = 0;
-                if ( v10 > 0 )
-                {
-                  v12 = -2 * v9;
-                  v53 = -2 * v9;
-                  do
-                  {
-                    if ( v11 < v44 )
-                      v13 = this->pSectors[v52 / 0x74].pFloors[v11];
+          Log::Warning(L"Sector[%u]", i);
+          v51 = pSector->uNumFloors + pSector->uNumPortals;
+          if (!v51)
+            continue;
+
+          //v9 = pSector->uNumFloors;
+                //v10 = v9 + pSector->uNumPortals;
+                //v11 = 0;
+                //v44 = v9;
+                //v48 = 0;
+
+                  //v12 = -2 * v9;
+                  //v53 = -2 * v9;
+           for (uint j = 0; j < v51; ++j)
+           {
+             unsigned int uFaceID;
+             if (j < pSector->uNumFloors)
+               uFaceID = pSector->pFloors[j];
+             else
+               uFaceID = pSector->pPortals[j - pSector->uNumFloors];
+
+             auto pFace = pFaces + uFaceID;
+                    //v14 = (signed __int16)v13;
+                    //v15 = this->pFaces;
+                    //v46 = v13;
+                    //v14 *= 96;
+                    //v45 = v13 * sizeof(BLVFace);
+                    //v16 = pFaces + uFaceID;
+                    //v17 = v16->uPolygonType;
+             if (pFace->uPolygonType == POLYGON_Floor ||
+                 pFace->uPolygonType == POLYGON_InBetweenFloorAndWall)
+             {
+               //pVertexIDs = pFace->pVertexIDs;
+                      //v19 = this->pVertices;
+               //v20 = pVertices[pFace->pVertexIDs[0]].y;
+                      v54 = 0;
+                      //v57 = 0;
+                      //v5 = v16->uNumVertices == 0;
+                      v59 = pVertices[pFace->pVertexIDs[0]].y >= sY;
+
+                        //v21 = pFace->pVertexIDs + 1;
+               for (uint k = 1; k < pFace->uNumVertices; ++k)
+               {
+                 if (v54 >= 2)
+                   break;
+
+                 //v49 = &pVertices[pFace->pVertexIDs[k]];
+                 auto v2 = &pVertices[pFace->pVertexIDs[k]];
+                          //v22 = pVertex->y;
+                          //v47 = pVertex->y;
+                 v50 = v2->y >= sY;
+                 if ( v59 ^ v50 )
+                 {
+                            //v58 = &pVertices[pFace->pVertexIDs[k - 1]];
+                   auto v1 = &pVertices[pFace->pVertexIDs[k - 1]];
+                            //v23 = v58->x;
+                            //HIWORD(v24) = HIWORD(v49);
+                            //LOWORD(v24) = v49->x;
+                            //v49 = v24;
+                            //v59 = v49->x;
+                   v25 = v1->x >= sX ? 0 : 2;  // BUG TODO TROLOLO
+                   v26 = v25 | v2->x < sX;     // SWAP v1 and v2 till the result's correct
+                   if ( v26 != 3 )
+                   {
+                    if (!v26)
+                      ++v54;
                     else
-                      v13 = *(unsigned __int16 *)((char *)this->pSectors[v52 / 0x74].pPortals + v12);
-                    v14 = (signed __int16)v13;
-                    v15 = this->pFaces;
-                    v46 = v14;
-                    v14 *= 96;
-                    v45 = v14;
-                    v16 = (BLVFace *)((char *)v15 + v14);
-                    v17 = v16->uPolygonType;
-                    if ( v17 == 3 || v17 == 4 )
                     {
-                      pVertexIDs = v16->pVertexIDs;
-                      v19 = this->pVertices;
-                      v20 = v19[*pVertexIDs].y;
-                      v54 = 0;
-                      v57 = 0;
-                      v5 = v16->uNumVertices == 0;
-                      v59 = v20 >= sY;
-                      if ( !v5 )
+                      if (v1->x >= v2->x)
                       {
-                        v21 = pVertexIDs + 1;
-                        do
-                        {
-                          if ( v54 >= 2 )
-                            break;
-                          v49 = &v19[*v21];
-                          v22 = v49->y;
-                          v47 = v49->y;
-                          v50 = v22 >= sY;
-                          if ( v59 ^ v50 )
-                          {
-                            v58 = &v19[*(v21 - 1)];
-                            v23 = v58->x;
-                            HIWORD(v24) = HIWORD(v49);
-                            LOWORD(v24) = v49->x;
-                            v49 = v24;
-                            v59 = (signed __int16)v24;
-                            v25 = (signed __int16)v24 >= sX ? 0 : 2;
-                            v26 = v25 | v23 < sX;
-                            if ( v26 != 3 )
-                            {
-                              if ( !v26
-                                || (v58->x >= (signed __int16)v49 ? (v32 = v23 - v59,
-                                                                     v58 = (Vec3_short_ *)(v58->y - v47),
-                                                                     LODWORD(v33) = v32 << 16,
-                                                                     HIDWORD(v33) = v32 >> 16,
-                                                                     v59 = v33 / (signed int)v58,
-                                                                     v34 = this->pVertices,
-                                                                     v58 = (Vec3_short_ *)(v33 / (signed int)v58),
-                                                                     v59 = sY - v34[*v21].y,
-                                                                     v59 = (unsigned __int64)((signed int)v58
-                                                                                            * (signed __int64)v59) >> 16,
-                                                                     v31 = *v21) : (v27 = v58->y,
-                                                                                    v59 -= v23,
-                                                                                    v58 = (Vec3_short_ *)(v47 - v27),
-                                                                                    LODWORD(v28) = v59 << 16,
-                                                                                    HIDWORD(v28) = v59 >> 16,
-                                                                                    v59 = v28 / (v47 - v27),
-                                                                                    v29 = (Vec3_short_ *)(v28 / (v47 - v27)),
-                                                                                    v30 = this->pVertices,
-                                                                                    v58 = v29,
-                                                                                    v59 = sY - v30[*(v21 - 1)].y,
-                                                                                    v59 = (unsigned __int64)((signed int)v29 * (signed __int64)v59) >> 16,
-                                                                                    v31 = *(v21 - 1)),
-                                    v19 = this->pVertices,
-                                    v59 + v19[v31].x > sX) )
-                                ++v54;
-                            }
-                          }
-                          ++v57;
-                          v59 = v50;
-                          ++v21;
-                        }
-                        while ( v57 < *(&this->pFaces->uNumVertices + v45) );
-                        if ( v54 == 1 )
-                        {
-                          v35 = v55++;
-                          v43[v35] = v46;
-                        }
+                        int _a58;
+                        int _a59;
+
+                        v32 = v1->x - v2->x;
+                        LODWORD(v33) = v32 << 16;
+                        HIDWORD(v33) = v32 >> 16;
+                        _a58 = v33 / (v1->y - v2->y);
+                        _a59 = (unsigned __int64)(_a58 * (__int64)(sY - v2->y)) >> 16;
+
+                        if (v59 + pVertices[k].x > sX)
+                          ++v54;
+                      }
+                      else
+                      {
+                        int _a58;
+                        int _a59;
+                        v32 = v2->x - v1->x;
+                        LODWORD(v33) = v32 << 16;
+                        HIDWORD(v33) = v32 >> 16;
+                        _a58 = v33 / (v2->y - v1->y);
+                        _a59 = (unsigned __int64)(_a58 * (signed __int64)(sY - v1->y)) >> 16;
+
+                        if (_a59 + pVertices[k - 1].x > sX)
+                          ++v54;
                       }
                     }
-                    v11 = v48 + 1;
-                    v12 = v53 + 2;
-                    v7 = __OFSUB__(v48 + 1, v51);
-                    v6 = v48++ + 1 - v51 < 0;
-                    v53 += 2;
-                  }
-                  while ( v6 ^ v7 );
-                  v4 = v43[0];
-                }
-              }
+                   }
+                 }
+
+                 v59 = v50;
+               }
+
+               if (pFace->uNumVertices)
+               {
+                 if (v54 == 1)
+                 {
+                   v35 = v55++;
+                   v43[v35] = uFaceID;
+                 }
+               }
+             }
             }
+            v4 = v43[0];
           }
-        }
-      }
-    }
-    ++v56;
-    v52 += 116;
   }
-  while ( v56 < this->uNumSectors );
+
   if ( v55 == 1 )
     return this->pFaces[v4].uSectorID;
   v37 = 0;
@@ -3610,7 +3543,7 @@
   int v44; // ecx@36
   int v45; // edi@36
   int v46; // ecx@36
-  unsigned __int16 *v47; // edx@44
+  __int16 *v47; // edx@44
   int v48; // ecx@44
   unsigned int v49; // ecx@46
   unsigned __int16 v50; // ax@48
@@ -4034,12 +3967,12 @@
   AIDirection v52; // [sp+0h] [bp-60h]@75
   AIDirection v53; // [sp+1Ch] [bp-44h]@116
   int v54; // [sp+38h] [bp-28h]@53
-  int v55; // [sp+3Ch] [bp-24h]@6
+  unsigned int uSectorID; // [sp+3Ch] [bp-24h]@6
   int v56; // [sp+40h] [bp-20h]@6
   unsigned int _this; // [sp+44h] [bp-1Ch]@51
   int v58; // [sp+48h] [bp-18h]@51
   int v59; // [sp+4Ch] [bp-14h]@8
-  int v60; // [sp+50h] [bp-10h]@6
+  unsigned int uFaceID; // [sp+50h] [bp-10h]@6
   int v61; // [sp+54h] [bp-Ch]@14
   int v62; // [sp+58h] [bp-8h]@6
   unsigned int v63; // [sp+5Ch] [bp-4h]@1
@@ -4053,9 +3986,9 @@
       v1 = v0->uAIState;
       if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed )
         goto LABEL_123;
-      v55 = v0->uSectorID;
-      v2 = _46ED1B_collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, (unsigned int *)&v55, &v60);
-      v0->uSectorID = v55;
+      uSectorID = v0->uSectorID;
+      v2 = _46ED1B_collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, &uSectorID, &uFaceID);
+      v0->uSectorID = uSectorID;
       v3 = v0->pMonsterInfo.uFlying;
       v56 = v2;
       v62 = v3;
@@ -4070,7 +4003,7 @@
         v5 = pIndoor->GetSector(v0->vPosition.x, v0->vPosition.y, v4);
         v0->uSectorID = v5;
         if ( !v5
-          || (v56 = _46CEC3_get_floor_level(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &v60), v56 == -30000) )
+          || (v56 = _46CEC3_get_floor_level(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &uFaceID), v56 == -30000) )
           goto LABEL_123;
       }
       if ( v0->uCurrentActionAnimation == 1 )
@@ -4100,18 +4033,18 @@
         if ( v6 > 1000 )
           v6 = 1000;
         v12 = stru_5C6E00->SinCos(v0->uYawAngle);
-        v55 = v12;
+        uSectorID = v12;
         v13 = v12 * (signed __int64)v6;
         v61 = v13 >> 16;
         v0->vVelocity.x = WORD1(v13);
-        v55 = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
-        v61 = (unsigned __int64)(v55 * (signed __int64)v6) >> 16;
+        uSectorID = stru_5C6E00->SinCos(v0->uYawAngle - stru_5C6E00->uIntegerHalfPi);
+        v61 = (unsigned __int64)(uSectorID * (signed __int64)v6) >> 16;
         v7 = v62 == 0;
-        v0->vVelocity.y = (unsigned int)(v55 * v6) >> 16;
+        v0->vVelocity.y = (unsigned int)(uSectorID * v6) >> 16;
         if ( !v7 )
         {
           v14 = stru_5C6E00->SinCos(v0->uPitchAngle - stru_5C6E00->uIntegerHalfPi);
-          v55 = v14;
+          uSectorID = v14;
           v15 = v14 * (signed __int64)v6;
           v61 = v15 >> 16;
           v0->vVelocity.z = WORD1(v15);
@@ -4120,16 +4053,16 @@
       else
       {
         v61 = v0->vVelocity.x;
-        v55 = 55000;
+        uSectorID = 55000;
         v61 = (unsigned __int64)(55000i64 * v61) >> 16;
         v0->vVelocity.x = v61;
         v61 = v0->vVelocity.y;
-        v61 = (unsigned __int64)(v55 * (signed __int64)v61) >> 16;
+        v61 = (unsigned __int64)(uSectorID * (signed __int64)v61) >> 16;
         v7 = v62 == 0;
         v0->vVelocity.y = v61;
         if ( !v7 )
         {
-          v55 = 55000;
+          uSectorID = 55000;
           v61 = v0->vVelocity.z;
           v61 = (unsigned __int64)(55000i64 * v61) >> 16;
           v0->vVelocity.z = v61;
@@ -4139,7 +4072,7 @@
       v17 = pIndoor->pFaces;
       v51 = __OFSUB__(v16, v56);
       v8 = v16 - v56 < 0;
-      v18 = v60;
+      v18 = uFaceID;
       if ( v8 ^ v51 )
       {
         v0->vPosition.z = v56 + 1;
@@ -4167,8 +4100,8 @@
       v0->vVelocity.x = 0;
       if ( BYTE2(v17[v18].uAttributes) & 0x40 )
       {
-        if ( v0->uAIState == 5 )
-          v0->uAIState = 11;
+        if (v0->uAIState == Dead)
+          v0->uAIState = Removed;
       }
 LABEL_123:
       ++v63;
@@ -4179,7 +4112,7 @@
     v21 = v0->uActorHeight;
     stru_721530.field_84 = -1;
     stru_721530.field_70 = 0;
-    v55 = 0;
+    uSectorID = 0;
     stru_721530.field_0 = 1;
     stru_721530.field_8 = v20;
     stru_721530.prolly_normal_d = v20;
@@ -4256,12 +4189,12 @@
           v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
           v32 = v58 + v0->vPosition.z;
         }
-        v33 = _46ED1B_collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &v60);
-        v34 = pIndoor->pFaces[v60].uAttributes;
+        v33 = _46ED1B_collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID);
+        v34 = pIndoor->pFaces[uFaceID].uAttributes;
         v35 = v34 & 0x400000;
-        if ( v35 && v0->uAIState == 5 )
+        if (v35 && v0->uAIState == Dead)
         {
-          v0->uAIState = 11;
+          v0->uAIState = Removed;
           goto LABEL_120;
         }
         if ( v59 != v22 || v62 != v22 || v35 == v22 )
@@ -4436,8 +4369,8 @@
         }
       }
 LABEL_120:
-      ++v55;
-      if ( v55 >= 100 )
+      ++uSectorID;
+      if ( uSectorID >= 100 )
         goto LABEL_123;
       v20 = stru_721530.prolly_normal_d;
     }
@@ -4535,7 +4468,7 @@
   ptr_6A0D08 = 0;
   _6A0D0C_txt_lod_loading = 0;
   TryLoadLevelFromLOD();
-  uNumStationaryLightsApplied = 0;
+  pStationaryLightsStack->uNumLightsActive = 0;
   v4 = pIndoor->Load(
          pCurrentMapName,
          (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1,
@@ -4800,8 +4733,8 @@
   {
     pParty->sRotationX = 0;
     pParty->sRotationY = 0;
+    pParty->vPosition.z = 0;
     pParty->vPosition.y = 0;
-    pParty->vPosition.z = 0;
     pParty->vPosition.x = 0;
     pParty->uFallStartY = 0;
     pParty->uFallSpeed = 0;
--- a/Indoor.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Indoor.h	Mon Oct 29 09:28:08 2012 +0600
@@ -185,7 +185,7 @@
   char uGreen;
   char uBlue;
   char uType;
-  __int16 uAtributes;
+  __int16 uAtributes;           // & 0x08    doesn't light faces
   __int16 uBrightness;
 };
 #pragma pack(pop)
@@ -238,7 +238,7 @@
 
 /*  101 */
 #pragma pack(push, 1)
-struct BLVMapVertex
+struct BLVMapOutline
 {
   unsigned __int16 uVertex1ID;
   unsigned __int16 uVertex2ID;
@@ -250,6 +250,15 @@
 #pragma pack(pop)
 
 
+#define FACE_TWO_SIDED        0x00000001 // portal/two-sided
+// 0x02  color is saturated against lights
+#define FACE_TEXTURE_ANIMATED 0x00000010 // like wavy water
+#define FACE_INVISIBLE        0x00002000
+#define FACE_TEXTURE_FRAME    0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
+#define FACE_TEXTURE_FLOW     0x00040000 // The texture moves slowly. For horizontal facets only.
+#define FACE_CLICKABLE        0x02000000 // Event can be triggered by clicking on the facet.
+#define FACE_PRESSURE_PLATE   0x04000000 // Event can be triggered by stepping on the facet.
+#define FACE_ETHEREAL         0x20000000 // Untouchable. You can pass through it.
 
 /*   93 */
 #pragma pack(push, 1)
@@ -271,6 +280,12 @@
   struct Texture *GetTexture();
   void FromODM(struct ODMFace *a2);
 
+  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Visible() const   {return !Invisible();}
+  inline bool TwoSided() const  {return uAttributes & FACE_TWO_SIDED;}
+  inline bool Animated() const  {return uAttributes & FACE_TEXTURE_ANIMATED;}
+  inline bool Clickable() const {return uAttributes & FACE_CLICKABLE;}
+
 
   struct Plane_float_ pFacePlane;
   struct Plane_int_ pFacePlane_old;
@@ -282,11 +297,11 @@
   unsigned __int16 *pXInterceptDisplacements;
   unsigned __int16 *pYInterceptDisplacements;
   unsigned __int16 *pZInterceptDisplacements;
-  unsigned __int16 *pVertexUIDs;
-  unsigned __int16 *pVertexVIDs;
-  unsigned __int16 uFaceExtraID;
-  unsigned __int16 uBitmapID;
-  unsigned __int16 uSectorID;
+  signed __int16   *pVertexUIDs;
+  signed __int16   *pVertexVIDs;
+  unsigned __int16  uFaceExtraID;
+  unsigned __int16  uBitmapID;
+  unsigned __int16  uSectorID;
   __int16 uBackSectorID;
   struct BBox_short_ pBounding;
   PolygonType uPolygonType;
@@ -328,7 +343,7 @@
 struct BLVSector
 {
   int field_0;
-  __int16 field_4;
+  unsigned __int16 uNumFloors;
   __int16 field_6;
   unsigned __int16 *pFloors;
   __int16 field_C;
@@ -360,7 +375,7 @@
   unsigned __int16 *pMarkers;
   __int16 uNumLights;
   __int16 field_56;
-  BLVLightMM7 *pLights;
+  unsigned __int16 *pLights;
   __int16 uWaterLevel;
   __int16 uMistLevel;
   __int16 uLightDistanceMultiplier;
@@ -373,10 +388,10 @@
 
 
 #pragma pack(push, 1)
-struct BLVMapVertices
+struct BLVMapOutlines
 {
-  uint         uNumVertices;
-  BLVMapVertex pVertices[1];
+  uint          uNumOutlines;
+  BLVMapOutline pOutlines[1];
 };
 #pragma pack(pop)
 
@@ -411,7 +426,7 @@
     pLights = 0;
     pDoors = 0;
     pNodes = 0;
-    pMapVertices = 0;
+    pMapOutlines = 0;
     uNumSpawnPoints = 0;
     pSpawnPoints = 0;
   }
@@ -424,9 +439,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 +462,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;
@@ -510,14 +525,14 @@
 #pragma pack(push, 1)
 struct BLVRenderParams
 {
-  int Set(struct IndoorLocation_drawstru *a2);
+  int Reset(struct IndoorLocation_drawstru *a2);
 
   int field_0_timer_;
   int uFlags;
   Vec3_int_ vPartyPos;
   int sPartyRotY;
   int sPartyRotX;
-  int uRadius;
+  int uPartySectorID;
   int sCosineY;
   int sSineY;
   int sCosineNegX;
@@ -542,7 +557,7 @@
   int uViewportCenterX;
   int uViewportCenterY;
   struct stru170_stru2 *field_7C;
-  int field_80;
+  unsigned int uNumFacesRenderedThisFrame;
   int field_84;
   int field_88;
   int field_8C;
--- a/IndoorCamera.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/IndoorCamera.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -41,14 +41,14 @@
   v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
   if ( sRotationX )
   {
-    v6 = v5;
+    v6 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
     a1->vWorldViewPosition.x = v5 * fRotationXCosine + fRotationXSine * vCamToVertexZ;
     a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
     a1->vWorldViewPosition.z = v8 * vCamToVertexZ - v6 * v7;
   }
   else
   {
-    a1->vWorldViewPosition.x = v5;
+    a1->vWorldViewPosition.x = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
     a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
     a1->vWorldViewPosition.z = vCamToVertexZ;
   }
@@ -75,38 +75,38 @@
 //----- (004239A7) --------------------------------------------------------
 void IndoorCamera::Initialize2()
 {
-  IndoorCamera *v1; // esi@1
+  //IndoorCamera *v1; // esi@1
   double v2; // st7@4
-  double v3; // st7@6
-  int v4; // eax@6
-  int v5; // eax@6
-  int v6; // ST04_4@6
-  int v7; // eax@6
-  int v8; // ST04_4@6
+  //double v3; // st7@6
+  //int v4; // eax@6
+  //int v5; // eax@6
+  //int v6; // ST04_4@6
+  //int v7; // eax@6
+  //int v8; // ST04_4@6
 
-  v1 = this;
-  this->fRotationYSine = sin((3.141592653589793 + 3.141592653589793) * (double)this->sRotationY * 0.00048828125);
-  v1->fRotationYCosine = cos((3.141592653589793 + 3.141592653589793) * (double)v1->sRotationY * 0.00048828125);
+  //v1 = this;
+  fRotationYSine = sin((3.141592653589793 + 3.141592653589793) * (double)sRotationY * 0.00048828125);
+  fRotationYCosine = cos((3.141592653589793 + 3.141592653589793) * (double)sRotationY * 0.00048828125);
   if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    v1->fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)-v1->sRotationX * 0.00048828125);
-    v2 = (3.141592653589793 + 3.141592653589793) * (double)-v1->sRotationX;
+    fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)-sRotationX * 0.00048828125);
+    v2 = (3.141592653589793 + 3.141592653589793) * (double)-sRotationX;
   }
   else
   {
-    v1->fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)v1->sRotationX * 0.00048828125);
-    v2 = (3.141592653589793 + 3.141592653589793) * (double)v1->sRotationX;
+    fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)sRotationX * 0.00048828125);
+    v2 = (3.141592653589793 + 3.141592653589793) * (double)sRotationX;
   }
-  v3 = cos(v2 * 0.00048828125);
-  v4 = v1->sRotationY;
-  v1->fRotationXCosine = v3;
-  v5 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi);
-  v6 = v1->sRotationY;
-  v1->_int_sine = v5;
-  v1->_int_cosine = stru_5C6E00->SinCos(v6);
-  v7 = stru_5C6E00->SinCos(v1->sRotationX - stru_5C6E00->uIntegerHalfPi);
-  v8 = v1->sRotationX;
-  v1->_int_sine_2 = v7;
-  v1->_int_cosine_2 = stru_5C6E00->SinCos(v8);
+  //v3 = cos(v2 * 0.00048828125);
+  //v4 = sRotationY;
+  fRotationXCosine = cos(v2 * 0.00048828125);
+  //v5 = stru_5C6E00->SinCos(sRotationY - stru_5C6E00->uIntegerHalfPi);
+  //v6 = sRotationY;
+  _int_sine = stru_5C6E00->SinCos(sRotationY - stru_5C6E00->uIntegerHalfPi);
+  _int_cosine = stru_5C6E00->SinCos(sRotationY);
+  //v7 = stru_5C6E00->SinCos(sRotationX - stru_5C6E00->uIntegerHalfPi);
+  //v8 = sRotationX;
+  _int_sine_2 = stru_5C6E00->SinCos(sRotationX - stru_5C6E00->uIntegerHalfPi);
+  _int_cosine_2 = stru_5C6E00->SinCos(sRotationX);
 }
 // 4D864C: using guessed type char byte_4D864C;
\ No newline at end of file
--- a/IndoorCameraD3D.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/IndoorCameraD3D.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -13,31 +13,18 @@
 
 
 //----- (004364C5) --------------------------------------------------------
-void IndoorCameraD3D::_4364C5(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *a1, stru320 *a5)
+void IndoorCameraD3D::ViewTransfrom_OffsetUV(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutVertices, stru320 *a5)
 {
-  unsigned int v5; // ebx@1
-  char *v6; // edx@2
-  char *v7; // eax@2
-
-  v5 = uNumVertices;
-  if ( (signed int)uNumVertices > 0 )
+  for (uint i = 0; i < uNumVertices; ++i)
   {
-    v6 = (char *)&a1->vWorldPosition.z;
-    v7 = (char *)&pVertices->vWorldPosition.z;
-    do
-    {
-      *((int *)v6 - 2) = *((int *)v7 - 2);
-      *((int *)v6 - 1) = *((int *)v7 - 1);
-      *(int *)v6 = *(int *)v7;
-      v7 += 48;
-      v6 += 48;
-      --v5;
-      *((float *)v6 - 5) = (double)a5->pDeltaUV[0] + *((float *)v7 - 5);
-      *((float *)v6 - 4) = (double)a5->pDeltaUV[1] + *((float *)v7 - 4);
-    }
-    while ( v5 );
+    pOutVertices[i].vWorldPosition.x = pVertices[i].vWorldPosition.x;
+    pOutVertices[i].vWorldPosition.y = pVertices[i].vWorldPosition.y;
+    pOutVertices[i].vWorldPosition.z = pVertices[i].vWorldPosition.z;
+
+    pOutVertices[i].u = pVertices[i].u + a5->pDeltaUV[0];
+    pOutVertices[i].v = pVertices[i].v + a5->pDeltaUV[1];
   }
-  ViewTransform(a1, uNumVertices);
+  ViewTransform(pOutVertices, uNumVertices);
 }
 
 //----- (0043669D) --------------------------------------------------------
@@ -108,153 +95,216 @@
 
 
 //----- (00436455) --------------------------------------------------------
-bool IndoorCameraD3D::IsFaceFacedTowardsCamera(BLVFace *pFace)
+bool IndoorCameraD3D::IsCulled(BLVFace *pFace)
 {
-  IndoorCameraD3D *v2; // edi@1
-  bool result; // eax@1
   RenderVertexSoft v; // [sp+8h] [bp-30h]@1
 
-  v2 = this;
   Vec3_short__to_RenderVertexSoft(&v, &pIndoor->pVertices[*pFace->pVertexIDs]);
-  LOBYTE(result) = is_vertex_with_normal_from_face_towards_camera(pFace, &v);
-  return result;
+  return is_face_faced_to_camera(pFace, &v);
 }
 
 //----- (00436523) --------------------------------------------------------
 void IndoorCameraD3D::ViewTransform(RenderVertexSoft *a1a, unsigned int uNumVertices)
 {
-  __debugbreak();
-  /*
-  unsigned int v3; // esi@4
-  unsigned int v4; // ecx@7
-  float v7; // [sp+4h] [bp-4h]@7
-
-  auto a1 = this;
-  if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
+  if (byte_4D864C && pGame->uFlags & 0x80 ||
+      uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    __asm
-    {
-      fld     pIndoorCamera->fRotationYCosine
-      fld     pIndoorCamera->fRotationYSine
-      fld     pIndoorCamera->fRotationXCosine
-    }
-    v4 = uNumVertices;
-    v7 = pIndoorCamera->fRotationXSine;
+    float sin_x = pIndoorCamera->fRotationXSine,
+          cos_x = pIndoorCamera->fRotationXCosine;
+    float sin_y = pIndoorCamera->fRotationYSine,
+          cos_y = pIndoorCamera->fRotationYCosine;
+
+    //v4 = uNumVertices;
+    //v7 = pIndoorCamera->fRotationXSine;
     if ( pIndoorCamera->sRotationX )
     {
-      if ( (signed int)uNumVertices > 0 )
-      {
-        _EAX = a1a;
-        do
-        {
-          __asm
-          {
-            fild    pIndoorCamera->pos.x
-            fsubr   dword ptr [eax]
-            fstp    [ebp+a1]
-            fild    pIndoorCamera->pos.y
-            fsubr   dword ptr [eax+4]
-            fstp    [ebp+uNumVertices]
-            fild    pIndoorCamera->pos.z
-            fsubr   dword ptr [eax+8]
-          }
+
+        //_EAX = a1a;
+    for (uint i = 0; i < uNumVertices; ++i)
+    {
+          float st0, st1, st2;
           if ( pRenderer->pRenderD3D )
           {
-            __asm
+            /*__asm
             {
-              fld     [ebp+uNumVertices]
-              fmul    st, st(3)
-              fld     [ebp+a1]
-              fmul    st, st(5)
-              faddp   st(1), st
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(6)
-              fsubp   st(1), st
-            }
+              fld     [ebp+uNumVertices] // [(a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fmul    st, st(3)          // [pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fld     [ebp+a1]           // [(a1a[i].x - pIndoorCamera->pos.x)]   [pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fmul    st, st(5)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              faddp   st(1), st          // [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fld     [ebp+a1]           // [(a1a[i].x - pIndoorCamera->pos.x)]   [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // [pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]   [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]   [(a1a[i].z - pIndoorCamera->pos.z)]   [pIndoorCamera->fRotationXCosine]   [pIndoorCamera->fRotationYSine]   [pIndoorCamera->fRotationYCosine]
+
+              fld     [ebp+uNumVertices] // 0[a1a[i].y - pIndoorCamera->pos.y]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+
+              fmul    st, st(6)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+
+              fsubp   st(1), st          // 0[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+            }*/
+            st0 = sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            st2 = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z);
           }
           else
           {
-            __asm
+            /*__asm
             {
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(4)
-              fsubp   st(1), st
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(6)
-              faddp   st(1), st
-            }
+              fld     [ebp+a1]           // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 2[pIndoorCamera->fRotationXCosine]
+                                         // 3[pIndoorCamera->fRotationYSine]
+                                         // 4[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 2[pIndoorCamera->fRotationXCosine]
+                                         // 3[pIndoorCamera->fRotationYSine]
+                                         // 4[pIndoorCamera->fRotationYCosine]
+              fld     [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // 0[pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fsubp   st(1), st          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 2[pIndoorCamera->fRotationXCosine]
+                                         // 3[pIndoorCamera->fRotationYSine]
+                                         // 4[pIndoorCamera->fRotationYCosine]
+              fld     [ebp+a1]           // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(4)          // 0[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+              fld     [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+              fmul    st, st(6)          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 3[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 4[pIndoorCamera->fRotationXCosine]
+                                         // 5[pIndoorCamera->fRotationYSine]
+                                         // 6[pIndoorCamera->fRotationYCosine]
+              faddp   st(1), st          // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y) + pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)]
+                                         // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)]
+                                         // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                         // 3[pIndoorCamera->fRotationXCosine]
+                                         // 4[pIndoorCamera->fRotationYSine]
+                                         // 5[pIndoorCamera->fRotationYCosine]
+            }*/
+            st0 = cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y) + sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x);
+            st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            st2 = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z);
           }
-          __asm
-          {
-            fld     st(1)
-            fmul    st, st(4)
-            fld     st(3)
-            fmul    [ebp+var_4]
-          }
-          ++_EAX;
-          --v4;
-          __asm
-          {
-            fsubp   st(1), st
-            fstp    dword ptr [eax-24h]
-            fstp    dword ptr [eax-20h]
-            fmul    [ebp+var_4]
-            fld     st(1)
-            fmul    st, st(3)
-            faddp   st(1), st
-            fstp    dword ptr [eax-1Ch]
-            fstp    st
-          }
-        }
-        while ( v4 );
+
+          a1a[i].vWorldViewPosition.x = st1*cos_x - st2*sin_x;
+          a1a[i].vWorldViewPosition.y = st0;
+          a1a[i].vWorldViewPosition.z = st2*cos_x + st1*sin_x;
       }
-      __asm { fstp    st }
     }
     else
     {
-      __asm { fstp    st }
-      if ( (signed int)uNumVertices > 0 )
+      for (uint i = 0; i < uNumVertices; ++i)
       {
-        _EAX = a1a;
-        do
-        {
-          __asm
-          {
-            fild    pIndoorCamera->pos.x
-            fsubr   dword ptr [eax]
-            fstp    [ebp+a1]
-            fild    pIndoorCamera->pos.y
-            fsubr   dword ptr [eax+4]
-            fstp    [ebp+uNumVertices]
-            fild    pIndoorCamera->pos.z
-            fsubr   dword ptr [eax+8]
-          }
           if ( pRenderer->pRenderD3D )
           {
-            __asm
+            /*__asm
             {
-              fld     [ebp+uNumVertices]
-              fmul    st, st(2)
-              fld     [ebp+a1]
-              fmul    st, st(4)
-              faddp   st(1), st
+              fld     [ebp+uNumVertices]   // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fmul    st, st(2)            // 0[sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fld     [ebp+a1]             // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              fmul    st, st(4)            // 0[cos_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              faddp   st(1), st            // 0[cos_y * (a1a[i].x - pIndoorCamera->pos.x) + sin_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
               fstp    dword ptr [eax+0Ch]
-              fld     [ebp+a1]
-              fmul    st, st(2)
-              fld     [ebp+uNumVertices]
-              fmul    st, st(4)
-              fsubp   st(1), st
-            }
+              fld     [ebp+a1]             // 0[(a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fmul    st, st(2)            // 0[sin_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fld     [ebp+uNumVertices]   // 0[(a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[sin_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              fmul    st, st(4)            // 0[cos_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[sin_y * (a1a[i].x - pIndoorCamera->pos.x)]
+                                           // 2[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 3[sin_y]
+                                           // 4[cos_y]
+              fsubp   st(1), st            // 0[sin_y * (a1a[i].x - pIndoorCamera->pos.x) - cos_y * (a1a[i].y - pIndoorCamera->pos.y)]
+                                           // 1[(a1a[i].z - pIndoorCamera->pos.z)]
+                                           // 2[sin_y]
+                                           // 3[cos_y]
+              fstp    dword ptr [eax+10h]
+              fstp    dword ptr [eax+14h]
+            }*/
+            a1a[i].vWorldViewPosition.x = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            a1a[i].vWorldViewPosition.y = sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y);
+            a1a[i].vWorldViewPosition.z = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z);
           }
           else
           {
-            __asm
+            __debugbreak();
+            /*__asm
             {
               fld     [ebp+a1]
               fmul    st, st(3)
@@ -267,101 +317,95 @@
               fld     [ebp+uNumVertices]
               fmul    st, st(4)
               faddp   st(1), st
-            }
+
+              fstp    dword ptr [eax+10h]
+              fstp    dword ptr [eax+14h]
+            }*/
           }
-          __asm
-          {
-            fstp    dword ptr [eax+10h]
-            fstp    dword ptr [eax+14h]
-          }
-          ++_EAX;
-          --v4;
-        }
-        while ( v4 );
       }
     }
-    __asm
-    {
-      fstp    st
-      fstp    st
-    }
   }
-  else
-  {
-    v3 = uNumVertices;
-    if ( (signed int)uNumVertices > 0 )
-    {
-      do
-      {
-        :ViewTransform(a1a);
-        ++a1a;
-        --v3;
-      }
-      while ( v3 );
-    }
-  }*/
+  else for (uint i = 0; i < uNumVertices; ++i)
+    pIndoorCamera->ViewTransform(a1a + i);
 }
 
 
 //----- (00436932) --------------------------------------------------------
-char IndoorCameraD3D::GetFacetOrientation(char a1, Vec3_float_ *a2, Vec3_float_ *a3, Vec3_float_ *a4)
+bool IndoorCameraD3D::GetFacetOrientation(char polyType, Vec3_float_ *a2, Vec3_float_ *a3, Vec3_float_ *a4)
 {
-  Vec3_float_ *v5; // eax@9
-  double v6; // st7@9
-
-  if ( a1 == 1 )
+  switch ((PolygonType)polyType)
   {
-    a4->x = -a2->y;
-    a4->y = a2->x;
-    a4->z = 0.0;
-LABEL_9:
-    v5 = a3;
-    a3->x = 0.0;
-    a3->y = 0.0;
-    v6 = 1.0;
-LABEL_11:
-    v5->z = v6;
-    return 1;
-  }
-  if ( a1 == 3 || a1 == 5 )
-  {
-LABEL_10:
-    a4->x = 1.0;
-    a4->y = 0.0;
-    a4->z = 0.0;
-    v5 = a3;
-    a3->x = 0.0;
-    a3->y = 1.0;
-    v6 = 0.0;
-    goto LABEL_11;
-  }
-  if ( a1 == 4 || a1 == 6 )
-  {
-    if ( fabs(a2->z) < 0.70811361 )
+    case POLYGON_VerticalWall:
     {
       a4->x = -a2->y;
       a4->y = a2->x;
       a4->z = 0.0;
-      a4->Normalize();
-      goto LABEL_9;
+
+      a3->x = 0.0;
+      a3->y = 0.0;
+      a3->z = 1.0f;
+    }
+    return true;
+
+    case POLYGON_Floor:
+    case POLYGON_Ceiling:
+    {
+      a4->x = 1.0;
+      a4->y = 0.0;
+      a4->z = 0.0;
+
+      a3->x = 0.0;
+      a3->y = 1.0;
+      a3->z = 0.0;
     }
-    goto LABEL_10;
+    return true;
+
+    case POLYGON_InBetweenFloorAndWall:
+    case POLYGON_InBetweenCeilingAndWall:
+    {
+      if (fabs(a2->z) < 0.70811361)
+      {
+        a4->x = -a2->y;
+        a4->y = a2->x;
+        a4->z = 0.0;
+        a4->Normalize();
+
+        a3->x = 0.0;
+        a3->y = 0.0;
+        a3->z = 1.0;
+      }
+      else
+      {
+        a4->x = 1.0;
+        a4->y = 0.0;
+        a4->z = 0.0;
+
+        a3->x = 0.0;
+        a3->y = 1.0;
+        a3->z = 0.0;
+      }
+    }
+    return true;
+
+    default:
+      return false;
   }
-  return 1;
 }
 
 
 //----- (00438258) --------------------------------------------------------
-bool IndoorCameraD3D::is_vertex_with_normal_from_face_towards_camera(BLVFace *pFace, RenderVertexSoft *a2)
+bool IndoorCameraD3D::is_face_faced_to_camera(BLVFace *pFace, RenderVertexSoft *a2)
 {
-  char result; // al@2
+  if (pFace->TwoSided())
+    return false;
 
+  //really strange cull; dot(to_cam, normal) < 0 means we see the BACK face, not font %_%
   if ( (a2->vWorldPosition.z - (double)pIndoorCamera->pos.z) * (double)pFace->pFacePlane_old.vNormal.z
      + (a2->vWorldPosition.y - (double)pIndoorCamera->pos.y) * (double)pFace->pFacePlane_old.vNormal.y
-     + (a2->vWorldPosition.x - (double)pIndoorCamera->pos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0
-    || (result = 1, pFace->uAttributes & 1) )
-    result = 0;
-  return result;
+     + (a2->vWorldPosition.x - (double)pIndoorCamera->pos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0)
+    return false;
+
+  return true;
 }
 
 //----- (00438250) --------------------------------------------------------
@@ -562,7 +606,7 @@
   while ( v10 < 1 );
   if ( v10 < 1 )
   {
-    _436BB7_project_and_stuff(vert, 1u, 0);
+    Project(vert, 1u, 0);
 LABEL_15:
     pD3DVertices[0].pos.x = vert[0].vWorldViewProjX;
     pD3DVertices[0].pos.y = vert[0].vWorldViewProjY;
@@ -623,7 +667,7 @@
       //v19 = pRenderer->pRenderD3D->pDevice;
       ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
       ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_POINTLIST,
-              452,
+              D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
               pD3DVertices,
               uNumD3DVertices,
               16));
@@ -776,7 +820,7 @@
       ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
       ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
               D3DPT_LINELIST,
-              452,
+              D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
               v24,
               2,
               16));
@@ -815,7 +859,7 @@
       || (signed int)uOutNumVertices >= 2 )
     {
       ViewTransform(pVertices, 2u);
-      _436BB7_project_and_stuff(pVertices, 2u, 0);
+      Project(pVertices, 2u, 0);
       goto LABEL_11;
     }
   }
@@ -930,7 +974,7 @@
 
 
 //----- (004378BA) --------------------------------------------------------
-void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *a3)
+void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *out)
 {
   float *v4; // ecx@1
   float *v5; // eax@1
@@ -941,7 +985,7 @@
   double v10; // st7@3
   double v11; // st6@3
 
-  v4 = (float *)a3;
+  v4 = (float *)out;
   v5 = &a1->_12;
   v6 = 3;
   do
@@ -970,162 +1014,125 @@
 //----- (004376E7) --------------------------------------------------------
 void IndoorCameraD3D::CreateWorldMatrixAndSomeStuff()
 {
-  IndoorCameraD3D *v1; // esi@1
+  //IndoorCameraD3D *v1; // esi@1
   double v2; // st7@1
-  signed int v3; // edi@1
-  int v4; // eax@1
-  double v5; // st7@2
-  double v6; // st7@3
-  Matrix3x3_float_ a3; // [sp+10h] [bp-B8h]@1
-  Matrix3x3_float_ v8; // [sp+34h] [bp-94h]@1
-  Matrix3x3_float_ a2; // [sp+58h] [bp-70h]@1
-  Matrix3x3_float_ v10; // [sp+7Ch] [bp-4Ch]@1
-  Matrix3x3_float_ a1; // [sp+A0h] [bp-28h]@1
+  //signed int v3; // edi@1
+  //int v4; // eax@1
+  //double v5; // st7@2
+  //double v6; // st7@3
+  Matrix3x3_float_ m1; // [sp+10h] [bp-B8h]@1
+  Matrix3x3_float_ m2; // [sp+34h] [bp-94h]@1
+  Matrix3x3_float_ m3; // [sp+58h] [bp-70h]@1
+  Matrix3x3_float_ m4; // [sp+7Ch] [bp-4Ch]@1
+  Matrix3x3_float_ m5; // [sp+A0h] [bp-28h]@1
   float v12; // [sp+C4h] [bp-4h]@1
 
-  v1 = this;
-  a1._13 = 0.0;
-  a1._23 = 0.0;
-  a1._31 = 0.0;
-  a1._32 = 0.0;
-  a1._33 = 1.0;
-  v10._11 = 1.0;
-  v10._12 = 0.0;
-  v10._13 = 0.0;
-  v10._21 = 0.0;
-  v10._31 = 0.0;
-  a2._12 = 0.0;
-  a2._21 = 0.0;
-  a2._22 = 1.0;
-  a2._23 = 0.0;
-  a2._32 = 0.0;
-  v12 = cos(0.0);
-  v2 = sin(0.0);
-  a1._11 = v12;
-  a1._12 = v2;
-  a1._21 = -v2;
-  a1._22 = v12;
-  v10._22 = pIndoorCamera->fRotationXCosine;
-  v10._32 = -pIndoorCamera->fRotationXSine;
-  v10._23 = pIndoorCamera->fRotationXSine;
-  v10._33 = pIndoorCamera->fRotationXCosine;
-  a2._11 = pIndoorCamera->fRotationYCosine;
-  a2._13 = -pIndoorCamera->fRotationYSine;
-  a2._31 = pIndoorCamera->fRotationYSine;
-  a2._33 = pIndoorCamera->fRotationYCosine;
-  MatrixMultiply(&a1, &a2, &a3);
-  MatrixMultiply(&v10, &a3, &v8);
-  v3 = 0;
-  v4 = (int)&v1->field_4.x;
-  do
+ //RotationZ(0)
+  m5._11 = cosf(0);         m5._12 = sinf(0);        m5._13 = 0;
+  m5._21 = -sinf(0);        m5._22 = cosf(0);        m5._23 = 0;
+  m5._31 = 0;               m5._32 = 0;              m5._33 = 1;
+
+  float cos_x1 = pIndoorCamera->fRotationXCosine,
+        sin_x1 = pIndoorCamera->fRotationXSine;
+ //RotationX(x)
+  m4._11 = 1;               m4._12 = 0;              m4._13 = 0;
+  m4._21 = 0;               m4._22 = cos_x1;         m4._23 = sin_x1;
+  m4._31 = 0;               m4._32 = -sin_x1;        m4._33 = cos_x1;
+  
+  float cos_y1 = pIndoorCamera->fRotationYCosine,
+        sin_y1 = pIndoorCamera->fRotationYSine;
+ //RotationY(some_angle)
+  m3._11 = cos_y1;          m3._12 = 0;              m3._13 = -sin_y1;
+  m3._21 = 0;               m3._22 = 1;              m3._23 = 0;
+  m3._31 = sin_y1;          m3._32 = 0;              m3._33 = cos_y1;
+
+  MatrixMultiply(&m5, &m3, &m1);
+  MatrixMultiply(&m4, &m1, &m2);
+
+  for (uint i = 0; i < 3; ++i)
   {
-    v5 = *(&v8._11 + v3++);
-    *(float *)(v4 + 16) = v5;
-    *(float *)v4 = *(float *)((char *)&v8._12 - (char *)v1 + v4);
-    *(float *)(v4 + 32) = *(float *)((char *)&v8._22 - (char *)v1 + v4);
-    v4 += 4;
+    field_4[0].v[i] = m2.v[1][i];
+    field_4[1].v[i] = m2.v[0][i];
+    field_4[2].v[i] = m2.v[2][i];
   }
-  while ( v3 < 3 );
-  LODWORD(v1->field_D8) = 0x3F91361Du;
-  v1->flt_D0 = (double)pViewport->uScreenWidth * 0.8814736;
-  v6 = 0.8814736 * (double)pViewport->uScreenHeight;
-  v1->flt_D4 = v6;
-  if ( v1->flt_D0 > v6 )
-    v6 = v1->flt_D0;
-  v1->flt_fov = v6;
-  v1->field_C8 = (double)pViewport->uScreenCenterX;
-  v1->field_CC = (double)(pViewport->uScreenCenterY - pViewport->uScreenY);
+
+  inv_fov = 1.1344639;
+  fov_x = (double)pViewport->uScreenWidth * 0.8814736;
+
+  fov_y = 0.8814736 * (double)pViewport->uScreenHeight;
+  fov = fov_y;
+  if ( fov_x > fov )
+    fov = fov_x;
+  screenCenterX = (double)pViewport->uScreenCenterX;
+  screenCenterY = (double)(pViewport->uScreenCenterY - pViewport->uScreenY);
 }
 
 
 //----- (00437691) --------------------------------------------------------
-IndoorCameraD3D_Vec3 *IndoorCameraD3D::Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut)
+void IndoorCameraD3D::Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut)
 {
-  IndoorCameraD3D_Vec3 *result; // eax@1
-
-  result = (IndoorCameraD3D_Vec3 *)pVector;
-  pOut->y = this->field_14.x * pVector->x + this->field_4.x * pVector->y + this->field_24.x * pVector->z;
-  pOut->z = this->field_14.y * result->x + this->field_4.y * result->y + this->field_24.y * result->z;
-  pOut->x = this->field_14.z * result->x + this->field_4.z * result->y + this->field_24.z * pVector->z;
-  return result;
+  pOut->y = field_4[1].x * pVector->x + field_4[0].x * pVector->y + field_4[2].x * pVector->z;
+  pOut->z = field_4[1].y * pVector->x + field_4[0].y * pVector->y + field_4[2].y * pVector->z;
+  pOut->x = field_4[1].z * pVector->x + field_4[0].z * pVector->y + field_4[2].z * pVector->z;
 }
 
 //----- (00437607) --------------------------------------------------------
 void IndoorCameraD3D::_437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2)
 {
-  IndoorCameraD3D *v3; // edi@1
   double v4; // st7@1
-  signed int v5; // ecx@1
-  char *v6; // eax@1
-  double v7; // st6@2
   IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1
-  Vec3_float_ v9; // [sp+Ch] [bp-18h]@1
-  int v10; // [sp+20h] [bp-4h]@1
 
-  v3 = this;
-  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v8);
-  v10 = 0;
-  v9.x = (double)pIndoorCamera->pos.x;
-  v9.y = (double)pIndoorCamera->pos.y;
-  v9.z = (double)pIndoorCamera->pos.z;
+  v8.x = (double)pIndoorCamera->pos.x;
+  v8.y = (double)pIndoorCamera->pos.y;
+  v8.z = (double)pIndoorCamera->pos.z;
   Vec3Transform(a1, a2);
-  v4 = 0.0;
-  v5 = 0;
-  v6 = (char *)&a2->x;
-  do
-  {
-    v7 = *(&v9.x + v5++) * *(float *)v6;
-    v6 += 4;
-    v4 = v4 + v7;
-  }
-  while ( v5 < 3 );
-  v10 = -1;
+
+  v4 = v8.x * a2->x + v8.y * a2->y + v8.z * a2->z;
   a2->dot = v4 + 0.000099999997;
-  //IndoorCameraD3D_Vec3::dtor(&v8);
 }
 
 //----- (004374E8) --------------------------------------------------------
 void IndoorCameraD3D::_4374E8_ProllyBuildFrustrum()
 {
-  IndoorCameraD3D *v1; // esi@1
-  double v2; // st7@1
+  //IndoorCameraD3D *v1; // esi@1
+  //double v2; // st7@1
   double v3; // st7@1
-  double v4; // st7@1
+  //double v4; // st7@1
   double v5; // st7@1
-  double v6; // st7@1
+  //double v6; // st7@1
   IndoorCameraD3D_Vec3 v7; // [sp+Ch] [bp-24h]@1
-  float v8; // [sp+10h] [bp-20h]@1
-  float v9; // [sp+14h] [bp-1Ch]@1
-  float v10; // [sp+18h] [bp-18h]@1
-  float v11; // [sp+1Ch] [bp-14h]@1
-  float v12; // [sp+20h] [bp-10h]@1
-  int v13; // [sp+2Ch] [bp-4h]@1
+  //float v8; // [sp+10h] [bp-20h]@1
+  //float v9; // [sp+14h] [bp-1Ch]@1
+  //float v10; // [sp+18h] [bp-18h]@1
+  //float v11; // [sp+1Ch] [bp-14h]@1
+  //float v12; // [sp+20h] [bp-10h]@1
+  //int v13; // [sp+2Ch] [bp-4h]@1
 
-  v1 = this;
+  //v1 = this;
   //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v7);
-  v2 = 2.0 / v1->field_D8;
-  v13 = 0;
-  v3 = atan(v2 * v1->flt_fov / v1->flt_D0);
-  v12 = v3;
-  v11 = sin(v3);
-  v4 = cos(v12);
-  v8 = -v11;
-  v9 = 0.0;
-  v10 = v4;
-  _437607(&v7, v1->std__vector_000034_prolly_frustrum);
-  v8 = v11;
-  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[1]);
-  v5 = atan(2.0 / v1->field_D8 * v1->flt_fov / (v1->flt_D4 + 0.5));
-  v12 = v5;
-  v11 = sin(v5);
-  v6 = cos(v12);
-  v9 = v11;
-  v8 = 0.0;
-  v10 = v6;
-  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[2]);
-  v9 = -v11;
-  _437607(&v7, &v1->std__vector_000034_prolly_frustrum[3]);
-  v13 = -1;
+  //v2 = 2.0 / inv_fov;
+  //v13 = 0;
+  v3 = atan(2.0 / inv_fov * fov / fov_x);
+  //v12 = v3;
+  //v11 = sin(v3);
+  //v4 = cos(v3);
+  v7.x = -sin(v3);
+  v7.y = 0.0;
+  v7.z = cos(v3);
+  _437607(&v7, std__vector_000034_prolly_frustrum);
+  v7.x = sin(v3);
+  _437607(&v7, &std__vector_000034_prolly_frustrum[1]);
+  v5 = atan(2.0 / inv_fov * fov / (fov_y + 0.5));
+  //v12 = v5;
+  //v11 = sin(v5);
+  //v6 = cos(v5);
+  v7.y = sin(v5);
+  v7.x = 0.0;
+  v7.z = cos(v5);
+  _437607(&v7, &std__vector_000034_prolly_frustrum[2]);
+  v7.y = -sin(v5);
+  _437607(&v7, &std__vector_000034_prolly_frustrum[3]);
+  //v13 = -1;
   //IndoorCameraD3D_Vec3::dtor(&v7);
 }
 
@@ -1155,9 +1162,9 @@
   if ( (signed int)*pOutNumVertices <= 3
     || ((v5 = a2,
          memcpy(&v18, a2, sizeof(v18)),
-         (v18.vWorldPosition.z - (double)pBLVRenderParams->vPartyPos.z) * thisa->vNormal.z
-       + (v18.vWorldPosition.y - (double)pBLVRenderParams->vPartyPos.y) * thisa->vNormal.y
-       + (v18.vWorldPosition.x - (double)pBLVRenderParams->vPartyPos.x) * thisa->vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0),
+         (v18.vWorldPosition.z - (double)pBLVRenderParams->vPartyPos.z) * thisa->face_plane.vNormal.z
+       + (v18.vWorldPosition.y - (double)pBLVRenderParams->vPartyPos.y) * thisa->face_plane.vNormal.y
+       + (v18.vWorldPosition.x - (double)pBLVRenderParams->vPartyPos.x) * thisa->face_plane.vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0),
         a2_3 = 0,
         memcpy(&v5[v4], v5, sizeof(v5[v4])),
         memcpy(&v5[*pOutNumVertices + 1], &v5[1], sizeof(v5[*pOutNumVertices + 1])),
@@ -1225,50 +1232,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;
+  if (uNumVertices <= 0)
+    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 +1274,23 @@
         v15 = a1;
         v14 = sr_vertices_50D9D8;
       }
-      ++a6a;
-      if ( a6a == uNumVertices )
+      if (i == uNumVertices - 1)
         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;
-      if ( (signed int)*pOutNumVertices < v18 )
+      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 (*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)
@@ -1399,7 +1391,7 @@
   return result;
 }
 //----- (00436F09) --------------------------------------------------------
-void IndoorCameraD3D::_436F09(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
+void IndoorCameraD3D::_436F09_mess_with_lightmap__clipflag_4(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
   unsigned int *pOutNumVertices_; // ebx@1
   double v6; // st7@2
@@ -1502,7 +1494,7 @@
 
 
 //----- (00436CDC) --------------------------------------------------------
-void IndoorCameraD3D::_436CDC(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
+void IndoorCameraD3D::_436CDC_mess_with_lightmap__clipflag_2(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
   signed int v5; // esi@2
   char *v6; // edx@5
@@ -1598,11 +1590,8 @@
 
 
 //----- (00436BB7) --------------------------------------------------------
-void IndoorCameraD3D::_436BB7_project_and_stuff(RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4)
+void IndoorCameraD3D::Project(RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4)
 {
-  unsigned int v4; // ebx@1
-  IndoorCameraD3D *v5; // edi@1
-  float *v6; // esi@2
   double v7; // st7@7
   double v8; // st7@9
   double v9; // st6@10
@@ -1613,65 +1602,59 @@
   float uNumVerticesa; // [sp+14h] [bp+Ch]@13
   float uNumVerticesb; // [sp+14h] [bp+Ch]@20
 
-  v4 = uNumVertices;
-  v5 = this;
-  if ( (signed int)uNumVertices > 0 )
+  for (uint i = 0; i < uNumVertices; ++i)
   {
-    v6 = &pVertices->vWorldViewProjX;
-    do
+    if (byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
     {
-      if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      {
-        v7 = 1.0 / *(v6 - 3);
-        *v6 = *(v6 - 2) * v5->flt_fov * v7 + v5->field_C8;
-        v6[1] = (double)(signed int)pViewport->uViewportW - (*(v6 - 1) * v5->flt_fov * v7 + v5->field_CC);
-      }
-      else
-      {
-        extern void _outdoor_project(RenderVertexSoft *v);
-        _outdoor_project((RenderVertexSoft *)(v6 - 6));
-      }
+      v7 = 1.0 / pVertices[i].vWorldViewPosition.x;
+
+      pVertices[i].vWorldViewProjX = pVertices[i].vWorldViewPosition.y * fov * v7 + screenCenterX;
+      pVertices[i].vWorldViewProjY = (signed int)pViewport->uViewportW - (pVertices[i].vWorldViewPosition.z * fov * v7 + screenCenterY);
+    }
+    else
+    {
+      extern void _outdoor_project(RenderVertexSoft *v);
+      _outdoor_project(pVertices + i);
+    }
+
       if ( a4 )
       {
+        __debugbreak();
         v8 = (double)(signed int)pViewport->uViewportZ;
-        if ( v8 >= *v6 )
-          v9 = *v6;
+        if ( v8 >= pVertices[i].vWorldViewProjX )
+          v9 = pVertices[i].vWorldViewProjX;
         else
           v9 = v8;
         v10 = (double)(signed int)pViewport->uViewportX;
         if ( v10 <= v9 )
         {
-          if ( v8 >= *v6 )
-            v8 = *v6;
+          if ( v8 >= pVertices[i].vWorldViewProjX)
+            v8 = pVertices[i].vWorldViewProjX;
         }
         else
         {
           uNumVerticesa = v10;
           v8 = uNumVerticesa;
         }
-        *v6 = v8;
+        pVertices[i].vWorldViewProjX = v8;
         v11 = (double)(signed int)pViewport->uViewportW;
-        if ( v11 >= v6[1] )
-          v12 = v6[1];
+        if ( v11 >= pVertices[i].vWorldViewProjY)
+          v12 = pVertices[i].vWorldViewProjY;
         else
           v12 = v11;
         v13 = (double)(signed int)pViewport->uViewportY;
         if ( v13 <= v12 )
         {
-          if ( v11 >= v6[1] )
-            v11 = v6[1];
+          if ( v11 >= pVertices[i].vWorldViewProjY)
+            v11 = pVertices[i].vWorldViewProjY;
         }
         else
         {
           uNumVerticesb = v13;
           v11 = uNumVerticesb;
         }
-        v6[1] = v11;
+        pVertices[i].vWorldViewProjY = v11;
       }
-      v6 += 12;
-      --v4;
-    }
-    while ( v4 );
   }
 }
 
@@ -1680,8 +1663,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 +1673,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 * fov * v6 + screenCenterX;
+    //v7 = a2a + 6.7553994e15;
+    *a5 = floorf(a2a + 0.5f);
+    a2b = (double)z * fov * v6 + screenCenterY;
+    //v8 = a2b + 6.7553994e15;
+    *a6 = pViewport->uViewportW - floorf(a2b + 0.5f);
   }
   else
   {
--- a/IndoorCameraD3D.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/IndoorCameraD3D.h	Mon Oct 29 09:28:08 2012 +0600
@@ -15,9 +15,17 @@
   //void ~IndoorCameraD3D_Vec3() {}
 
   void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D_Vec3 *, bool);
-  float x;
-  float y;
-  float z;
+
+  union
+  {
+    struct
+    {
+      float x;
+      float y;
+      float z;
+    };
+    float v[3];
+  };
 };
 #pragma pack(pop)
 
@@ -121,16 +129,16 @@
   double GetPolygonMinZ(struct RenderVertexSoft *pVertices, unsigned int uStripType);
   struct IDirect3DTexture2 *LoadTextureAndGetHardwarePtr(char *Str1);
   void Project(signed int x, signed int y, signed int z, int *a5, int *a6);
-  void _436BB7_project_and_stuff(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4);
-  void _436CDC(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
-  void _436F09(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
+  void Project(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4);
+  void _436CDC_mess_with_lightmap__clipflag_2(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
+  void _436F09_mess_with_lightmap__clipflag_4(struct RenderVertexSoft *pInVertices, int uNumInVertices, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
   int _437143(unsigned int uNumInVertices, struct RenderVertexSoft *pOutVertices, struct RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices);
   bool _4371C3(struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused);
   bool _437285_prolly_colide_vertices_against_frustrum(struct RenderVertexSoft *a1, unsigned int *pOutNumVertices, struct RenderVertexSoft *pVertices, IndoorCameraD3D_Vec4 *a4, signed int uNumVertices, char a6, int _unused);
   char _437376(struct stru154 *thisa, struct RenderVertexSoft *a2, unsigned int *pOutNumVertices);
   void _4374E8_ProllyBuildFrustrum();
   void _437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2);
-  IndoorCameraD3D_Vec3 *Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut);
+  void Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut);
   void CreateWorldMatrixAndSomeStuff();
   void MatrixMultiply(struct Matrix3x3_float_ *a1, struct Matrix3x3_float_ *a2, struct Matrix3x3_float_ *a3);
   void PrepareAndDrawDebugOutline(struct BLVFace *pFace, unsigned int uDiffuse);
@@ -142,24 +150,24 @@
   void _438141_draw_list_0037C();
   void _438240_draw_lits();
   void Reset_list_0037C();
-  bool is_vertex_with_normal_from_face_towards_camera(struct BLVFace *pFace, struct RenderVertexSoft *a2);
-  char GetFacetOrientation(char a1, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4);
+  bool is_face_faced_to_camera(struct BLVFace *pFace, struct RenderVertexSoft *a2);
+  bool GetFacetOrientation(char polyType, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4);
   void ViewTransform(struct RenderVertexSoft *a1a, unsigned int uNumVertices);
-  bool IsFaceFacedTowardsCamera(struct BLVFace *pFace);
-  void _4364C5(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *a1, struct stru320 *a5);
+  bool IsCulled(struct BLVFace *pFace);
+  void ViewTransfrom_OffsetUV(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pOutVertices, struct stru320 *a5);
   char ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow);
 
   void (__thiscall ***vdestructor_ptr)(IndoorCameraD3D *, bool);
-  IndoorCameraD3D_Vec3 field_4;
-  IndoorCameraD3D_Vec3 field_14;
-  IndoorCameraD3D_Vec3 field_24;
+  IndoorCameraD3D_Vec3 field_4[3];
+  //IndoorCameraD3D_Vec3 field_14;
+  //IndoorCameraD3D_Vec3 field_24;
   IndoorCameraD3D_Vec4 std__vector_000034_prolly_frustrum[6];
-  float flt_fov;
-  float field_C8;
-  float field_CC;
-  float flt_D0;
-  float flt_D4;
-  float field_D8;
+  float fov;
+  float screenCenterX;
+  float screenCenterY;
+  float fov_x;
+  float fov_y;
+  float inv_fov;
   float field_DC;
   float field_E0;
   float field_E4;
--- a/Indoor_stuff.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Indoor_stuff.h	Mon Oct 29 09:28:08 2012 +0600
@@ -74,19 +74,22 @@
    // _eh_vector_constructor_iterator_(field_FA8, 2252, 150,
    //    (void (__thiscall *)(void *))stru170_stru0::stru170_stru0,
    //    (void (__thiscall *)(void *))stru170_stru0::dtor);
+    uNumFaceIDs = 0;
+    std__vector_000FA8 = 0;
+    uNumVisibleNotEmptySectors = 0;
   }
 
-  void _4AFB86(int a2, unsigned int uFaceID);
-  void _4B0EA8(signed int a2, unsigned int uFaceID);
-  int 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)
 
@@ -108,11 +111,11 @@
   char field_3;
   char field_4;
   char field_5;
-  __int16 field_6;
-  __int16 field_8;
-  __int16 field_A;
-  __int16 field_C;
-  __int16 field_E;
+  __int16 field_6_rnd_value;
+  __int16 field_8_rnd_value;
+  __int16 field_A_rnd_value;
+  __int16 field_C_time_left;
+  __int16 field_E_time_to_live;
   char field_10;
   char field_11;
   char field_12;
@@ -158,7 +161,7 @@
   Plane_int_ plane_4;
   Vec3_int_ vec_14;
   Vec3_int_ vec_20;
-  int field_2C;
+  unsigned int uCurrentAmbientLightLevel;
   int field_30;
   int field_34;
   int field_38;
@@ -176,7 +179,7 @@
   int field_98;
   Vec3_int_ vec_9C;
   int field_A8;
-  int field_AC;
+  unsigned int uNumLightsApplied;
   int _blv_lights_radii[20];
   int _blv_lights_inv_radii[20];
   int _blv_lights_xs[20];
@@ -206,13 +209,13 @@
   float _blv_lights_rs[20];
   float _blv_lights_gs[20];
   float _blv_lights_bs[20];
-  char _blv_lights_smthngs[20];
+  char _blv_lights_types[20];
   int field_3E4;
   int field_3E8;
   int field_3EC;
   int field_3F0;
   int field_3F4;
-  int field_3F8;
+  unsigned int uDefaultAmbientLightLevel;
 };
 #pragma pack(pop)
 
@@ -372,14 +375,13 @@
   {}
 
   int _49B04D(struct ODMFace *a2, struct BSPVertexBuffer *a3);
-  int _49B0C9(struct Vec3_float_ *pNormal, float a3);
+  int _49B0C9(struct Vec3_float_ *pNormal, float dist);
   int _49B13D(struct ODMFace *pFace, struct BSPVertexBuffer *pVertices, struct Vec3_float_ *a3, float *a4);
 
 
   void (__thiscall ***vdestructor_ptr)(stru154 *, bool);
-  Vec3_float_ vNormal;
-  float field_10;
-  char field_14;
+  Plane_float_ face_plane;
+  PolygonType polygonType;
   char field_15;
   char field_16;
   char field_17;
--- a/Items.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Items.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -1752,11 +1752,11 @@
     v4 = item__getname_buffer;
     v10 = "%s";
 LABEL_10:
-    sprintfex(v4, v10, v11);
+    sprintf(v4, v10, v11);
     return v4;
   }
   v4 = item__getname_buffer;
-  sprintfex(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName);
+  sprintf(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName);
   if ( v1->uItemID == 601 )
   {
     v5 = v1->field_1A;
@@ -1802,7 +1802,7 @@
         || v7 == 67
         || v7 == 68 )
       {
-        sprintfex(
+        sprintf(
           item__getname_buffer,
           "%s %s",
           *(unsigned int *)&pItemsTable->pEnchantments[22].field_8[28 * v7 + 8],
@@ -1868,7 +1868,7 @@
   unsigned int v48; // ecx@123
   int v49; // eax@123
   int v50; // eax@123
-  unsigned int Dst; // [sp+Ch] [bp-C88h]@33
+  unsigned char Dst[0xC80]; // [sp+Ch] [bp-C88h]@33
   int v52; // [sp+C8Ch] [bp-8h]@33
   int v53; // [sp+C90h] [bp-4h]@1
   int v54; // [sp+C9Ch] [bp+8h]@3
@@ -2021,13 +2021,13 @@
     v10 = 0;
     if ( v52 )
       v10 = rand() % v52;
-    v4->uItemID = Dst;
+    v4->uItemID = *(uint *)Dst;
     if ( !Dst )
       v4->uItemID = 1;
     v11 = *(&v5->pItems[v4->uItemID].field_2C + v54);
     if ( v11 < v10 )
     {
-      v12 = &Dst;
+      v12 = (uint *)Dst;
       do
       {
         ++v12;
@@ -2226,9 +2226,9 @@
     while ( a2b < v5->field_11798 );
   }
   v45 = rand();
-  v4->uAdditionalValue = Dst;
+  v4->uAdditionalValue = *(uint *)Dst;
   v46 = v45 % v39 + 1;
-  a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (Dst + 1389) + v5->pItems[v4->uItemID].uEquipType);
+  a2c = *((unsigned char *)&v5->pItems[0].uItemID + 28 * (*(uint *)Dst + 1389) + v5->pItems[v4->uItemID].uEquipType);
   if ( a2c < v46 )
   {
     for ( j = (int *)&Dst; ; j = (int *)v59 )
--- a/Keyboard.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Keyboard.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -716,9 +716,9 @@
     return VK_UP;
   if ( !strcmp(Str, "DOWN") )
     return VK_DOWN;
-  if ( !strcmp(Str, ascii_4E2D48) )
+  if (!strcmp(Str, "") || !strcmp(Str, "LEFT"))
     return VK_LEFT;
-  if ( !strcmp(Str, ascii_4E2D40) )
+  if (!strcmp(Str, "") || !strcmp(Str, "RIGHT"))
     return VK_RIGHT;
   if ( !strcmp(Str, "RETURN") )
     return VK_RETURN;
--- a/LOD.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/LOD.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -585,13 +585,13 @@
   v49 = v7;
   v69 = v3->uTargetPitch;
   pTarget = v3->pTarget;
-  v57 = v3->field_28;
+  v57 = v3->sZValue;
   v61 = v3->pPalette;
   v9 = (v6 * this->uWidth + 32768) >> 16;
-  v72 = v3->field_C;
+  v72 = v3->uScreenSpaceY;
   result = (v5 * v7 + 32768) >> 16;
   v10 = (int *)(v72 - result + 1);
-  v11 = v3->field_8 - (v9 >> 1) + 1;
+  v11 = v3->uScreenSpaceX - (v9 >> 1) + 1;
   v65 = v72 - result + 1;
   v59 = v11 + v9 - 1;
   if ( BYTE1(v3->uFlags) & 8 )
@@ -602,7 +602,7 @@
   }
   v12 = v72;
   pTargetZ = v10;
-  v75 = v3->field_8 - (v9 >> 1) + 1;
+  v75 = v3->uScreenSpaceX - (v9 >> 1) + 1;
   v79 = v11 + v9 - 1;
   if ( !(v3->uFlags & 8) )
   {
@@ -881,7 +881,7 @@
   v16 = a2->pTarget;
   v15 = a2->pPalette;
   v5 = this->uHeight - 1;
-  for ( i = v4 * a2->field_C - (this->uWidth >> 1) + a2->field_8 + 1; v5 >= 0; --v5 )
+  for ( i = v4 * a2->uScreenSpaceY - (this->uWidth >> 1) + a2->uScreenSpaceX + 1; v5 >= 0; --v5 )
   {
     v6 = &this->pSpriteLines[v5];
     v7 = LOWORD(v6->dword_0);
@@ -2416,7 +2416,7 @@
     File = FindContainer("pending", 0);
     if ( !File )
     {
-      sprintfex(Args, "Can't find %s!", pContainer);
+      sprintf(Args, "Can't find %s!", pContainer);
       Abortf(Args);
     }
   }
--- a/LayingItem.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/LayingItem.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -36,8 +36,8 @@
   v1 = this;
   pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)];
   v3 = abs(pParty->vPosition.x - v1->vPosition.x);
-  v15 = abs(pParty->vPosition.z - v1->vPosition.y);
-  v16 = abs(pParty->vPosition.y + pParty->sEyelevel - v1->vPosition.z);
+  v15 = abs(pParty->vPosition.y - v1->vPosition.y);
+  v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z);
   v4 = v3;
   v5 = v15;
   v6 = v16;
--- a/LightmapBuilder.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/LightmapBuilder.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -2,6 +2,7 @@
 #include "Game.h"
 #include "stru314.h"
 #include "Outdoor.h"
+#include "Log.h"
 
 #include "mm7_data.h"
 
@@ -12,11 +13,11 @@
 
 
 LightsStack_StationaryLight_ *pStationaryLightsStack = new LightsStack_StationaryLight_;
-StationaryLight pStationaryLights[400];
-int uNumStationaryLightsApplied; // weak
+//StationaryLight pStationaryLights[400];
+//int uNumStationaryLightsApplied; // weak
 LightsStack_MobileLight_ *pMobileLightsStack = new LightsStack_MobileLight_;
-MobileLight pMobileLights[400];
-int uNumMobileLightsApplied;
+//MobileLight pMobileLights[400];
+//int uNumMobileLightsApplied;
 
 
 
@@ -35,11 +36,6 @@
 //----- (0045BB06) --------------------------------------------------------
 LightmapBuilder::LightmapBuilder()
 {
-  //std__vector_000004.reserve(512);
-  //std__vector_183808.reserve(768);
-
-  for (uint i = 0; i < 256; ++i)
-    field_3C8C34[i].flt_2C = 0.0f;
 }
 
 
@@ -47,185 +43,85 @@
 
 
 //----- (0045BC07) --------------------------------------------------------
-char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char a7)
+bool LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char uClipFlag)
 {
-  char *v7; // eax@3
-  signed int v8; // ecx@3
-  RenderVertexSoft *v9; // eax@10
-  unsigned int v10; // edx@10
-  const void *v11; // esi@11
-  void *v12; // edi@11
-  char v13; // zf@11
-  stru154 *v14; // esi@12
-  double v16; // st7@17
-  double v17; // st6@17
-  float v18; // eax@17
-  int *v19; // esi@20
-  double v20; // st7@21
-  int v21; // eax@21
-  unsigned int v22; // eax@21
-  int v23; // ecx@23
-  float v24; // ST04_4@23
-  float v25; // [sp+8h] [bp-64h]@18
-  Vec3_float_ *v26; // [sp+18h] [bp-54h]@17
-  int v27; // [sp+1Ch] [bp-50h]@17
-  int arg0; // [sp+2Ch] [bp-40h]@21
-  int v29; // [sp+30h] [bp-3Ch]@21
-  int v30; // [sp+34h] [bp-38h]@21
-  //double v31; // [sp+38h] [bp-34h]@21
-  //double v32; // [sp+40h] [bp-2Ch]@21
-  //double v33; // [sp+48h] [bp-24h]@21
-  int v34; // [sp+50h] [bp-1Ch]@24
-  LightmapBuilder *thisa; // [sp+54h] [bp-18h]@1
-  int v36; // [sp+58h] [bp-14h]@21
-  int v37; // [sp+5Ch] [bp-10h]@21
-  unsigned __int64 v38; // [sp+60h] [bp-Ch]@21
-  int a9; // [sp+68h] [bp-4h]@8
+  Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21
+  RenderVertexSoft *a9; // [sp+68h] [bp-4h]@8
+
+  if (!uNumVertices)
+    return false;
+
+  static RenderVertexSoft static_69B140[64];
 
-  thisa = this;
-  if ( !uNumVertices )
-    return 0;
+  a9 = a5;
+  if (a6)
+  {
+    for (uint i = 0; i < uNumVertices; ++i)
+      memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft));
 
-  static bool _static_initialized = false;
-  static RenderVertexSoft LightmapBuilder_static_sub_45BC07_stru_69B140[64];
-  if (!_static_initialized)
-  {
-    for (uint i = 0; i < 64; ++i)
-      LightmapBuilder_static_sub_45BC07_stru_69B140[i].flt_2C = 0.0f;
-    _static_initialized = true;
+    __debugbreak();
+    if (pGame->pIndoorCameraD3D->_437376(
+           a3,
+           static_69B140,
+           &uNumVertices) == 1)
+    {
+      if ( !uNumVertices )
+        return false;
+      a9 = static_69B140;
+    }
   }
 
-  a9 = (int)a5;
-  if ( a6 == 0.0 )
-  {
-    v14 = a3;
-  }
-  else
-  {
-    if ( (signed int)uNumVertices > 0 )
-    {
-      v9 = LightmapBuilder_static_sub_45BC07_stru_69B140;
-      v10 = (char *)a5 - (char *)LightmapBuilder_static_sub_45BC07_stru_69B140;
-      a5 = (RenderVertexSoft *)uNumVertices;
-      do
-      {
-        v11 = (char *)v9 + v10;
-        v12 = v9;
-        ++v9;
-        v13 = a5 == (RenderVertexSoft *)1;
-        a5 = (RenderVertexSoft *)((char *)a5 - 1);
-        memcpy(v12, v11, 0x30u);
-      }
-      while ( !v13 );
-    }
-    v14 = a3;
-    if ( pGame->pIndoorCameraD3D->_437376(
-           a3,
-           LightmapBuilder_static_sub_45BC07_stru_69B140,
-           &uNumVertices) == 1 )
-    {
-      if ( !uNumVertices )
-        return 0;
-      a9 = (int)LightmapBuilder_static_sub_45BC07_stru_69B140;
-    }
-  }
-  v16 = v14->vNormal.z;
-  v17 = v14->vNormal.y;
-  v18 = v14->vNormal.x;
-
-  static stru314 LightmapBuilder_static_sub_45BC07_stru_69B110;
-  v27 = (int)&LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C;
-  LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.y = v17;
-  LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.x = v18;
-  v26 = &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10;
-  LightmapBuilder_static_sub_45BC07_stru_69B110.field_4.z = v16;
-  dword_69B138 = LODWORD(v14->field_10);
-  if ( !pGame->pIndoorCameraD3D->GetFacetOrientation(
-          v14->field_14,
-          &LightmapBuilder_static_sub_45BC07_stru_69B110.field_4,
-          &LightmapBuilder_static_sub_45BC07_stru_69B110.field_10,
-          &LightmapBuilder_static_sub_45BC07_stru_69B110.field_1C) )
+  static stru314 static_69B110;
+  static_69B110.field_4.x = a3->face_plane.vNormal.x;
+  static_69B110.field_4.y = a3->face_plane.vNormal.y;
+  static_69B110.field_4.z = a3->face_plane.vNormal.z;
+  static_69B110.dist = a3->face_plane.dist;
+  if (!pGame->pIndoorCameraD3D->GetFacetOrientation(
+          a3->polygonType,
+          &static_69B110.field_4,
+          &static_69B110.field_10,
+          &static_69B110.field_1C))
   {
     MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0);
     ExitProcess(0);
   }
-  a5 = 0;
-  if ( a2->field_AC > 0 )
+
+  for (uint i = 0; i < a2->uNumLightsApplied; ++i)
   {
-    v19 = a2->_blv_lights_ys;
-    do
+    pos.x = a2->_blv_lights_xs[i];
+    pos.y = a2->_blv_lights_ys[i];
+    pos.z = a2->_blv_lights_zs[i];
+
+    uint uColorR = (uint)floorf(a2->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF,
+         uColorG = (uint)floorf(a2->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF,
+         uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF;
+    uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB;
+    if (!uColor)
+      uColor = 0x00FFFFF;
+
+    if (!_45BE86_build_light_polygon(
+              &pos,
+              a2->_blv_lights_radii[i],
+              uColor,
+              a2->_blv_lights_light_dot_faces[i],
+              a2->_blv_lights_types[i],
+              &static_69B110,
+              uNumVertices,
+              a9,
+              uClipFlag) )
     {
-      v20 = *((float *)v19 + 80) * 255.0;
-      arg0 = *(v19 - 20);
-      v29 = *v19;
-      v30 = v19[60];
-      v21 = *(v19 - 60);
-      a6 = v20;
-      v36 = v21;
-      v37 = v19[20];
-      //v33 = a6 + 6.7553994e15;
-      a6 = *((float *)v19 + 100) * 255.0;
-      //v32 = a6 + 6.7553994e15;
-      a6 = *((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));
-      //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);
-      if (!v22)
-        v22 = 0x00FFFFFF;
-      v27 = a7;
-      v23 = (int)a5;
-      v26 = (Vec3_float_ *)a9;
-      LOBYTE(v23) = *((unsigned char *)&a5[20].vWorldViewPosition.y + (unsigned int)a2);
-      v25 = (double)v37;
-      v24 = (double)v36;
-      if ( !_45BE86_build_light_polygon(
-              (int)&arg0,
-              v24,
-              v22,
-              v25,
-              v23,
-              &LightmapBuilder_static_sub_45BC07_stru_69B110,
-              uNumVertices,
-              (RenderVertexSoft *)a9,
-              a7) )
-      {
-        MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
-        v34 = 5080748;
-      }
-      a5 = (RenderVertexSoft *)((char *)a5 + 1);
-      ++v19;
+      MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
     }
-    while ( (signed int)a5 < a2->field_AC );
   }
-  return 1;
+  return true;
 }
 
 //----- (0045BE86) --------------------------------------------------------
-char LightmapBuilder::_45BE86_build_light_polygon(int arg0, float a4, int arg8, float a5, int uLightType, stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag)
+bool LightmapBuilder::_45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag)
 {
-  LightmapBuilder *v10; // esi@1
   Lightmap *v11; // edi@3
-  double v12; // st7@5
-  double v13; // st7@5
-  stru314 *v14; // ebx@5
-  double v15; // st7@5
-  RenderVertexSoft *pLightmapVertices; // edx@5
   double v17; // st7@5
-  double v18; // st7@5
-  char *v19; // eax@5
-  double v20; // st6@5
-  double v21; // st5@5
-  signed int v22; // ecx@5
-  double v23; // st5@5
   double v24; // st7@6
-  int v25; // ebx@8
-  double v26; // st7@8
-  int v27; // eax@8
-  double v28; // st6@8
-  double v29; // st6@8
-  double v30; // st5@8
   int v31; // eax@8
   int v32; // ebx@8
   unsigned int v33; // ecx@8
@@ -236,156 +132,103 @@
   double v38; // st7@14
   double v39; // st7@16
   double v40; // st7@16
-  double v41; // st7@22
-  stru9 *v42; // ecx@22
-  char result; // al@22
-  unsigned int *v44; // ebx@23
   int v45; // eax@24
-  RenderVertexSoft *v46; // edi@27
-  std::string *v47; // ecx@34
-  char *v48; // esi@39
-  int v49; // eax@39
-  unsigned __int8 v50; // sf@39
-  unsigned __int8 v51; // of@39
-  const char *v52; // [sp-Ch] [bp-58h]@34
   int v53; // [sp-8h] [bp-54h]@34
-  std::string v54; // [sp-4h] [bp-50h]@19
-  float v55; // [sp+0h] [bp-4Ch]@22
-  float v56; // [sp+4h] [bp-48h]@22
-  int v57; // [sp+8h] [bp-44h]@22
-  unsigned int v58; // [sp+Ch] [bp-40h]@16
-  void *v59; // [sp+10h] [bp-3Ch]@16
-  float v60; // [sp+20h] [bp-2Ch]@8
-  float v61; // [sp+24h] [bp-28h]@8
-  float v62; // [sp+28h] [bp-24h]@8
-  Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
-  //double v64; // [sp+38h] [bp-14h]@8
-  int pLightmapVertices_; // [sp+40h] [bp-Ch]@5
-  float v66; // [sp+44h] [bp-8h]@5
-  char v67; // [sp+4Bh] [bp-1h]@2
-  float arg0b; // [sp+54h] [bp+8h]@8
-  int arg0c; // [sp+54h] [bp+8h]@8
-  int arg0a; // [sp+54h] [bp+8h]@8
 
-  v10 = this;
-  if ( a4 == 0.0 )
-    return 1;
-  v67 = uLightType & 1;
+  if (fabsf(radius) < 1e-6f)
+    return true;
+
   v11 = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] :
                          &std__vector_183808[std__vector_183808_size];
-  v12 = a4 - a5;
-  this->flt_3C8C24 = v12;
-  v13 = sqrt((a4 + a4 - v12) * v12);
-  v10->flt_3C8C28 = v13;
-  v14 = a7;
-  v66 = 1.0 / a4;
-  v10->flt_3C8C2C = 1.0 - (a4 - v13) * v66;
-  v11->field_C08 = (signed __int64)((double)*(signed int *)arg0 - a5 * v14->field_4.x);
-  v11->field_C0A = (signed __int64)((double)*(signed int *)(arg0 + 4) - a5 * v14->field_4.y);
-  v15 = a4;
-  v11->field_C0C = (signed __int64)((double)*(signed int *)(arg0 + 8) - a5 * v14->field_4.z);
-  pLightmapVertices = v11->pVertices;
-  v17 = v15 * v10->flt_3C8C2C;
-  pLightmapVertices_ = (int)v11->pVertices;
-  v10->flt_3C8C30 = v17;
-  v10->flt_3C8C0C = v17 * v14->field_10.x;
-  v10->flt_3C8C10 = v17 * v14->field_10.y;
-  v10->flt_3C8C14 = v17 * v14->field_10.z;
-  v10->flt_3C8C18 = v17 * v14->field_1C.x;
-  v10->flt_3C8C1C = v17 * v14->field_1C.y;
-  v10->flt_3C8C20 = v17 * v14->field_1C.z;
-  LODWORD(a5) = v11->field_C08;
-  v18 = (double)SLODWORD(a5);
-  v11->pVertices[0].vWorldPosition.x = v18 - v10->flt_3C8C18 + v10->flt_3C8C0C;
-  LODWORD(a5) = v11->field_C0A;
-  v19 = (char *)&v11->pVertices[0].vWorldPosition.y;
-  v20 = (double)SLODWORD(a5);
-  v21 = v20 - v10->flt_3C8C1C;
-  LODWORD(a5) = v11->field_C0C;
-  v22 = 4;
-  v11->pVertices[0].vWorldPosition.y = v21 + v10->flt_3C8C10;
-  v23 = (double)SLODWORD(a5);
-  a5 = v23;
-  v11->pVertices[0].vWorldPosition.z = v23 - v10->flt_3C8C20 + v10->flt_3C8C14;
+  flt_3C8C24 = radius - dot_dist;
+  flt_3C8C28 = sqrt((radius + dot_dist) * (radius - dot_dist));
+  flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius;
+  v11->field_C08 = (double)pos->x - dot_dist * a7->field_4.x;
+  v11->field_C0A = (double)pos->y - dot_dist * a7->field_4.y;
+  v11->field_C0C = (double)pos->z - dot_dist * a7->field_4.z;
+
+  v17 = radius * flt_3C8C2C_lightmaps_brightness;
+  flt_3C8C30 = v17;
+  flt_3C8C0C = v17 * a7->field_10.x;
+  flt_3C8C10 = v17 * a7->field_10.y;
+  flt_3C8C14 = v17 * a7->field_10.z;
+  flt_3C8C18 = v17 * a7->field_1C.x;
+  flt_3C8C1C = v17 * a7->field_1C.y;
+  flt_3C8C20 = v17 * a7->field_1C.z;
+
+  /*
+  v11->pVertices[0].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C;
+  v11->pVertices[0].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10;
+  v11->pVertices[0].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14;
   v11->pVertices[0].u = 0.0;
   v11->pVertices[0].v = 0.0;
-  v11->pVertices[1].vWorldPosition.x = v18 - v10->flt_3C8C18 - v10->flt_3C8C0C;
-  v11->pVertices[1].vWorldPosition.y = v20 - v10->flt_3C8C1C - v10->flt_3C8C10;
-  v11->pVertices[1].vWorldPosition.z = v23 - v10->flt_3C8C20 - v10->flt_3C8C14;
+
+  v11->pVertices[1].vWorldPosition.x = v11->field_C08 - flt_3C8C18 - flt_3C8C0C;
+  v11->pVertices[1].vWorldPosition.y = v11->field_C0A - flt_3C8C1C - flt_3C8C10;
+  v11->pVertices[1].vWorldPosition.z = v11->field_C0C - flt_3C8C20 - flt_3C8C14;
   v11->pVertices[1].u = 0.0;
   v11->pVertices[1].v = 1.0;
-  v11->pVertices[2].vWorldPosition.x = v18 + v10->flt_3C8C18 - v10->flt_3C8C0C;
-  v11->pVertices[2].vWorldPosition.y = v20 + v10->flt_3C8C1C - v10->flt_3C8C10;
-  v11->pVertices[2].vWorldPosition.z = v23 + v10->flt_3C8C20 - v10->flt_3C8C14;
+
+  v11->pVertices[2].vWorldPosition.x = v11->field_C08 + flt_3C8C18 - flt_3C8C0C;
+  v11->pVertices[2].vWorldPosition.y = v11->field_C0A + flt_3C8C1C - flt_3C8C10;
+  v11->pVertices[2].vWorldPosition.z = v11->field_C0C + flt_3C8C20 - flt_3C8C14;
   v11->pVertices[2].u = 1.0;
   v11->pVertices[2].v = 1.0;
-  v11->pVertices[3].vWorldPosition.x = v18 + v10->flt_3C8C18 + v10->flt_3C8C0C;
-  v11->pVertices[3].vWorldPosition.y = v20 + v10->flt_3C8C1C + v10->flt_3C8C10;
-  v11->pVertices[3].vWorldPosition.z = a5 + v10->flt_3C8C20 + v10->flt_3C8C14;
+
+  v11->pVertices[3].vWorldPosition.x = v11->field_C08 + flt_3C8C18 + flt_3C8C0C;
+  v11->pVertices[3].vWorldPosition.y = v11->field_C0A + flt_3C8C1C + flt_3C8C10;
+  v11->pVertices[3].vWorldPosition.z = v11->field_C0C + flt_3C8C20 + flt_3C8C14;
   v11->pVertices[3].u = 1.0;
   v11->pVertices[3].v = 0.0;
-  do
-  {
-    v24 = v14->field_4.y * *(float *)v19
-        + *((float *)v19 + 1) * v14->field_4.z
-        + v14->field_4.x * *((float *)v19 - 1)
-        + *(float *)&v14->field_28;
-    *((float *)v19 - 1) = *((float *)v19 - 1) - v24 * v14->field_4.x;
-    *(float *)v19 = *(float *)v19 - v24 * v14->field_4.y;
-    v19 += 48;
-    --v22;
-    *((float *)v19 - 11) = *((float *)v19 - 11) - v24 * v14->field_4.z;
-  }
-  while ( v22 );
-  v11->field_C10 = arg8;
-  v11->uNumVertices = 4;
-  if ( pGame->uFlags2 & 4 )
+  */
+
+  for (uint i = 0; i < 4; ++i)
   {
-    LODWORD(a5) = v11->field_C0C;
-    v25 = arg0;
-    v26 = (double)SLODWORD(a5);
-    LODWORD(a5) = v11->field_C0A;
-    v27 = v11->field_C08;
-    a5 = (double)SLODWORD(a5);
-    arg8 = v27;
-    v28 = (double)v27;
-    v61 = a5;
-    v60 = v28;
-    v62 = v26;
-    *(float *)&arg8 = (double)*(signed int *)(arg0 + 8);
-    arg0b = (double)*(signed int *)(arg0 + 4);
-    v29 = (double)*(signed int *)v25 - v28;
-    v30 = arg0b - a5;
-    a5 = *(float *)&arg8 - v26;
-    a1.x = v29;
-    a1.z = a5;
-    a1.y = v30;
+    v11->pVertices[i].vWorldPosition.x = v11->field_C08 - flt_3C8C18 + flt_3C8C0C;
+    v11->pVertices[i].vWorldPosition.y = v11->field_C0A - flt_3C8C1C + flt_3C8C10;
+    v11->pVertices[i].vWorldPosition.z = v11->field_C0C - flt_3C8C20 + flt_3C8C14;
+    v11->pVertices[i].u = 0.0;
+    v11->pVertices[i].v = 0.0;
+
+    v24 = a7->field_4.y * v11->pVertices[i].vWorldPosition.y
+        + a7->field_4.z * v11->pVertices[i].vWorldPosition.z
+        + a7->field_4.x * v11->pVertices[i].vWorldPosition.x
+        + a7->dist;
+
+    v11->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x;
+    v11->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y;
+    v11->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z;
+  }
+
+  v11->uColorMask = uColorMask;
+  v11->uNumVertices = 4;
+
+  if (~pGame->uFlags2 & 4)
+    v11->fBrightness = flt_3C8C2C_lightmaps_brightness;
+  else
+  {
+    Vec3_float_ a1; // [sp+2Ch] [bp-20h]@8
+    a1.x = (double)pos->x - v11->field_C08;
+    a1.y = (double)pos->y - v11->field_C0A;
+    a1.z = (double)pos->z - v11->field_C0C;
     a1.Normalize();
-    //v64 = v62 + 6.7553994e15;
-    //LODWORD(a5) = LODWORD(v64);
-    LODWORD(a5) = floorf(v62 + 0.5f);
-    //v64 = v61 + 6.7553994e15;
-    //arg0c = LODWORD(v64);
-    arg0c = floorf(v61 + 0.5f);
-    //v64 = v60 + 6.7553994e15;
-    //arg8 = LODWORD(v64);
-    arg8 = floorf(v60 + 0.5f);
-    auto v64 /*HIDWORD(v64)*/ = abs(*(int *)(v25 + 8) - (signed)LODWORD(a5));
-    arg0a = abs(*(int *)(v25 + 4) - arg0c);
-    v31 = abs(*(int *)v25 - arg8);
-    LODWORD(a5) = v31;
-    v32 = arg0a;
-    v33 = v64;//HIDWORD(v64);
-    if ( v31 < arg0a )
+
+    auto dist_x = abs(pos->x - v11->field_C08), //v31
+         dist_y = abs(pos->y - v11->field_C0A), //v32  arg0a
+         dist_z = abs(pos->z - v11->field_C0C); //v33  _v64
+    v31 = dist_x;
+    v32 = dist_y;
+    v33 = dist_z;
+    if (v31 < dist_y)
     {
       v34 = v31;
-      v31 = arg0a;
+      v31 = dist_y;
       v32 = v34;
     }
-    if ( v31 < v64)//SHIDWORD(v64) )
+    if (v31 < dist_z)//SHIDWORD(v64) )
     {
       v35 = v31;
-      v31 = v64;//HIDWORD(v64);
+      v31 = dist_z;//HIDWORD(v64);
       v33 = v35;
     }
     if ( v32 < (signed int)v33 )
@@ -395,118 +238,112 @@
       v32 = v36;
     }
     v37 = v33 >> 2;
-    LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31;
-    v38 = (double)SLODWORD(a5);
-    if ( v38 > a4 )
-      return 1;
-    a4 = v66 * v38;
+    //LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31;
+    v38 = (double)(signed)(((unsigned int)(11 * v32) >> 5) + v37 + v31);
+    if (v38 > radius)
+      return true;
+    //radius = (1 / radius) * v38;
     if ( uLightType & 4 )
     {
-      v59 = (void *)v37;
-      uLightType = dword_4D86CC;
-      v58 = v37;
+      //v59 = (void *)v37;
+      //uLightType = flt_4D86CC;
+      //v58 = v37;
       v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y);
-      v40 = v39 * 1.0 * *(float *)&uLightType;
+      v40 = v39 * 1.0 * flt_4D86CC;
+
+      v11->fBrightness = v40 - (1 / radius) * v38 * v40;
+    }
+    else if ( uLightType & 8 )
+    {
+        v40 = 1.0 * 1.0;
+        v11->fBrightness = v40 - (1 / radius) * v38;
     }
     else
     {
-      if ( uLightType & 8 )
-      {
-        v40 = 1.0 * 1.0;
-      }
-      else
-      {
         MessageBoxW(nullptr, L"Invalid light type!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:277", 0);
-        v40 = *(float *)&uLightType;
-      }
     }
-    v14 = a7;
-    pLightmapVertices = (RenderVertexSoft *)pLightmapVertices_;
-    v11->flt_C14 = v40 - a4 * v40;
-  }
-  else
-  {
-    v11->flt_C14 = v10->flt_3C8C2C;
   }
-  v41 = v14->field_4.z;
-  v42 = pGame->pStru9Instance;
-  v59 = &v11->uNumVertices;
-  v58 = (unsigned int)pLightmapVertices;
-  *(float *)&v57 = v41;
-  v56 = v14->field_4.y;
-  v55 = v14->field_4.x;
-  result = v42->_4980B9(a9, a2, v55, v56, *(float *)&v57, pLightmapVertices, &v11->uNumVertices);
-  if ( !result )
-    return result;
-  v44 = &v11->uNumVertices;
-  if ( !v11->uNumVertices )
-    return 1;
-  v45 = v10->_45C6D6(a2, a9, v11);
-  if ( v45 != a2 && v45 > 0 )
-    v10->_45C4B9(a2, a9, v11);
-  v59 = (void *)*v44;
-  v46 = (RenderVertexSoft *)pLightmapVertices_;
-  pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)pLightmapVertices_, (unsigned int)v59);
-  v59 = 0;
-  v58 = *v44;
-  pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(v46, v58, 0);
+
+  if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices,
+                                      a7->field_4.x, a7->field_4.y, a7->field_4.z,
+                                      v11->pVertices, &v11->uNumVertices))
+    return false;
+
+  //v44 = &v11->uNumVertices;
+  if (!v11->uNumVertices)
+    return true;
+
+  v45 = _45C6D6(uNumVertices, a9, v11);
+  if ( v45 != uNumVertices && v45 > 0 )
+    _45C4B9(uNumVertices, a9, v11);
+  //v59 = v11->uNumVertices;
+  //v46 = (RenderVertexSoft *)pLightmapVertices_;
+  pGame->pIndoorCameraD3D->ViewTransform(v11->pVertices, v11->uNumVertices);
+  //v59 = 0;
+  //v58 = v11->uNumVertices;
+  pGame->pIndoorCameraD3D->Project(v11->pVertices, v11->uNumVertices, 0);
+
+  unsigned int _a4 = 0;
   if ( !(uClipFlag & 1) )
-    goto LABEL_38;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    _a4 = 1;
+  else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
     if ( uClipFlag & 2 )
     {
-      v59 = &a4;
-      v58 = (unsigned int)v10->field_3C8C34;
-      v57 = *v44;
-      pGame->pIndoorCameraD3D->_436CDC(v46, v57, v10->field_3C8C34, (unsigned int *)&a4);
-LABEL_33:
-      v59 = v44;
-      v58 = (unsigned int)v10->field_3C8C34;
-      v57 = (int)v46;
-      v56 = a4;
-      pGame->pIndoorCameraD3D->_437143(LODWORD(a4), v46, v10->field_3C8C34, v44);
-      goto LABEL_37;
+      //v59 = &a4;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = *v44;
+      pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4);
+
+      //v59 = v44;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = (int)v46;
+      //v56 = a4;
+      pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices);
     }
-    if ( uClipFlag & 4 )
+    else if ( uClipFlag & 4 )
     {
-      v59 = &a4;
-      v58 = (unsigned int)v10->field_3C8C34;
-      v57 = *v44;
-      pGame->pIndoorCameraD3D->_436F09(v46, v57, v10->field_3C8C34, (unsigned int *)&a4);
-      goto LABEL_33;
+      //v59 = &a4;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = *v44;
+      pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v11->pVertices, v11->uNumVertices, field_3C8C34, &_a4);
+
+      //v59 = v44;
+      //v58 = (unsigned int)field_3C8C34;
+      //v57 = (int)v46;
+      //v56 = a4;
+      pGame->pIndoorCameraD3D->_437143(_a4, v11->pVertices, field_3C8C34, &v11->uNumVertices);
     }
-    v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330";
-    v52 = "Undefined clip flag specified";
+    else
+      MessageBoxW(nullptr, L"Undefined clip flag specified", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:330", 0);
   }
   else
-  {
-    v58 = (unsigned int)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335";
-    v52 = "Lightpoly builder native indoor clipping not implemented";
-  }
-  MessageBoxA(nullptr, v52, (const char *)v58, 0);
-LABEL_37:
-  if ( a4 != 0.0 )
+    MessageBoxW(nullptr, L"Lightpoly builder native indoor clipping not implemented", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:335", 0);
+
+  if (_a4)
   {
-LABEL_38:
-    if ( v67 )
+    if (uLightType & 1)
     {
-      v48 = (char *)&v10->std__vector_000004_size;
-      v49 = *(unsigned int *)v48;
-      v51 = __OFSUB__(*(unsigned int *)v48, 511);
-      v50 = *(unsigned int *)v48 - 511 < 0;
+      //v48 = (char *)&std__vector_000004_size;
+      //v49 = std__vector_000004_size;
+      //v51 = __OFSUB__(std__vector_000004_size, 511);
+      //v50 = std__vector_000004_size - 511 < 0;
+      if (std__vector_000004_size < 512 - 1)
+        ++std__vector_000004_size;
     }
     else
     {
-      v48 = (char *)&v10->std__vector_183808_size;
-      v49 = *(unsigned int *)v48;
-      v51 = __OFSUB__(*(unsigned int *)v48, 767);
-      v50 = *(unsigned int *)v48 - 767 < 0;
+      //v48 = (char *)&std__vector_183808_size;
+      //v49 = std__vector_183808_size;
+      //v51 = __OFSUB__(std__vector_183808_size, 767);
+      //v50 = std__vector_183808_size - 767 < 0;
+      if (std__vector_183808_size < 768 - 1)
+        ++std__vector_183808_size;
     }
-    if ( v50 ^ v51 )
-      *(unsigned int *)v48 = v49 + 1;
+    //if ( v50 ^ v51 )
+    //  *(unsigned int *)v48 = v49 + 1;
   }
-  return 1;
+  return true;
 }
 
 //----- (0045C4B9) --------------------------------------------------------
@@ -724,139 +561,82 @@
 //----- (0045C7F6) --------------------------------------------------------
 bool LightmapBuilder::ApplyLights_IndoorFace(unsigned int uFaceID)
 {
-  BLVFace *pFace; // esi@1
-  int v3; // ebx@1
-  int uSectorID; // edi@1
-  int v5; // ecx@5
-  BLVLightMM7 *v6; // eax@7
-  int v7; // edi@10
-  bool result; // eax@14
-  LightmapBuilder *thisa; // [sp+Ch] [bp-Ch]@1
-  MobileLight *pMobileLight; // [sp+10h] [bp-8h]@2
-  int uSectLights; // [sp+10h] [bp-8h]@5
-  StationaryLight *pStationaryLight; // [sp+10h] [bp-8h]@11
-  int v13; // [sp+14h] [bp-4h]@1
-  int i; // [sp+14h] [bp-4h]@5
+  auto pFace = &pIndoor->pFaces[uFaceID];
+  auto pSector = pIndoor->pSectors + pFace->uSectorID;
+
+  stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;
 
-  pFace = &pIndoor->pFaces[uFaceID];
-  v3 = uNumMobileLightsApplied;
-  v13 = 0;
-  thisa = this;
-  uSectorID = pFace->uSectorID;
-  uFaceID = 0;
-  stru_F8AD28.field_2C = (stru_F8AD28.field_3F8 + pIndoor->pSectors[uSectorID].uMinAmbientLightLevel) << 16;
-  if ( uNumMobileLightsApplied > 0 )
+  uint uNumLightsApplied = 0;
+  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
+  {
+    if (uNumLightsApplied >= 20)
+      break;
+
+    ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0);
+  }
+
+  for (uint i = 0; i < pSector->uNumLights; ++i)
   {
-    pMobileLight = pMobileLights;
-    do
-    {
-      if ( (signed int)uFaceID >= 20 )
-        break;
-      ApplyLight_BLV((StationaryLight *)pMobileLight, pFace, &uFaceID, 1, 0);
-      ++v13;
-      ++pMobileLight;
-    }
-    while ( v13 < v3 );
-  }
-  v5 = 0;
-  i = 0;
-  for ( uSectLights = pIndoor->pSectors[uSectorID].uNumLights; i < uSectLights; v5 = i++ + 1 )
-  {
-    if ( (signed int)uFaceID >= 20 )
+    if (uNumLightsApplied >= 20 )
       break;
-    v6 = &pIndoor->pLights[*(&pIndoor->pSectors[uSectorID].pLights->vPosition.x + v5)];
-    if ( !(v6->uAtributes & 8) )
-      ApplyLight_BLV((StationaryLight *)v6, pFace, &uFaceID, 0, (int)&byte_4E94D0);
+
+    auto pLight = &pIndoor->pLights[pSector->pLights[i]];
+    if (~pLight->uAtributes & 0x08)
+      ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &byte_4E94D0);
   }
-  v7 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
+
+  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
   {
-    pStationaryLight = pStationaryLights;
-    do
-    {
-      if ( (signed int)uFaceID >= 20 )
-        break;
-      ApplyLight_BLV(pStationaryLight, pFace, &uFaceID, 0, (int)&byte_4E94D0);
-      ++pStationaryLight;
-      ++v7;
-    }
-    while ( v7 < uNumStationaryLightsApplied );
+    if (uNumLightsApplied >= 20)
+      break;
+
+    ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &byte_4E94D0);
   }
-  result = uFaceID;
-  stru_F8AD28.field_AC = uFaceID;
-  LOBYTE(result) = 1;
-  return result;
+
+  stru_F8AD28.uNumLightsApplied = uNumLightsApplied;
+  return true;
 }
-// 4E94D0: using guessed type char byte_4E94D0;
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
 
 //----- (0045C911) --------------------------------------------------------
-bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, char X, int a5)
+bool LightmapBuilder::ApplyLight_BLV(StationaryLight *pLight, BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5)
 {
-  BLVFace *result; // eax@0
-  StationaryLight *v7; // edi@1
-  signed int v8; // ecx@1
-  int v9; // edx@2
-  int v10; // edx@4
-  int v11; // esi@4
-  int v12; // edx@6
   double v13; // st7@8
-  __int16 v14; // fps@8
-  char v15; // c0@9
-  char v16; // c2@9
-  char v17; // c3@9
-  double v18; // st6@12
-  __int16 v19; // fps@12
-  char v20; // c0@12
-  char v21; // c2@12
-  char v22; // c3@12
-  signed int v23; // [sp+10h] [bp-4h]@2
-  //float pLighta; // [sp+1Ch] [bp+8h]@13
-  signed int a2a; // [sp+20h] [bp+Ch]@4
+
+  if (!pLight->uRadius)
+    return false;
 
-  v7 = pLight;
-  v8 = pLight->uRadius;
-  if ( v8 > 0
-    && (result = a2, v9 = pLight->vPosition.x, v23 = v9, v9 > a2->pBounding.x1 - v8)
-    && v9 < v8 + a2->pBounding.x2
-    && (v10 = pLight->vPosition.y, v11 = a2->pBounding.y1 - v8, a2a = v10, v10 > v11)
-    && v10 < v8 + result->pBounding.y2
-    && (v12 = pLight->vPosition.z, v12 > result->pBounding.z1 - v8)
-    && v12 < v8 + result->pBounding.z2
-    && ((v13 = (double)v12 * result->pFacePlane.vNormal.z
-             + (double)a2a * result->pFacePlane.vNormal.y
-             + (double)v23 * result->pFacePlane.vNormal.x
-             + result->pFacePlane.dist,
-         //UNDEF(v14),
-         X)
-     || (v15 = v13 < 0.0, v16 = 0, v17 = v13 == 0.0, BYTE1(result) = HIBYTE(v14), v13 >= 0.0))
-    && (v18 = (double)pLight->uRadius,
-        //UNDEF(v19),
-        v20 = v13 < v18,
-        v21 = 0,
-        v22 = v13 == v18,
-        BYTE1(result) = HIBYTE(v19),
-        v13 <= v18) )
+  if (pLight->vPosition.x > a2->pBounding.x1 - pLight->uRadius &&
+      pLight->vPosition.x < a2->pBounding.x2 + pLight->uRadius &&
+      pLight->vPosition.y > a2->pBounding.y1 - pLight->uRadius &&
+      pLight->vPosition.y < a2->pBounding.y2 + pLight->uRadius &&
+      pLight->vPosition.z > a2->pBounding.z1 - pLight->uRadius &&
+      pLight->vPosition.z < a2->pBounding.z2 + pLight->uRadius)
   {
-    stru_F8AD28._blv_lights_radii[*pSlot] = v8;
-    stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / v8;
-    stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x;
-    stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y;
-    stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z;
-    stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689;
-    stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
-    stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
-    //pLighta = v13;
-    stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v13 + 0.5f));//COERCE_UNSIGNED_INT64(pLighta + 6.7553994e15));
-    result = (BLVFace *)*pSlot;
-    stru_F8AD28._blv_lights_smthngs[(*pSlot)++] = v7->field_B;
-    LOBYTE(result) = 1;
+    v13 = (double)pLight->vPosition.z * a2->pFacePlane.vNormal.z +
+          (double)pLight->vPosition.y * a2->pFacePlane.vNormal.y +
+          (double)pLight->vPosition.x * a2->pFacePlane.vNormal.x +
+          a2->pFacePlane.dist;
+    if ((bLightBackfaces || v13 >= 0.0f) && fabsf(v13) <= pLight->uRadius)
+    {
+      auto slot = *pSlot;
+
+      stru_F8AD28._blv_lights_radii[slot] = pLight->uRadius;
+      stru_F8AD28._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius;
+      stru_F8AD28._blv_lights_xs[slot] = pLight->vPosition.x;
+      stru_F8AD28._blv_lights_ys[slot] = pLight->vPosition.y;
+      stru_F8AD28._blv_lights_zs[slot] = pLight->vPosition.z;
+      stru_F8AD28._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f;
+      stru_F8AD28._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f;
+      stru_F8AD28._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f;
+      stru_F8AD28._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f));
+      stru_F8AD28._blv_lights_types[slot] = pLight->uLightType;
+
+      *pSlot += 1;
+      return true;
+    }
   }
-  else
-  {
-    LOBYTE(result) = 0;
-  }
-  return (bool)result;
+
+  return false;
 }
 
 //----- (0045CA88) --------------------------------------------------------
@@ -900,7 +680,7 @@
     v19 = v9;
     v20 = v8;
     v7->flt_2C = 0.0;
-    if ( a2->field_AC > 0 )
+    if ( a2->uNumLightsApplied > 0 )
     {
       v10 = (char *)a2->_blv_lights_ys;
       for ( j = a2->_blv_lights_ys; ; v10 = (char *)j )
@@ -910,7 +690,7 @@
         HIDWORD(v12) = *(unsigned int *)v10;
         LODWORD(v13) = *((unsigned int *)v10 + 60);
         v14 = a3a;
-        LOBYTE(v14) = v6->_blv_lights_smthngs[a3a];
+        LOBYTE(v14) = v6->_blv_lights_types[a3a];
         v15 = v11;
         *(_QWORD *)&v16.x = v12;
         v16.z = v13;
@@ -919,7 +699,7 @@
         ++a3a;
         ++j;
         v7->flt_2C = v17;
-        if ( a3a >= a2->field_AC )
+        if ( a3a >= a2->uNumLightsApplied )
           break;
         v6 = a2;
       }
@@ -1135,12 +915,12 @@
 
   v2 = 0;
   thisa = this;
-  v3 = stru_F8AD28.field_3F8 + pFace->uShadeType;
+  v3 = stru_F8AD28.uDefaultAmbientLightLevel + pFace->uShadeType;
   pSlot = 0;
-  stru_F8AD28.field_2C = v3 << 16;
-  if ( uNumMobileLightsApplied > 0 )
+  stru_F8AD28.uCurrentAmbientLightLevel = v3 << 16;
+  if ( pMobileLightsStack->uNumLightsActive > 0 )
   {
-    pMobileLight = pMobileLights;
+    pMobileLight = pMobileLightsStack->pLights;
     do
     {
       if ( pSlot >= 20 )
@@ -1149,12 +929,12 @@
       ++v2;
       ++pMobileLight;
     }
-    while ( v2 < uNumMobileLightsApplied );
+    while ( v2 < pMobileLightsStack->uNumLightsActive );
   }
   v5 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
+  if ( pStationaryLightsStack->uNumLightsActive > 0 )
   {
-    pStationaryLight = pStationaryLights;
+    pStationaryLight = pStationaryLightsStack->pLights;
     do
     {
       if ( pSlot >= 20 )
@@ -1163,14 +943,12 @@
       ++v5;
       ++pStationaryLight;
     }
-    while ( v5 < uNumStationaryLightsApplied );
+    while ( v5 < pStationaryLightsStack->uNumLightsActive );
   }
   result = pSlot;
-  stru_F8AD28.field_AC = pSlot;
-  LOBYTE(result) = 1;
-  return result;
+  stru_F8AD28.uNumLightsApplied = pSlot;
+  return true;
 }
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
 
 //----- (0045CE50) --------------------------------------------------------
 bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4)
@@ -1186,6 +964,8 @@
   RenderD3D *v13; // ecx@11
   char v14; // dl@11
 
+  __debugbreak();
+
   v6 = pLight->uRadius;
   if ( v6 > 0
     && (result = (int)pFace, v7 = pLight->vPosition.x, v7 > pFace->pBoundingBox.x1 - v6)
@@ -1213,16 +993,16 @@
     v11 = abs(v10);
     v12 = pRenderer->bUsingSpecular;
     stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = v11;
-    stru_F8AD28._blv_lights_smthngs[*pSlot] = pLight->field_B;
+    stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType;
     v13 = pRenderer->pRenderD3D;
-    v14 = stru_F8AD28._blv_lights_smthngs[*pSlot];
+    v14 = stru_F8AD28._blv_lights_types[*pSlot];
     if ( pRenderer->pRenderD3D && v12 && v14 & 4 )
-      v14 = byte_4E94D2;
-    stru_F8AD28._blv_lights_smthngs[*pSlot] = v14;
+      v14 = _4E94D2_light_type;
+    stru_F8AD28._blv_lights_types[*pSlot] = v14;
     result = 4 * *pSlot;
     if ( v13 && v12 )
     {
-      if ( stru_F8AD28._blv_lights_smthngs[*pSlot] & 4 )
+      if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 )
       {
         *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
                                                                 * 0.33000001;
@@ -1241,54 +1021,53 @@
   }
   return result;
 }
-// 4E94D2: using guessed type char byte_4E94D2;
+// 4E94D2: using guessed type char _4E94D2_light_type;
 
 //----- (0045D036) --------------------------------------------------------
-bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X)
+bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces)
 {
   int v6; // esi@1
-  LightmapBuilder *v7; // edi@1
+  //LightmapBuilder *v7; // edi@1
   MobileLight *v8; // ebx@2
   int v9; // esi@5
   StationaryLight *v10; // ebx@6
-  bool result; // eax@9
+  //bool result; // eax@9
   unsigned int a7; // [sp+Ch] [bp-4h]@1
 
   v6 = 0;
-  v7 = this;
+  //v7 = this;
   a7 = 0;
-  stru_F8AD28.field_2C = pOutdoor->field_CBC_terrain_triangles_shade_type;
-  if ( uNumMobileLightsApplied > 0 )
+  stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type;
+  if ( pMobileLightsStack->uNumLightsActive > 0 )
   {
-    v8 = pMobileLights;
+    v8 = pMobileLightsStack->pLights;
     do
     {
       if ( (signed int)a7 >= 20 )
         break;
-      StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, X, &a7);
+      StackLight_TerrainFace((StationaryLight *)v8, pNormal, a3, a1, uStripType, bLightBackfaces, &a7);
       ++v6;
       ++v8;
     }
-    while ( v6 < uNumMobileLightsApplied );
+    while ( v6 < pMobileLightsStack->uNumLightsActive );
   }
   v9 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
+  if ( pStationaryLightsStack->uNumLightsActive > 0 )
   {
-    v10 = pStationaryLights;
+    v10 = pStationaryLightsStack->pLights;
     do
     {
       if ( (signed int)a7 >= 20 )
         break;
-      StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, X, &a7);
+      StackLight_TerrainFace(v10, pNormal, a3, a1, uStripType, bLightBackfaces, &a7);
       ++v9;
       ++v10;
     }
-    while ( v9 < uNumStationaryLightsApplied );
+    while ( v9 < pStationaryLightsStack->uNumLightsActive );
   }
-  result = a7;
-  stru_F8AD28.field_AC = a7;
-  LOBYTE(result) = 1;
-  return result;
+
+  stru_F8AD28.uNumLightsApplied = a7;
+  return true;
 }
 // 519AB4: using guessed type int uNumStationaryLightsApplied;
 
@@ -1481,16 +1260,16 @@
   v54 = abs(v60);
   v55 = pRenderer->bUsingSpecular;
   stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54;
-  stru_F8AD28._blv_lights_smthngs[*v53] = v8->field_B;
+  stru_F8AD28._blv_lights_types[*v53] = v8->uLightType;
   v56 = pRenderer->pRenderD3D;
-  v57 = stru_F8AD28._blv_lights_smthngs[*v53];
+  v57 = stru_F8AD28._blv_lights_types[*v53];
   if ( pRenderer->pRenderD3D && v55 && v57 & 4 )
-    v57 = byte_4E94D2;
-  stru_F8AD28._blv_lights_smthngs[*v53] = v57;
+    v57 = _4E94D2_light_type;
+  stru_F8AD28._blv_lights_types[*v53] = v57;
   result = 4 * *v53;
   if ( v56 && v55 )
   {
-    if ( stru_F8AD28._blv_lights_smthngs[*v53] & 4 )
+    if ( stru_F8AD28._blv_lights_types[*v53] & 4 )
     {
       *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result)
                                                               * 0.33000001;
@@ -1504,7 +1283,7 @@
   LOBYTE(result) = 1;
   return result;
 }
-// 4E94D2: using guessed type char byte_4E94D2;
+// 4E94D2: using guessed type char _4E94D2_light_type;
 
 //----- (0045D3C7) --------------------------------------------------------
 bool LightmapBuilder::_45D3C7(stru148 *a1)
@@ -1783,7 +1562,7 @@
   char v3; // zf@1
   IDirect3DDevice3 *v4; // eax@2
   HRESULT v5; // eax@2
-  char *v6; // eax@2
+  //char *v6; // eax@2
   struct IDirect3DTexture2 *v7; // edi@4
   HRESULT v8; // eax@8
   HRESULT v9; // eax@8
@@ -1800,13 +1579,13 @@
   HRESULT v20; // eax@21
   IDirect3DDevice3 *v21; // eax@21
   HRESULT v22; // eax@21
-  IDirect3DDevice3 *v23; // eax@23
+  //IDirect3DDevice3 *v23; // eax@23
   std::string v25; // [sp+44h] [bp-44h]@12
   signed int v26; // [sp+48h] [bp-40h]@21
   signed int v27; // [sp+4Ch] [bp-3Ch]@21
   Lightmap *v28; // [sp+50h] [bp-38h]@2
   int v29; // [sp+54h] [bp-34h]@2
-  float v30; // [sp+58h] [bp-30h]@2
+  //float v30; // [sp+58h] [bp-30h]@2
   int arg4; // [sp+68h] [bp-20h]@8
   float v32; // [sp+6Ch] [bp-1Ch]@8
   float v33; // [sp+70h] [bp-18h]@8
@@ -1820,13 +1599,13 @@
   LODWORD(v38) = (int)this;
   if ( !v3 )
   {
-    v30 = 0.0;
+    //v30 = 0.0;
     //v4 = pRenderer->pRenderD3D->pDevice;
     ErrD3D(v4->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
-    v6 = (char *)stru_69BD44.c_str();
-    if ( !stru_69BD44.c_str() )
-      v6 = (char *)&dword_4D86F0;
-    v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v6);
+    //v6 = (char *)stru_69BD44.c_str();
+    //if ( !stru_69BD44.c_str() )
+    //  v6 = (char *)&dword_4D86F0;
+    v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
     if ( pRenderer->bUsingSpecular )
       pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
     if ( !byte_4D864C || !(pGame->uFlags & 1) )
@@ -1892,253 +1671,134 @@
       //LODWORD(v30) = 1;
       //v29 = 28;
       //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1);
-      v30 = pRenderer->uFogColor;
-      v23 = pRenderer->pRenderD3D->pDevice;
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1));
+      //v30 = pRenderer->uFogColor;
+      //v23 = pRenderer->pRenderD3D->pDevice;
       //v29 = 34;
       //v28 = (Lightmap *)v23;
-      v23->SetRenderState(D3DRENDERSTATE_FOGCOLOR, LODWORD(pRenderer->uFogColor));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, pRenderer->uFogColor));
       //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, false);
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, false));
     }
   }
   return 1;
 }
-// 4D864C: using guessed type char byte_4D864C;
-// 4D86F0: using guessed type int dword_4D86F0;
+
 
 //----- (0045DA56) --------------------------------------------------------
-bool LightmapBuilder::DrawLightmaps2(float a2)
+bool LightmapBuilder::DrawLightmaps2(float z_bias)
 {
-  LightmapBuilder *v2; // esi@1
-  bool result; // eax@1
-  signed int v4; // edi@2
-  std::string v5; // [sp-14h] [bp-3Ch]@5
-  const char *v6; // [sp-4h] [bp-2Ch]@5
-  int v7; // [sp+0h] [bp-28h]@5
   Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2
-  std::string *v9; // [sp+18h] [bp-10h]@5
-  unsigned int v10; // [sp+1Ch] [bp-Ch]@5
-  Lightmap *a1; // [sp+20h] [bp-8h]@3
-  int a3; // [sp+27h] [bp-1h]@5
+  v.z = 1.0;
+  v.y = 1.0;
+  v.x = 1.0;
+  
+  for (uint i = 0; i < std__vector_183808_size; ++i)
+    if (!DrawLightmap(std__vector_183808 + i, &v, z_bias))
+      MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0);
 
-  v2 = this;
-  result = this->std__vector_183808_size;
-  if ( result )
-  {
-    v4 = 0;
-    v.z = 1.0;
-    v.y = 1.0;
-    v.x = 1.0;
-    if ( result > 0 )
-    {
-      a1 = this->std__vector_183808;
-      do
-      {
-        result = DrawLightmap(a1, &v, a2);
-        if ( !result )
-        {
-          MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0);
-          v10 = 0x4D86ECu;
-        }
-        ++a1;
-        ++v4;
-      }
-      while ( v4 < (signed int)v2->std__vector_183808_size);
-    }
-  }
-  LOBYTE(result) = 1;
-  return result;
+  return true;
 }
 
 //----- (0045DAE8) --------------------------------------------------------
-bool LightmapBuilder::DrawLightmap(Lightmap *a1, Vec3_float_ *arg4, float thisa)
+bool LightmapBuilder::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias)
 {
-  Lightmap *v4; // edx@1
-  bool result; // eax@2
-  double v6; // st7@3
-  Vec3_float_ *v7; // ecx@3
-  LEVEL_TYPE v8; // edi@3
-  int v9; // esi@3
   double v10; // st7@4
-  unsigned int v11; // ebx@6
-  char *v12; // ecx@7
-  int v13; // edx@7
   double v14; // st7@7
   __int16 v15; // fps@8
-  unsigned __int8 v16; // c2@8
-  unsigned __int8 v17; // c3@8
   double v18; // st3@8
-  int v19; // eax@11
-  double v20; // st3@11
-  int v21; // eax@11
-  char v22; // zf@11
-  HRESULT v23; // eax@15
   signed int v24; // [sp-1Ch] [bp-670h]@13
   const char *v25; // [sp-18h] [bp-66Ch]@13
   int v26; // [sp-14h] [bp-668h]@13
-  HRESULT a2; // [sp+0h] [bp-654h]@15
-  char v28; // [sp+4h] [bp-650h]@7
-  double v29; // [sp+640h] [bp-14h]@3
-  __int64 v30; // [sp+648h] [bp-Ch]@3
-  float v31; // [sp+650h] [bp-4h]@3
-  signed int a1b; // [sp+65Ch] [bp+8h]@3
-  float a1c; // [sp+65Ch] [bp+8h]@3
-  float a1d; // [sp+65Ch] [bp+8h]@3
-  float a1e; // [sp+65Ch] [bp+8h]@3
-  unsigned int a1a; // [sp+65Ch] [bp+8h]@7
-  int arg4a; // [sp+660h] [bp+Ch]@3
+  RenderVertexD3D3 a2[32]; // [sp+0h] [bp-654h]@7
 
-  v4 = a1;
-  if ( (signed int)a1->uNumVertices >= 3 )
+
+  if (pLightmap->uNumVertices < 3)
   {
-    v6 = (double)BYTE1(a1->field_C10) * a1->flt_C14;
-    v30 = a1->field_C10 & 0xFFi64;
-    a1b = BYTE2(a1->field_C10);
-    v7 = arg4;
-    //v31 = v6;
-    *((float *)&v30 + 1) = (double)v30 * v4->flt_C14;
-    a1c = (double)a1b * v4->flt_C14 * arg4->x;
-    //v29 = a1c + 6.7553994e15;
-    //arg4a = LODWORD(v29);
-    arg4a = floorf(a1c + 0.5f);
+    Log::Warning(L"Lightmap uNumVertices < 3");
+    return false;
+  }
 
-    a1d = v6 * v7->y;
-    v29 = a1d + 6.7553994e15;
-    LODWORD(v31) = LODWORD(v29);
-
-    a1e = *((float *)&v30 + 1) * v7->z;
-
-    v29 = a1e + 6.7553994e15;
-    HIDWORD(v30) = LODWORD(v29);
+  uint uLightmapColorMaskR = (pLightmap->uColorMask >> 16) & 0xFF;
+  uint uLightmapColorR = floorf(uLightmapColorMaskR * pLightmap->fBrightness * pColorMult->x + 0.5f);
+  
+  uint uLightmapColorMaskG = (pLightmap->uColorMask >> 8) & 0xFF;
+  uint uLightmapColorG = floorf(uLightmapColorMaskG * pLightmap->fBrightness * pColorMult->y + 0.5f);
+ 
+  uint uLightmapColorMaskB = pLightmap->uColorMask & 0xFF;
+  uint uLightmapColorB = floorf(uLightmapColorMaskB * pLightmap->fBrightness * pColorMult->z + 0.5f);
+ 
+  uint uLightmapColor = uLightmapColorB | (uLightmapColorMaskG << 8) | (uLightmapColorMaskR << 16);
 
-    v8 = uCurrentlyLoadedLevelType;
-    v9 = LODWORD(v29) | ((LODWORD(v31) | (arg4a << 8)) << 8);
-    if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-      v10 = (double)pOutdoorCamera->shading_dist_mist;
-    else
-      v10 = 16192.0;
-    v11 = v4->uNumVertices;
-    if ( (signed int)v11 > 0 )
+  if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    v10 = (double)pOutdoorCamera->shading_dist_mist;
+  else
+    v10 = 16192.0;
+  v14 = 1.0 / v10;
+
+  for (uint i = 0; i < pLightmap->uNumVertices; ++i)
+  {
+    v18 = 1.0 - 1.0 / (v14 * pLightmap->pVertices[i].vWorldViewPosition.x * 1000.0);
+    if (fabsf(z_bias) < 1e-5f)
     {
-      v12 = &v28;
-      v13 = (int)&v4->pVertices[0].vWorldViewPosition;
-      v14 = 1.0 / v10;
-      a1a = v11;
-      do
-      {
-        //UNDEF(v15);
-        v18 = 1.0 - 1.0 / (v14 * *(float *)v13 * 1000.0);
-        if ( !(v17 | v16) )
-        {
-          v18 = v18 - thisa;
-          if ( v18 < 0.000099999997 )
-            v18 = 0.000099999997;
-        }
-        *((float *)v12 + 1) = v18;
-        v19 = *(unsigned int *)(v13 + 12);
-        *((unsigned int *)v12 + 4) = 0;
-        v20 = 1.0 / *(float *)v13;
-        *((unsigned int *)v12 - 1) = v19;
-        *(unsigned int *)v12 = *(unsigned int *)(v13 + 16);
-        *((unsigned int *)v12 + 5) = *(unsigned int *)(v13 + 24);
-        v21 = *(unsigned int *)(v13 + 28);
-        *((unsigned int *)v12 + 3) = v9;
-        *((unsigned int *)v12 + 6) = v21;
-        v13 += 48;
-        v12 += 32;
-        v22 = a1a-- == 1;
-        *((float *)v12 - 6) = v20;
-      }
-      while ( !v22 );
+      v18 = v18 - z_bias;
+      if (v18 < 0.000099999997)
+        v18 = 0.000099999997;
     }
-    if ( v8 == 1 )
-    {
-      v26 = 1346;
-      v25 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp";
-      v24 = 28;
-    }
-    else
-    {
-      v26 = 1354;
-      v25 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp";
-      v24 = 16;
-    }
-    v23 = pRenderer->pRenderD3D->pDevice->DrawPrimitive(
-            D3DPT_TRIANGLEFAN,
-            452,
-            &a2,
-            v11,
-            v24);
-    //CheckHRESULT((CheckHRESULT_stru0 *)&thisa, v23, v25, v26, 0);
-    LOBYTE(result) = 1;
+
+    a2[i].pos.x = pLightmap->pVertices[i].vWorldViewProjX;
+    a2[i].pos.z = v18;
+    a2[i].pos.y = pLightmap->pVertices[i].vWorldViewProjY;
+    a2[i].rhw = 1.0 / pLightmap->pVertices[i].vWorldViewPosition.x;
+    a2[i].diffuse = uLightmapColor;
+    a2[i].specular = 0;
+    a2[i].texcoord.x = pLightmap->pVertices[i].u;
+    a2[i].texcoord.y = pLightmap->pVertices[i].v;
   }
-  else
-  {
-    LOBYTE(result) = 0;
-  }
-  return result;
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    v24 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
+   else
+    v24 = D3DDP_DONOTLIGHT;
+
+  ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+            a2,
+            pLightmap->uNumVertices,
+            v24));
+
+  return true;
 }
 
 //----- (0045DCA9) --------------------------------------------------------
 void LightmapBuilder::DoDrawLightmaps()
 {
-  const char *v1; // ebx@0
-  int v2; // ebp@0
-  int v3; // edi@0
-  int v4; // esi@0
-  HRESULT v5; // eax@4
-  HRESULT v6; // eax@4
-  HRESULT v7; // eax@4
-  char *v8; // eax@4
-  //IDirect3DDevice3Vtbl *v9; // ebp@6
-  struct IDirect3DTexture2 *v10; // ST90_4@6
-  //IDirect3DDevice3 *v11; // ST88_4@6
-  HRESULT v12; // eax@6
-  HRESULT v13; // eax@6
-  HRESULT v14; // eax@6
-  HRESULT v15; // eax@6
-  HRESULT v16; // eax@6
-  HRESULT v17; // eax@6
-  HRESULT v18; // eax@6
-  HRESULT v19; // eax@6
-  LightmapBuilder *v20; // [sp+98h] [bp-8h]@1
-  LightmapBuilder *v21; // [sp+9Ch] [bp-4h]@1
-  LightmapBuilder *thisa; // [sp+A4h] [bp+4h]@0
-  //CheckHRESULT_stru0 a8; // [sp+A8h] [bp+8h]@0
-  //CheckHRESULT_stru0 thisaa; // [sp+B4h] [bp+14h]@0
+  if (!std__vector_183808_size)
+    return;
+
+  if (pRenderer->bUsingSpecular)
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+ 
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+
+  auto pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
 
-  v21 = this;
-  v20 = this;
-  if ( this->std__vector_183808_size )
-  {
-    if ( pRenderer->bUsingSpecular )
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
 
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+  DrawLightmaps2(0.00050000002);
 
-    v8 = (char *)stru_69BD44.c_str();
-    if ( !stru_69BD44.size() )
-      v8 = (char *)&dword_4D86F0;
-    //v9 = pRenderer->pRenderD3D->pDevice->lpVtbl;
-    v10 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr(v8);
-    //v11 = pRenderer->pRenderD3D->pDevice;
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v10));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
 
-    DrawLightmaps2(0.00050000002);
-
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
-    if ( pRenderer->bUsingSpecular )
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
-  }
+  if (pRenderer->bUsingSpecular)
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
 }
\ No newline at end of file
--- a/LightmapBuilder.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/LightmapBuilder.h	Mon Oct 29 09:28:08 2012 +0600
@@ -17,8 +17,8 @@
   __int16 field_C0A;
   __int16 field_C0C;
   __int16 field_C0E;
-  int field_C10;
-  float flt_C14;
+  unsigned int uColorMask;
+  float fBrightness;
   int field_C18;
 };
 #pragma pack(pop)
@@ -28,12 +28,12 @@
 #pragma pack(push, 1)
 struct LightmapBuilder
 {
-   LightmapBuilder();
-   inline ~LightmapBuilder() //----- (0045BBAA)
-   {}
+  LightmapBuilder();
+  inline ~LightmapBuilder() //----- (0045BBAA)
+  {}
 
   void DoDrawLightmaps();
-  bool DrawLightmap(Lightmap *a1, Vec3_float_ *arg4, float thisa);
+  bool DrawLightmap(Lightmap *a1, Vec3_float_ *pColorMult, float z_bias);
   bool DrawLightmaps2(float a2);
   char _45D74F_MessWithLight(int a2, int *a3);
   void DrawLightmaps(int a2);
@@ -42,19 +42,19 @@
   int _45D426(struct Span *a1, struct Edge **a2, unsigned int a3, struct Edge *a4, int a5);
   bool _45D3C7(struct stru148 *a1);
   bool StackLight_TerrainFace(struct StationaryLight *pLight, struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot);
-  bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X);
+  bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces);
   bool ApplyLight_ODM(struct StationaryLight *pLight, struct ODMFace *pFace, unsigned int *pSlot, char a4);
   bool ApplyLights_OutdoorFace(struct ODMFace *pFace);
   double _45CC0C_light(struct Vec3_float_ a1, float a2, float a3, struct Vec3_float_ *pNormal, float a5, int uLightType);
   int _45CBD4(struct RenderVertexSoft *a2, int a3, int *a4, int *a5);
   int _45CB89(struct RenderVertexSoft *a1, int a2);
   int _45CA88(struct stru320 *a2, struct RenderVertexSoft *a3, int a4, struct Vec3_float_ *pNormal);
-  bool ApplyLight_BLV(struct StationaryLight *pLight, struct BLVFace *a2, unsigned int *pSlot, char X, int a5);
+  bool ApplyLight_BLV(struct StationaryLight *pLight, struct BLVFace *a2, unsigned int *pSlot, bool bLightBackfaces, char *a5);
   bool ApplyLights_IndoorFace(unsigned int uFaceID);
   int _45C6D6(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap);
   int _45C4B9(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap);
-  char _45BE86_build_light_polygon(int arg0, float a4, int arg8, 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);
+  bool _45BE86_build_light_polygon(Vec3_int_ *pos, float radius, unsigned int uColorMask, float dot_dist, int uLightType, struct stru314 *a7, unsigned int uNumVertices, RenderVertexSoft *a9, char uClipFlag);
+  bool ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char uClipFlag);
 
 
   void (__thiscall ***vdestructor_ptr)(LightmapBuilder *, bool);
@@ -72,7 +72,7 @@
   float flt_3C8C20;
   float flt_3C8C24;
   float flt_3C8C28;
-  float flt_3C8C2C;
+  float flt_3C8C2C_lightmaps_brightness;
   float flt_3C8C30;
   RenderVertexSoft field_3C8C34[256];
   int uFlags;
@@ -83,8 +83,8 @@
 
 
 extern LightsStack_StationaryLight_ *pStationaryLightsStack;
-extern StationaryLight pStationaryLights[400];
-extern int uNumStationaryLightsApplied; // weak
+//extern StationaryLight pStationaryLights[400];
+//extern int uNumStationaryLightsApplied; // weak
 extern LightsStack_MobileLight_ *pMobileLightsStack;
-extern MobileLight pMobileLights[400];
-extern int uNumMobileLightsApplied;
\ No newline at end of file
+//extern MobileLight pMobileLights[400];
+//extern int uNumMobileLightsApplied;
\ No newline at end of file
--- a/Lights.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Lights.h	Mon Oct 29 09:28:08 2012 +0600
@@ -13,7 +13,7 @@
   unsigned __int8 uLightColorR;
   unsigned __int8 uLightColorG;
   unsigned __int8 uLightColorB;
-  char field_B;
+  char uLightType;
 };
 #pragma pack(pop)
 
@@ -28,7 +28,7 @@
   unsigned __int8 uLightColorR;
   unsigned __int8 uLightColorG;
   unsigned __int8 uLightColorB;
-  char field_B;
+  char uLightType;
   __int16 field_C;
   __int16 uSectorID;
   __int16 field_10;
@@ -72,7 +72,7 @@
   }
 
   //----- (004AD3C8) --------------------------------------------------------
-  inline bool AddLight(__int16 x, __int16 y, __int16 z, __int16 a5, unsigned char r, unsigned char g, unsigned char b, char a9)
+  inline bool AddLight(__int16 x, __int16 y, __int16 z, __int16 a5, unsigned char r, unsigned char g, unsigned char b, char uLightType)
   {
     unsigned int v9; // eax@1
     std::string v11; // [sp-18h] [bp-18h]@3
@@ -92,7 +92,7 @@
       pLight->uLightColorR = (unsigned __int8)r;
       pLight->uLightColorG = g;
       pLight->uLightColorB = b;
-      pLight->field_B = a9;
+      pLight->uLightType = uLightType;
       return true;
   }
 
@@ -123,7 +123,7 @@
     this->uNumLightsActive = 0;
   }
   
-  bool AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, int *a10);
+  bool AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, char a10);
 
 
 
--- a/LightsStack.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/LightsStack.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -4,38 +4,25 @@
 #include "mm7_data.h"
 
 //----- (00467D88) --------------------------------------------------------
-bool LightsStack_MobileLight_::AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, int *a10)
+bool LightsStack_MobileLight_::AddLight(__int16 x, __int16 y, __int16 z, __int16 uSectorID, int uRadius, unsigned __int8 r, unsigned __int8 g, unsigned __int8 b, char uLightType)
 {
-  unsigned int v10; // eax@1
-  int v11; // esi@2
-  MobileLight *result; // eax@2
-  std::string v13; // [sp-18h] [bp-1Ch]@3
-  const char *v14; // [sp-8h] [bp-Ch]@3
-  int v15; // [sp-4h] [bp-8h]@3
-
-  v10 = this->uNumLightsActive;
-  if ( (signed int)v10 >= 400 )
+  if (uNumLightsActive >= 400)
   {
     MessageBoxW(nullptr, L"Too many mobile lights!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MobileLightStack.cpp:51", 0);
-    result = 0;
+    return false;
   }
-  else
-  {
-    v11 = uRadius;
-    result = &this->pLights[v10];
-    result->vPosition.x = x;
-    result->vPosition.y = y;
-    result->vPosition.z = z;
-    result->uRadius = v11;
-    result->field_C = (((v11 < 0) - 1) & 0x3E) - 31;
-    result->uSectorID = uSectorID;
-    result->field_10 = v11 * v11 >> 5;
-    result->uLightColorR = r;
-    result->uLightColorG = g;
-    result->uLightColorB = b;
-    result->field_B = (char)a10;
-    ++this->uNumLightsActive;
-    LOBYTE(result) = 1;
-  }
-  return (bool)result;
+
+  pLights[uNumLightsActive].vPosition.x = x;
+  pLights[uNumLightsActive].vPosition.y = y;
+  pLights[uNumLightsActive].vPosition.z = z;
+  pLights[uNumLightsActive].uRadius = uRadius;
+  pLights[uNumLightsActive].field_C = (((uRadius < 0) - 1) & 0x3E) - 31;
+  pLights[uNumLightsActive].uSectorID = uSectorID;
+  pLights[uNumLightsActive].field_10 = uRadius * uRadius >> 5;
+  pLights[uNumLightsActive].uLightColorR = r;
+  pLights[uNumLightsActive].uLightColorG = g;
+  pLights[uNumLightsActive].uLightColorB = b;
+  pLights[uNumLightsActive++].uLightType = uLightType;
+
+  return true;
 }
--- a/Might and Magic Trilogy.vcxproj.filters	Mon Oct 22 09:20:49 2012 +0600
+++ b/Might and Magic Trilogy.vcxproj.filters	Mon Oct 29 09:28:08 2012 +0600
@@ -147,7 +147,6 @@
     <ClInclude Include="TurnEngine.h" />
     <ClInclude Include="stru220.h" />
     <ClInclude Include="stru279.h" />
-    <ClInclude Include="stru346.h" />
     <ClInclude Include="stru314.h" />
     <ClInclude Include="SaveLoad.h" />
     <ClInclude Include="stru287.h" />
@@ -200,7 +199,6 @@
     </ClInclude>
     <ClInclude Include="Log.h" />
     <ClInclude Include="FrameTableInc.h" />
-    <ClInclude Include="resource.h" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="lib">
@@ -317,7 +315,4 @@
     <ClCompile Include="mm7_6.cpp" />
     <ClCompile Include="GameUIs.cpp" />
   </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="Might and Magic Trilogy.rc" />
-  </ItemGroup>
 </Project>
\ No newline at end of file
--- a/Monsters.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Monsters.h	Mon Oct 29 09:28:08 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/Mouse.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Mouse.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -390,53 +390,15 @@
 }
 
 //----- (00469E3B) --------------------------------------------------------
-unsigned __int16 *Mouse::_469E3B()
+void Mouse::DrawCursorToTarget()
 {
-  unsigned __int16 *result; // eax@1
-  int v2; // esi@3
-  unsigned int v3; // edx@3
-  int v4; // edi@4
-  unsigned __int16 *v5; // ebx@5
-  unsigned __int16 *v6; // esi@6
-  unsigned int v7; // [sp+4h] [bp-Ch]@2
-  unsigned __int16 *v8; // [sp+8h] [bp-8h]@2
-  unsigned __int16 *v9; // [sp+Ch] [bp-4h]@2
+  if (!pCursorBitmap3_sysmembits_16bit)
+    return;
 
-  result = this->pCursorBitmap3_sysmembits_16bit;
-  if ( result )
-  {
-    v9 = this->pCursorBitmap3_sysmembits_16bit;
-    v7 = pRenderer->uTargetSurfacePitch;
-    v8 = pRenderer->pTargetSurface;
-    result = (unsigned __int16 *)this->field_44;
-    if ( (signed int)result < this->field_4C )
-    {
-      v2 = this->field_48;
-      v3 = pRenderer->uTargetSurfacePitch * (int)result;
-      do
-      {
-        v4 = this->field_40;
-        if ( v4 < v2 )
-        {
-          v5 = &v8[v3 + v4];
-          do
-          {
-            v6 = v9;
-            ++v9;
-            ++v4;
-            *v5 = *v6;
-            v2 = this->field_48;
-            ++v5;
-          }
-          while ( v4 < v2 );
-        }
-        v3 += v7;
-        result = (unsigned __int16 *)((char *)result + 1);
-      }
-      while ( (signed int)result < this->field_4C );
-    }
-  }
-  return result;
+  auto pSrc = pCursorBitmap3_sysmembits_16bit;
+  for (uint y = field_44; y < field_4C; ++y)
+    for (uint x = field_40; x < field_48; ++x)
+      pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
 }
 
 //----- (00469EA4) --------------------------------------------------------
@@ -780,8 +742,8 @@
   int v2; // eax@2
   int v3; // esi@4
   char result; // al@5
-  const char *v5; // eax@6
-  std::string v6; // [sp-18h] [bp-12Ch]@9
+  //const char *v5; // eax@6
+  //std::string v6; // [sp-18h] [bp-12Ch]@9
   const char *v7; // [sp-8h] [bp-11Ch]@9
   int v8; // [sp-4h] [bp-118h]@9
   DDSURFACEDESC2 Dst; // [sp+Ch] [bp-108h]@1
@@ -828,10 +790,7 @@
   }
   else
   {
-    v5 = std__string_720990.c_str();
-    if ( !std__string_720990.size() )
-      v5 = (const char *)&dword_4D86F0;
-    if ( !LoadCursor(v5) )
+    if ( !LoadCursor("micon1") )
     {
       MessageBoxW(nullptr, L"Could not load async mouse cursor image", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp:182", 0);
     }
--- a/Mouse.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Mouse.h	Mon Oct 29 09:28:08 2012 +0600
@@ -72,7 +72,7 @@
   void DrawCursor();
   void _469E1C();
   void _469E24();
-  unsigned __int16 *_469E3B();
+  void DrawCursorToTarget();
   void _469EA4();
   void Activate(int bActive);
   void SetMouseClick(int x, int y);
--- a/OSAPI.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/OSAPI.cpp	Mon Oct 29 09:28:08 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/Outdoor.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Outdoor.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -61,8 +61,8 @@
                                           * (signed __int64)pParty->field_18) >> 16);
   v3 = stru_5C6E00->SinCos(pParty->sRotationY - stru_5C6E00->uIntegerHalfPi);
   pIndoorCamera->field_4C = v1;
-  pIndoorCamera->pos.y = pParty->vPosition.z - ((unsigned __int64)(v3 * (signed __int64)pParty->field_18) >> 16);
-  pIndoorCamera->pos.z = pParty->vPosition.y + pParty->sEyelevel;
+  pIndoorCamera->pos.y = pParty->vPosition.y - ((unsigned __int64)(v3 * (signed __int64)pParty->field_18) >> 16);
+  pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;
   if ( v2 || pRenderer->pRenderD3D )
   {
     ResetStru148s();
@@ -70,7 +70,7 @@
     sub_481ED9_MessWithOutdoorCamera();
   }
   pIndoorCamera->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x);
-  pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.z);
+  pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y);
   if ( v2 )
   {
     Software_ResetNewEdges();
@@ -104,18 +104,18 @@
   sr_sub_486F92_MessWithEdgesAndSpans();
   pOutdoorCamera->_487355();
 LABEL_16:
-  uNumMobileLightsApplied = 0;
-  uNumStationaryLightsApplied = 0;
+  pMobileLightsStack->uNumLightsActive = 0;
+  pStationaryLightsStack->uNumLightsActive = 0;
   if ( !pRenderer->pRenderD3D )
   {
     pRenderer->ExecOutdoorDrawSW();
     pGame->pIndoorCameraD3D->_438240_draw_lits();
   }
   pGame->PushStationaryLights(-1);
-  pGame->PushStru165s();
+  pGame->PrepareBloodsplats();
   if ( v2 )
   {
-    v4 = WorldPosToGridCellZ(pParty->vPosition.z);
+    v4 = WorldPosToGridCellZ(pParty->vPosition.y);
     v5 = WorldPosToGridCellX(pParty->vPosition.x);
     pOutdoor->_47EF60(v5, v4, 1);
   }
@@ -500,7 +500,7 @@
     || v15 )
     return 2;
   v5 = WorldPosToGridCellX(pParty->vPosition.x);
-  v6 = WorldPosToGridCellZ(pParty->vPosition.z);
+  v6 = WorldPosToGridCellZ(pParty->vPosition.y);
   v7 = _47ED83(v5, v6 - 1);
   v8 = pTileTable->pTiles[_47ECC1(v7)].uTerrainType;
   if ( v8 )
@@ -1805,7 +1805,7 @@
       {
         v62 = pBitmaps_LOD->LoadTexture(Str2);
         v63 = (ODMFace *)pFilename;
-        BYTE1(v63->uFaceAttributes) &= 0xBFu;
+        BYTE1(v63->uAttributes) &= 0xBFu;
 LABEL_68:
         v63->uTextureID = v62;
         v145 = (signed __int16)v62 != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62] : 0;
@@ -2048,7 +2048,7 @@
         File = 0;
         do
         {
-          v106 = (char *)&File->uFaceAttributes + *(int *)(v87 + 84);
+          v106 = (char *)&File->uAttributes + *(int *)(v87 + 84);
           memcpy(v106, v85, 4u);
           v88 = v5->pBModels;
           ++File;
@@ -2070,9 +2070,9 @@
           if ( v90->sCogTriggeredID )
           {
             if ( v90->HasEventHint() )
-              BYTE2(File->uFaceAttributes) |= 0x10u;
+              BYTE2(File->uAttributes) |= 0x10u;
             else
-              BYTE2(File->uFaceAttributes) &= 0xEFu;
+              BYTE2(File->uAttributes) &= 0xEFu;
           }
           ++thisa;
           v89 = v5->pBModels;
@@ -2778,7 +2778,7 @@
   __int16 v13; // cx@21
   SpriteFrame *v14; // eax@24
   SpriteFrame *v15; // ebx@25
-  int *v16; // eax@25
+  //int *v16; // eax@25
   int v17; // eax@35
   int v18; // ST78_4@36
   int v19; // eax@36
@@ -2911,19 +2911,19 @@
 LABEL_25:
       v62 = 0;
       v15 = v14;
-      v16 = (int *)v14->uFlags;
-      if ( (unsigned __int8)v16 & 2 )
+      //v16 = (int *)v14->uFlags;
+      if (v14->uFlags & 2)
         v62 = 2;
-      if ( (unsigned int)v16 & 0x40000 )
+      if (v14->uFlags & 0x40000)
         v62 |= 0x40u;
-      if ( (unsigned int)v16 & 0x20000 )
+      if (v14->uFlags & 0x20000)
         LOBYTE(v62) = v62 | 0x80;
-      if ( (256 << v41) & (unsigned int)v16 )
+      if ((256 << v41) & v14->uFlags)
         v62 |= 4u;
       if ( v15->uGlowRadius )
       {
-        LOBYTE(v16) = byte_4E94D3;
-        pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, v16);
+        //LOBYTE(v16) = byte_4E94D3;
+        pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
       }
       v17 = (x - pIndoorCamera->pos.x) << 16;
       if ( pIndoorCamera->sRotationX )
@@ -3012,14 +3012,14 @@
             goto LABEL_53;
           }
         }
-        v28->field_26 = v27;
-        v28->field_20 = x;
-        v28->field_28 = v46;
-        v28->field_22 = y;
-        v28->field_24 = v61;
+        v28->uScreenSpaceX = v27;
+        v28->some_x = x;
+        v28->uScreenSpaceY = v46;
+        v28->some_y = y;
+        v28->some_z = v61;
         HIWORD(v34) = HIWORD(X);
         LOWORD(v34) = 0;
-        v28->field_2A = 0;
+        v28->uPaletteSubindex = 0;
         v28->sZValue = v34 + (8 * v59 | 3);
         v28->field_14 = v59;
         v35 = pMonsterList->pMonsters;
@@ -3028,7 +3028,7 @@
         v38 = *(int *)(v1 + 150) < 0;
         v28->field_1E = v62 | 0x200;
         v28->pSpriteFrame = v15;
-        v28->field_2C_prolly_tint = *((int *)&v35[v36] - 36);
+        v28->uTintColor = *((int *)&v35[v36] - 36);
         if ( !v38 && (!(v38 | v37) || *(int *)(v1 + 146)) )
           v28->field_1E = v62 | 0x200;
       }
--- a/Outdoor.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Outdoor.h	Mon Oct 29 09:28:08 2012 +0600
@@ -74,13 +74,16 @@
 
   
   static bool IsBackfaceCulled(struct ODMFace *a1, struct RenderVertexSoft *a2, struct stru148 *a3);
-
+  
+  inline bool Invisible() const {return uAttributes & FACE_INVISIBLE;}
+  inline bool Visible() const   {return !Invisible();}
+  inline bool TwoSided() const  {return uAttributes & FACE_TWO_SIDED;}
 
   struct Plane_int_ pFacePlane;
   int zCalc1;
   int zCalc2;
   int zCalc3;
-  unsigned int uFaceAttributes;
+  unsigned int uAttributes;
   unsigned __int16 pVertexIDs[20];
   unsigned __int16 pTextureUIDs[20];
   unsigned __int16 pTextureVIDs[20];
--- a/OutdoorCamera.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/OutdoorCamera.h	Mon Oct 29 09:28:08 2012 +0600
@@ -47,7 +47,7 @@
   unsigned int uNumEdges;
   unsigned int uNumSurfs;
   unsigned int uNumSpans;
-  int field_3C;
+  unsigned int uNumBillboards;
   float field_40;
   int field_44;
   int outdoor_grid_band_3;
--- a/Overlays.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Overlays.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -96,8 +96,8 @@
   int v6; // [sp-4h] [bp-8h]@4
   Texture *v7; // [sp-4h] [bp-8h]@14
 
-  result = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+  result = pCurrentScreen;
+  if ( pCurrentScreen
     || pParty->bTurnBasedModeOn != 1 )
     return result;
   if ( pTurnEngine->field_4 == 3 )
@@ -144,7 +144,7 @@
   }
   return result;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 // 50C994: using guessed type int dword_50C994;
 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
 
--- a/ParticleEngine.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/ParticleEngine.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -7,7 +7,6 @@
 #include "IndoorCamera.h"
 #include "Math.h"
 #include "LOD.h"
-#include "stru346.h"
 
 #include "mm7_data.h"
 
@@ -44,7 +43,7 @@
     v3 = (Particle *)this;
     do
     {
-      if ( !v3->bFree )
+      if ( !v3->uType )
         break;
       ++v2;
       ++v3;
@@ -57,7 +56,7 @@
       if ( v2 > this->uEndParticle )
         this->uEndParticle = v2;
       v4 = &this->pParticles[v2];
-      v4->bFree = a2->bFree;
+      v4->uType = a2->bFree;
       v4->x = a2->x;
       v4->y = a2->y;
       v4->z = a2->z;
@@ -70,8 +69,8 @@
       v5 = a2->uDiffuse;
       v4->uParticleColor = v5;
       v4->uLightColor = v5;
-      v6 = (v4->bFree & 4) == 0;
-      v4->field_20 = a2->field_20;
+      v6 = (v4->uType & 4) == 0;
+      v4->timeToLive = a2->timeToLive;
       v4->uTextureID = a2->uTextureID;
       v4->flt_28 = a2->flt_28;
       if ( v6 )
@@ -91,128 +90,100 @@
 //----- (0048ABF3) --------------------------------------------------------
 void ParticleEngine::Draw()
 {
-  ParticleEngine *v1; // esi@1
+  uTimeElapsed += pEventTimer->uTimeElapsed;
+  pLines.uNumLines = 0;
 
-  v1 = this;
-  v1->uTimeElapsed += pEventTimer->uTimeElapsed;
-  this->pLines.uNumLines = 0;
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     DrawParticles_BLV();
   else
     DrawParticles_ODM();
-  if ( pRenderer->pRenderD3D )
+
+  if (pRenderer->pRenderD3D)
   {
-    if ( v1->pLines.uNumLines )
+    if (pLines.uNumLines)
     {
       pRenderer->pRenderD3D->pDevice->SetTexture(0, 0);
       pRenderer->pRenderD3D->pDevice->DrawPrimitive(
         D3DPT_LINELIST,
-        452,
-        v1->pLines.pLineVertices,
-        v1->pLines.uNumLines,
-        16);
+        D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+        pLines.pLineVertices,
+        pLines.uNumLines,
+        D3DDP_DONOTLIGHT);
     }
   }
 }
 
 //----- (0048AC65) --------------------------------------------------------
-int ParticleEngine::UpdateParticles()
+void ParticleEngine::UpdateParticles()
 {
-  ParticleEngine *v1; // ebx@1
   unsigned int time; // edi@1
-  int v3; // eax@1
-  int v4; // esi@2
   int v5; // eax@3
   char v6; // sf@4
   float v7; // ST4C_4@11
   double v8; // st7@12
   int v9; // eax@12
   double v10; // st7@14
-  float v11; // ST4C_4@14
-  float v12; // ST3C_4@14
-  double v13; // ST20_8@14
-  float v14; // ST3C_4@14
-  double v15; // ST18_8@14
-  float v16; // ST3C_4@14
-  double v17; // ST10_8@14
-  signed int result; // eax@19
   signed int v19; // [sp+38h] [bp-14h]@1
   int v20; // [sp+3Ch] [bp-10h]@1
   unsigned int time_; // [sp+40h] [bp-Ch]@1
   int v22; // [sp+44h] [bp-8h]@12
-  int v23; // [sp+48h] [bp-4h]@1
 
   v20 = 0;
-  v1 = this;
   time = pMiscTimer->bPaused == 0 ? pEventTimer->uTimeElapsed : 0;
-  v3 = this->uStartParticle;
   v19 = 500;
   time_ = pMiscTimer->bPaused == 0 ? pEventTimer->uTimeElapsed : 0;
-  v23 = this->uStartParticle;
-  if ( v3 <= this->uEndParticle )
+
+  for (uint i = uStartParticle; i < uEndParticle; ++i)
   {
-    v4 = (int)((char *)&this->pParticles[v3].uParticleColor + 1);
-    do
-    {
-      v5 = *(int *)(v4 - 0x1D);
-      if ( v5 )
-      {
-        v6 = ((*(int *)(v4 + 3) - time) & 0x80000000u) != 0;
-        *(int *)(v4 + 3) -= time;
-        if ( v6 )
-        {
-          *(int *)(v4 - 0x1D) = 0;
-        }
+    auto p = pParticles + i;
+
+      v5 = p->uType;
+      if (!p->uType)
+        continue;
+
+        v6 = (p->timeToLive - time) < 0;
+        p->timeToLive -= time;
+        if (v6)
+          p->uType = 0;
         else
         {
           if ( BYTE1(v5) & 2 )
           {
-            *(int *)(v4 + 15) = *(int *)(v4 - 25);
-            *(int *)(v4 + 19) = *(int *)(v4 - 21);
-            *(int *)(v4 + 23) = *(int *)(v4 - 17);
+            p->_x = p->x;
+            p->_y = p->y;
+            p->_z = p->z;
           }
           if ( v5 & 1 )
-            *(float *)(v4 - 5) = *(float *)(v4 - 5) - (double)(signed int)time_ * 5.0;
+            p->flt_18 = p->flt_18 - (double)(signed int)time_ * 5.0;
           if ( v5 & 8 )
           {
             v7 = (double)(signed int)time_;
-            *(float *)(v4 - 25) = (double)(rand() % 5 - 2) * v7 * 0.0625 + *(float *)(v4 - 25);
-            *(float *)(v4 - 21) = (double)(rand() % 5 - 2) * v7 * 0.0625 + *(float *)(v4 - 21);
-            *(float *)(v4 - 17) = (double)(rand() % 5 + 4) * v7 * 0.0625 + *(float *)(v4 - 17);
+            *(float *)&p->x += (double)(rand() % 5 - 2) * v7 / 16.0f;
+            *(float *)&p->y += (double)(rand() % 5 - 2) * v7 / 16.0f;
+            *(float *)&p->z += (double)(rand() % 5 + 4) * v7 / 16.0f;
           }
-          v8 = (double)(signed int)time_ * 0.0078125;
-          v9 = (signed int)(time * *(int *)(v4 + 27)) / 16;
-          *(float *)(v4 - 25) = v8 * *(float *)(v4 - 13) + *(float *)(v4 - 25);
-          *(float *)(v4 - 21) = v8 * *(float *)(v4 - 9) + *(float *)(v4 - 21);
-          *(float *)(v4 - 17) = v8 * *(float *)(v4 - 5) + *(float *)(v4 - 17);
-          *(int *)(v4 + 31) += v9;
-          v22 = 2 * *(int *)(v4 + 3);
-          if ( 2 * *(int *)(v4 + 3) >= 255 )
+          v8 = (double)(signed int)time_ / 128.0f;
+          v9 = (signed int)(time * p->field_38) / 16;
+          *(float *)&p->x += v8 * p->flt_10;
+          *(float *)&p->y += v8 * p->flt_14;
+          *(float *)&p->z += v8 * p->flt_18;
+          p->_rotation += v9;
+          v22 = 2 * p->timeToLive;
+          if ( 2 * p->timeToLive >= 255 )
             v22 = 255;
           v10 = (double)v22 * 0.0039215689;
-          v11 = v10;
-          v12 = (double)*(char *)(v4 + 1) * v10;
-          v13 = v12 + 6.7553994e15;
-          v14 = (double)*(char *)v4 * v11;
-          v15 = v14 + 6.7553994e15;
-          v16 = (double)(*(int *)(v4 - 1) & 0xFF) * v11;
-          v17 = v16 + 6.7553994e15;
-          *(int *)(v4 + 71) = LODWORD(v17) | ((LODWORD(v15) | (LODWORD(v13) << 8)) << 8);
-          if ( v23 < v19 )
-            v19 = v23;
-          if ( v23 > v20 )
-            v20 = v23;
+          p->uLightColor = (uint)floorf(p->b + 0.5) |
+                           ((uint)floorf(p->g + 0.5) << 8) |
+                           ((uint)floorf(p->r + 0.5) << 16);
+          if ( i < v19 )
+            v19 = i;
+          if ( i > v20 )
+            v20 = i;
         }
-      }
-      ++v23;
-      v4 += 104;
-    }
-    while ( v23 <= v1->uEndParticle );
   }
-  v1->uEndParticle = v20;
-  result = v19;
-  v1->uStartParticle = v19;
-  return result;
+
+  uEndParticle = v20;
+  uStartParticle = v19;
 }
 
 //----- (0048AE74) --------------------------------------------------------
@@ -275,7 +246,7 @@
   int y; // [sp+4Ch] [bp-4h]@3
 
   pParticle = &this->pParticles[uParticleID];
-  if ( !pParticle->bFree )
+  if ( !pParticle->uType )
     return 0;
   uParticleID = LODWORD(pParticle->x);
   v56 = *(float *)&uParticleID + 6.7553994e15;
@@ -288,7 +259,7 @@
   {
     if ( pBLVRenderParams->sPartyRotX )
     {
-      if ( BYTE1(pParticle->bFree) & 2 )
+      if ( BYTE1(pParticle->uType) & 2 )
       {
         v11 = pParticle->_x + 6.7553994e15;
         uParticleID = (LODWORD(v11) - pBLVRenderParams->vPartyPos.x) << 16;
@@ -314,12 +285,12 @@
         LODWORD(v18) = pBLVRenderParams->uViewportCenterX
                      - ((signed int)((unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16) >> 16);
         v19 = pParticle->field_58;
-        pParticle->field_48 = v18;
+        pParticle->uScreenSpaceZ = v18;
         uParticleID = (unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16;
         v20 = pBLVRenderParams->uViewportCenterY
             - ((signed int)((unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16) >> 16);
-        pParticle->field_54 = v14;
-        pParticle->field_4C = v20;
+        pParticle->sZValue2 = v14;
+        pParticle->uScreenSpaceW = v20;
       }
       uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
       y = (LODWORD(y_int_) - pBLVRenderParams->vPartyPos.y) << 16;
@@ -340,7 +311,7 @@
     }
     else
     {
-      if ( BYTE1(pParticle->bFree) & 2 )
+      if ( BYTE1(pParticle->uType) & 2 )
       {
         v25 = pParticle->_x + 6.7553994e15;
         uParticleID = (LODWORD(v25) - pBLVRenderParams->vPartyPos.x) << 16;
@@ -363,11 +334,11 @@
         LODWORD(v33) = pBLVRenderParams->uViewportCenterX
                      - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16);
         v34 = pParticle->field_58;
-        pParticle->field_48 = v33;
+        pParticle->uScreenSpaceZ = v33;
         v35 = pBLVRenderParams->uViewportCenterY
             - ((signed int)((unsigned __int64)(v34 * (signed __int64)v29) >> 16) >> 16);
-        pParticle->field_54 = v27;
-        pParticle->field_4C = v35;
+        pParticle->sZValue2 = v27;
+        pParticle->uScreenSpaceW = v35;
       }
       uParticleID = (x_int - pBLVRenderParams->vPartyPos.x) << 16;
       y = (LODWORD(y_int_) - pBLVRenderParams->vPartyPos.y) << 16;
@@ -419,9 +390,9 @@
           1) )
     return 0;
   pGame->pIndoorCameraD3D->Project(uParticleID, y, z, (int *)&a5 + 1, &a6);
-  pParticle->flt_5C = pGame->pIndoorCameraD3D->flt_D0;
+  pParticle->flt_5C = pGame->pIndoorCameraD3D->fov_x;
   v4 = pParticle->flt_5C;
-  pParticle->flt_60 = pGame->pIndoorCameraD3D->flt_D4;
+  pParticle->flt_60 = pGame->pIndoorCameraD3D->fov_y;
   v5 = v4 + 6.7553994e15;
   LODWORD(v6) = 0;
   HIDWORD(v6) = SLOWORD(v5);
@@ -433,7 +404,7 @@
   pParticle->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->field_58) >> 16;
   v10 = uParticleID;
 LABEL_19:
-  pParticle->field_50 = v10;
+  pParticle->sZValue = v10;
   return 1;
 }
 
@@ -502,7 +473,7 @@
   v4 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY);
   v5 = stru_5C6E00->SinCos(pIndoorCamera->sRotationY - stru_5C6E00->uIntegerHalfPi);
   v6 = &v2->pParticles[uID];
-  if ( v6->bFree )
+  if ( v6->uType )
   {
     v7 = v6->x + 6.7553994e15;
     v41 = LODWORD(v7);
@@ -510,7 +481,7 @@
     v42 = v6->z + 6.7553994e15;
     if ( v3 )
     {
-      if ( BYTE1(v6->bFree) & 2 )
+      if ( BYTE1(v6->uType) & 2 )
       {
         v8 = v6->_x + 6.7553994e15;
         uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16;
@@ -536,7 +507,7 @@
                           - ((signed int)((unsigned __int64)(v15
                                                            * (signed __int64)(signed int)(((unsigned __int64)(uIDd * (signed __int64)v3) >> 16)
                                                                                         - ((unsigned __int64)(v11 * (signed __int64)v44) >> 16))) >> 16) >> 16);
-        v6->field_50 = HIDWORD(v12);
+        v6->sZValue = HIDWORD(v12);
       }
       uIDe = (v41 - pIndoorCamera->pos.x) << 16;
       v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16;
@@ -553,7 +524,7 @@
     }
     else
     {
-      if ( BYTE1(v6->bFree) & 2 )
+      if ( BYTE1(v6->uType) & 2 )
       {
         v18 = v6->_x + 6.7553994e15;
         uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16;
@@ -573,7 +544,7 @@
                                                                                         - ((unsigned __int64)(uIDf * (signed __int64)v5) >> 16))) >> 16) >> 16);
         v25 = pViewport->uScreenCenterY
             - ((signed int)((unsigned __int64)(v24 * (signed __int64)SLODWORD(v21)) >> 16) >> 16);
-        v6->field_50 = ((unsigned __int64)(v20 * (signed __int64)v5) >> 16)
+        v6->sZValue = ((unsigned __int64)(v20 * (signed __int64)v5) >> 16)
                      + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16);
         v6->uScreenSpaceY = v25;
       }
@@ -604,7 +575,7 @@
       v6->uScreenSpaceY = pViewport->uScreenCenterY - v33;
       v35 = v32;
       v6->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->field_58) >> 16;
-      v6->field_50 = X_4;
+      v6->sZValue = X_4;
       v36 = v6->uScreenSpaceX;
       if ( v36 >= (signed int)pViewport->uViewportX )
       {
@@ -626,152 +597,110 @@
 //----- (0048BBA6) --------------------------------------------------------
 void ParticleEngine::DrawParticles_BLV()
 {
-  ParticleEngine *v1; // esi@1
-  int v2; // eax@1
-  unsigned __int8 v3; // zf@1
-  char v4; // sf@1
-  unsigned __int8 v5; // of@1
-  Render *v6; // ebx@2
-  char *v7; // edi@2
-  signed int v8; // ecx@7
-  int v9; // eax@10
-  signed int v10; // eax@12
   int v11; // eax@18
   int v12; // ecx@20
   int v13; // edx@20
   Particle *v14; // eax@28
   RenderBillboardTransform_local0 v15; // [sp+Ch] [bp-58h]@1
-  int v16; // [sp+5Ch] [bp-8h]@5
-  int v17; // [sp+60h] [bp-4h]@1
 
   v15.uParentBillboardID = -1;
-  v1 = this;
-  v2 = this->uStartParticle;
-  v5 = __OFSUB__(v2, this->uEndParticle);
-  v3 = v2 == this->uEndParticle;
-  v4 = v2 - this->uEndParticle < 0;
-  v17 = this->uStartParticle;
-  if ( (unsigned __int8)(v4 ^ v5) | v3 )
+
+  for (uint i = uStartParticle; i < uEndParticle; ++i)
   {
-    v6 = pRenderer;
-    v7 = (char *)&this->pParticles[v2].field_54 + 2;
-    do
+    auto p = pParticles + i;
+
+    if (!p->uType)
+      continue;
+
+    if (!ViewProject_TrueIfStillVisible(i))
+      continue;
+
+    if (p->uScreenSpaceX >= pBLVRenderParams->uViewportX &&
+        p->uScreenSpaceX < pBLVRenderParams->uViewportZ &&
+        p->uScreenSpaceY >= pBLVRenderParams->uViewportY &&
+        p->uScreenSpaceY < pBLVRenderParams->uViewportW)
     {
-      if ( *(int *)(v7 - 86) )
+      if (pRenderer->pRenderD3D)
       {
-        if ( v1->ViewProject_TrueIfStillVisible(v2) )
+        if (p->uType & 0x0100)
         {
-          v16 = *(int *)(v7 - 22);
-          if ( v16 >= (signed int)pBLVRenderParams->uViewportX )
+          v14 = &pParticles[i];
+          v15.field_10 = v14->field_58 / 4;
+          v15.field_14 = v14->field_58 / 4;
+          v15.uScreenSpaceX = v14->uScreenSpaceX;
+          v15.uScreenSpaceY = v14->uScreenSpaceY;
+          v15.sZValue = v14->sZValue;
+          pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, v14->uLightColor, v14->_rotation);
+          return;
+        }
+        if (p->uType & 0x0200)
+        {
+          if (pLines.uNumLines < 100)
           {
-            if ( v16 < (signed int)pBLVRenderParams->uViewportZ )
-            {
-              v8 = *(int *)(v7 - 18);
-              if ( v8 >= (signed int)pBLVRenderParams->uViewportY )
-              {
-                if ( v8 < (signed int)pBLVRenderParams->uViewportW )
-                {
-                  if ( pRenderer->pRenderD3D )
-                  {
-                    v9 = *(int *)(v7 - 86);
-                    if ( BYTE1(v9) & 1 )
-                    {
-                      v14 = &v1->pParticles[v17];
-                      v15.field_10 = v14->field_58 >> 2;
-                      v15.field_14 = v14->field_58 >> 2;
-                      v15.field_8 = v14->uScreenSpaceX;
-                      v15.field_C = v14->uScreenSpaceY;
-                      v15.field_28 = v14->field_50;
-                      pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, v14->uLightColor, v14->_rotation);
-                      return;
-                    }
-                    if ( BYTE1(v9) & 2 )
-                    {
-                      v10 = v1->pLines.uNumLines;
-                      if ( v10 < 100 )
-                      {
-                        v1->pLines.pLineVertices[2 * v10].pos.x = (double)v16;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.y = (double)*(signed int *)(v7 - 18);
-                        v16 = *((short *)v7 - 2);
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.z = 1.0
-                                                                                 - 1.0 / ((double)v16 * 0.061758894);
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].rhw = 1.0;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].diffuse = *(int *)(v7 + 14);
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].specular = 0;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].texcoord.x = 0.0;
-                        *((float *)&v1->pParticles[0].bFree + 16 * (v1->pLines.uNumLines + 813)) = 0.0;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 14);
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 10);
-                        v16 = *(short *)v7;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.z = 1.0
-                                                                                     - 1.0 / ((double)v16 * 0.061758894);
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].rhw = 1.0;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].diffuse = *(int *)(v7 + 14);
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].specular = 0;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].texcoord.x = 0.0;
-                        v1->pLines.pLineVertices[2 * v1->pLines.uNumLines++ + 1].texcoord.y = 0.0;
-                      }
-                    }
-                    if ( *(v7 - 85) & 4 )
-                    {
-                      v15.field_10 = *(int *)(v7 + 2);
-                      v15.field_14 = *(int *)(v7 + 2);
-                      v15.field_8 = *(int *)(v7 - 22);
-                      v15.field_C = *(int *)(v7 - 18);
-                      v15.field_28 = *(int *)(v7 - 6);
-                      pRenderer->MakeParticleBillboardAndPush_BLV(
-                        &v15,
-                        pBitmaps_LOD->pHardwareTextures[*(int *)(v7 - 50)],
-                        *(int *)(v7 + 14),
-                        *(int *)(v7 - 26));
-                    }
-                    if ( *(v7 - 85) & 8 )
-                    {
-                      v15.field_10 = *(int *)(v7 + 2);
-                      v15.field_14 = *(int *)(v7 + 2);
-                      v15.field_8 = *(int *)(v7 - 22);
-                      v15.field_C = *(int *)(v7 - 18);
-                      v15.field_28 = *(int *)(v7 - 6);
-                      pRenderer->MakeParticleBillboardAndPush_BLV(
-                        &v15,
-                        pSprites_LOD->pHardwareSprites[*(int *)(v7 - 50)].pTexture,
-                        *(int *)(v7 + 14),
-                        *(int *)(v7 - 26));
-                    }
-                  }
-                  else
-                  {
-                    v11 = 13 * *(int *)(v7 + 2) >> 16;
-                    if ( v11 > 30 )
-                      v11 = 30;
-                    v12 = v8 - v11;
-                    v13 = v16 - (v11 >> 1);
-                    if ( v13 + v11 < (signed int)pViewport->uViewportX
-                      || v13 >= (signed int)pViewport->uViewportZ
-                      || v12 + v11 < (signed int)pViewport->uViewportY
-                      || v12 >= (signed int)pViewport->uViewportW )
-                    {
-                      v6 = pRenderer;
-                    }
-                    else
-                    {
-                      v6 = pRenderer;
-                      pRenderer->_4A48E4(v13, v12, *(int *)(v7 - 6), *(int *)(v7 + 14), v11);
-                    }
-                  }
-                }
-              }
-            }
+            pLines.pLineVertices[2 * pLines.uNumLines].pos.x = p->uScreenSpaceX;
+            pLines.pLineVertices[2 * pLines.uNumLines].pos.y = p->uScreenSpaceY;
+            pLines.pLineVertices[2 * pLines.uNumLines].pos.z = 1.0 - 1.0 / ((short)p->sZValue * 0.061758894);
+            pLines.pLineVertices[2 * pLines.uNumLines].rhw = 1.0;
+            pLines.pLineVertices[2 * pLines.uNumLines].diffuse = p->uLightColor;
+            pLines.pLineVertices[2 * pLines.uNumLines].specular = 0;
+            pLines.pLineVertices[2 * pLines.uNumLines].texcoord.x = 0.0;
+            pLines.pLineVertices[2 * pLines.uNumLines].texcoord.y = 0.0;
+
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.x = p->uScreenSpaceZ;
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.y = p->uScreenSpaceW;
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((short)p->sZValue2 * 0.061758894);
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].rhw = 1.0;
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].diffuse = p->uLightColor;
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].specular = 0;
+            pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.x = 0.0;
+            pLines.pLineVertices[2 * pLines.uNumLines++ + 1].texcoord.y = 0.0;
           }
         }
+        if (p->uType & 0x0400)
+        {
+          v15.field_10 = p->field_58;
+          v15.field_14 = p->field_58;
+          v15.uScreenSpaceX = p->uScreenSpaceX;
+          v15.uScreenSpaceY = p->uScreenSpaceY;
+          v15.sZValue = p->sZValue;
+          pRenderer->MakeParticleBillboardAndPush_BLV(&v15,
+                        pBitmaps_LOD->pHardwareTextures[p->uTextureID],
+                        v14->uLightColor,
+                        p->_rotation);
+        }
+        if (p->uType & 0x0800)
+        {
+          v15.field_10 = p->field_58;
+          v15.field_14 = p->field_58;
+          v15.uScreenSpaceX = p->uScreenSpaceX;
+          v15.uScreenSpaceY = p->uScreenSpaceY;
+          v15.sZValue = p->sZValue;
+          pRenderer->MakeParticleBillboardAndPush_BLV(&v15,
+                        pSprites_LOD->pHardwareSprites[p->uTextureID].pTexture,
+                        v14->uLightColor,
+                        p->_rotation);
+        }
       }
-      v7 += 104;
-      v2 = v17 + 1;
-      v5 = __OFSUB__(v17 + 1, v1->uEndParticle);
-      v3 = v17 + 1 == v1->uEndParticle;
-      v4 = v17++ + 1 - v1->uEndParticle < 0;
+      else
+      {
+                    v11 = 13 * p->field_58 >> 16;
+                     if ( v11 > 30 )
+                       v11 = 30;
+                    v12 = p->uScreenSpaceY - v11;
+                    v13 = p->uScreenSpaceX - (v11 >> 1);
+                     if ( v13 + v11 < (signed int)pViewport->uViewportX
+                       || v13 >= (signed int)pViewport->uViewportZ
+                       || v12 + v11 < (signed int)pViewport->uViewportY
+                       || v12 >= (signed int)pViewport->uViewportW )
+                     {
+                      ;
+                     }
+                     else
+                     {
+                      pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor, v11);
+                     }
+      }
     }
-    while ( (unsigned __int8)(v4 ^ v5) | v3 );
   }
 }
 
@@ -783,7 +712,6 @@
   unsigned __int8 v3; // zf@1
   char v4; // sf@1
   unsigned __int8 v5; // of@1
-  Render *pRender; // ebx@2
   char *v7; // edi@2
   int v8; // eax@6
   signed int v9; // eax@8
@@ -791,7 +719,7 @@
   int v11; // ecx@16
   int v12; // edx@16
   Particle *v13; // eax@24
-  stru346 v14; // [sp+Ch] [bp-58h]@1
+  RenderBillboardTransform_local0 v14; // [sp+Ch] [bp-58h]@1
   int v15; // [sp+5Ch] [bp-8h]@9
   int v16; // [sp+60h] [bp-4h]@1
 
@@ -804,8 +732,7 @@
   v16 = this->uStartParticle;
   if ( (unsigned __int8)(v4 ^ v5) | v3 )
   {
-    pRender = pRenderer;
-    v7 = (char *)&this->pParticles[v2].field_50 + 2;
+    v7 = (char *)&this->pParticles[v2].sZValue + 2;
     do
     {
       if ( *(int *)(v7 - 82) && v1->_48B5B3(v2) )
@@ -818,11 +745,11 @@
             v13 = &v1->pParticles[v16];
             v14.field_10 = v13->field_58 >> 2;
             v14.field_14 = v13->field_58 >> 2;
-            v14.field_8 = v13->uScreenSpaceX;
-            v14.field_C = v13->uScreenSpaceY;
-            v14.field_28 = v13->field_50;
+            v14.uScreenSpaceX = v13->uScreenSpaceX;
+            v14.uScreenSpaceY = v13->uScreenSpaceY;
+            v14.sZValue = v13->sZValue;
             pRenderer->MakeParticleBillboardAndPush_ODM(
-              (RenderBillboardTransform_local0 *)&v14,
+              &v14,
               0,
               v13->uLightColor,
               v13->_rotation);
@@ -845,7 +772,7 @@
               v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].diffuse = *(int *)(v7 + 18);
               v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].specular = 0;
               v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].texcoord.x = 0.0;
-              *((float *)&v1->pParticles[0].bFree + 16 * (v1->pLines.uNumLines + 813)) = 0.0;
+              *((float *)&v1->pParticles[0].uType + 16 * (v1->pLines.uNumLines + 813)) = 0.0;
               v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 10);
               v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 6);
               v15 = *(short *)v7;
@@ -865,11 +792,11 @@
           {
             v14.field_10 = *(int *)(v7 + 6);
             v14.field_14 = *(int *)(v7 + 6);
-            v14.field_8 = *(int *)(v7 - 18);
-            v14.field_C = *(int *)(v7 - 14);
-            v14.field_28 = *(int *)(v7 - 2);
+            v14.uScreenSpaceX = *(int *)(v7 - 18);
+            v14.uScreenSpaceY = *(int *)(v7 - 14);
+            v14.sZValue = *(int *)(v7 - 2);
             pRenderer->MakeParticleBillboardAndPush_ODM(
-              (RenderBillboardTransform_local0 *)&v14,
+              &v14,
               pBitmaps_LOD->pHardwareTextures[*(int *)(v7 - 46)],
               *(int *)(v7 + 18),
               *(int *)(v7 - 22));
@@ -878,11 +805,11 @@
           {
             v14.field_10 = *(int *)(v7 + 6);
             v14.field_14 = *(int *)(v7 + 6);
-            v14.field_8 = *(int *)(v7 - 18);
-            v14.field_C = *(int *)(v7 - 14);
-            v14.field_28 = *(int *)(v7 - 2);
+            v14.uScreenSpaceX = *(int *)(v7 - 18);
+            v14.uScreenSpaceY = *(int *)(v7 - 14);
+            v14.sZValue = *(int *)(v7 - 2);
             pRenderer->MakeParticleBillboardAndPush_ODM(
-              (RenderBillboardTransform_local0 *)&v14,
+              &v14,
               pSprites_LOD->pHardwareSprites[*(int *)(v7 - 46)].pTexture,
               *(int *)(v7 + 18),
               *(int *)(v7 - 22));
@@ -900,12 +827,11 @@
             || *(int *)(v7 - 14) < (signed int)pViewport->uViewportY
             || v12 >= (signed int)pViewport->uViewportW )
           {
-            pRender = pRenderer;
+            ;
           }
           else
           {
-            pRender = pRenderer;
-            pRenderer->_4A48E4(v11, v12, *(int *)(v7 - 2), *(int *)(v7 + 18), v10);
+            pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, *(int *)(v7 - 2), *(int *)(v7 + 18), v10);
           }
         }
       }
--- a/ParticleEngine.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/ParticleEngine.h	Mon Oct 29 09:28:08 2012 +0600
@@ -15,7 +15,7 @@
   float flt_14;
   float flt_18;
   unsigned int uDiffuse;
-  int field_20;
+  int timeToLive;
   unsigned int uTextureID;
   float flt_28;
   int field_2C;
@@ -30,15 +30,26 @@
 #pragma pack(push, 1)
 struct Particle
 {
-  int bFree;
+  int uType; // 0x0000: empty
+             // 0x0100: color plane
+             // 0x0200: line
+             // 0x0400: bitmap plane
+             // 0x0800: sprite plane
   float x;
   float y;
   float z;
   float flt_10;
   float flt_14;
   float flt_18;
-  int uParticleColor;
-  int field_20;
+  union
+  {
+    struct
+    {
+      unsigned char r, g, b, a;
+    };
+    unsigned int uParticleColor;
+  };
+  int timeToLive;
   unsigned int uTextureID;
   float flt_28;
   float _x;
@@ -48,10 +59,10 @@
   int _rotation;
   int uScreenSpaceX;
   int uScreenSpaceY;
-  float field_48;
-  int field_4C;
-  int field_50;
-  int field_54;
+  int uScreenSpaceZ;  // line end x
+  int uScreenSpaceW;  // line end y
+  int sZValue;
+  int sZValue2;  // line end z
   int field_58;
   float flt_5C;
   float flt_60;
@@ -84,7 +95,7 @@
   void ResetParticles();
   void AddParticle(Particle_ *a2);
   void Draw();
-  int UpdateParticles();
+  void   UpdateParticles();
   bool ViewProject_TrueIfStillVisible(unsigned int uParticleID);
   bool _48B5B3(unsigned int uID);
   void DrawParticles_BLV();
--- a/Party.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Party.cpp	Mon Oct 29 09:28:08 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;
   }
 }
@@ -777,8 +775,8 @@
         if ( ((Actor *)((char *)v0 - 59))->Actor::CanAct() && *((char *)v0 + 2) != 4 && *(char *)v0 != 5 )
         {
           v1 = abs(*(short *)((char *)v0 + 83) - pParty->vPosition.x);
-          v2 = abs(*(short *)((char *)v0 + 85) - pParty->vPosition.z);
-          v3 = abs(*(short *)((char *)v0 + 87) - pParty->vPosition.y);
+          v2 = abs(*(short *)((char *)v0 + 85) - pParty->vPosition.y);
+          v3 = abs(*(short *)((char *)v0 + 87) - pParty->vPosition.z);
           if ( (double)sub_4621DA(v1, v2, v3) < 512.0 )
             Actor::_402968(v4, 4, 0, 0);
         }
--- a/Party.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Party.h	Mon Oct 29 09:28:08 2012 +0600
@@ -148,6 +148,14 @@
   static void TakeFood(unsigned int uNumFood);
   static __int16 GiveFood(unsigned int _this);
 
+  inline bool WizardEyeActive()      {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;}
+  inline int  WizardEyeSkillLevel()  {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;}
+  inline bool FlyActive()            {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;}
+  inline bool WaterWalkActive()      {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;}
+  inline bool ImmolationActive()     {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;}
+  inline bool ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;}
+  inline bool FeatherFallActive()    {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;}
+
 
   int field_0;
   unsigned int uPartyHeight;
--- a/Player.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Player.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -7,7 +7,7 @@
 #include "Party.h"
 #include "GUIButton.h"
 #include "LOD.h"
-#include "Monsters.h"
+#include "Monsters.h" 
 #include "GUIWindow.h"
 #include "Viewport.h"
 #include "Actor.h"
@@ -4143,7 +4143,7 @@
     LOBYTE(v7) = GetActualSkillLevel(PLAYER_SKILL_UNARMED);
     if ( v7 )
     {
-      v6 = (unsigned __int16)word_4EDEDC;
+      v6 = (unsigned __int16)word_4EDED8[1];
 LABEL_4:
       v47 = v6;
       goto LABEL_17;
@@ -4656,7 +4656,7 @@
   {
     if ( !HasItemEquipped((ITEM_EQUIP_TYPE)v3) )
       goto LABEL_11;
-    v5 = *(int *)v4 - 1;                     // BUG
+    v5 = pEquipment.uOffHand  - 1;            // BUG
                                                 // v5 = _this->cEquippedItems.uOffHand - 1;
     if ( a2 != 17 )
       break;
@@ -7746,7 +7746,7 @@
     v21 = v67;
     goto LABEL_83;
   }
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 23 )
+  if ( pCurrentScreen == 23 )
     return;
   if ( !((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() )
     goto LABEL_89;
@@ -7762,7 +7762,7 @@
     pMouse->RemoveHoldingItem();
     pGUIWindow_CurrentMenu->Release();
     pIcons_LOD->_4114F2();
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+    pCurrentScreen = 0;
     viewparams->bRedrawGameUI = 1;
     _42777D_CastSpell_UseWand_ShootArrow(v24, a2 - 1, 0x85u, 1, 0);
   }
@@ -7777,7 +7777,7 @@
       *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = a2 - 1;
       ++dword_50C9E8;
     }
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+    if ( pCurrentScreen
       && pGUIWindow_CurrentMenu
       && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null
       && (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
@@ -7789,7 +7789,7 @@
     }
   }
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 // 50C9AC: using guessed type int dword_50C9AC;
 // 50C9EC: using guessed type int dword_50C9EC[];
 // 6BE3C4: using guessed type char bUnderwater;
--- a/Player.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Player.h	Mon Oct 29 09:28:08 2012 +0600
@@ -93,8 +93,16 @@
 {
   PLAYER_CLASS_KNIGHT = 0x0,
   PLAYER_CLASS_THEIF = 0x4,
+  PLAYER_CLASS_BOUNTY_HUNTER = 0x7,
+  PLAYER_CLASS_MONK = 0x8,
+  PLAYER_CLASS_PALADIN = 0xC,
+  PLAYER_CLASS_SHOOTER = 0x10,
+  PLAYER_CLASS_RANGER = 0x14,
   PLAYER_CLASS_CLERIC = 0x18,
+  PLAYER_CLASS_PRIEST_OF_MOON = 0x1B,
+  PLAYER_CLASS_DRUID = 0x1C,
   PLAYER_CLASS_SORCERER = 0x20,
+  PLAYER_CLASS_LICH = 0x23,
 };
 
 
@@ -193,6 +201,29 @@
 #pragma pack(push, 1)
 struct Player
 {
+  enum Condition: unsigned __int32
+  {
+    Condition_Cursed = 0,
+    Condition_Weak = 1,
+    Condition_Sleep = 2,
+    Condition_Fear = 3,
+    Condition_Drunk = 4,
+    Condition_Insane = 5,
+    Condition_Poison1 = 6,
+    Condition_Disease1 = 7,
+    Condition_Posion2 = 8,
+    Condition_Disease2 = 9,
+    Condition_Poison3 = 10,
+    Condition_Disease3 = 11,
+    Condition_Paralyzed = 12,
+    Condition_Unconcious = 13,
+    Condition_Dead = 14,
+    Condition_Pertified = 15,
+    Condition_Eradicated = 16,
+    Condition_Zombie = 17,
+    Condition_Good = 18
+  };
+
   Player();
 
   void SetVariable(enum VariableType var, signed int a3);
@@ -315,6 +346,9 @@
   bool Recover(signed int a2);
   bool CanCastSpell(unsigned int uRequiredMana);
 
+  inline bool Dead()       {return pConditions[Condition::Condition_Dead] != 0;}
+  inline bool Eradicated() {return pConditions[Condition::Condition_Eradicated] != 0;}
+
 
 
   __int64 pConditions[20];
@@ -398,7 +432,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	Mon Oct 22 09:20:49 2012 +0600
+++ b/Render.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -63,6 +63,7 @@
 
 
 
+void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1);
 
 
 /*  384 */
@@ -173,11 +174,7 @@
 //----- (00440CB8) --------------------------------------------------------
 void Render::DrawBillboardList_BLV()
 {
-  int v0; // ebx@1
-  char *v1; // esi@2
   __int16 v2; // ax@3
-  unsigned __int16 *v3; // eax@6
-  char v4; // zf@6
   int v5; // eax@11
   RenderBillboardTransform_local0 soft_billboard; // [sp+4h] [bp-50h]@1
 
@@ -189,46 +186,38 @@
   soft_billboard.uViewportY = pBLVRenderParams->uViewportY;
   soft_billboard.uViewportZ = pBLVRenderParams->uViewportZ - 1;
   soft_billboard.uViewportW = pBLVRenderParams->uViewportW;
-  v0 = 0;
-  pOutdoorCamera->field_3C = uNumBillboardsToDraw;
-  if ( (signed int)uNumBillboardsToDraw > 0 )
-  {
-    v1 = (char *)&pBillboardRenderList[0].field_28;
-    do
-    {
-      soft_billboard.field_8 = *((short *)v1 - 1);
-      soft_billboard.uParentBillboardID = v0;
-      soft_billboard.field_C = *(short *)v1;
-      soft_billboard.field_10 = *((int *)v1 - 10);
-      soft_billboard.field_14 = *((int *)v1 - 9);
-      soft_billboard.field_28 = *((int *)v1 - 6);
-      soft_billboard.uFlags = *((short *)v1 - 5);
-      soft_billboard.uTintColor = *((int *)v1 + 1);
-      v2 = *((short *)v1 - 8);
+
+  pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
+
+  for (uint i = 0; i < uNumBillboardsToDraw; ++i)
+  {
+    auto p = pBillboardRenderList + i;
+
+      soft_billboard.uScreenSpaceX = p->uScreenSpaceX;
+      soft_billboard.uParentBillboardID = i;
+      soft_billboard.uScreenSpaceY = p->uScreenSpaceY;
+      soft_billboard.field_10 = p->field_0;
+      soft_billboard.field_14 = p->field_4;
+      soft_billboard.sZValue = p->sZValue;
+      soft_billboard.uFlags = p->field_1E;
+      soft_billboard.uTintColor = p->uTintColor;
+      v2 = p->uHwSpriteID;
       if ( v2 != -1 )
       {
         if ( pRenderer->pRenderD3D )
-        {
-          pRenderer->_4A43B1(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], *((short *)v1 + 1));
-        }
+          pRenderer->DrawBillboard_Indoor(&soft_billboard, &pSprites_LOD->pHardwareSprites[v2], p->uPaletteSubindex);
         else
         {
-          v3 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), *((short *)v1 + 1), 1);
-          v4 = (*(v1 - 9) & 1) == 0;
-          soft_billboard.pPalette = v3;
-          if ( !v4 )
-            soft_billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)];
+          soft_billboard.pPalette = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, p->uPaletteSubindex, 1);
+          if (p->field_1E & 0x0100)
+            soft_billboard.pPalette = pPaletteManager->field_261600[p->uPalette];
           if ( !(soft_billboard.uFlags & 0x40) && soft_billboard.uFlags & 0x80 )
-            soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1);
-          v5 = *((short *)v1 - 8);
+            soft_billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(p->uPalette, 0, 1);
+          v5 = p->uHwSpriteID;
           if ( v5 >= 0 )
             pSprites_LOD->pSpriteHeaders[v5]._4ACC38(&soft_billboard, 1);
         }
       }
-      ++v0;
-      v1 += 52;
-    }
-    while ( v0 < (signed int)uNumBillboardsToDraw );
   }
 }
 
@@ -1645,8 +1634,8 @@
           {
             a1->ViewTransform(&ptr_801A08[_ESI], 1u);
             a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->_436BB7_project_and_stuff(&ptr_801A08[_ESI], 1u, 0);
-            a1->_436BB7_project_and_stuff(&ptr_801A04[_ESI], 1u, 0);
+            a1->Project(&ptr_801A08[_ESI], 1u, 0);
+            a1->Project(&ptr_801A04[_ESI], 1u, 0);
           }
           v79 += 512;
           ++_ESI;
@@ -1734,8 +1723,8 @@
           {
             a1->ViewTransform(&ptr_801A08[_ESI], 1u);
             a1->ViewTransform(&ptr_801A04[_ESI], 1u);
-            a1->_436BB7_project_and_stuff(&ptr_801A08[_ESI], 1u, 0);
-            a1->_436BB7_project_and_stuff(&ptr_801A04[_ESI], 1u, 0);
+            a1->Project(&ptr_801A08[_ESI], 1u, 0);
+            a1->Project(&ptr_801A04[_ESI], 1u, 0);
           }
           v92 -= 512;
           ++_ESI;
@@ -1999,7 +1988,7 @@
           if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 )
             goto LABEL_162;
           thisa->ViewTransform(array_50AC10, a5);
-          thisa->_436BB7_project_and_stuff(array_50AC10, a5, 0);
+          thisa->Project(array_50AC10, a5, 0);
         }
         this_3 = a2->vWorldViewPosition.x < 8.0
               || a8->vWorldViewPosition.x < 8.0
@@ -2012,7 +2001,7 @@
             || v32 < pVertices->vWorldViewPosition.x;
         LOBYTE(v33) = 0;
         pGame->pLightmapBuilder->std__vector_000004_size = 0;
-        if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
         {
           if ( this_3 )
             LOBYTE(v33) = 3;
@@ -2030,8 +2019,8 @@
               v33,
               -1);
         }
-        if ( stru_F8AD28.field_AC > 0 )
-          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0.0, v33);
+        if ( stru_F8AD28.uNumLightsApplied > 0 )
+          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
         v34 = a5;
         v35 = byte_4D864C == 0;
         v16->uNumVertices = a5;
@@ -2153,14 +2142,14 @@
         goto LABEL_112;
       }
       thisb->ViewTransform(array_50AC10, uNumVertices);
-      thisb->_436BB7_project_and_stuff(array_50AC10, uNumVertices, 0);
+      thisb->Project(array_50AC10, uNumVertices, 0);
     }
     this_3a = a2->vWorldViewPosition.x < 8.0 || a8->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0;
     v54 = (double)pOutdoorCamera->shading_dist_mist;
     v108 = v54 < a2->vWorldViewPosition.x || v54 < a8->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x;
     a8 = 0;
     v96->std__vector_000004_size = 0;
-    if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
     {
       a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0);
       static_sub_0048034E_stru_76D590._49B0C9(v99, *(float *)&a4);
@@ -2175,13 +2164,13 @@
           (char)a8,
           -1);
     }
-    if ( stru_F8AD28.field_AC > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 )
       v96->ApplyLights(
         &stru_F8AD28,
         &static_sub_0048034E_stru_76D590,
         uNumVertices,
         array_50AC10,
-        0.0,
+        0,
         (char)a8);
     v55 = uNumVertices;
     v35 = byte_4D864C == 0;
@@ -2290,7 +2279,7 @@
       if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 )
         goto LABEL_126;
       thisc->ViewTransform(array_50AC10, v100);
-      thisc->_436BB7_project_and_stuff(array_50AC10, v100, 0);
+      thisc->Project(array_50AC10, v100, 0);
     }
     this_3b = a2->vWorldViewPosition.x < 8.0
            || pVertices->vWorldViewPosition.x < 8.0
@@ -2299,7 +2288,7 @@
     v108 = v69 < a2->vWorldViewPosition.x || v69 < pVertices->vWorldViewPosition.x || v69 < _ECX->vWorldViewPosition.x;
     LOBYTE(v70) = 0;
     v96->std__vector_000004_size = 0;
-    if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+    if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
     {
       if ( this_3b )
         LOBYTE(v70) = 3;
@@ -2317,8 +2306,8 @@
           v70,
           -1);
     }
-    if ( stru_F8AD28.field_AC > 0 )
-      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0.0, v70);
+    if ( stru_F8AD28.uNumLightsApplied > 0 )
+      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
     v71 = a8;
     v72 = v100;
     v35 = byte_4D864C == 0;
@@ -2595,7 +2584,7 @@
         array_50AC10[3].u = 1.0;
         array_50AC10[3].v = 0.0;
         pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1);
-        if ( stru_F8AD28.field_AC <= 0 )
+        if ( stru_F8AD28.uNumLightsApplied <= 0 )
         {
           v17->field_108 = 0;
         }
@@ -2711,7 +2700,7 @@
     array_50AC10[2].u = 1.0;
     array_50AC10[2].v = 1.0;
     pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0);
-    if ( stru_F8AD28.field_AC <= 0 )
+    if ( stru_F8AD28.uNumLightsApplied <= 0 )
     {
       v38->field_108 = 0;
     }
@@ -2805,7 +2794,7 @@
           array_50AC10[2].u = 1.0;
           array_50AC10[2].v = 0.0;
           pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1);
-          if ( stru_F8AD28.field_AC <= 0 )
+          if ( stru_F8AD28.uNumLightsApplied <= 0 )
           {
             v17->field_108 = 0;
           }
@@ -2904,17 +2893,17 @@
   billboard.uViewportZ = pViewport->uViewportZ - 1;
   billboard.uViewportW = pViewport->uViewportW;
   v0 = 0;
-  pOutdoorCamera->field_3C = uNumBillboardsToDraw;
+  pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
   v16 = 0;
   if ( (signed int)uNumBillboardsToDraw > 0 )
   {
     v17 = 0;
-    v1 = (char *)&pBillboardRenderList[0].field_28;
+    v1 = (char *)&pBillboardRenderList[0].uScreenSpaceY;
     do
     {
-      billboard.field_8 = *((short *)v1 - 1);
+      billboard.uScreenSpaceX = *((short *)v1 - 1);
       v2 = *((short *)v1 - 5);
-      billboard.field_C = *(short *)v1;
+      billboard.uScreenSpaceY = *(short *)v1;
       v3 = *((int *)v1 - 10);
       billboard.uParentBillboardID = v0;
       v4 = *((int *)v1 + 1);
@@ -2924,14 +2913,14 @@
       v6 = *((short *)v1 - 8);
       billboard.field_14 = v5;
       v7 = *((int *)v1 - 6);
-      billboard.field_28 = *((int *)v1 - 6);
+      billboard.sZValue = *((int *)v1 - 6);
       billboard.uFlags = v2;
       if ( v6 != -1 )
       {
         v8 = *((short *)v1 + 1);
         if ( pRenderer->pRenderD3D )
         {
-          billboard.field_28 = v7;
+          billboard.sZValue = v7;
           billboard.uFlags = v2;
           pRenderer->TransformBillboard(
             &billboard,
@@ -3074,7 +3063,7 @@
             if ( a6 )
             {
               LOBYTE(v11) = byte_4E94D3;
-              pMobileLightsStack->AddLight(x, y, z, a5, a6, 0xFFu, 0xFFu, 0xFFu, v11);
+              pMobileLightsStack->AddLight(x, y, z, a5, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
             }
             v12 = (x - pIndoorCamera->pos.x) << 16;
             if ( pIndoorCamera->sRotationX )
@@ -3141,17 +3130,17 @@
                   v3->pSpriteFrame = v28;
                   v3->field_4 = v26;
                   v3->field_1E = v46;
-                  v3->field_20 = x;
-                  v3->field_22 = y;
-                  v3->field_24 = z;
-                  v3->field_26 = v35;
-                  v3->field_28 = v32;
+                  v3->some_x = x;
+                  v3->some_y = y;
+                  v3->some_z = z;
+                  v3->uScreenSpaceX = v35;
+                  v3->uScreenSpaceY = v32;
                   HIWORD(v26) = HIWORD(v42);
                   LOWORD(v26) = 0;
                   v27 = (*(v0 - 2) & 0x20) == 0;
                   v3->sZValue = v26 + (8 * v41 | 2);
-                  v3->field_2A = 0;
-                  v3->field_2C_prolly_tint = 0;
+                  v3->uPaletteSubindex = 0;
+                  v3->uTintColor = 0;
                   if ( !v27 )
                   {
                     if ( !pRenderer->pRenderD3D )
@@ -3573,22 +3562,22 @@
                     v27->field_0 = v26;
                     v27->field_4 = v26;
                     v29 = v38;
-                    v27->field_26 = v25;
+                    v27->uScreenSpaceX = v25;
                     HIBYTE(v29) |= 2u;
                     v27->uPalette = v28;
                     v27->field_1E = v29;
-                    v27->field_20 = x;
-                    v27->field_22 = y;
-                    v27->field_24 = v36;
-                    v27->field_28 = v40;
+                    v27->some_x = x;
+                    v27->some_y = y;
+                    v27->some_z = v36;
+                    v27->uScreenSpaceY = v40;
                     HIWORD(v30) = HIWORD(v39);
                     v31 = 8 * v35 | 5;
                     LOWORD(v30) = 0;
                     v27->uIndoorSectorID = 0;
                     v27->sZValue = v30 + v31;
-                    v27->field_2A = 0;
+                    v27->uPaletteSubindex = 0;
                     v27->pSpriteFrame = v9;
-                    v27->field_2C_prolly_tint = 0;
+                    v27->uTintColor = 0;
                   }
                 }
                 goto LABEL_38;
@@ -3627,7 +3616,7 @@
           local_0.flt_14 = 0.0;
           local_0.flt_18 = 0.0;
           local_0.flt_28 = 1.0;
-          local_0.field_20 = (rand() & 0x80) + 128;
+          local_0.timeToLive = (rand() & 0x80) + 128;
           local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
           pGame->pParticleEngine->AddParticle(&local_0);
         }
@@ -4140,61 +4129,42 @@
 //----- (0049E4FC) --------------------------------------------------------
 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear)
 {
-  unsigned int flags; // esi@1
-  IDirect3DViewport3 *v6; // eax@6
-  D3DRECT v7; // [sp+Ch] [bp-10h]@6
-
-  flags = 0;
-  if ( bClearColor )
-    flags = 1;                                  // D3DRMCLEAR_TARGET
-  if ( bClearDepth )
-    flags |= 2u;                                // D3DRMCLEAR_ZBUFFER
-  if ( flags )
-  {
-    v6 = this->pViewport;
-    v7.x1 = 0;
-    v7.y1 = 0;
-    v7.x2 = 640;
-    v7.y2 = 480;                                // BUG
-    v6->Clear2(
-      1,
-      &v7,
-      flags,
-      uClearColor,
-      LODWORD(z_clear),
-      0);
-  }
+  uint uClearFlags = 0;
+
+  if (bClearColor)
+    uClearFlags |= D3DCLEAR_TARGET;
+  if (bClearDepth)
+    uClearFlags |= D3DCLEAR_ZBUFFER;
+  
+  D3DRECT rects[] = {{0, 0, 640, 480}};
+  if (uClearFlags)
+    pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0);
 }
 
 
 //----- (0049E54D) --------------------------------------------------------
 void RenderD3D::Present(bool bForceBlit)
 {
-  RenderD3D *v2; // esi@1
-  char bFullscreen; // zf@1
-  struct tagRECT Rect; // [sp+8h] [bp-28h]@4
   RECT v5; // [sp+18h] [bp-18h]@1
   struct tagPOINT Point; // [sp+28h] [bp-8h]@4
 
-  v2 = this;
   v5.left = 0;
   v5.top = 0;
-  bFullscreen = this->bWindowed == 0;
   v5.bottom = 480;
   v5.right = 640;
-  if ( !bFullscreen || bForceBlit )
-  {
-    GetClientRect(this->hWindow, &Rect);
+
+  if (bWindowed || bForceBlit)
+  {
+    RECT rc;
+    GetClientRect(hWindow, &rc);
     Point.y = 0;
     Point.x = 0;
-    ClientToScreen(v2->hWindow, &Point);
-    OffsetRect(&Rect, Point.x, Point.y);
-    v2->pFrontBuffer->Blt(&Rect, v2->pBackBuffer, &v5, DDBLT_WAIT, 0);
+    ClientToScreen(hWindow, &Point);
+    OffsetRect(&rc, Point.x, Point.y);
+    pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0);
   }
   else
-  {
-    this->pFrontBuffer->Flip(0, 1u);
-  }
+    pFrontBuffer->Flip(0, 1);
 }
 
 
@@ -4511,7 +4481,7 @@
               *(int *)v34 = 0;
               v34 += 32;
               --v33;
-              *((int *)v34 - 9) = LODWORD(pRenderer->uFogColor) | v35 & 0xFF000000;
+              *((int *)v34 - 9) = pRenderer->uFogColor | v35 & 0xFF000000;
             }
             while ( v33 );
           }
@@ -4624,6 +4594,8 @@
   LOBYTE(v1->field_103668) = 0;
   v1->field_1036B8 = 0;
   v1->_gpu_memory_used = 0;
+  uNumBillboardsToDraw = 0;
+  bFogEnabled = false;
 }
 
 bool Render::Initialize(bool bWindowed, uint uDefaultDevice,
@@ -4701,20 +4673,13 @@
 //----- (0049ECC4) --------------------------------------------------------
 void Render::ClearBlack()
 {
-  Render *v1; // eax@1
-  RenderD3D *v2; // ecx@1
-
-  v1 = this;
-  v2 = this->pRenderD3D;
-  if ( v2 )
-  {
-    if ( v1->field_40110 )
-      pRenderD3D->ClearTarget(1u, 0, 0, 0.0);
+  if (pRenderD3D)
+  {
+    if (field_40110)
+      pRenderD3D->ClearTarget(true, 0, false, 0.0);
   }
   else
-  {
-    memset(pRenderer->pTargetSurface, 0, 4 * (v1->field_10 * v1->field_14 >> 1));
-  }
+    memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2));
 }
 
 
@@ -4727,7 +4692,8 @@
   RECT x; // [sp+68h] [bp-10h]@3
 
   memset(&v3, 0, sizeof(DDBLTFX));
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      pVersion->pVersionInfo.dwMajorVersion >= 5)
   {
     x.left = uWindowX;
     x.right = uWindowX + uWindowHeight;
@@ -5146,9 +5112,9 @@
   signed int v15; // eax@11
   char v16; // zf@20
   int result; // eax@21
-  char v18; // [sp+Ch] [bp-ACh]@3
-  __int16 v19; // [sp+44h] [bp-74h]@3
-  char v20; // [sp+48h] [bp-70h]@3
+  char v18[58]; // [sp+Ch] [bp-ACh]@3
+ // __int16 v19; // [sp+44h] [bp-74h]@3
+  char v20[48]; // [sp+48h] [bp-70h]@3
   char *v21; // [sp+78h] [bp-40h]@7
   char *v22; // [sp+7Ch] [bp-3Ch]@7
   int v23; // [sp+80h] [bp-38h]@4
@@ -5187,7 +5153,7 @@
   memset(&v18, 0, 0x38u);
   v8 = Dst;
   v37 = 0;
-  v19 = 0;
+  *(_WORD *)&v18[56] = 0;
   Src = 10;
   v28 = 5;
   v29 = 1;
@@ -5444,20 +5410,13 @@
 //----- (0049FBCD) --------------------------------------------------------
 void Render::ClearTarget(unsigned int uColor)
 {
-  Render *v2; // eax@1
-  RenderD3D *v3; // ecx@1
-
-  v2 = this;
-  v3 = this->pRenderD3D;
-  if ( v3 )
-  {
-    if ( v2->field_40110 )
-      pRenderD3D->ClearTarget(1u, uColor, 0, 0.0);
+  if (pRenderD3D)
+  {
+    if (field_40110)
+      pRenderD3D->ClearTarget(true, uColor, false, 0.0);
   }
   else
-  {
-    memset32(v2->pTargetSurface, uColor, v2->field_10 * v2->field_14 >> 1);
-  }
+    memset32(pTargetSurface, uColor, field_10 * field_14 / 2);
 }
 
 
@@ -5488,7 +5447,7 @@
       {
         if (pAsyncMouse)
           pAsyncMouse->_46BAEC();
-        pRenderD3D->Present(0);
+        pRenderD3D->Present(false);
         if (pAsyncMouse)
           pAsyncMouse->_46BB0A();
       }
@@ -6148,7 +6107,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
@@ -7116,78 +7075,44 @@
 }
 
 //----- (004A1EB6) --------------------------------------------------------
-void Render::SetGameRenderStates()
-{
-  Render *v1; // esi@1
-  unsigned int v2; // eax@1
-  RenderD3D *v3; // ecx@2
-  unsigned int uFogColor; // edi@6
-  IDirect3DDevice3 *v5; // eax@8
-  //IDirect3DDevice3Vtbl *v6; // ecx@8
-  RenderD3D *v7; // eax@9
-  RenderD3D *v8; // eax@9
-  std::string v9; // [sp-14h] [bp-2Ch]@4
-  IDirect3DDevice3 *v10; // [sp-8h] [bp-20h]@9
-  signed int v11; // [sp-4h] [bp-1Ch]@4
-  int v12; // [sp+0h] [bp-18h]@4
-  std::string *v13; // [sp+10h] [bp-8h]@4
-  int a3; // [sp+17h] [bp-1h]@4
-
-  v1 = this;
-  v2 = this->uNumD3DSceneBegins;
-  this->uNumD3DSceneBegins = v2 + 1;
-  if ( !v2 )
-  {
-    v3 = this->pRenderD3D;
+void Render::BeginSceneD3D()
+{
+  if (!uNumD3DSceneBegins++)
+  {
     if (pRenderD3D)
     {
-      pRenderD3D->ClearTarget(1u, 0, 1u, 1.0);
+      pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0);
       pRenderer->uNumBillboardsToDraw = 0;
       pRenderD3D->pDevice->BeginScene();
-      if ( !pRenderD3D->DoesRaiseExceptions() )
-      {
-          MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0);
+      if (!pRenderD3D->DoesRaiseExceptions())
+      {
+        MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0);
       }
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
         uFogColor = GetLevelFogColor();
       else
         uFogColor = 0;
-      v5 = v1->pRenderD3D->pDevice;
-      //v6 = v5->lpVtbl;
+
       if ( uFogColor & 0xFF000000 )
       {
-        v12 = 1;
-        v11 = 28;
-        v10 = v5;
-        pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u);
-        //v7 = v1->pRenderD3D;
-        v12 = uFogColor & 0xFFFFFF;
-        v11 = 34;
-        //v10 = v7->pDevice;
+        pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1);
         pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor & 0xFFFFFF);
-        v8 = v1->pRenderD3D;
-        *(float *)&v12 = 0.0;
-        v11 = 35;
-        //v10 = v8->pDevice;
         pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0);
-        v1->bUsingSpecular = 1;
+        bUsingSpecular = true;
       }
       else
       {
-        *(float *)&v12 = 0.0;
-        v11 = 28;
-        v10 = v5;
         pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0);
-        v1->bUsingSpecular = 0;
+        bUsingSpecular = 0;
       }
     }
     else
     {
-      LockRenderSurface((void **)&v1->pTargetSurface, &v1->uTargetSurfacePitch);
-      if ( v1->pTargetSurface )
-        v1->field_18_locked_pitch = v1->uTargetSurfacePitch;
+      LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch);
+      if (pTargetSurface)
+        field_18_locked_pitch = uTargetSurfacePitch;
       else
-        --v1->uNumD3DSceneBegins;
+        --uNumD3DSceneBegins;
     }
   }
 }
@@ -7195,23 +7120,19 @@
 //----- (004A1FE1) --------------------------------------------------------
 void Render::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene()
 {
-  char v1; // zf@1
-
-  v1 = this->uNumD3DSceneBegins-- == 1;
-  if ( v1 )
-  {
-    if ( this->pRenderD3D )
-    {
-      pGame->draw_debug_outlines();
-      DoRenderBillboards_D3D();
-      pGame->pStru6Instance->RenderSpecialEffects();
-      pRenderD3D->pDevice->EndScene();
-    }
-    else
-    {
-      pGame->pStru6Instance->RenderSpecialEffects();
-    }
-  }
+  --uNumD3DSceneBegins;
+  if (uNumD3DSceneBegins)
+    return;
+
+  if (pRenderD3D)
+  {
+    pGame->draw_debug_outlines();
+    DoRenderBillboards_D3D();
+    pGame->pStru6Instance->RenderSpecialEffects();
+    pRenderD3D->pDevice->EndScene();
+  }
+  else
+    pGame->pStru6Instance->RenderSpecialEffects();
 }
 
 
@@ -7370,7 +7291,7 @@
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
           D3DPT_TRIANGLEFAN,
-          452,
+          D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
           arary_77E5C8,
           uNumVertices,
           16));
@@ -7430,7 +7351,7 @@
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
                 D3DPT_TRIANGLEFAN,
-                452,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
                 arary_77E5C8,
                 uNumVertices,
                 16));
@@ -7461,7 +7382,7 @@
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3u));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
                 D3DPT_TRIANGLEFAN,
-                452,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
                 arary_77E5C8,
                 uNumVertices,
                 16));
@@ -7479,7 +7400,7 @@
               *(int *)v38 = 0;
               v38 += 32;
               --v37;
-              *((int *)v38 - 9) = LODWORD(pRenderer->uFogColor) | v39 & 0xFF000000;
+              *((int *)v38 - 9) = pRenderer->uFogColor | v39 & 0xFF000000;
             }
             while ( v37 );
           }
@@ -7488,7 +7409,7 @@
           ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5u));
           ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
                   D3DPT_TRIANGLEFAN,
-                  452,
+                  D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
                   arary_77E5C8,
                   uNumVertices,
                   16));
@@ -7572,7 +7493,7 @@
     ErrD3D(pRenderD3D->pDevice->SetTexture(0, a4));
     ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
       D3DPT_TRIANGLEFAN,
-      452,
+      D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
       arary_77E5C8,
       uNumVertices,
       24));
@@ -7628,7 +7549,7 @@
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
         D3DPT_TRIANGLEFAN,
-        452,
+        D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
         arary_77E5C8,
         a2,
         28));
@@ -7639,81 +7560,66 @@
 
 
 //----- (004A2FC0) --------------------------------------------------------
-void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int a6, int a7, int a8)
-{
-  Render *v8; // edi@1
-  unsigned int v9; // esi@3
-  HRESULT v10; // eax@8
-  HRESULT v11; // eax@8
+void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8)
+{
+  //Render *v8; // edi@1
+  //unsigned int v9; // esi@3
   char *v12; // ecx@9
   char *v13; // eax@9
   double v14; // st6@10
   int v15; // edx@10
   Texture *v16; // edx@10
   double v17; // st6@10
-  char v18; // zf@10
+  //char v18; // zf@10
   Texture *v19; // edx@10
-  HRESULT v20; // eax@11
-  HRESULT v21; // eax@11
-  HRESULT v22; // eax@11
   Texture *v23; // edx@16
   char *v24; // ecx@16
   char *v25; // eax@16
   double v26; // st6@17
   int v27; // esi@17
   double v28; // st6@17
-  HRESULT v29; // eax@18
-  HRESULT v30; // eax@18
-  HRESULT v31; // eax@18
-  HRESULT v32; // eax@18
   unsigned int v33; // ecx@18
   char *v34; // eax@19
-  HRESULT v35; // eax@21
-  HRESULT v36; // eax@21
-  HRESULT v37; // eax@21
-  HRESULT v38; // eax@21
-  HRESULT v39; // eax@21
-  HRESULT v40; // eax@21
-  HRESULT v41; // eax@21
-  HRESULT v42; // eax@21
-  HRESULT v43; // eax@21
-  HRESULT v44; // eax@21
-  Texture *v45; // edx@23
-  char *v46; // ecx@23
-  char *v47; // eax@23
-  double v48; // st6@24
-  int v49; // esi@24
-  double v50; // st6@24
-  HRESULT v51; // eax@25
-  HRESULT v52; // eax@25
+  //Texture *v45; // edx@23
+  //char *v46; // ecx@23
+  //char *v47; // eax@23
+  //double v48; // st6@24
+  //int v49; // esi@24
+  //double v50; // st6@24
   const char *v53; // [sp-Ch] [bp-20h]@21
-  int v54; // [sp-8h] [bp-1Ch]@21
-  unsigned int v55; // [sp-4h] [bp-18h]@21
+  //int v54; // [sp-8h] [bp-1Ch]@21
+  //unsigned int v55; // [sp-4h] [bp-18h]@21
   const char *v56; // [sp+0h] [bp-14h]@0
   int v57; // [sp+4h] [bp-10h]@0
   unsigned int v58; // [sp+8h] [bp-Ch]@0
-  LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3
-  int a3a; // [sp+10h] [bp-4h]@4
-
-  v8 = this;
-  if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 )
-  {
-    v59 = pGame->pLightmapBuilder;
-    v9 = v59->std__vector_000004_size;
-    if ( v9 )
-      a3a = -1;
-    else
-      a3a = a7;
-    pGame->_44EDE4(a3, &a3a);
-    if ( byte_4D864C && pGame->uFlags & 1 )
-    {
+  //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3
+  //int a3a; // [sp+10h] [bp-4h]@4
+
+  //v8 = this;
+  if (!uNumD3DSceneBegins || uNumVertices < 3)
+    return;
+
+  //auto a3 = pFace;
+  //auto a6 = uPackedID;
+    //v59 = pGame->pLightmapBuilder;
+    //v9 = v59->std__vector_000004_size;
+
+  auto uCorrectedColor = uColor;
+  if (pGame->pLightmapBuilder->std__vector_000004_size)
+    uCorrectedColor = 0xFFFFFFFF;
+  pGame->AlterGamma(pFace, &uCorrectedColor);
+
+  if (byte_4D864C && pGame->uFlags & 1)
+  {
+      __debugbreak();
       ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
       ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
       if ( (signed int)uNumVertices > 0 )
       {
         v12 = (char *)&array_507D30[0].vWorldViewPosition;
         v13 = (char *)&arary_77E5C8[0].pos.y;
-        a7 = uNumVertices;
+        auto a7 = uNumVertices;
+        uint v18;
         do
         {
           v14 = *(float *)v12 * 0.061758894;
@@ -7721,7 +7627,7 @@
           *((int *)v13 + 4) = 0;
           *((int *)v13 - 1) = v15;
           *(int *)v13 = *((int *)v12 + 4);
-          *((int *)v13 + 3) = a3a;
+          *((int *)v13 + 3) = uCorrectedColor;
           v16 = pTex;
           v13 += 32;
           *((float *)v13 - 7) = 1.0 - 1.0 / v14;
@@ -7741,63 +7647,47 @@
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
               D3DPT_TRIANGLEFAN,
-              452,
+              D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
               arary_77E5C8,
               uNumVertices,
               28));
-      v59->_45D74F_MessWithLight(-1, 0);
-    }
-    else
-    {
-      if ( !v9 || byte_4D864C && pGame->uFlags & 2 )
-      {
-        if ( (signed int)uNumVertices > 0 )
-        {
-          v45 = pTex;
-          v46 = (char *)&array_507D30[0].vWorldViewPosition;
-          v47 = (char *)&arary_77E5C8[0].pos.y;
-          pTex = (Texture *)uNumVertices;
-          do
-          {
-            v48 = *(float *)v46 * 0.061758894;
-            v49 = *((int *)v46 + 3);
-            *((int *)v47 + 4) = 0;
-            *((int *)v47 - 1) = v49;
-            *(int *)v47 = *((int *)v46 + 4);
-            *((int *)v47 + 3) = a3a;
-            v47 += 32;
-            *((float *)v47 - 7) = 1.0 - 1.0 / v48;
-            v50 = 1.0 / *(float *)v46;
-            v46 += 48;
-            v18 = pTex == (Texture *)1;
-            pTex = (Texture *)((char *)pTex - 1);
-            *((float *)v47 - 6) = v50;
-            a7 = v45->uTextureWidth;
-            *((float *)v47 - 3) = *((float *)v46 - 6) / (double)a7;
-            a7 = v45->uTextureHeight;
-            *((float *)v47 - 2) = *((float *)v46 - 5) / (double)a7;
-          }
-          while ( !v18 );
-        }
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
-        ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
-        v55 = 0;
-        v54 = 1490;
-        ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
-                D3DPT_TRIANGLEFAN,
-                452,
+      pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0);
+  }
+  else
+  {
+    if (!pGame->pLightmapBuilder->std__vector_000004_size ||
+        byte_4D864C && pGame->uFlags & 2)
+    {
+      for (uint i = 0; i < uNumVertices; ++i)
+      {
+        arary_77E5C8[i].pos.x = array_507D30[i].vWorldViewProjX;
+        arary_77E5C8[i].pos.y = array_507D30[i].vWorldViewProjY;
+        arary_77E5C8[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
+        arary_77E5C8[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
+        arary_77E5C8[i].diffuse = uCorrectedColor;
+        arary_77E5C8[i].specular = 0;
+        arary_77E5C8[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
+        arary_77E5C8[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
+      }
+
+      ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1));
+      ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
+      ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
                 arary_77E5C8,
                 uNumVertices,
                 28));
-      }
-      else
-      {
+    }
+    else
+    {
+      __debugbreak();
         if ( (signed int)uNumVertices > 0 )
         {
           v23 = pTex;
           v24 = (char *)&array_507D30[0].vWorldViewPosition;
           v25 = (char *)&arary_77E5C8[0].pos.y;
           pTex = (Texture *)uNumVertices;
+          uint v18;
           do
           {
             v26 = *(float *)v24 * 0.061758894;
@@ -7805,7 +7695,7 @@
             *((int *)v25 + 4) = 0;
             *((int *)v25 - 1) = v27;
             *(int *)v25 = *((int *)v24 + 4);
-            *((int *)v25 + 3) = a7;
+            *((int *)v25 + 3) = uColor;
             v25 += 32;
             *((float *)v25 - 7) = 1.0 - 1.0 / v26;
             v28 = 1.0 / *(float *)v24;
@@ -7813,10 +7703,10 @@
             v18 = pTex == (Texture *)1;
             pTex = (Texture *)((char *)pTex - 1);
             *((float *)v25 - 6) = v28;
-            a3 = (BLVFace *)v23->uTextureWidth;
-            *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)a3;
-            a3 = (BLVFace *)v23->uTextureHeight;
-            *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)a3;
+            //a3 = (BLVFace *)v23->uTextureWidth;
+            *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth;
+            //a3 = (BLVFace *)v23->uTextureHeight;
+            *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight;
           }
           while ( !v18 );
         }
@@ -7825,19 +7715,19 @@
         ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
                 D3DPT_TRIANGLEFAN,
-                452,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
                 arary_77E5C8,
                 uNumVertices,
                 28));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
-        v59->_45D74F_MessWithLight(-1, 0);
+        pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0);
         v33 = uNumVertices;
         if ( (signed int)uNumVertices > 0 )
         {
           v34 = (char *)&arary_77E5C8[0].diffuse;
           do
           {
-            *(int *)v34 = a3a;
+            *(int *)v34 = uCorrectedColor;
             v34 += 32;
             --v33;
           }
@@ -7851,14 +7741,13 @@
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3));
         ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
                 D3DPT_TRIANGLEFAN,
-                452,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
                 arary_77E5C8,
                 uNumVertices,
                 28));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1));
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false));
-      }
     }
   }
 }
@@ -7866,7 +7755,7 @@
 
 
 //----- (004A43B1) --------------------------------------------------------
-void Render::_4A43B1(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int a4)
+void Render::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex)
 {
   RenderBillboardTransform_local0 *v4; // ebx@2
   double v5; // st7@2
@@ -7903,23 +7792,23 @@
   if ( this->uNumD3DSceneBegins )
   {
     v4 = pSoftBillboard;
-    v5 = (double)HIWORD(pSoftBillboard->field_28);
+    v5 = (double)HIWORD(pSoftBillboard->sZValue);
     pSoftBillboarda = v5;
     v6 = v5;
     v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6));
-    v8 = a4;
+    v8 = uPaletteSubindex;
     v9 = v7;
-    v28 = a4 & 0xFF000000;
-    if ( a4 & 0xFF000000 )
-      pBillboardRenderListD3D[v9].bOpaque = 3;
+    v28 = uPaletteSubindex & 0xFF000000;
+    if ( uPaletteSubindex & 0xFF000000 )
+      pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Opaque_3;
     else
-      pBillboardRenderListD3D[v9].bOpaque = 0;
+      pBillboardRenderListD3D[v9].uOpacity = RenderBillboardD3D::Transparent;
     v10 = a3;
     pBillboardRenderListD3D[v9].field_90 = v4->field_44;
-    pBillboardRenderListD3D[v9].field_94 = v4->field_28;
+    pBillboardRenderListD3D[v9].sZValue = v4->sZValue;
     pBillboardRenderListD3D[v9].uParentBillboardID = v4->uParentBillboardID;
-    v25 = v4->field_8;
-    v24 = v4->field_C;
+    v25 = v4->uScreenSpaceX;
+    v24 = v4->uScreenSpaceY;
     a1 = (double)(v4->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_10);
     v29 = (double)(v4->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_14);
     v31 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX);
@@ -7956,39 +7845,39 @@
       v17 = v17 * -1.0;
     pBillboardRenderListD3D[v9].pQuards[1].specular = 0;
     pBillboardRenderListD3D[v9].pQuards[1].diffuse = v12;
-    *(float *)(v9 * 156 + 15684320) = v13 - v17 * a1;
-    *(float *)(v9 * 156 + 15684324) = v32 - v18 * v29;
-    *(float *)(v9 * 156 + 15684328) = v15;
-    *(float *)(v9 * 156 + 15684332) = v16;
-    *(float *)(v9 * 156 + 15684344) = 0.0;
-    *(float *)(v9 * 156 + 15684348) = 1.0;
+    pBillboardRenderListD3D[v9].pQuards[1].pos.x = v13 - v17 * a1;
+    pBillboardRenderListD3D[v9].pQuards[1].pos.y = v32 - v18 * v29;
+    pBillboardRenderListD3D[v9].pQuards[1].pos.z = v15;
+    pBillboardRenderListD3D[v9].pQuards[1].rhw = v16;
+    pBillboardRenderListD3D[v9].pQuards[1].texcoord.x = 0.0;
+    pBillboardRenderListD3D[v9].pQuards[1].texcoord.y = 1.0;
     v19 = v10->uBufferHeight - v10->uAreaY - v10->uAreaHeight;
     v20 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth);
     if ( v4->uFlags & 4 )
       v20 = v20 * -1.0;
     pBillboardRenderListD3D[v9].pQuards[2].specular = 0;
     pBillboardRenderListD3D[v9].pQuards[2].diffuse = v12;
-    *(float *)(v9 * 156 + 15684352) = v20 * a1 + v13;
-    *(float *)(v9 * 156 + 15684356) = v32 - (double)v19 * v29;
-    *(float *)(v9 * 156 + 15684360) = v15;
-    *(float *)(v9 * 156 + 15684364) = v16;
-    *(float *)(v9 * 156 + 15684376) = 1.0;
-    *(float *)(v9 * 156 + 15684380) = 1.0;
+    pBillboardRenderListD3D[v9].pQuards[2].pos.x = v20 * a1 + v13;
+    pBillboardRenderListD3D[v9].pQuards[2].pos.y = v32 - (double)v19 * v29;
+    pBillboardRenderListD3D[v9].pQuards[2].pos.z = v15;
+    pBillboardRenderListD3D[v9].pQuards[2].rhw = v16;
+    pBillboardRenderListD3D[v9].pQuards[2].texcoord.x = 1.0;
+    pBillboardRenderListD3D[v9].pQuards[2].texcoord.y = 1.0;
     v21 = v10->uBufferHeight - v10->uAreaY;
     v22 = (double)(v10->uAreaX + v10->uAreaWidth + (v10->uBufferWidth >> 1) - v10->uBufferWidth);
     if ( v4->uFlags & 4 )
       v22 = v22 * -1.0;
     pBillboardRenderListD3D[v9].pQuards[3].specular = 0;
     pBillboardRenderListD3D[v9].pQuards[3].diffuse = v12;
-    *(float *)(v9 * 156 + 15684384) = v22 * a1 + v13;
-    *(float *)(v9 * 156 + 15684388) = v32 - (double)v21 * v29;
-    *(float *)(v9 * 156 + 15684392) = v15;
-    *(float *)(v9 * 156 + 15684396) = v16;
-    *(float *)(v9 * 156 + 15684408) = 1.0;
-    *(float *)(v9 * 156 + 15684412) = 0.0;
+    pBillboardRenderListD3D[v9].pQuards[3].pos.x = v22 * a1 + v13;
+    pBillboardRenderListD3D[v9].pQuards[3].pos.y = v32 - (double)v21 * v29;
+    pBillboardRenderListD3D[v9].pQuards[3].pos.z = v15;
+    pBillboardRenderListD3D[v9].pQuards[3].rhw = v16;
+    pBillboardRenderListD3D[v9].pQuards[3].texcoord.x = 1.0;
+    pBillboardRenderListD3D[v9].pQuards[3].texcoord.y = 0.0;
     v23 = v10->pTexture;
     pBillboardRenderListD3D[v9].uNumVertices = 4;
-    *(float *)(v9 * 156 + 15684416) = pSoftBillboarda;
+    pBillboardRenderListD3D[v9].flt_88 = pSoftBillboarda;
     pBillboardRenderListD3D[v9].pTexture = v23;
   }
 }
@@ -8043,18 +7932,18 @@
 
   if ( this->uNumD3DSceneBegins )
   {
-    if ( HIWORD(a2->field_28) )
-    {
-      v5 = (double)HIWORD(a2->field_28);
+    if ( HIWORD(a2->sZValue) )
+    {
+      v5 = (double)HIWORD(a2->sZValue);
       v6 = v5;
       v7 = v5;
       v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
-      pBillboardRenderListD3D[v8].bOpaque = 1;
+      pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1;
       pBillboardRenderListD3D[v8].field_90 = a2->field_44;
-      pBillboardRenderListD3D[v8].field_94 = a2->field_28;
+      pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
       pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID;
-      v9 = a2->field_8;
-      v10 = a2->field_C;
+      v9 = a2->uScreenSpaceX;
+      v10 = a2->uScreenSpaceY;
       v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10);
       v12 = (double)v9;
       v13 = v12;
@@ -8077,7 +7966,7 @@
            + ((double)(unsigned __int16)v20 * 0.000015259022 + (double)(v20 >> 16)) * v16
            - 12.0)
           * v11
-          + (double)a2->field_C;
+          + (double)a2->uScreenSpaceY;
       pBillboardRenderListD3D[v8].pQuards[0].specular = 0;
       pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse;
       pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22;
@@ -8085,8 +7974,8 @@
       pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / v6;
       pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0;
       pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0;
-      v23 = (double)(a2->field_8 - 12) - v13;
-      v24 = (double)a2->field_C - v15;
+      v31 = (double)(a2->uScreenSpaceX + 12) - v13;
+      v32 = (double)a2->uScreenSpaceY - v15;
       v25 = stru_5C6E00->SinCos(angle);
       v26 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
       v27 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
@@ -8102,7 +7991,7 @@
            + ((double)(unsigned __int16)v27 * 0.000015259022 + (double)(v27 >> 16)) * v23
            - 12.0)
           * v11
-          + (double)a2->field_C;
+          + (double)a2->uScreenSpaceY;
       pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z;
       v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw;
       pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29;
@@ -8111,8 +8000,8 @@
       pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse;
       pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0;
       pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0;
-      v31 = (double)(a2->field_8 + 12) - v13;
-      v32 = (double)a2->field_C - v15;
+      v23 = (double)(a2->uScreenSpaceX - 12) - v13;
+      v24 = (double)a2->uScreenSpaceY - v15;
       v33 = stru_5C6E00->SinCos(angle);
       v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
       v35 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
@@ -8129,7 +8018,7 @@
            + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v31
            - 12.0)
           * v11
-          + (double)a2->field_C;
+          + (double)a2->uScreenSpaceY;
       pBillboardRenderListD3D[v8].pQuards[2].specular = 0;
       pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37;
       pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw;
@@ -8137,8 +8026,8 @@
       pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38;
       pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0;
       pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0;
-      v39 = (double)(a2->field_8 + 12) - v13;
-      v40 = (double)(a2->field_C - 25) - v15;
+      v39 = (double)(a2->uScreenSpaceX + 12) - v13;
+      v40 = (double)(a2->uScreenSpaceY - 25) - v15;
       v41 = stru_5C6E00->SinCos(angle);
       v42 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
       v43 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
@@ -8154,7 +8043,7 @@
            + ((double)(unsigned __int16)v43 * 0.000015259022 + (double)(v43 >> 16)) * v39
            - 12.0)
           * v11
-          + (double)a2->field_C;
+          + (double)a2->uScreenSpaceY;
       v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z;
       pBillboardRenderListD3D[v8].pQuards[3].specular = 0;
       pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46;
@@ -8219,16 +8108,16 @@
 
   if ( this->uNumD3DSceneBegins )
   {
-    v5 = (double)HIWORD(a2->field_28);
+    v5 = (double)HIWORD(a2->sZValue);
     v6 = v5;
     v7 = v5;
     v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
-    pBillboardRenderListD3D[v8].bOpaque = 1;
+    pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1;
     pBillboardRenderListD3D[v8].field_90 = a2->field_44;
-    pBillboardRenderListD3D[v8].field_94 = a2->field_28;
+    pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
     pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID;
-    v9 = a2->field_8;
-    v10 = a2->field_C;
+    v9 = a2->uScreenSpaceX;
+    v10 = a2->uScreenSpaceY;
     v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10);
     v12 = (double)v9;
     v13 = v12;
@@ -8252,7 +8141,7 @@
          + ((double)(unsigned __int16)v21 * 0.000015259022 + (double)(v21 >> 16)) * v16
          - 12.0)
         * v11
-        + (double)a2->field_C;
+        + (double)a2->uScreenSpaceY;
     pBillboardRenderListD3D[v8].pQuards[0].specular = 0;
     pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse;
     pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23;
@@ -8262,8 +8151,8 @@
     pBillboardRenderListD3D[v8].pQuards[0].rhw = v25;
     pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0;
     pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0;
-    v26 = (double)(a2->field_8 - 12) - v13;
-    v27 = (double)a2->field_C - v15;
+    v26 = (double)(a2->uScreenSpaceX - 12) - v13;
+    v27 = (double)a2->uScreenSpaceY - v15;
     v28 = stru_5C6E00->SinCos(angle);
     v29 = stru_5C6E00->SinCos(v19);
     v30 = stru_5C6E00->SinCos(v19);
@@ -8279,7 +8168,7 @@
          + ((double)(unsigned __int16)v30 * 0.000015259022 + (double)(v30 >> 16)) * v26
          - 12.0)
         * v11
-        + (double)a2->field_C;
+        + (double)a2->uScreenSpaceY;
     pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24;
     pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32;
     pBillboardRenderListD3D[v8].pQuards[1].specular = 0;
@@ -8287,8 +8176,8 @@
     pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse;
     pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0;
     pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0;
-    v33 = (double)(a2->field_8 + 12) - v13;
-    v34 = (double)a2->field_C - v15;
+    v33 = (double)(a2->uScreenSpaceX + 12) - v13;
+    v34 = (double)a2->uScreenSpaceY - v15;
     v35 = stru_5C6E00->SinCos(angle);
     v36 = stru_5C6E00->SinCos(v19);
     v37 = stru_5C6E00->SinCos(v19);
@@ -8304,7 +8193,7 @@
          + ((double)(unsigned __int16)v37 * 0.000015259022 + (double)(v37 >> 16)) * v33
          - 12.0)
         * v11
-        + (double)a2->field_C;
+        + (double)a2->uScreenSpaceY;
     pBillboardRenderListD3D[v8].pQuards[2].specular = 0;
     pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24;
     pBillboardRenderListD3D[v8].pQuards[2].rhw = v25;
@@ -8312,8 +8201,8 @@
     pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39;
     pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0;
     pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0;
-    v40 = (double)(a2->field_8 + 12) - v13;
-    v41 = (double)(a2->field_C - 25) - v15;
+    v40 = (double)(a2->uScreenSpaceX + 12) - v13;
+    v41 = (double)(a2->uScreenSpaceY - 25) - v15;
     v42 = stru_5C6E00->SinCos(angle);
     v43 = stru_5C6E00->SinCos(v19);
     v44 = stru_5C6E00->SinCos(v19);
@@ -8329,7 +8218,7 @@
          + ((double)(unsigned __int16)v44 * 0.000015259022 + (double)(v44 >> 16)) * v40
          - 12.0)
         * v11
-        + (double)a2->field_C;
+        + (double)a2->uScreenSpaceY;
     pBillboardRenderListD3D[v8].pQuards[3].specular = 0;
     pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24;
     pBillboardRenderListD3D[v8].pQuards[3].rhw = v25;
@@ -8383,20 +8272,20 @@
   if ( a1->uNumD3DSceneBegins )
   {
     v5 = a2;
-    v6 = (double)HIWORD(a2->field_28);
+    v6 = (double)HIWORD(a2->sZValue);
     v31 = v6;
     v7 = v6;
     v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
     if ( BYTE3(v5->uTintColor) )
-      pBillboardRenderListD3D[v8].bOpaque = 3;
+      pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3;
     else
-      pBillboardRenderListD3D[v8].bOpaque = 0;
+      pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent;
     v9 = pSprite;
     pBillboardRenderListD3D[v8].field_90 = v5->field_44;
-    pBillboardRenderListD3D[v8].field_94 = v5->field_28;
+    pBillboardRenderListD3D[v8].sZValue = v5->sZValue;
     pBillboardRenderListD3D[v8].uParentBillboardID = v5->uParentBillboardID;
-    v24 = v5->field_8;
-    v23 = v5->field_C;
+    v24 = v5->uScreenSpaceX;
+    v23 = v5->uScreenSpaceY;
     v30 = (double)(v5->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_10);
     v29 = (double)(v5->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_14);
     pSpritea = (double)((v9->uBufferWidth >> 1) - v9->uAreaX);
@@ -8481,7 +8370,7 @@
 
 
 //----- (004A48E4) --------------------------------------------------------
-int Render::_4A48E4(int a2, int a3, int a4, int a5, int a6)
+int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6)
 {
   int v6; // ecx@1
   int v7; // ebx@1
@@ -8498,8 +8387,8 @@
   unsigned int v18; // [sp+28h] [bp+Ch]@1
   int v19; // [sp+34h] [bp+18h]@1
 
-  v6 = a2;
-  v7 = (a6 >> 1) + a3;
+  v6 = screenSpaceX;
+  v7 = (a6 >> 1) + screenSpaceY;
   v17 = 0;
   v15 = 0;
   v8 = (a6 >> 1) + v6;
@@ -8507,22 +8396,22 @@
   v9 = 2 * (a6 >> 1);
   v10 = (a6 >> 1) * ((a6 >> 1) - 1);
   x = v8 - (a6 >> 1);
-  v16 = (a6 >> 1) + a3 - v8;
+  v16 = (a6 >> 1) + screenSpaceY - v8;
   v19 = a6 >> 1;
   v13 = v9;
   v18 = v8;
   do
   {
-    sub_4A46E6(x, v16 + v18, a4, 2 * v19, a5);
+    sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor);
     if ( v15 )
-      sub_4A46E6(x, v17 + v7, a4, 2 * v19, a5);
+      sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor);
     v14 -= v15;
     if ( v14 <= v10 )
     {
       if ( v19 != v17 )
       {
-        sub_4A46E6(v18, v16 + x, a4, 2 * v17, a5);
-        sub_4A46E6(v18, v19 + v7, a4, 2 * v17, a5);
+        sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor);
+        sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor);
       }
       --v19;
       v13 -= 2;
@@ -8661,7 +8550,7 @@
   ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9));
   ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
     D3DPT_TRIANGLEFAN,
-    452,
+    D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
     v29,
     4,
     24));
@@ -8713,7 +8602,7 @@
     v6 = 0;
     pBillboardRenderListD3D[v5].field_90 = 0;
     pBillboardRenderListD3D[v5].uParentBillboardID = -1;
-    pBillboardRenderListD3D[v5].bOpaque = 2;
+    pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2;
     if ( a1->field_10 > 0 )
     {
       v7 = (char *)&a1->field_14[62];
@@ -8755,22 +8644,12 @@
 //----- (004A4DE1) --------------------------------------------------------
 bool Render::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
 {
-  //const char *v5; // ebx@1
-  //Render *v6; // edi@1
-  //HWLTexture *pHWLTexture; // esi@1
-  //signed int result; // eax@1
-  //IDirectDrawSurface **v9; // ebx@9
-  //IDirectDrawSurface4 *v10; // edi@11
-  //int v11; // ebx@11
   HRESULT v12; // eax@14
   unsigned __int16 *v13; // ecx@19
   unsigned __int16 *v14; // eax@19
   DWORD v15; // edx@20
   HRESULT v16; // eax@23
   stru350 Dst; // [sp+Ch] [bp-F8h]@12
-  //DDSURFACEDESC2 desc; // [sp+6Ch] [bp-98h]@13
-  //DDSCAPS2 v19; // [sp+E8h] [bp-1Ch]@13
-  //int v20; // [sp+100h] [bp-4h]@12
 
   auto pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
   if ( pHWLTexture )
@@ -9149,7 +9028,7 @@
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u));
     ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
       D3DPT_TRIANGLEFAN,
-      452,
+      D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
       v36,
       4,
       28));
@@ -9675,52 +9554,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;
+    }
 }
 
 
@@ -10946,15 +10793,15 @@
           dword_A74C88 = 1;
         goto LABEL_38;
       }
-      v6 = &stru_506F20;
-      stru_506F20.Release();
+      v6 = &pTexture_PCX;
+      pTexture_PCX.Release();
       v9 = 0;
       v8 = "makeme.pcx";
     }
     else
     {
-      v6 = &stru_506F20;
-      stru_506F20.Release();
+      v6 = &pTexture_PCX;
+      pTexture_PCX.Release();
       v7 = "title.pcx";
       if ( uCurrentMenuID )
         v7 = "lsave640.pcx";
@@ -11269,4 +11116,101 @@
   fread(pSpriteOffsets, 4, uNumItems, pFile);
 
   return true;
-}
\ No newline at end of file
+}
+
+
+
+
+
+
+
+
+
+//----- (004A1C1E) --------------------------------------------------------
+void DoRenderBillboards_D3D()
+{
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
+
+  for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i)
+  {
+    auto p = pRenderer->pBillboardRenderListD3D + i;
+
+    if (p->uOpacity != RenderBillboardD3D::InvalidOpacity)
+      SetBillboardBlendOptions(p->uOpacity);
+    
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+        D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+        p->pQuards,
+        p->uNumVertices,
+        D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS));
+  }
+
+  if (pRenderer->bFogEnabled)
+  {
+    pRenderer->bFogEnabled = false;
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
+    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
+  }
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
+}
+
+
+
+
+
+//----- (004A1DA8) --------------------------------------------------------
+void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1)
+{
+  switch (a1)
+  {
+    case RenderBillboardD3D::Transparent:
+    {
+      if (pRenderer->bFogEnabled)
+      {
+        pRenderer->bFogEnabled = false;
+        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
+        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, GetLevelFogColor() & 0xFFFFFF));
+        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
+      }
+
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1));
+    }
+    break;
+
+    case RenderBillboardD3D::Opaque_1:
+    case RenderBillboardD3D::Opaque_2:
+    case RenderBillboardD3D::Opaque_3:
+    {
+      if (pRenderer->bUsingSpecular)
+      {
+        if (!pRenderer->bFogEnabled)
+        {
+          pRenderer->bFogEnabled = true;
+          ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
+        }
+      }
+
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
+      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
+    }
+    break;
+
+    default:
+      Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1);
+    break;
+  }
+}
+
--- a/Render.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Render.h	Mon Oct 29 09:28:08 2012 +0600
@@ -18,6 +18,10 @@
 #pragma pack(push, 1)
 struct RenderVertexSoft
 {
+  inline RenderVertexSoft():
+    flt_2C(0.0f)
+  {}
+
   Vec3_float_ vWorldPosition;
   Vec3_float_ vWorldViewPosition;
   float vWorldViewProjX;
@@ -50,21 +54,21 @@
 {
   int field_0;
   int field_4;
-  float flt_8;
-  float flt_C;
+  float fov_x;
+  float fov_y;
   int sZValue;
   int field_14;
   unsigned __int16 uHwSpriteID;
   __int16 uPalette;
   __int16 uIndoorSectorID;
   __int16 field_1E;
-  __int16 field_20;
-  __int16 field_22;
-  __int16 field_24;
-  __int16 field_26;
-  __int16 field_28;
-  __int16 field_2A;
-  int field_2C_prolly_tint;
+  __int16 some_x;
+  __int16 some_y;
+  __int16 some_z;
+  __int16 uScreenSpaceX;
+  __int16 uScreenSpaceY;
+  unsigned __int16 uPaletteSubindex;
+  unsigned int uTintColor;
   SpriteFrame *pSpriteFrame;
 };
 #pragma pack(pop)
@@ -167,13 +171,22 @@
 #pragma pack(push, 1)
 struct RenderBillboardD3D
 {
+  enum OpacityType: unsigned __int32
+  {
+    Transparent = 0,
+    Opaque_1 = 1,
+    Opaque_2 = 2,
+    Opaque_3 = 3,
+    InvalidOpacity = 0xFFFFFFFF
+  };
+
   IDirect3DTexture2 *pTexture;
   unsigned int uNumVertices;
   RenderVertexD3D3 pQuards[4];
   float flt_88;
-  unsigned int bOpaque;
+  OpacityType uOpacity;
   int field_90;
-  int field_94;
+  int sZValue;
   unsigned int uParentBillboardID;
 };
 #pragma pack(pop)
@@ -264,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();
@@ -291,19 +304,19 @@
   unsigned int Billboard_ProbablyAddToListAndSortByZOrder(unsigned int a1);
   unsigned int GetBillboardDrawListSize();
   unsigned int GetParentBillboardID(unsigned int uBillboardID);
-  void SetGameRenderStates();
+  void BeginSceneD3D();
   void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
   unsigned int GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6);
   void DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture);
   void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7);
   void DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *a4);
   void _4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex);
-  void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int a6, int a7, int a8);
+  void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8);
   void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
   void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
   void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int a1a, RenderBillboard *pBillboard);
-  void _4A43B1(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int a4);
-  int _4A48E4(int a2, int a3, int a4, int a5, int a6);
+  void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex);
+  int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6);
   void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9);
   void _4A4CC9(struct stru6_stru1_indoor_sw_billboard *a1, int a2);
   bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture);
@@ -326,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();
@@ -409,7 +422,7 @@
   unsigned int uMinDeviceTextureDim;
   int field_10365C;
   unsigned int bUsingSpecular;
-  float uFogColor;
+  uint uFogColor;
   int field_103668;
   unsigned int pHDWaterBitmapIDs[7];
   char field_103688[32];
@@ -421,7 +434,7 @@
   int _gpu_memory_used;
   void (__cdecl *pBeforePresentFunction)();
   int field_1036C4;
-  int turnFogOn;
+  uint bFogEnabled;
   int field_1036CC;
   RenderBillboardD3D pBillboardRenderListD3D[1000];
   unsigned int uNumBillboardsToDraw;
@@ -444,14 +457,14 @@
 {
   unsigned __int16 *pTarget;
   int *pTargetZ;
-  int field_8;
-  int field_C;
+  int uScreenSpaceX;
+  int uScreenSpaceY;
   int field_10;
   int field_14;
   char field_18[8];
   unsigned __int16 *pPalette;
   unsigned __int16 *pPalette2;
-  int field_28;
+  int sZValue;
   unsigned int uFlags;
   unsigned int uTargetPitch;
   unsigned int uViewportX;
--- a/SaveLoad.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/SaveLoad.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -42,45 +42,13 @@
 //----- (0045EE8A) --------------------------------------------------------
 void __fastcall LoadGame(unsigned int uSlot)
 {
-  //unsigned int v1; // ebx@1
-  //char v2; // zf@1
-  //signed int v3; // esi@3
-  //signed int v4; // esi@8
-  //char *v5; // eax@9
-  //unsigned int v6; // eax@12
-  //unsigned int v7; // esi@13
-  //char *v8; // ecx@14
-  //FILE *v9; // eax@22
-  //FILE *v10; // eax@26
-  //FILE *v11; // eax@29
-  //FILE *v12; // eax@32
-  //FILE *v13; // eax@35
-  //FILE *v14; // eax@38
-  //unsigned int v15; // edi@41
-  //Player *v16; // esi@41
-  //int *v17; // esi@46
-  //int v18; // edi@46
-  //int v19; // ebx@46
-  //int v20; // ecx@49
-  //int v21; // eax@51
-  //int v22; // ecx@56
-  //bool v23; // edx@56
-  //AudioPlayer *v24; // ebx@60
   bool v25; // esi@62
   bool v26; // eax@62
-  //signed int v27; // esi@66
-  //RGBTexture *v28; // edi@67
-  std::string v29; // [sp-18h] [bp-108h]@25
   int v30; // [sp-Ch] [bp-FCh]@65
   int v31; // [sp-8h] [bp-F8h]@4
-  //signed int v32; // [sp-4h] [bp-F4h]@4
   char DstBuf[100]; // [sp+Ch] [bp-E4h]@23
-  //char pContainer; // [sp+20h] [bp-D0h]@62
   char Str[123]; // [sp+70h] [bp-80h]@25
-  //char a3[5]; // [sp+EBh] [bp-5h]@2
 
-  //v1 = uSlot;
-  //v2 = pSavegameUsedSlots[uSlot] == 0;
   dword_5B65C8 = 0;
   if (!pSavegameUsedSlots[uSlot])
   {
@@ -221,7 +189,7 @@
 
 
   pGUIWindow_CurrentMenu->Release();
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+  pCurrentScreen = 0;
 
   viewparams->bRedrawGameUI = true;
 
@@ -321,7 +289,7 @@
   int v61; // [sp+224h] [bp-4Ch]@30
   int v62; // [sp+228h] [bp-48h]@2
   LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2
-  std::string *v64; // [sp+24Ch] [bp-24h]@1
+  //std::string *v64; // [sp+24Ch] [bp-24h]@1
   size_t Size; // [sp+250h] [bp-20h]@26
   __int16 *v66; // [sp+254h] [bp-1Ch]@1
   void *DstBuf; // [sp+258h] [bp-18h]@2
@@ -332,42 +300,49 @@
   int a3; // [sp+26Fh] [bp-1h]@8
 
   v66 = a2;
-  v64 = (std::string *)a1;
+  //v64 = (std::string *)a1;
+
   strcpy(byte_6BE3B0, pCurrentMapName);
-  result = _strcmpi(pCurrentMapName, "d05.blv");
-  if ( result )
-  {
-    DstBuf = operator new(0xF4240u);
-    pDir.Reset();
+  if (!_strcmpi(pCurrentMapName, "d05.blv"))
+    return false;
+
+  DstBuf = malloc(0xF4240u);
+  pDir.Reset();
     v52 = pParty->vPosition.x;
-    v51 = pParty->vPosition.z;
-    v62 = pParty->vPosition.y;
+    v51 = pParty->vPosition.y;
+    v62 = pParty->vPosition.z;
     v53 = pParty->sRotationY;
     v54 = pParty->sRotationX;
-    pParty->vPosition.x = pParty->vPrevPosition.x;
-    pParty->vPosition.z = pParty->vPrevPosition.z;
-    pParty->vPosition.y = pParty->vPrevPosition.y;
-    pParty->uFallStartY = pParty->vPrevPosition.y;
-    pParty->sRotationY = pParty->sPrevRotationY;
-    pParty->sRotationX = pParty->sPrevRotationX;
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
-    else
-      pOutdoor->uLastVisitDay = pParty->uTimePlayed;
-    v3 = MakeScreenshot(150, 112);
-    strcpy((char *)&pDir, "image.pcx");
+  pParty->vPosition.x = pParty->vPrevPosition.x;
+  pParty->vPosition.y = pParty->vPrevPosition.z;
+  pParty->vPosition.z = pParty->vPrevPosition.y;
+  pParty->uFallStartY = pParty->vPrevPosition.y;
+  pParty->sRotationY = pParty->sPrevRotationY;
+  pParty->sRotationX = pParty->sPrevRotationX;
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
+  else
+    pOutdoor->uLastVisitDay = pParty->uTimePlayed;
+
+  v3 = MakeScreenshot(150, 112);
+  {
+    strcpy(pDir.pFilename, "image.pcx");
+
     pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
-    free(v3);
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
+  }
+  free(v3);
+
+    if ( pCurrentScreen == 11 )
     {
       pRenderer->DrawTextureIndexed(
         8u,
         8u,
-        (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+        (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
       pRenderer->DrawTextureIndexed(
         0x12u,
         0x8Du,
-        (Texture *)(uTextureID_save_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_save_up] : 0));
+        (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
       v36 = pGlobalTXT_LocalizationStrings[190];
       v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]);
       pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, v36, 0, 0, 0);
@@ -447,13 +422,13 @@
       {
         v39 = v69;
         v38 = (const char *)v70;
-        sprintfex(Str, "data\\lloyd%d%d.pcx", v70, v69);
+        sprintf(Str, "data\\lloyd%d%d.pcx", v70, v69);
         v8 = fopen(Str, "rb");
         if ( v8 )
         {
           v39 = v69;
           v38 = (const char *)v70;
-          sprintfex(Str, "lloyd%d%d.pcx", v70, v69);
+          sprintf(Str, "lloyd%d%d.pcx", v70, v69);
           fseek(v8, 0, 2);
           pDir.uDataSize = ftell(v8);
           rewind(v8);
@@ -464,7 +439,7 @@
           if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
           {
             v39 = 207;
-            sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 207);
+            sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
             Size = 5080748;
           }
@@ -475,7 +450,7 @@
       ++v70;
     }
     while ( v70 <= 4 );
-    if ( !v66 )
+    if ( !a2 )
     {
       sub_42FA22_mess_with_laying_item_list();
       v9 = (int)malloc(0xF4240u);
@@ -657,7 +632,7 @@
       free((void *)v9);
     }
     free(DstBuf);
-    if ( v64 )
+    if ( a1 )
     {
       if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
       {
@@ -669,13 +644,13 @@
       }
     }
     pParty->vPosition.x = v52;
-    pParty->vPosition.z = v51;
-    pParty->vPosition.y = v62;
+    pParty->vPosition.y = v51;
+    pParty->vPosition.z = v62;
     pParty->uFallStartY = v62;
     pParty->sRotationY = v53;
     result = v54;
     pParty->sRotationX = v54;
-  }
+
   return result;
 }
 
@@ -709,7 +684,7 @@
   }
   GUI_UpdateWindows();
   pGUIWindow_CurrentMenu->Release();
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+  pCurrentScreen = 0;
   v3 = pSavegameThumbnails;
   viewparams->bRedrawGameUI = 1;
   do
@@ -727,7 +702,7 @@
   ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!"
   viewparams->bRedrawGameUI = 1;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 
 
--- a/Texture.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Texture.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -55,7 +55,7 @@
 Texture *ptr_506440;
 Texture *pTexture_506444;
 Texture *pTexture_506448; // idb
-Texture pTextures_tabs[8][2];
+Texture *pTextures_tabs[8][2];
 Texture *pTexture_mapbordr; // idb
 Texture *pTexture_pagemask; // idb
 Texture *pTextures_5064A0[14];
@@ -70,7 +70,7 @@
 
 
 RGBTexture stru_506E40; // weak
-RGBTexture stru_506F20;
+RGBTexture pTexture_PCX;
 
 
 int uTextureID_RestUI_restb4; // weak
@@ -1114,317 +1114,194 @@
 //----- (0040EAD8) --------------------------------------------------------
 unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile)
 {
-  RGBTexture *v4; // esi@1
-  unsigned int result; // eax@2
-  unsigned int v6; // ebx@3
-  unsigned __int16 v7; // cx@5
-  unsigned __int16 v8; // ax@5
-  unsigned int v9; // eax@5
-  char v10; // zf@5
-  signed int v11; // ecx@14
-  int v12; // ebx@19
-  signed int v13; // ecx@19
-  int v14; // ebx@52
-  unsigned __int16 *v15; // edi@52
-  __int16 v16; // ax@54
-  unsigned __int16 *v17; // edi@59
-  __int16 v18; // ax@61
-  unsigned __int16 *v19; // edi@66
-  unsigned __int16 v20; // ax@68
-  int v21; // eax@73
-  char DstBuf[60]; // [sp+Ch] [bp-90h]@3
-  char pColorMap[48]; // [sp+48h] [bp-54h]@3
-  PCXHeader1 pcxh1; // [sp+78h] [bp-24h]@3
-  PCXHeader2 pcxh2; // [sp+88h] [bp-14h]@3
-  int v26; // [sp+90h] [bp-Ch]@51
-  int v27; // [sp+94h] [bp-8h]@54
-  unsigned __int8 v28; // [sp+9Bh] [bp-1h]@54
+  signed int result; // eax@2
+  unsigned char test_byte; // edx@3
+  //unsigned int read_offset; // ebx@37
+  unsigned int row_position; // edi@40
+  unsigned char value; // cl@63
+  char count; // [sp+50h] [bp-Ch]@43
+  unsigned short current_line; // [sp+54h] [bp-8h]@38
+  unsigned short *dec_position; 
+  unsigned short *temp_dec_position; 
+  PCXHeader1 psx_head1;
+  PCXHeader2 psx_head2;
+	short int width, height;
+	BYTE  color_map[48];	// Colormap for 16-color images
 
-  v4 = this;
-  if ( pFile )
-  {
-    fread(&pcxh1, 1u, 1u, pFile);
-    fread(&pcxh1.version, 1u, 1u, pFile);
-    fread(&pcxh1.encoding, 1u, 1u, pFile);
-    fread(&pcxh1.bpp, 1u, 1u, pFile);
-    v6 = 2;
-    fread(&pcxh1.left, 2u, 1u, pFile);
-    fread(&pcxh1.up, 2u, 1u, pFile);
-    fread(&pcxh1.right, 2u, 1u, pFile);
-    fread(&pcxh1.bottom, 2u, 1u, pFile);
-    fread(&pcxh1.hres, 2u, 1u, pFile);
-    fread(&pcxh1.vres, 2u, 1u, pFile);
-    fread(pColorMap, 0x30u, 1u, pFile);
-    fread(&pcxh2, 1u, 1u, pFile);
-    fread(&pcxh2.planes, 1u, 1u, pFile);
-    fread(&pcxh2.pitch, 2u, 1u, pFile);
-    fread(&pcxh2.palette_info, 2u, 1u, pFile);
-    fread(DstBuf, 58u, 1u, pFile);
-    if ( pcxh1.bpp == 8 )
-    {
-      v7 = pcxh1.right - pcxh1.left + 1;
-      v8 = pcxh1.bottom - pcxh1.up;
-      v4->uWidth = v7;
-      ++v8;
-      v4->uHeight = v8;
-      v9 = (signed __int16)v7 * (signed __int16)v8;
-      v10 = mode == 0;
-      v4->uNumPixels = v9;
-      if ( v10 )
+  if (!pFile)
+    return 1;
+  
+ 
+ fread(&psx_head1, 1, 16, pFile);
+ fread(&color_map, 1, 48, pFile);
+ fread(&psx_head2, 1, 6, pFile);
+
+  if (psx_head1.bpp!=8)
+		return 3; 
+ uWidth=(short int )(psx_head1.right-psx_head1.left+1);  // word @ 000014
+ uHeight=(short int )(psx_head1.bottom-psx_head1.up+1);  // word @ 000016
+ 
+
+ uNumPixels=uWidth*uHeight;		  // dword @ 000010
+
+
+      if ( mode == 0 )
       {
-        if ( v4->pPixels )
+        if ( pPixels )
         {
-          pAllocator->FreeChunk(v4->pPixels);
-          v4->pPixels = 0;
+          pAllocator->FreeChunk(pPixels);
+          pPixels = 0;
         }
-        v4->pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk(
-                                            v4->pPixels,
-                                            2 * v4->uNumPixels + 4,
-                                            v4->pName);
-        v6 = 2;
+        pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk(
+                                            pPixels,
+                                            2 * uNumPixels + 4,
+                                            pName);
       }
       else
       {
         if ( mode != 1 && mode == 2 )
         {
-          operator new(2 * v9 + 4);
-          v4->pPixels = 0;
-          *(unsigned int *)&v4->field_20 |= 1u;
+          pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16));
+          field_20 |= 1;
         }
       }
-      if ( v4->pPixels )
+
+
+
+
+      auto pOutPixels = pPixels;
+ 
+ memset(pOutPixels, 0, uNumPixels * sizeof(__int16));
+
+  short i=1;
+  while ( (1<<i) !=uWidth)
+  {
+	  ++i;
+      if (i >= 15)
+	  break;
+  }
+  field_18=i;
+  short i_=1;
+  while ( (1<<i_) !=uHeight)
+  {
+	  ++i_;
+      if (i_ >= 15)
+	  break;
+  }
+  field_1A=i_;
+  switch (field_18)
+	  {
+  case 2:   field_1C = 3;    break;
+  case 3:   field_1C = 7;    break;
+  case 4:   field_1C = 15;   break;
+  case 5:   field_1C = 31;   break;
+  case 6:   field_1C = 63;   break;
+  case 7:   field_1C = 127;  break;
+  case 8:   field_1C = 255;  break;
+  case 9:   field_1C = 511;  break;
+  case 10:  field_1C = 1023; break;
+  case 11:  field_1C = 2047; break;
+  case 12:  field_1C = 4095; break;
+	  }
+
+  switch (field_1A)
+	  {
+  case 2:   field_1E = 3;    break;
+  case 3:   field_1E = 7;    break;
+  case 4:   field_1E = 15;   break;
+  case 5:   field_1E = 31;   break;
+  case 6:   field_1E = 63;   break;
+  case 7:   field_1E = 127;  break;
+  case 8:   field_1E = 255;  break;
+  case 9:   field_1E = 511;  break;
+  case 10:  field_1E = 1023; break;
+  case 11:  field_1E = 2047; break;
+  case 12:  field_1E = 4095; break;
+	  }
+
+
+  fseek(pFile, 128 - 70, SEEK_CUR);
+
+
+  for (uint y = 0; y < uHeight; ++y)
+  {
+    unsigned __int16 *pDst = pPixels + y * uWidth;
+
+    uint x = 0;
+    do
+    {
+      uint ctrl = 0;
+      fread(&ctrl, 1, 1, pFile);
+      if ((ctrl & 0xC0) == 0xC0)
       {
-        v11 = 1;
-        while ( 1 << v11 != v4->uWidth )
-        {
-          ++v11;
-          if ( v11 >= 15 )
-            goto LABEL_19;
-        }
-        v4->field_18 = v11;
-LABEL_19:
-        v12 = v4->uHeight;
-        v13 = 1;
-        while ( 1 << v13 != v12 )
-        {
-          ++v13;
-          if ( v13 >= 15 )
-            goto LABEL_24;
-        }
-        v4->field_1A = v13;
-LABEL_24:
-        switch ( v4->field_18 )
-        {
-          case 2:
-            v4->field_1C = 3;
-            break;
-          case 3:
-            v4->field_1C = 7;
-            break;
-          case 4:
-            v4->field_1C = 15;
-            break;
-          case 5:
-            v4->field_1C = 31;
-            break;
-          case 6:
-            v4->field_1C = 63;
-            break;
-          case 7:
-            v4->field_1C = 127;
-            break;
-          case 8:
-            v4->field_1C = 255;
-            break;
-          case 9:
-            v4->field_1C = 511;
-            break;
-          case 10:
-            v4->field_1C = 1023;
-            break;
-          case 11:
-            v4->field_1C = 2047;
-            break;
-          case 12:
-            v4->field_1C = 4095;
-            break;
-          default:
-            break;
-        }
-        switch ( v4->field_1A )
-        {
-          case 2:
-            v4->field_1E = 3;
-            break;
-          case 3:
-            v4->field_1E = 7;
-            break;
-          case 4:
-            v4->field_1E = 15;
-            break;
-          case 5:
-            v4->field_1E = 31;
-            break;
-          case 6:
-            v4->field_1E = 63;
-            break;
-          case 7:
-            v4->field_1E = 127;
-            break;
-          case 8:
-            v4->field_1E = 255;
-            break;
-          case 9:
-            v4->field_1E = 511;
-            break;
-          case 10:
-            v4->field_1E = 1023;
-            break;
-          case 11:
-            v4->field_1E = 2047;
-            break;
-          case 12:
-            v4->field_1E = 4095;
-            break;
-          default:
-            break;
-        }
-        if ( pcxh2.planes == 1 )
-          Abortf("24bit PCX Only!");
-        if ( pcxh2.planes == 3 )
-        {
-          v26 = 0;
-          if ( v12 > 0 )
-          {
-            do
-            {
-              v14 = 0;
-              v15 = &v4->pPixels[v26 * v4->uWidth];
-              if ( pcxh2.pitch )
-              {
-                do
-                {
-                  fread((char *)&mode + 3, 1u, 1u, pFile);
-                  if ( (BYTE3(mode) & 0xC0) == -64 )
-                  {
-                    BYTE3(mode) &= 0x3Fu;
-                    fread(&v28, 1u, 1u, pFile);
-                    v27 = 0;
-                    v16 = v28;
-                    if ( BYTE3(mode) )
-                    {
-                      do
-                      {
-                        ++v14;
-                        *v15 = LOWORD(pRenderer->uTargetRMask) & (v16 << (pRenderer->uTargetGBits
-                                                                       + pRenderer->uTargetRBits
-                                                                       + pRenderer->uTargetBBits
-                                                                       - 8));
-                        ++v15;
-                        ++v27;
-                      }
-                      while ( v27 < BYTE3(mode) );
-                    }
-                  }
-                  else
-                  {
-                    ++v14;
-                    *v15 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(mode) << (pRenderer->uTargetGBits
-                                                                           + pRenderer->uTargetRBits
-                                                                           + pRenderer->uTargetBBits
-                                                                           - 8));
-                    ++v15;
-                  }
-                }
-                while ( v14 < (unsigned __int16)pcxh2.pitch );
-              }
-              v17 = &v4->pPixels[v26 * v4->uWidth];
-              while ( v14 < 2 * (unsigned __int16)pcxh2.pitch )
-              {
-                fread((char *)&mode + 3, 1u, 1u, pFile);
-                if ( (BYTE3(mode) & 0xC0) == -64 )
-                {
-                  BYTE3(mode) &= 0x3Fu;
-                  fread(&v28, 1u, 1u, pFile);
-                  v27 = 0;
-                  v18 = v28;
-                  if ( BYTE3(mode) )
-                  {
-                    do
-                    {
-                      *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(v18 << (pRenderer->uTargetGBits
-                                                                                + pRenderer->uTargetBBits
-                                                                                - 8));
-                      ++v14;
-                      ++v17;
-                      ++v27;
-                    }
-                    while ( v27 < BYTE3(mode) );
-                  }
-                }
-                else
-                {
-                  *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(mode) << (pRenderer->uTargetGBits
-                                                                                    + pRenderer->uTargetBBits
-                                                                                    - 8));
-                  ++v14;
-                  ++v17;
-                }
-              }
-              v19 = &v4->pPixels[v26 * v4->uWidth];
-              while ( v14 < 3 * (unsigned __int16)pcxh2.pitch )
-              {
-                fread((char *)&mode + 3, 1u, 1u, pFile);
-                if ( (BYTE3(mode) & 0xC0) == -64 )
-                {
-                  BYTE3(mode) &= 0x3Fu;
-                  fread(&v28, 1u, 1u, pFile);
-                  v27 = 0;
-                  v20 = v28;
-                  if ( BYTE3(mode) )
-                  {
-                    do
-                    {
-                      *v19 |= v20 >> (8 - pRenderer->uTargetBBits);
-                      ++v14;
-                      ++v19;
-                      ++v27;
-                    }
-                    while ( v27 < BYTE3(mode) );
-                  }
-                }
-                else
-                {
-                  *v19 |= BYTE3(mode) >> (8 - pRenderer->uTargetBBits);
-                  ++v14;
-                  ++v19;
-                }
-              }
-              v21 = v4->uHeight;
-              ++v26;
-            }
-            while ( v26 < v21 );
-          }
-        }
-        if ( bCloseFile )
-          fclose(pFile);
-        result = 0;
+        uint uNumPixels = ctrl & 0x3F;
+        uint clr = 0;
+        fread(&clr, 1, 1, pFile);
+        for (uint i = 0; i < uNumPixels; ++i)
+          pDst[x++] = pRenderer->uTargetRMask & (clr << (pRenderer->uTargetGBits +
+                                                         pRenderer->uTargetRBits +
+                                                         pRenderer->uTargetBBits - 8));
       }
       else
       {
-        result = v6;
+        pDst[x++] = pRenderer->uTargetRMask & (ctrl << (pRenderer->uTargetGBits +
+                                                        pRenderer->uTargetRBits +
+                                                        pRenderer->uTargetBBits - 8));
       }
-    }
-    else
+    } while (x < psx_head2.pitch);
+
+
+
+
+
+    x = 0;
+    do
     {
-      result = 3;
-    }
+      uint ctrl = 0;
+      fread(&ctrl, 1, 1, pFile);
+      if ((ctrl & 0xC0) == 0xC0)
+      {
+        uint uNumPixels = ctrl & 0x3F;
+        uint clr = 0;
+        fread(&clr, 1, 1, pFile);
+        for (uint i = 0; i < uNumPixels; ++i)
+          pDst[x++] |= pRenderer->uTargetGMask & (clr << (pRenderer->uTargetGBits +
+                                                         pRenderer->uTargetBBits - 8));
+      }
+      else
+      {
+        pDst[x++] |= pRenderer->uTargetGMask & (ctrl << (pRenderer->uTargetGBits +
+                                                        pRenderer->uTargetBBits - 8));
+      }
+    } while (x < psx_head2.pitch);
+ 
+
+
+
+
+    x = 0;
+    do
+    {
+      uint ctrl = 0;
+      fread(&ctrl, 1, 1, pFile);
+      if ((ctrl & 0xC0) == 0xC0)
+      {
+        uint uNumPixels = ctrl & 0x3F;
+        uint clr = 0;
+        fread(&clr, 1, 1, pFile);
+        for (uint i = 0; i < uNumPixels; ++i)
+          pDst[x++] |= pRenderer->uTargetBMask & (clr >> (8 - pRenderer->uTargetBBits));
+      }
+      else
+      {
+        pDst[x++] |= pRenderer->uTargetBMask & (ctrl >> (8 - pRenderer->uTargetRBits));
+      }
+    } while (x < psx_head2.pitch);
   }
-  else
-  {
-    result = 1;
-  }
-  return result;
+
+  if (bCloseFile)
+    fclose(pFile);
+  return 0;
 }
 
 //----- (0040E51F) --------------------------------------------------------
--- a/Texture.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/Texture.h	Mon Oct 29 09:28:08 2012 +0600
@@ -157,7 +157,7 @@
 extern Texture *ptr_506440;
 extern Texture *pTexture_506444;
 extern Texture *pTexture_506448; // idb
-extern Texture pTextures_tabs[8][2];
+extern Texture *pTextures_tabs[8][2];
 extern Texture *pTexture_mapbordr; // idb
 extern Texture *pTexture_pagemask; // idb
 extern Texture *pTextures_5064A0[14];
@@ -172,7 +172,7 @@
 
 
 extern RGBTexture stru_506E40; // weak
-extern RGBTexture stru_506F20;
+extern RGBTexture pTexture_PCX;
 
 
 extern int uTextureID_RestUI_restb4; // weak
--- a/TurnEngine.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/TurnEngine.h	Mon Oct 29 09:28:08 2012 +0600
@@ -18,7 +18,7 @@
 struct stru262_TurnBased
 {
   signed int _404544();
-  int _40471C();
+  void _40471C();
   signed int Start();
   void End(bool bPlaySound);
   void _405E14();
--- a/VideoPlayer.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/VideoPlayer.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -364,7 +364,7 @@
       pRenderer->ClearTarget(0);
       pRenderer->EndScene();
     }
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 16;
+    pCurrentScreen = 16;
     if ( pVideoPlayer->uMovieFormat == 2 )
     {
       if ( pVideoPlayer->pBinkMovie )
@@ -423,11 +423,11 @@
       }
     }
     if ( a4 == 1 )
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+      pCurrentScreen = 0;
     pVideoPlayer->bPlayingMovie = 0;
     ShowCursor(1);
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16 )
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+    if ( pCurrentScreen == 16 )
+      pCurrentScreen = 0;
   }
 }
 
@@ -919,7 +919,7 @@
       SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
 
       if (uBinkVersion < 0x0003000000000000)
-        return BinkOpen(hMightVid, 0x08800000);
+        return BinkOpen(hMightVid, 0x8800000);
       else
         return BinkOpen(hMightVid, 0x82000000);
     }
@@ -930,7 +930,7 @@
       SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
 
       if (uBinkVersion < 0x0003000000000000)
-        return BinkOpen(hMagicVid, 0x08800000);
+        return BinkOpen(hMagicVid, 0x8800000);
       else
         return BinkOpen(hMagicVid, 0x82000000);
     }
@@ -1192,10 +1192,10 @@
     {
       pAudioPlayer->PlaySound(SOUND_0, 0, 0, -1, 0, 0, 0, 0);
       ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
-      ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-      ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-      ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-      ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+      ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+      ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+      ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+      ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
     }
     bGameoverLoop = 0;
   }
--- a/Vis.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Vis.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -93,7 +93,7 @@
     }
   }
   pGame->pIndoorCameraD3D->ViewTransform(static_sub_4C1026_array_F8F200, v7);
-  pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(static_sub_4C1026_array_F8F200, v7, 1);
+  pGame->pIndoorCameraD3D->Project(static_sub_4C1026_array_F8F200, v7, 1);
   v15 = this;
   SortVectors_x(static_sub_4C1026_array_F8F200, 0, v7 - 1);
   if ( static_sub_4C1026_array_F8F200[0].vWorldViewPosition.x > (double)a4
@@ -369,7 +369,7 @@
         v7 = v6;
         if ( is_part_of_selection(&pIndoor->pFaces[v6], a5) )
         {
-          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(&pIndoor->pFaces[v7]) )
+          if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v7]) )
           {
             if ( Intersect_Ray_Face(pRay, pRay + 1, &fDepth, &a1, &pIndoor->pFaces[v7], 0xFFFFFFFFu) )
             {
@@ -1419,6 +1419,8 @@
   Vis *thisa; // [sp+68h] [bp-8h]@1
   RenderVertexSoft *v16; // [sp+6Ch] [bp-4h]@2
 
+  __debugbreak();
+
   result = sRight;
   thisa = this;
   if ( sRight > sLeft )
@@ -1600,20 +1602,17 @@
 //----- (004C0646) --------------------------------------------------------
 bool Vis::PickMouse(float fDepth, float fMouseX, float fMouseY, stru157 *a5, stru157 *a6)
 {
-  Vis *v6; // esi@1
-  bool result; // eax@4
   RenderVertexSoft pMouseRay[2]; // [sp+1Ch] [bp-60h]@1
 
-  v6 = this;
-  this->stru1.uNumPointers = 0;
+  stru1.uNumPointers = 0;
   CastPickRay(pMouseRay, fMouseX, fMouseY, fDepth);
-  PickBillboards(fDepth, fMouseX, fMouseY, &v6->stru1, a5);
+  PickBillboards(fDepth, fMouseX, fMouseY, &stru1, a5);
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-    PickIndoor(fDepth, pMouseRay, &v6->stru1, a6);
+    PickIndoor(fDepth, pMouseRay, &stru1, a6);
   else
-    PickOutdoor(fDepth, pMouseRay, &v6->stru1, a6, 0);
-  v6->stru1.create_object_pointers(0);
-  sort_object_pointers(v6->stru1.array_1804, 0, v6->stru1.uNumPointers - 1);
+    PickOutdoor(fDepth, pMouseRay, &stru1, a6, 0);
+  stru1.create_object_pointers(0);
+  sort_object_pointers(stru1.array_1804, 0, stru1.uNumPointers - 1);
   return true;
 }
 
@@ -2000,7 +1999,7 @@
       if ( v5 < (signed int)pIndoor->uNumFaces )
       {
         v6 = &pIndoor->pFaces[v5];
-        if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(&pIndoor->pFaces[v5]) )
+        if ( !pGame->pIndoorCameraD3D->IsCulled(&pIndoor->pFaces[v5]) )
         {
           if ( is_part_of_selection(v6, a2) )
           {
--- a/Weather.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/Weather.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -9,7 +9,7 @@
 
 
 
-struct Weather *pWeather;
+struct Weather *pWeather = new Weather;
 
 
 
--- a/mm7_1.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_1.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -203,7 +203,7 @@
   v1 = uPlayerID;
   a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   v84 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xAFu, 0xFFu);
-  v85 = pGUIWindow_CurrentMenu->field_2C_focus_id;
+  v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
   v86 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
   v79 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
   pPlayer = (Player *)&stru_AA1058[3].pSounds[6972 * v1 + 40552];
@@ -212,7 +212,7 @@
   v4 = v79;
   if ( !pPlayer->uSkillPoints )
     v4 = 65535;
-  sprintfex(
+  sprintf(
     pTmpBuf,
     "%s ",
     pGlobalTXT_LocalizationStrings[206],        // Skills for
@@ -223,7 +223,7 @@
     pPlayer->uSkillPoints);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
   v5 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;// Weapons,   Level
-  sprintfex(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[242], pGlobalTXT_LocalizationStrings[131]);
+  sprintf(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[242], pGlobalTXT_LocalizationStrings[131]);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, v5, a5, pTmpBuf, 0, 0, 0);
   v6 = pGUIWindow_CurrentMenu;
   v70 = 0;
@@ -285,7 +285,7 @@
       {
         if ( !(v87 & 0xC0) )
         {
-          sprintfex(pTmpBuf, "%s\r400%2d", pSkillNames[v62], uY);
+          sprintf(pTmpBuf, "%s\r400%2d", pSkillNames[v62], uY);
           goto LABEL_28;
         }
         v16 = pGlobalTXT_LocalizationStrings[432];
@@ -298,7 +298,7 @@
         v50 = v58;
         v46 = v88;
       }
-      sprintfex(pTmpBuf, "%s ", pSkillNames[v62], v15, v46, v50, v54);
+      sprintf(pTmpBuf, "%s ", pSkillNames[v62], v15, v46, v50, v54);
 LABEL_28:
       pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, v5, v58, pTmpBuf, 0, 0, 0);
       v6 = pGUIWindow_CurrentMenu;
@@ -312,7 +312,7 @@
     v6->DrawText(pFontLucida, 24, v5, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0);
   }
   uYa = v5 + 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
-  sprintfex(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[138], pGlobalTXT_LocalizationStrings[131]);
+  sprintf(pTmpBuf, "%s\r400%s", pGlobalTXT_LocalizationStrings[138], pGlobalTXT_LocalizationStrings[131]);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, uYa, a5, pTmpBuf, 0, 0, 0);
   v17 = pGUIWindow_CurrentMenu;
   v71 = 0;
@@ -370,7 +370,7 @@
       {
         if ( !(v21 & 0xC0) )
         {
-          sprintfex(pTmpBuf, "%s\r400%2d", pSkillNames[v63], v23);
+          sprintf(pTmpBuf, "%s\r400%2d", pSkillNames[v63], v23);
           goto LABEL_58;
         }
         v25 = (v21 & 0x80u) != 0;
@@ -384,7 +384,7 @@
         v51 = v59;
         v47 = v89;
       }
-      sprintfex(pTmpBuf, "%s ", pSkillNames[v63], v24, v47, v51, v55);
+      sprintf(pTmpBuf, "%s ", pSkillNames[v63], v24, v47, v51, v55);
 LABEL_58:
       pGUIWindow_CurrentMenu->DrawText(pFontLucida, 24, uYa, v59, pTmpBuf, 0, 0, 0);
       v17 = pGUIWindow_CurrentMenu;
@@ -405,7 +405,7 @@
       0,
       0);
   v27 = 2 * LOBYTE(pFontLucida->uFontHeight) + 13;
-  sprintfex(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[11], pGlobalTXT_LocalizationStrings[131]);
+  sprintf(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[11], pGlobalTXT_LocalizationStrings[131]);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 248, v27, a5, pTmpBuf, 0, 0, 0);
   v28 = pGUIWindow_CurrentMenu;
   v72 = 0;
@@ -464,7 +464,7 @@
       {
         if ( !(v90 & 0xC0) )
         {
-          sprintfex(pTmpBuf, "%s\r177%2d", pSkillNames[v64], uYb);
+          sprintf(pTmpBuf, "%s\r177%2d", pSkillNames[v64], uYb);
           goto LABEL_88;
         }
         v35 = pGlobalTXT_LocalizationStrings[432];
@@ -477,7 +477,7 @@
         v52 = v60;
         v48 = v91;
       }
-      sprintfex(pTmpBuf, "%s ", pSkillNames[v64], v34, v48, v52, v56);
+      sprintf(pTmpBuf, "%s ", pSkillNames[v64], v34, v48, v52, v56);
 LABEL_88:
       pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, v27, v60, pTmpBuf, 0, 0, 0);
       v28 = pGUIWindow_CurrentMenu;
@@ -493,7 +493,7 @@
     v28->DrawText(pFontLucida, 248, v27, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0);
   }
   uYc = v27 + 2 * LOBYTE(pFontLucida->uFontHeight) - 10;
-  sprintfex(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[143], pGlobalTXT_LocalizationStrings[131]);
+  sprintf(pTmpBuf, "%s\r177%s", pGlobalTXT_LocalizationStrings[143], pGlobalTXT_LocalizationStrings[131]);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 248, uYc, a5, pTmpBuf, 0, 0, 0);
   v36 = pGUIWindow_CurrentMenu;
   v73 = 0;
@@ -552,7 +552,7 @@
       {
         if ( !(v40 & 0xC0) )
         {
-          sprintfex(pTmpBuf, "%s\r177%2d", pSkillNames[v65], v42);
+          sprintf(pTmpBuf, "%s\r177%2d", pSkillNames[v65], v42);
           goto LABEL_118;
         }
         v25 = (v40 & 0x80u) != 0;
@@ -566,7 +566,7 @@
         v53 = v61;
         v49 = v92;
       }
-      sprintfex(pTmpBuf, "%s ", pSkillNames[v65], v43, v49, v53, v57);
+      sprintf(pTmpBuf, "%s ", pSkillNames[v65], v43, v49, v53, v57);
 LABEL_118:
       LOBYTE(v38) = pGUIWindow_CurrentMenu->DrawText(pFontLucida, 248, uYc, v61, pTmpBuf, 0, 0, 0);
       v36 = pGUIWindow_CurrentMenu;
@@ -619,14 +619,14 @@
   v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   v3 = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE);
   pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
-  sprintfex(pTmpBuf, "%s ", pGlobalTXT_LocalizationStrings[23], v2);// TODO check args
-  sprintfex(
+  sprintf(pTmpBuf, "%s ", pGlobalTXT_LocalizationStrings[23], v2);// TODO check args
+  sprintf(
     Source,
     pGlobalTXT_LocalizationStrings[429],
     &stru_AA1058[3].pSounds[6972 * v1 + 40720],
     pClassNames[stru_AA1058[3].pSounds[6972 * v1 + 40737]]);
   strcat(pTmpBuf, Source);
-  strcat(pTmpBuf, byte_4E2FD4);
+  strcat(pTmpBuf, "\xC" "00000");
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf, 0, 0, 0);
   result = dword_506528;
   a1.uFrameX = 12;
@@ -680,7 +680,7 @@
         break;
       v17 = pParty->uFine;
 LABEL_42:
-      sprintfex(pTmpBuf, v6, v17);
+      sprintf(pTmpBuf, v6, v17);
       v6 = pTmpBuf;
 LABEL_43:
       v14 = dword_723E84[v20 / 4];
@@ -871,7 +871,7 @@
         if ( !(v16 & 0xF0) )
         {
           if ( v16 & 1
-            || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 13 )
+            || pCurrentScreen != 13 )
           {
             if ( v16 & 2 )
               pRenderer->_4A6776(a2a, a3, v7);
@@ -926,7 +926,7 @@
   }
   while ( v27 < 126 );
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 // 507958: using guessed type int uTextureID_507958;
 // 50C9A8: using guessed type int dword_50C9A8;
 
@@ -1024,7 +1024,7 @@
         60,
         v0);
     v3 = pPlayer->GetActualLevel();
-    sprintfex(pTmpBuf, "%lu", v3);
+    sprintf(pTmpBuf, "%lu", v3);
     v4 = pPlayer->GetBaseLevel();
     if ( pPlayer->GetActualLevel() <= v4 )
       v5 = pPlayer->GetExperienceDisplayColor();
@@ -1052,9 +1052,9 @@
         pGlobalTXT_LocalizationStrings[107],
         60,
         v0);
-    sprintfex(pTmpBuf, "%d", pPlayer->sHealth);
+    sprintf(pTmpBuf, "%d", pPlayer->sHealth);
     v8 = pPlayer->GetMaxHealth();
-    v9 = sub_4178FE(pPlayer->sHealth, v8);
+    v9 = UI_GetHealthManaStringColor(pPlayer->sHealth, v8);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v7, v9, pTmpBuf, 84, v0);
     v10 = v45 + v7;
     if ( v43 == v0 )
@@ -1066,9 +1066,9 @@
         pGlobalTXT_LocalizationStrings[209],
         60,
         v0);
-    sprintfex(pTmpBuf, "%d", pPlayer->sMana);
+    sprintf(pTmpBuf, "%d", pPlayer->sMana);
     v11 = pPlayer->GetMaxMana();
-    v12 = sub_4178FE(pPlayer->sMana, v11);
+    v12 = UI_GetHealthManaStringColor(pPlayer->sMana, v11);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v10, v12, pTmpBuf, 84, v0);
     v13 = v45 + v10;
     if ( v43 == v0 )
@@ -1081,11 +1081,11 @@
         60,
         v0);
     v14 = pPlayer->GetActualAC();
-    sprintfex(pTmpBuf, "%d", v14);
+    sprintf(pTmpBuf, "%d", v14);
     v15 = v0;
     v16 = pPlayer->GetBaseAC();
     v17 = pPlayer->GetActualAC();
-    v18 = sub_4178FE(v17, v16);
+    v18 = UI_GetHealthManaStringColor(v17, v16);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v13, v18, pTmpBuf, 84, v15);
     v0 = 0;
     v19 = v45 + v13;
@@ -1099,7 +1099,7 @@
         60,
         0);
     v20 = pPlayer->GetActualAttack(0);
-    sprintfex(pTmpBuf, "%+d", v20);
+    sprintf(pTmpBuf, "%+d", v20);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v19, 0, pTmpBuf, 84, 0);
     v21 = v45 + v19;
     if ( !v43 )
@@ -1124,7 +1124,7 @@
         60,
         0);
     v24 = pPlayer->GetRangedAttack();
-    sprintfex(pTmpBuf, "%+d", v24);
+    sprintf(pTmpBuf, "%+d", v24);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v23, 0, pTmpBuf, 84, 0);
     v25 = v45 + v23;
     if ( !v43 )
@@ -1159,7 +1159,7 @@
       --v30;
     }
     while ( v30 );
-    sprintfex(pTmpBuf, "%lu", v28);
+    sprintf(pTmpBuf, "%lu", v28);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v27, 0, pTmpBuf, 84, 0);
     v31 = v45 + v27;
     if ( !v43 )
@@ -1171,7 +1171,7 @@
         pGlobalTXT_LocalizationStrings[168],
         60,
         0);
-    sprintfex(pTmpBuf, "%lu", pPlayer->uSkillPoints);
+    sprintf(pTmpBuf, "%lu", pPlayer->uSkillPoints);
     pGUIWindow_CurrentMenu->DrawTextInRect(
       pFontArrus,
       v44,
@@ -1225,10 +1225,10 @@
     v39 = v46;
   }
   v40 = GetReputationString(v38);
-  sprintfex(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[180], v39, v40);
+  sprintf(pTmpBuf, "%s: ", pGlobalTXT_LocalizationStrings[180], v39, v40);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf, 0, 0, 0);
   v41 = pParty->GetPartyFame();
-  sprintfex(pTmpBuf, "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], v41);// Fame
+  sprintf(pTmpBuf, "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], v41);// Fame
   return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf, 0, 0, 0);
 }
 
@@ -1314,7 +1314,7 @@
     qword_507CC8 = pParty->uTimePlayed;
     byte_50697C = byte_50697C == 0;
     if ( byte_50697C
-      && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 5 )
+      && pCurrentScreen != 5 )
     {
       if ( bFlashQuestBook )
         pRenderer->DrawTextureTransparent(
@@ -1352,9 +1352,9 @@
     v0 = uGameUIFontMain;
     v1 = uGameUIFontShadow;
     v2 = sub_44100D() != 0 ? 381 : 322;
-    sprintfex(pTmpBuf, "\r087%lu", pParty->uNumFoodRations);
+    sprintf(pTmpBuf, "\r087%lu", pParty->uNumFoodRations);
     pGUIWindow0->DrawText(pFontSmallnum, 0, v2, v0, pTmpBuf, 0, 0, v1);
-    sprintfex(pTmpBuf, "\r028%lu", pParty->uNumGold);
+    sprintf(pTmpBuf, "\r028%lu", pParty->uNumGold);
     pGUIWindow0->DrawText(pFontSmallnum, 0, v2, v0, pTmpBuf, 0, 0, v1);
   }
 }
@@ -1758,19 +1758,19 @@
   uTextureID_BUTTMAKE2 = pIcons_LOD->LoadTexture("BUTTMAKE2", TEXTURE_16BIT_PALETTE);
 
   pGUIWindow0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
-  pGUIWindow0->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, 0xAu, 0, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  pGUIWindow0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x172u, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x61u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0xD4u, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x148u, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, nullstring, 0);
+  pGUIWindow0->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, 0xAu, 0, 0, "", 0);
+  pGUIWindow0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  pGUIWindow0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  pGUIWindow0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  pGUIWindow0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+  pGUIWindow0->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, "", 0);
+  pGUIWindow0->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x172u, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x61u, 0x194u, 5u, 0x31u, 1, 93, 0, 1u, 0, "", 0);
+  pGUIWindow0->CreateButton(0xD4u, 0x194u, 5u, 0x31u, 1, 93, 0, 2u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x148u, 0x194u, 5u, 0x31u, 1, 93, 0, 3u, 0, "", 0);
+  pGUIWindow0->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, 0, 4u, 0, "", 0);
   uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE);
   v6 = (Texture *)(uTextureID_ib_td1_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0);
   v7 = pGlobalTXT_LocalizationStrings[174];
@@ -1888,11 +1888,11 @@
                    v32,
                    v31,
                    0);
-  pGUIWindow0->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, 0, 0, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x86u, 0, 0x35u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x87u, 0, 0x36u, nullstring, 0);
-  pGUIWindow0->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, 0, 0, 0, nullstring, 0);
-  pGUIWindow0->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, 0, 0, 0, nullstring, 0);
+  pGUIWindow0->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, 0, 0, 0, "", 0);
+  pGUIWindow0->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x86u, 0, 0x35u, "", 0);
+  pGUIWindow0->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x87u, 0, 0x36u, "", 0);
+  pGUIWindow0->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, 0, 0, 0, "", 0);
+  pGUIWindow0->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, 0, 0, 0, "", 0);
   ptr_5079F8 = pGUIWindow0->CreateButton(
                  0x1DCu,
                  0x1C2u,
@@ -1955,7 +1955,7 @@
                  0xBCu,
                  0,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_507990 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507990] : 0),
                  0);
   ptr_5079E8 = pGUIWindow0->CreateButton(
@@ -1968,7 +1968,7 @@
                  0xBCu,
                  1u,
                  0,
-                 nullstring,
+                 "",
                  (Texture *)(uTextureID_50798C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50798C] : 0),
                  0);
   Load_isn_spells_21_27();
@@ -2143,9 +2143,9 @@
     if ( pWindowList[v3].field_30 != v1 )
     {
       pMouse->GetClickPos(&uClickX, &uClickY);
-      v4 = pWindowList[v3].field_38;
-      v29 = v4 + pWindowList[v3].field_28;
-      if ( v4 < v4 + pWindowList[v3].field_28 )
+      v4 = pWindowList[v3].pStartingPosActiveItem;
+      v29 = v4 + pWindowList[v3].pNumPresenceButton;
+      if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
       {
         while ( 1 )
         {
@@ -2184,10 +2184,10 @@
   if ( v26 == 37 )
   {
     v12 = pWindowList[v3].field_34;
-    if ( pWindowList[v3].field_2C_focus_id - pWindowList[v3].field_38 - v12 >= 0 )
-    {
-      v8 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 21;
-      pWindowList[v3].field_2C_focus_id -= v12;
+    if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 )
+    {
+      v8 = pCurrentScreen == 21;
+      pWindowList[v3].pCurrentPosActiveItem -= v12;
       if ( v8 )
       {
         pAudioPlayer->PlaySound((SoundID)66, v1, v1, -1, v1, v1, v1, v1);
@@ -2197,7 +2197,7 @@
     if ( pWindowList[v3].field_30 != v1 )
       goto LABEL_47;
     v9 = pWindowList[v3].pControlsHead;
-    v13 = pWindowList[v3].field_2C_focus_id;
+    v13 = pWindowList[v3].pCurrentPosActiveItem;
     if ( v13 > (signed int)v1 )
     {
       do
@@ -2223,11 +2223,11 @@
   {
     if ( v26 == 39 )
     {
-      v7 = pWindowList[v3].field_2C_focus_id + pWindowList[v3].field_34;
-      if ( v7 < pWindowList[v3].field_28 + pWindowList[v3].field_38 )
-      {
-        v8 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 21;
-        pWindowList[v3].field_2C_focus_id = v7;
+      v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34;
+      if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem )
+      {
+        v8 = pCurrentScreen == 21;
+        pWindowList[v3].pCurrentPosActiveItem = v7;
         if ( v8 )
         {
           pAudioPlayer->PlaySound((SoundID)66, v1, v1, -1, v1, v1, v1, v1);
@@ -2237,7 +2237,7 @@
       if ( pWindowList[v3].field_30 != v1 )
         goto LABEL_47;
       v9 = pWindowList[v3].pControlsHead;
-      v10 = pWindowList[v3].field_2C_focus_id;
+      v10 = pWindowList[v3].pCurrentPosActiveItem;
       if ( v10 > (signed int)v1 )
       {
         do
@@ -2251,16 +2251,16 @@
     }
     if ( v26 == 40 )
     {
-      v17 = pWindowList[v3].field_38;
-      v18 = pWindowList[v3].field_2C_focus_id;
-      if ( v18 >= pWindowList[v3].field_28 + v17 - 1 )
-        pWindowList[v3].field_2C_focus_id = v17;
+      v17 = pWindowList[v3].pStartingPosActiveItem;
+      v18 = pWindowList[v3].pCurrentPosActiveItem;
+      if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 )
+        pWindowList[v3].pCurrentPosActiveItem = v17;
       else
-        pWindowList[v3].field_2C_focus_id = v18 + 1;
+        pWindowList[v3].pCurrentPosActiveItem = v18 + 1;
       if ( pWindowList[v3].field_30 != v1 )
         return 1;
       v19 = pWindowList[v3].pControlsHead;
-      v20 = pWindowList[v3].field_2C_focus_id;
+      v20 = pWindowList[v3].pCurrentPosActiveItem;
       if ( v20 > (signed int)v1 )
       {
         do
@@ -2275,9 +2275,9 @@
     if ( v26 == 41 )
     {
       pMouse->GetClickPos(&uClickX, &uClickY);
-      v4 = pWindowList[v3].field_38;
-      v28 = v4 + pWindowList[v3].field_28;
-      if ( v4 < v4 + pWindowList[v3].field_28 )
+      v4 = pWindowList[v3].pStartingPosActiveItem;
+      v28 = v4 + pWindowList[v3].pNumPresenceButton;
+      if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
       {
         while ( 1 )
         {
@@ -2302,7 +2302,7 @@
             goto LABEL_45;
         }
 LABEL_66:
-        pWindowList[v3].field_2C_focus_id = v4;
+        pWindowList[v3].pCurrentPosActiveItem = v4;
         return 1;
       }
 LABEL_46:
@@ -2311,18 +2311,18 @@
     }
     goto LABEL_47;
   }
-  v22 = pWindowList[v3].field_2C_focus_id;
-  v23 = pWindowList[v3].field_38;
+  v22 = pWindowList[v3].pCurrentPosActiveItem;
+  v23 = pWindowList[v3].pStartingPosActiveItem;
   if ( v22 <= v23 )
-    v24 = pWindowList[v3].field_28 + v23 - 1;
+    v24 = pWindowList[v3].pNumPresenceButton + v23 - 1;
   else
     v24 = v22 - 1;
   v8 = pWindowList[v3].field_30 == v1;
-  pWindowList[v3].field_2C_focus_id = v24;
+  pWindowList[v3].pCurrentPosActiveItem = v24;
   if ( !v8 )
     return 1;
   v19 = pWindowList[v3].pControlsHead;
-  v25 = pWindowList[v3].field_2C_focus_id;
+  v25 = pWindowList[v3].pCurrentPosActiveItem;
   if ( v25 > (signed int)v1 )
   {
     do
@@ -2380,7 +2380,7 @@
     v10 = pGlobalTXT_LocalizationStrings[57];   // Days
     if ( v19 <= 1 )
       v10 = pGlobalTXT_LocalizationStrings[56]; // Day
-    sprintfex(pTmpBuf2, "%d %s ", v19, v10);
+    sprintf(pTmpBuf2, "%d %s ", v19, v10);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v9 )
@@ -2389,7 +2389,7 @@
       v11 = pGlobalTXT_LocalizationStrings[109];// Hour
     else
       v11 = pGlobalTXT_LocalizationStrings[110];// Hours
-    sprintfex(pTmpBuf2, "%d %s ", v9, v11);
+    sprintf(pTmpBuf2, "%d %s ", v9, v11);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v17 && !v19 )
@@ -2398,7 +2398,7 @@
       v12 = pGlobalTXT_LocalizationStrings[437];// Minute
     else
       v12 = pGlobalTXT_LocalizationStrings[436];// Minutes
-    sprintfex(pTmpBuf2, "%d %s ", v17, v12);
+    sprintf(pTmpBuf2, "%d %s ", v17, v12);
     strcat(pTmpBuf, pTmpBuf2);
   }
   if ( v18 && !v9 )
@@ -2407,7 +2407,7 @@
       v13 = pGlobalTXT_LocalizationStrings[439];// Second
     else
       v13 = pGlobalTXT_LocalizationStrings[438];// Seconds
-    sprintfex(pTmpBuf2, "%d %s ", v18, v13);
+    sprintf(pTmpBuf2, "%d %s ", v18, v13);
     strcat(pTmpBuf, pTmpBuf2);
   }
   return a1->DrawText(a2, 32, uY, 0, pTmpBuf, 0, 0, 0);
@@ -2509,7 +2509,7 @@
   v82 = pFontComic;
   if ( v1->uItemID )
   {
-    v79.str_48 = 0;
+    v79.Hint = 0;
     v79.uFrameWidth = 384;
     v79.uFrameHeight = 180;
     v79.uFrameY = 40;
@@ -2594,7 +2594,7 @@
     a2.y = _this->uAttributes & 1;
     if ( v13 & 2 )
     {
-      v79._415551(0);
+      v79.DrawMessageBox(0);
       //v15 = &;
       pRenderer->Clip(
         v79.uFrameX + 12,
@@ -2621,7 +2621,7 @@
     }
     if ( !v14 )
     {
-      v79._415551(0);
+      v79.DrawMessageBox(0);
       v15 = pRenderer;
       pRenderer->Clip(
         v79.uFrameX + 12,
@@ -2646,9 +2646,9 @@
       v79.DrawText2(pFontArrus, 0x64u, ((signed int)v79.uFrameHeight >> 1) - v18, v19, v52, v57);
       goto LABEL_116;
     }
-    sprintfex(a1, pGlobalTXT_LocalizationStrings[463], *((int *)v3 + 2));
-    strcpy(Dest, nullstring);
-    strcpy(v64, nullstring);
+    sprintf(a1, pGlobalTXT_LocalizationStrings[463], *((int *)v3 + 2));
+    strcpy(Dest, "");
+    strcpy(v64, "");
     v20 = v3[28];
     if ( (unsigned __int8)v20 <= 1u )
     {
@@ -2668,7 +2668,7 @@
           {
             v21 = v3[30];
             if ( v21 )
-              sprintfex(
+              sprintf(
                 Dest,
                 "%s: +%d",
                 pGlobalTXT_LocalizationStrings[11],
@@ -2683,11 +2683,11 @@
       v45 = (unsigned __int8)v3[32];
       v43 = pGlobalTXT_LocalizationStrings[203];
     }
-    sprintfex(Dest, "%s: +%d   %s: %dd%d", v43, v45, v48, v53, v58);
+    sprintf(Dest, "%s: +%d   %s: %dd%d", v43, v45, v48, v53, v58);
     v22 = v3[32];
     if ( v22 )
     {
-      sprintfex(Source, " +%d", (unsigned __int8)v22);
+      sprintf(Source, " +%d", (unsigned __int8)v22);
       strcat(Dest, Source);
     }
 LABEL_50:
@@ -2742,7 +2742,7 @@
       v79.uFrameHeight += (unsigned int)v83;
       v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
       v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79._415551(0);
+      v79.DrawMessageBox(0);
       v15 = pRenderer;
       pRenderer->Clip(
         v79.uFrameX + 12,
@@ -2784,7 +2784,7 @@
       v79.uFrameX -= 12;
       if ( v77 )
       {
-        sprintfex(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);
+        sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);
         v40 = v82;
         v61 = 0;
         v56 = 0;
@@ -2803,22 +2803,22 @@
           Str = (char *)(v72 - 1168);
           if ( v72 != 1168 )
           {
-            sprintfex(v65, " %d:yr", v72 - 1168);
+            sprintf(v65, " %d:yr", v72 - 1168);
             strcat(pTmpBuf, v65);
           }
-          if ( (((v71 || Str) && ((sprintfex(v65, " %d:mo", v71), strcat(pTmpBuf, v65), v71) || Str) || v70)
-             && ((sprintfex(v65, " %d:dy", v70), strcat(pTmpBuf, v65), v71) || Str || v70)
+          if ( (((v71 || Str) && ((sprintf(v65, " %d:mo", v71), strcat(pTmpBuf, v65), v71) || Str) || v70)
+             && ((sprintf(v65, " %d:dy", v70), strcat(pTmpBuf, v65), v71) || Str || v70)
              || v69)
-            && ((sprintfex(v65, " %d:hr", v69), strcat(pTmpBuf, v65), v71) || Str || v70 || v69)
+            && ((sprintf(v65, " %d:hr", v69), strcat(pTmpBuf, v65), v71) || Str || v70 || v69)
             || v68 )
           {
-            sprintfex(v65, " %d:mn", v68);
+            sprintf(v65, " %d:mn", v68);
             strcat(pTmpBuf, v65);
           }
           v79.DrawText(v82, 100, v79.uFrameHeight - 2 * LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
         }
         v37 = _this->GetValue();
-        sprintfex(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
+        sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
         v79.DrawText(v82, 100, v79.uFrameHeight - LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
         v38 = _this->uAttributes;
         if ( BYTE1(v38) & 1 )
@@ -2862,7 +2862,7 @@
       v54 = pGlobalTXT_LocalizationStrings[449];
       v49 = "%s: %d";
 LABEL_64:
-      sprintfex(v64, v49, v54, v59);
+      sprintf(v64, v49, v54, v59);
       goto LABEL_65;
     }
     v25 = _this->_bonus_type;
@@ -2892,7 +2892,7 @@
       v50 = pGlobalTXT_LocalizationStrings[210];
       v46 = "%s: %s";
     }
-    sprintfex(v64, v46, v50, v55, v60);
+    sprintf(v64, v46, v50, v55, v60);
     goto LABEL_65;
   }
 }
@@ -3093,27 +3093,27 @@
   v106.uViewportY = v12;
   v106.uViewportW = v12 + 128;
   v106.uViewportZ = v106.uViewportX + 128;
-  v106.field_8 = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2;
+  v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2;
   v106.field_10 = 65536;
   v106.field_14 = 65536;
-  v106.field_C = v115 + v12 + *(short *)(v11 + 18);
+  v106.uScreenSpaceY = v115 + v12 + *(short *)(v11 + 18);
   v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1);
-  v106.field_28 = 0;
+  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]];
-    v106.field_C = v115 + v106.uViewportY + v13->uBufferHeight;
+    v106.uScreenSpaceY = v115 + v106.uViewportY + v13->uBufferHeight;
     v222 = (IDirectDrawSurface *)v13->pTextureSurface;
     memset(&Dst, 0, 0x64u);
     Dst.dwSize = 100;
@@ -3127,13 +3127,13 @@
     v15 = v13->uAreaX;
     v119 = (signed int)v120 / 2;
     i = 0;
-    a4 = (char *)(v106.field_8 + v15 - (signed int)v120 / 2);
+    a4 = (char *)(v106.uScreenSpaceX + v15 - (signed int)v120 / 2);
     v115 = v13->uAreaY;
     v16 = v13->uAreaWidth + (signed int)v120 / 2 + v15 - (int)v120;
-    v124 = v106.field_C + v115 - v14;
+    v124 = v106.uScreenSpaceY + v115 - v14;
     v17 = v13->uAreaHeight + v115 - v14;
-    v116 = v106.field_8 + v16;
-    v119 = v106.field_C + v17;
+    v116 = v106.uScreenSpaceX + v16;
+    v119 = v106.uScreenSpaceY + v17;
     if ( (signed int)a4 < (signed int)v106.uViewportX )
     {
       v18 = v106.uViewportX - (int)a4;
@@ -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,
@@ -3286,7 +3283,7 @@
     v37 = v112[6];
     if ( v37 )
     {
-      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]);
+      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], *v112, aNPCProfessionNames[(signed int)v37]);
       goto LABEL_59;
     }
     v77 = 2000;
@@ -3543,7 +3540,7 @@
   a4 = (char *)v106.uViewportY;
   if ( v119 )
   {
-    sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP);
+    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
     v79 = v121->pMonsterInfo.uAC;
@@ -3553,7 +3550,7 @@
   }
   else
   {
-    sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);
+    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630];
     v75 = 0;
@@ -3561,7 +3558,7 @@
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
     v67 = "%s";
   }
-  sprintfex(pTmpBuf, v67, v70, v75, v79);
+  sprintf(pTmpBuf, v67, v70, v75, v79);
   a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
   a4 = &a4[LOBYTE(v56->uFontHeight) - 6] + LOBYTE(v56->uFontHeight);
   v95 = pGlobalTXT_LocalizationStrings[87];
@@ -3577,12 +3574,12 @@
   v105 = pGlobalTXT_LocalizationStrings[54];
   if ( v116 )
   {
-    sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, (&v95)[4 * v121->pMonsterInfo.uAttack1Type]);
+    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, (&v95)[4 * v121->pMonsterInfo.uAttack1Type]);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
     v57 = v121->pMonsterInfo.uAttack1DamageBonus;
     if ( v57 )
-      sprintfex(
+      sprintf(
         pTmpBuf,
         "%s",
         pGlobalTXT_LocalizationStrings[53],
@@ -3591,7 +3588,7 @@
         v121->pMonsterInfo.uAttack1DamageDiceSides,
         v57);
     else
-      sprintfex(
+      sprintf(
         pTmpBuf,
         "%s",
         pGlobalTXT_LocalizationStrings[53],
@@ -3601,10 +3598,10 @@
   }
   else
   {
-    sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
+    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     a4 = &a4[LOBYTE(v56->uFontHeight) - 3];
-    sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
+    sprintf(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
   }
   a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
   v58 = LOBYTE(v56->uFontHeight);
@@ -3624,7 +3621,7 @@
     v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629];
   if ( v114 )
   {
-    sprintfex(pTmpBuf, "%s", v120, 0, pSpellStats->pInfos[v114].pShortName);
+    sprintf(pTmpBuf, "%s", v120, 0, pSpellStats->pInfos[v114].pShortName);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v58 = LOBYTE(v56->uFontHeight);
     a4 = &a4[v58 - 3];
@@ -3633,7 +3630,9 @@
   v60 = v59->pMonsterInfo.uSpell2ID;
   if ( v60 )
   {
-    sprintfex(pTmpBuf, &byte_4E3318, 0, pSpellStats->pInfos[v60].pShortName);
+    __debugbreak();
+    const char *fmt = "\xC\x25\x30\x35\x75\x9\x30\x36\x30\x25\x73\n";
+    sprintf(pTmpBuf, fmt, 0, pSpellStats->pInfos[v60].pShortName);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v58 = LOBYTE(v56->uFontHeight);
     a4 = &a4[v58 - 3];
@@ -3646,7 +3645,7 @@
     v71 = pGlobalTXT_LocalizationStrings[628];
     v68 = "%s";
 LABEL_144:
-    sprintfex(pTmpBuf, v68, v71, v76, v80);
+    sprintf(pTmpBuf, v68, v71, v76, v80);
     a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0);
     v58 = LOBYTE(v56->uFontHeight);
     a4 = &a4[v58 - 3];
@@ -3692,7 +3691,7 @@
         else
           v81 = pGlobalTXT_LocalizationStrings[153];
       }
-      sprintfex(pTmpBuf, "%s", (&v85)[v124], 0, v81);
+      sprintf(pTmpBuf, "%s", (&v85)[v124], 0, v81);
       a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0);
       v63 = LOBYTE(v56->uFontHeight);
       v124 += 4;
@@ -3706,7 +3705,7 @@
     i = 0;
     do
     {
-      sprintfex(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]);
+      sprintf(pTmpBuf, "%s", (&v85)[4 * i], 0, pGlobalTXT_LocalizationStrings[630]);
       a1->DrawText(v56, 170, (int)a4, a5, pTmpBuf, 0, 0, 0);
       v65 = LOBYTE(v56->uFontHeight);
       ++i;
@@ -3717,7 +3716,7 @@
   }
   if ( (signed __int64)pParty->pPartyBuffs[3].uExpireTime > 0 )
   {
-    sprintfex(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP);
+    sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP);
     pFontSmallnum->GetLineWidth(pTmpBuf);
     result = a1->DrawText2(
                pFontSmallnum,
@@ -3740,7 +3739,7 @@
   if ( pTexture_RestUI_CurrentHourglassFrame )
     pTexture_RestUI_CurrentHourglassFrame->Release();
   pIcons_LOD->_40F9C5();
-  sprintfex(pTmpBuf, "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
+  sprintf(pTmpBuf, "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
   pTexture_RestUI_CurrentSkyFrame = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
 }
 
@@ -3771,7 +3770,7 @@
       pTexture_RestUI_CurrentSkyFrame = 0;
       pIcons_LOD->_4114F2();
       pIcons_LOD->_40F9C5();
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+      pCurrentScreen = 0;
       viewparams->bRedrawGameUI = 1;
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
       {
@@ -3797,10 +3796,10 @@
 
   if ( !dword_506F14 )
     pAudioPlayer->StopChannels(-1, -1);
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+  if ( pCurrentScreen )
   {
     pGUIWindow_CurrentMenu->Release();
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+    pCurrentScreen = 0;
     viewparams->bRedrawGameUI = 1;
   }
   pEventTimer->Pause();
@@ -3812,8 +3811,8 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
     uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(
                                    pParty->vPosition.x,
-                                   pParty->vPosition.z,
-                                   pParty->vPosition.y);
+                                   pParty->vPosition.y,
+                                   pParty->vPosition.z);
   if ( sub_476387() )
   {
     v0 = (char *)&pParty->pPlayers[0].uClass;
@@ -3839,7 +3838,7 @@
   ++pIcons_LOD->uTexturePacksCount;
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 5;
+  pCurrentScreen = 5;
   _507CD4_RestUI_hourglass_anim_controller = 0;
   uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE);
   uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE);
@@ -3859,7 +3858,7 @@
                           0xA7u,
                           0,
                           0,
-                          nullstring,
+                          "",
                           (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0),
                           0);
   pButton_RestUI_507634 = pGUIWindow_CurrentMenu->CreateButton(
@@ -3872,7 +3871,7 @@
                             0x61u,
                             0,
                             0x52u,
-                            nullstring,
+                            "",
                             (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0),
                             0);
   pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton(
@@ -3885,7 +3884,7 @@
                                    0x6Du,
                                    0,
                                    0x44u,
-                                   nullstring,
+                                   "",
                                    (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0),
                                    0);
   pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton(
@@ -3898,7 +3897,7 @@
                                0x60u,
                                0,
                                0x48u,
-                               nullstring,
+                               "",
                                (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0),
                                0);
   pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton(
@@ -3911,7 +3910,7 @@
                                   0x5Fu,
                                   0,
                                   0x4Du,
-                                  nullstring,
+                                  "",
                                   (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0),
                                   0);
 }
@@ -3952,7 +3951,7 @@
       8u,
       (Texture *)(uTextureID_RestUI_restmain != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restmain] : 0));
     v10 = pParty->uCurrentHour;
-    dword_506F1C = pGUIWindow_CurrentMenu->field_2C_focus_id;
+    dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
     if ( (signed int)pParty->uCurrentHour <= 12 )
     {
       if ( !v10 )
@@ -3986,7 +3985,7 @@
       v4 = 1;
       byte_4E2BC8 = 1;
     }
-    sprintfex(pTmpBuf, "hglas%03d", (unsigned __int8)v4);
+    sprintf(pTmpBuf, "hglas%03d", (unsigned __int8)v4);
     pTexture_RestUI_CurrentHourglassFrame = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
     pRenderer->DrawTextureIndexed(0x10Bu, 0x9Fu, pTexture_RestUI_CurrentHourglassFrame);
     memset(&Dst, 0, 0xBCu);
@@ -3999,7 +3998,7 @@
     Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
     Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, a5, *(int **)a9);
     Dst.pParent = 0;
-    sprintfex(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
+    sprintf(pTmpBuf, "\r408%d", uRestUI_FoodRequiredToRest);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
     pButton_RestUI_WaitUntilDawn->DrawLabel(
       pGlobalTXT_LocalizationStrings[237],
@@ -4020,13 +4019,13 @@
     Dst.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, a5, *(int **)a9);
     Dst.pParent = 0;
     v5 = pParty->uCurrentHour >= 0xC && pParty->uCurrentHour < 0x18;
-    sprintfex(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]);
+    sprintf(pTmpBuf, "%d:%02d %s", v10, pParty->uCurrentMinute, aAMPMNames[v5]);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
-    sprintfex(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
+    sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
-    sprintfex(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
+    sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
-    sprintfex(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
+    sprintf(pTmpBuf, "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, a5, pTmpBuf, 0, 0, *(unsigned int *)a9);
     if ( dword_506F14 )
       Sleep6Hours();
@@ -4543,9 +4542,9 @@
     }
     v18 = (double)pParty->vPosition.x - (double)v14;
     *(float *)&a4 = v18;
-    v19 = (double)pParty->vPosition.z - (double)v38;
+    v19 = (double)pParty->vPosition.y - (double)v38;
     v33 = v19;
-    v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.y - (double)v15;
+    v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15;
     *(float *)&sRotY = v19 * v19;
     *(float *)&sRotX = v18 * v18;
     v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY);
@@ -4650,8 +4649,8 @@
                  pGlobalTXT_LocalizationStrings[79],// Exit
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  ptr_507BB8->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, nullstring, 0);
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 10;
+  ptr_507BB8->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0);
+  pCurrentScreen = 10;
   pEventTimer->Pause();
   return 1;
 }
@@ -4693,7 +4692,7 @@
   v18 = pChestSmthn2ByType[v4];
   v21 = pChestWidthsByType[v4];
   v19 = pChestHeightsByType[v4];
-  sprintfex(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID);
+  sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID);
   v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
   pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
   v23 = 0;
@@ -4844,7 +4843,7 @@
   {
     if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 )
     {
-      sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold!
+      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold!
     }
     else
     {
@@ -4913,11 +4912,11 @@
       v3 = (signed int)(v4 * v3 / 100) / 100;
       if ( v3 < 1 )
         v3 = 1;
-      sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)!
+      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)!
     }
     else
     {
-      sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold!
+      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold!
     }
     v2 = 0;
   }
@@ -4980,7 +4979,6 @@
 //----- (00420EFF) --------------------------------------------------------
 void __cdecl GameUI_WritePointedObjectStatusString()
 {
-  unsigned int zero; // edi@1
   int v1; // ebx@6
   GUIWindow *v2; // edi@7
   GUIButton *i; // ecx@11
@@ -5027,12 +5025,13 @@
   unsigned int pY; // [sp+D8h] [bp-8h]@1
   unsigned int v45; // [sp+DCh] [bp-4h]@21
 
-  zero = 0;
+  v13 = nullptr;
+
   pMouse->uPointingObjectID = 0;
   pMouse->GetClickPos(&pX, &pY);
   if ( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 )
     return;
-  if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+  if ( !pCurrentScreen )
   {
     if ( (signed int)pX > 467 || (signed int)pY > 351 )
       goto _click_on_game_ui;
@@ -5067,7 +5066,7 @@
       }
       v31 = pLayingItems[v30].stru_24.GetDisplayName();
       v28 = pTmpBuf;
-      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s"
+      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s"
     }
     else
     {
@@ -5138,15 +5137,15 @@
   if ( uNumVisibleWindows <= 0 )
   {
 LABEL_38:
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
+    if ( pCurrentScreen == 10 )
     {
       sub_42038D();
       goto _return;
     }
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13 )
+    if ( pCurrentScreen == 13 )
     {
       if ( dword_F8B19C != 2
-        || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == zero)
+        || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0)
         || v16 == -65536 )
         goto _return;
       v15 = (ItemGen *)((char *)&pParty->pPickedItem + 36 * (v16 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 4);
@@ -5156,9 +5155,9 @@
 LABEL_50:
       uLastPointedObjectID = 1;
 _return:
-      if ( pMouse->uPointingObjectID == zero )
-      {
-        if ( uLastPointedObjectID != zero )
+      if ( pMouse->uPointingObjectID == 0 )
+      {
+        if ( uLastPointedObjectID != 0 )
         {
           pStatusBarString[0] = 0;
           bForceDrawStatusBar = 1;
@@ -5170,7 +5169,7 @@
     if ( (signed int)pY < 350 )
     {
       v14 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
-      if ( v14 == zero || v14 == -65536 || (unsigned int)v14 >= 0x1388 )
+      if ( v14 == 0 || v14 == -65536 || (unsigned int)v14 >= 0x1388 )
         goto _return;
       v15 = (ItemGen *)&pPlayers[uActiveCharacter]->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * v14 + 5];
       goto LABEL_49;
@@ -5181,7 +5180,7 @@
       && (signed int)pY >= (signed int)pWindowList[0].uFrameY
       && (signed int)pY <= (signed int)pWindowList[0].uFrameW )
     {
-      for ( i = pWindowList[0].pControlsHead; i != (GUIButton *)zero; i = i->pNext )
+      for ( i = pWindowList[0].pControlsHead; i != (GUIButton *)0; i = i->pNext )
       {
         if ( i->uButtonType == 1 )
         {
@@ -5191,14 +5190,14 @@
             && (signed int)pY <= (signed int)i->uW )
           {
             v37 = (UIMessageType)i->field_1C;
-            if ( v37 == zero )
+            if ( v37 == 0 )
               goto LABEL_28;
             v38 = i->uControlParam;
             if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
             {
               pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = v37;
               pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v38;
-              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = zero;
+              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
               ++pMessageQueue_50CBD0->uNumMessages;
             }
             goto LABEL_131;
@@ -5210,28 +5209,31 @@
           {
             v45 = pX - i->uX;
             v45 = pY - i->uY;
-            if ( (double)(signed int)i->uWidth != 0.0 )
-            {
-              if ( (double)(signed int)i->uHeight != 0.0 )
-              {
-                //UNDEF(v32);
-                if ( v33 | v34 )
+
+            if (pX >= i->uX && pX <= i->uZ &&
+                pY >= i->uY && pY <= i->uW)
+            //if ( (double)(signed int)i->uWidth != 0.0 )
+            //{
+            //  if ( (double)(signed int)i->uHeight != 0.0 )
+            //  {
+                 //UNDEF(v32);
+                //if ( v33 | v34 )
                 {
                   v35 = (UIMessageType)i->field_1C;
-                  if ( v35 != zero )
+                  if ( v35 != 0 )
                   {
                     v36 = i->uControlParam;
                     if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
                     {
                       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = v35;
                       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v36;
-                      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = zero;
+                      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
                       goto LABEL_27;
                     }
                   }
                   goto LABEL_28;
-                }
-              }
+                //}
+              //}
             }
           }
           else
@@ -5330,7 +5332,7 @@
                 v41 = v7;
                 v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points"
               }
-              sprintfex(Str1, v39, v41);
+              sprintf(Str1, v39, v41);
               v13 = Str1;
               goto _set_status_and_ret;
             }
@@ -5343,16 +5345,11 @@
     --v1;
     if ( v1 <= 0 )
     {
-      zero = 0;
       goto LABEL_38;
     }
   }
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-// 506578: using guessed type int uLastPointedObjectID;
-// 5075E0: using guessed type int pVisibleWindowsIdxs[20];
-// 5C35BC: using guessed type int bForceDrawStatusBar;
-// F8B19C: using guessed type int dword_F8B19C;
+
 
 //----- (00421626) --------------------------------------------------------
 GUIWindow *GameUI_InitializeCharacterWindow(unsigned int _this)
@@ -5368,7 +5365,7 @@
   pAudioPlayer->StopChannels(-1, -1);
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = v1;
+  pCurrentScreen = v1;
   v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
   pCharacterScreen_StatsBtn = v2->CreateButton(
                                 pViewport->uViewportX + 12,
@@ -5440,7 +5437,7 @@
                  (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
                  papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
                  0);
-  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, nullstring, 0);
+  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
   ptr_507694 = v2->CreateButton(
                  0x258u,
                  0x12Cu,
@@ -5453,12 +5450,12 @@
                  0,
                  pGlobalTXT_LocalizationStrings[64],
                  0);
-  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, nullstring, 0);
-  v2->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  v2->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  v2->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  v2->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
-  v2->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, nullstring, 0);
+  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
+  v2->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  v2->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  v2->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  v2->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+  v2->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
   sub_419100();
   return v2;
 }
@@ -5477,7 +5474,7 @@
   pAudioPlayer->StopChannels(-1, -1);
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 23;
+  pCurrentScreen = 23;
   v2 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|WINDOW_Options), v1, 0);
   ptr_50767C = v2->CreateButton(
                  394u,
@@ -5493,12 +5490,12 @@
                  (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
                  papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
                  0);
-  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, nullstring, 0);
-  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, nullstring, 0);
-  v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-  v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-  v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-  v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+  v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, 0x78u, 0, 0, "", 0);
+  ptr_507690 = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, 0x85u, 0, 0, "", 0);
+  v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+  v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+  v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+  v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   return v2;
 }
 
@@ -5571,16 +5568,16 @@
     }
     a1.field_58 = 4;
     a1.uObjectDescID = v6;
-    a1.vPosition.y = pParty->vPosition.z;
+    a1.vPosition.y = pParty->vPosition.y;
     a1.vPosition.x = pParty->vPosition.x;
-    a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.y;
+    a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
     a1.uSoundID = 0;
     a1.uFacing = 0;
     a1.uAttributes = 8;
     v8 = pIndoor->GetSector(
            pParty->vPosition.x,
-           pParty->vPosition.z,
-           pParty->sEyelevel + pParty->vPosition.y);
+           pParty->vPosition.y,
+           pParty->sEyelevel + pParty->vPosition.z);
     a1.uSpriteFrameID = 0;
     a1.uSectorID = v8;
     memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24));
@@ -5631,7 +5628,7 @@
     v4->PlaySound(15, 0);
   }
 LABEL_9:
-  if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+  if ( !pCurrentScreen )
   {
     viewparams->bRedrawGameUI = 1;
     if ( uActiveCharacter != v1 )
@@ -5641,16 +5638,16 @@
     pGUIWindow_CurrentMenu = GameUI_InitializeCharacterWindow(v5);
     return;
   }
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 8 )
+  if ( pCurrentScreen == 8 )
     return;
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
+  if ( pCurrentScreen == 10 )
   {
 LABEL_23:
     viewparams->bRedrawGameUI = 1;
     if ( uActiveCharacter == v1 )
     {
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
-      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 15;
+      pCurrentScreen = 15;
       goto LABEL_28;
     }
 LABEL_27:
@@ -5658,15 +5655,15 @@
       return;
     goto LABEL_28;
   }
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 13 )
-  {
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 14 )
+  if ( pCurrentScreen != 13 )
+  {
+    if ( pCurrentScreen == 14 )
     {
 LABEL_28:
       uActiveCharacter = v1;
       return;
     }
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 15 )
+    if ( pCurrentScreen != 15 )
     {
       viewparams->bRedrawGameUI = 1;
       uActiveCharacter = v1;
@@ -5688,7 +5685,7 @@
     goto LABEL_22;
   }
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 // F8B19C: using guessed type int dword_F8B19C;
 
 //----- (00421EA6) --------------------------------------------------------
@@ -5853,7 +5850,7 @@
       }
       else
       {
-        sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName);
+        sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName);
         ShowStatusBarString(pTmpBuf2, 2u);
         if ( v22->uItemID == 506 )
           _449B7E_toggle_bit(pParty->_award_bits, 184, 1u);
@@ -5923,17 +5920,17 @@
               }
             }
             a1.uObjectDescID = v6;
-            a1.vPosition.y = pParty->vPosition.z;
+            a1.vPosition.y = pParty->vPosition.y;
             a1.field_58 = 4;
             a1.vPosition.x = pParty->vPosition.x;
-            a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.y;
+            a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
             a1.uSoundID = 0;
             a1.uFacing = 0;
             a1.uAttributes = 8;
             a1.uSectorID = pIndoor->GetSector(
                              pParty->vPosition.x,
-                             pParty->vPosition.z,
-                             pParty->sEyelevel + pParty->vPosition.y);
+                             pParty->vPosition.y,
+                             pParty->sEyelevel + pParty->vPosition.z);
             a1.uSpriteFrameID = 0;
             memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u);
             v8 = (int *)pMouse->GetCursorPos(&v25);
@@ -5960,7 +5957,7 @@
       else
       {
         v12 = &pOutdoor->pBModels[(signed int)(unsigned __int16)v0 >> 9].pFaces[v2 & 0x3F];
-        if ( !(v12->uFaceAttributes & 0x2000000) )
+        if ( !(v12->uAttributes & 0x2000000) )
           goto LABEL_11;
         v11 = v12->sCogTriggeredID;
       }
@@ -6047,18 +6044,18 @@
 //----- (004226C2) --------------------------------------------------------
 bool __cdecl sub_4226C2()
 {
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-    && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 4
-    && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 17 )
-  {
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 18 )
+  if ( pCurrentScreen
+    && pCurrentScreen != 4
+    && pCurrentScreen != 17 )
+  {
+    if ( pCurrentScreen == 18 )
       return pVideoPlayer->pSmackerMovie != 0;
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 19 )
+    if ( pCurrentScreen != 19 )
       return 1;
   }
   return 0;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (004226EF) --------------------------------------------------------
 void __fastcall SetUserInterface(int a1, bool bReplace)
@@ -6396,13 +6393,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
@@ -6419,64 +6416,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
@@ -6484,14 +6482,14 @@
   signed int ie; // [sp+24h] [bp-4h]@61
 
   v1 = &pIndoor->pFaces[uFaceID];
-  _this = pGame->pIndoorCameraD3D;
-  v2 = &pIndoor->pVertices[*v1->pVertexIDs];
-  v3 = *(int *)&v2->x;
+  //this = pGame->pIndoorCameraD3D;
+  v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
+  //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)
-     + v1->pFacePlane_old.vNormal.z * (v4 - pBLVRenderParams->vPartyPos.z) < 0 )
+  //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 * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
   {
     dword_50B700 = 1;
   }
@@ -6501,110 +6499,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
@@ -6614,272 +6605,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	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_2.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -166,11 +166,11 @@
     v14 = pDialogueWindow;
     v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
     v16 = v15 - HIDWORD(v15);
-    LODWORD(v15) = pDialogueWindow->field_38;
-    HIDWORD(v15) = v15 + pDialogueWindow->field_28;
+    LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
+    HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
     v17 = (v16 >> 1) - v29 / 2 + 158;
-    v18 = -pDialogueWindow->field_28 < 0;
-    pOutString = (GUIFont *)pDialogueWindow->field_38;
+    v18 = -pDialogueWindow->pNumPresenceButton < 0;
+    pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
     if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
     {
       v31 = 2;
@@ -186,7 +186,7 @@
         v17 = v23 + v22 - 1;
         v21->uW = v17;
         v24 = v30;
-        if ( pDialogueWindow->field_2C_focus_id != v31 )
+        if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
           v24 = v28;
         _this.DrawText2(pFontArrus, 0, v23, v24, *v19, 3u);
         v14 = pDialogueWindow;
@@ -194,7 +194,7 @@
         ++v19;
         pOutString = (GUIFont *)((char *)pOutString + 1);
       }
-      while ( (signed int)pOutString < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
+      while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
     }
   }
   else
@@ -403,11 +403,11 @@
     return;
   }
   v8 = v14[0];
-  if ( pDialogueWindow->field_2C_focus_id != 2 )
+  if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
     v8 = v13[0];
   _this.DrawText2(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
   v9 = v14[0];
-  if ( pDialogueWindow->field_2C_focus_id != 3 )
+  if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
     v9 = v13[0];
   _this.DrawText2(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
 }
@@ -662,8 +662,8 @@
           pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
           if ( (signed int)pOutString < v9 / 3 )
             pOutString = (GUIFont *)(v9 / 3);
-          v10 = v8->field_38;
-          v11 = v10 + v8->field_28;
+          v10 = v8->pStartingPosActiveItem;
+          v11 = v10 + v8->pNumPresenceButton;
           v86 = 0;
           if ( (signed int)v10 < v11 )
           {
@@ -678,7 +678,7 @@
               }
               ++v10;
             }
-            while ( (signed int)v10 < v8->field_38 + v8->field_28 );
+            while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
             if ( v86 )
             {
               sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
@@ -687,9 +687,9 @@
               if ( (149 - v89) / v86 > 32 )
                 pOutString = (GUIFont *)32;
               v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
-              v89 = v8->field_38;
+              v89 = v8->pStartingPosActiveItem;
               v83 = v14;
-              if ( v89 < v89 + v8->field_28 )
+              if ( v89 < v89 + v8->pNumPresenceButton )
               {
                 v86 = 2;
                 do
@@ -716,13 +716,13 @@
                     v16->uW = v22;
                     v83 = v22;
                     v23 = v84[0];
-                    if ( pDialogueWindow->field_2C_focus_id != v21 )
+                    if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
                       v23 = v81;
                     v79.DrawText2(pFontArrus, 0, v20, v23, Str[1], 3u);
                   }
-                  v24 = v8->field_28;
+                  v24 = v8->pNumPresenceButton;
                   ++v89;
-                  v25 = v8->field_38 + v24;
+                  v25 = v8->pStartingPosActiveItem + v24;
                   ++v86;
                 }
                 while ( v89 < v25 );
@@ -768,7 +768,7 @@
     if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       return;
     v28 = *(int *)v84;
-    if ( pDialogueWindow->field_2C_focus_id != 2 )
+    if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
       v28 = v81;
     sprintfex(&Dest, format_4E2DC8, v28);
     sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
@@ -776,7 +776,7 @@
     v90 = pFontArrus->CalcTextHeight(&Dest, &v79, 0, 0);
     strcat(&Dest, "\n \n");
     v29 = *(int *)v84;
-    if ( pDialogueWindow->field_2C_focus_id != 3 )
+    if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
       v29 = v81;
     sprintfex(&a1, format_4E2DC8, v29);
     sprintfex(pTmpBuf2,
@@ -788,7 +788,7 @@
     v88 = pFontArrus->CalcTextHeight(&a1, &v79, 0, 0);
     strcat(&a1, "\n \n");
     v30 = *(int *)v84;
-    if ( pDialogueWindow->field_2C_focus_id != 4 )
+    if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
       v30 = v81;
     sprintfex(&v77, format_4E2DC8, v30);
     strcat(&v77, pGlobalTXT_LocalizationStrings[160]);
@@ -800,7 +800,7 @@
     if ( v31 >= 108 && v31 <= 120 )
     {
       v32 = *(int *)v84;
-      if ( pDialogueWindow->field_2C_focus_id != 5 )
+      if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
         v32 = v81;
       sprintfex(&v75, format_4E2DC8, v32);
       strcat(&v75, pGlobalTXT_LocalizationStrings[611]);
@@ -808,11 +808,11 @@
     }
     v33 = pDialogueWindow;
     Str[1] = (char *)pDialogueWindow;
-    v34 = pDialogueWindow->field_38;
-    v35 = v34 + pDialogueWindow->field_28;
+    v34 = pDialogueWindow->pStartingPosActiveItem;
+    v35 = v34 + pDialogueWindow->pNumPresenceButton;
     v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
-    v37 = -pDialogueWindow->field_28 < 0;
-    pOutString = (GUIFont *)pDialogueWindow->field_38;
+    v37 = -pDialogueWindow->pNumPresenceButton < 0;
+    pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
     if ( !(v37 ^ __OFSUB__(v34, v35)) )
     {
 LABEL_75:
@@ -858,9 +858,9 @@
 LABEL_73:
         v38->uW = v41;
       }
-      v47 = v33->field_38;
+      v47 = v33->pStartingPosActiveItem;
       pOutString = (GUIFont *)((char *)pOutString + 1);
-      if ( (signed int)pOutString >= v33->field_28 + v47 )
+      if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
         goto LABEL_75;
     }
     v42 = v90 + v88 + 2 * v36 + 146;
@@ -890,11 +890,11 @@
     v51 = pDialogueWindow;
     v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
     v53 = v52 - HIDWORD(v52);
-    LODWORD(v52) = pDialogueWindow->field_38;
-    HIDWORD(v52) = v52 + pDialogueWindow->field_28;
+    LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
+    HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
     v54 = (v53 >> 1) - v86 / 2 + 138;
-    v37 = -pDialogueWindow->field_28 < 0;
-    v89 = pDialogueWindow->field_38;
+    v37 = -pDialogueWindow->pNumPresenceButton < 0;
+    v89 = pDialogueWindow->pStartingPosActiveItem;
     if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
     {
       v85 = (Player *)2;
@@ -911,7 +911,7 @@
         v54 = v57 + v58 - 1;
         v55->uW = v54;
         v60 = v84[0];
-        if ( (Player *)pDialogueWindow->field_2C_focus_id != v59 )
+        if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
           v60 = v81;
         v79.DrawText2(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
         v51 = pDialogueWindow;
@@ -919,7 +919,7 @@
         pOutString = (GUIFont *)((char *)pOutString + 4);
         ++v89;
       }
-      while ( v89 < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
+      while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
     }
   }
 }
@@ -1144,11 +1144,11 @@
       while ( (signed int)v66 < (signed int)&pShopOptions[3] );
       v68 = pDialogueWindow;
       v109 = (const char **)((174 - v65) / 3);
-      result = (char *)pDialogueWindow->field_38;
-      v69 = (int)&result[pDialogueWindow->field_28];
+      result = (char *)pDialogueWindow->pStartingPosActiveItem;
+      v69 = (int)&result[pDialogueWindow->pNumPresenceButton];
       v70 = (3 * (58 - (signed int)v109) - v65) / 2 - (174 - v65) / 3 / 2 + 138;
-      v20 = -pDialogueWindow->field_28 < 0;
-      v106.y = pDialogueWindow->field_38;
+      v20 = -pDialogueWindow->pNumPresenceButton < 0;
+      v106.y = pDialogueWindow->pStartingPosActiveItem;
       if ( v20 ^ __OFSUB__((int)result, (int)v69) )
       {
         _this = (Player *)2;
@@ -1165,14 +1165,14 @@
           v70 = v73 + v74 - 1;
           v71->uW = v70;
           v76 = v104;
-          if ( (Player *)pDialogueWindow->field_2C_focus_id != v75 )
+          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v75 )
             v76 = v105;
           v101.DrawText2(pFontArrus, 0, v74, v76, *(const char **)v108, 3u);
           v68 = pDialogueWindow;
           _this = (Player *)((char *)_this + 1);
           v108 += 4;
           ++v106.y;
-          result = (char *)(pDialogueWindow->field_28 + pDialogueWindow->field_38);
+          result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
         }
         while ( v106.y < (signed int)result );
       }
@@ -1195,8 +1195,8 @@
           v108 = v32 * (100 - _this->GetMerchant()) / 100;
           if ( v108 < v32 / 3 )
             v108 = v32 / 3;
-          v33 = v30->field_38;
-          v34 = v33 + v30->field_28;
+          v33 = v30->pStartingPosActiveItem;
+          v34 = v33 + v30->pNumPresenceButton;
           v109 = 0;
           if ( (signed int)v33 >= v34 )
             goto LABEL_105;
@@ -1211,7 +1211,7 @@
             }
             ++v33;
           }
-          while ( (signed int)v33 < v30->field_28 + v30->field_38 );
+          while ( (signed int)v33 < v30->pNumPresenceButton + v30->pStartingPosActiveItem );
           if ( !v109 )
           {
 LABEL_105:
@@ -1232,11 +1232,11 @@
           v108 = (149 - v106.y) / (signed int)v109;
           if ( (149 - v106.y) / (signed int)v109 > 32 )
             v108 = 32;
-          result = (char *)v30->field_38;
+          result = (char *)v30->pStartingPosActiveItem;
           v37 = (149 - (signed int)v109 * v108 - v106.y) / 2 - v108 / 2 + 162;
           v106.y = (LONG)result;
           v103 = v37;
-          if ( (signed int)result < (signed int)&result[v30->field_28] )
+          if ( (signed int)result < (signed int)&result[v30->pNumPresenceButton] )
           {
             v109 = (const char **)2;
             do
@@ -1263,13 +1263,13 @@
                 v39->uW = v45;
                 v103 = v45;
                 v46 = v104;
-                if ( (const char **)pDialogueWindow->field_2C_focus_id != v44 )
+                if ( (const char **)pDialogueWindow->pCurrentPosActiveItem != v44 )
                   v46 = v105;
                 v101.DrawText2(pFontArrus, 0, v43, v46, Str, 3u);
               }
-              v47 = v30->field_38;
+              v47 = v30->pStartingPosActiveItem;
               ++v106.y;
-              result = (char *)(v30->field_28 + v47);
+              result = (char *)(v30->pNumPresenceButton + v47);
               v109 = (const char **)((char *)v109 + 1);
             }
             while ( v106.y < (signed int)result );
@@ -1345,11 +1345,11 @@
         while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
         v17 = pDialogueWindow;
         v103 = (174 - v14) / 4;
-        result = (char *)pDialogueWindow->field_38;
-        v18 = (int)&result[pDialogueWindow->field_28];
+        result = (char *)pDialogueWindow->pStartingPosActiveItem;
+        v18 = (int)&result[pDialogueWindow->pNumPresenceButton];
         v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
-        v20 = -pDialogueWindow->field_28 < 0;
-        _this = (Player *)pDialogueWindow->field_38;
+        v20 = -pDialogueWindow->pNumPresenceButton < 0;
+        _this = (Player *)pDialogueWindow->pStartingPosActiveItem;
         if ( v20 ^ __OFSUB__((int)result, v18) )
         {
           v108 = 2;
@@ -1366,14 +1366,14 @@
             v19 = v24 + v23 - 1;
             v21->uW = v19;
             v26 = v104;
-            if ( pDialogueWindow->field_2C_focus_id != v25 )
+            if ( pDialogueWindow->pCurrentPosActiveItem != v25 )
               v26 = v105;
             v101.DrawText2(pFontArrus, 0, v24, v26, *v109, 3u);
             v17 = pDialogueWindow;
             ++v108;
             ++v109;
             _this = (Player *)((char *)_this + 1);
-            result = (char *)(pDialogueWindow->field_28 + pDialogueWindow->field_38);
+            result = (char *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
           }
           while ( (signed int)_this < (signed int)result );
         }
@@ -1762,11 +1762,11 @@
       while ( (signed int)v73 < (signed int)&unk_F8B1C8 );
       v75 = pDialogueWindow;
       Str = (char *)((174 - v72) / 4);
-      result = (POINT *)pDialogueWindow->field_38;
-      v76 = (int)((char *)result + pDialogueWindow->field_28);
+      result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
+      v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
       v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138;
-      v28 = -pDialogueWindow->field_28 < 0;
-      v112 = pDialogueWindow->field_38;
+      v28 = -pDialogueWindow->pNumPresenceButton < 0;
+      v112 = pDialogueWindow->pStartingPosActiveItem;
       if ( v28 ^ __OFSUB__((int)result, v76) )
       {
         _this = (Player *)2;
@@ -1783,14 +1783,14 @@
           v77 = v81 + v80 - 1;
           v78->uW = v77;
           v83 = v106;
-          if ( (Player *)pDialogueWindow->field_2C_focus_id != v82 )
+          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 )
             v83 = v108;
           v104.DrawText2(pFontArrus, 0, v81, v83, *v111, 3u);
           v75 = pDialogueWindow;
           _this = (Player *)((char *)_this + 1);
           ++v111;
           ++v112;
-          result = (POINT *)(pDialogueWindow->field_28 + pDialogueWindow->field_38);
+          result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
         }
         while ( (signed int)v112 < (signed int)result );
       }
@@ -1885,11 +1885,11 @@
         while ( (signed int)v23 < (signed int)&pShopOptions[2] );
         Str = (char *)((174 - v22) / 2);
         v25 = pDialogueWindow;
-        result = (POINT *)pDialogueWindow->field_38;
-        v26 = (int)((char *)result + pDialogueWindow->field_28);
+        result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
+        v26 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
         v27 = (2 * (87 - (174 - v22) / 2) - v22) / 2 - (174 - v22) / 2 / 2 + 138;
-        v28 = -pDialogueWindow->field_28 < 0;
-        v112 = pDialogueWindow->field_38;
+        v28 = -pDialogueWindow->pNumPresenceButton < 0;
+        v112 = pDialogueWindow->pStartingPosActiveItem;
         if ( v28 ^ __OFSUB__((int)result, v26) )
         {
           _this = (Player *)2;
@@ -1907,14 +1907,14 @@
             v29->uW = v34;
             v27 = v34;
             v35 = v106;
-            if ( (Player *)pDialogueWindow->field_2C_focus_id != v33 )
+            if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v33 )
               v35 = v108;
             v104.DrawText2(pFontArrus, 0, v32, v35, *v111, 3u);
             v25 = pDialogueWindow;
             _this = (Player *)((char *)_this + 1);
             ++v111;
             ++v112;
-            result = (POINT *)(pDialogueWindow->field_28 + pDialogueWindow->field_38);
+            result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
           }
           while ( (signed int)v112 < (signed int)result );
         }
@@ -1935,8 +1935,8 @@
         v111 = (const char **)(v5 * (100 - _this->GetMerchant()) / 100);
         if ( (signed int)v111 < v5 / 3 )
           v111 = (const char **)(v5 / 3);
-        v6 = v2->field_38;
-        v7 = v6 + v2->field_28;
+        v6 = v2->pStartingPosActiveItem;
+        v7 = v6 + v2->pNumPresenceButton;
         v114 = 0;
         if ( (signed int)v6 < v7 )
         {
@@ -1951,7 +1951,7 @@
             }
             ++v6;
           }
-          while ( (signed int)v6 < v2->field_28 + v2->field_38 );
+          while ( (signed int)v6 < v2->pNumPresenceButton + v2->pStartingPosActiveItem );
           if ( v114 )
           {
             sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v111);
@@ -1959,11 +1959,11 @@
             v111 = (const char **)((signed int)(149 - v112) / v114);
             if ( (signed int)(149 - v112) / v114 > 32 )
               v111 = (const char **)32;
-            result = (POINT *)v2->field_38;
+            result = (POINT *)v2->pStartingPosActiveItem;
             v10 = (signed int)(149 - v114 * (int)v111 - v112) / 2 - (signed int)v111 / 2 + 162;
             v112 = (unsigned int)result;
             v105 = v10;
-            if ( (signed int)result < (signed int)((char *)result + v2->field_28) )
+            if ( (signed int)result < (signed int)((char *)result + v2->pNumPresenceButton) )
             {
               v114 = 2;
               do
@@ -1990,13 +1990,13 @@
                   v12->uW = v18;
                   v105 = v18;
                   v19 = v106;
-                  if ( pDialogueWindow->field_2C_focus_id != v17 )
+                  if ( pDialogueWindow->pCurrentPosActiveItem != v17 )
                     v19 = v108;
                   v104.DrawText2(pFontArrus, 0, v16, v19, Str, 3u);
                 }
-                v20 = v2->field_38;
+                v20 = v2->pStartingPosActiveItem;
                 ++v112;
-                result = (POINT *)(v2->field_28 + v20);
+                result = (POINT *)(v2->pNumPresenceButton + v20);
                 ++v114;
               }
               while ( (signed int)v112 < (signed int)result );
@@ -2486,11 +2486,11 @@
       while ( (signed int)v81 < (signed int)&pShopOptions[3] );
       v83 = pDialogueWindow;
       v152 = (174 - v80) / 3;
-      v84 = pDialogueWindow->field_38;
-      v85 = v84 + pDialogueWindow->field_28;
+      v84 = pDialogueWindow->pStartingPosActiveItem;
+      v85 = v84 + pDialogueWindow->pNumPresenceButton;
       v86 = (3 * (58 - v152) - v80) / 2 - v152 / 2 + 138;
-      v24 = -pDialogueWindow->field_28 < 0;
-      _this = (Player *)pDialogueWindow->field_38;
+      v24 = -pDialogueWindow->pNumPresenceButton < 0;
+      _this = (Player *)pDialogueWindow->pStartingPosActiveItem;
       if ( v24 ^ __OFSUB__(v84, v85) )
       {
         v153 = 2;
@@ -2506,7 +2506,7 @@
           v86 = v90 + v89 - 1;
           v88->uW = v86;
           v92 = v147;
-          if ( pDialogueWindow->field_2C_focus_id != v91 )
+          if ( pDialogueWindow->pCurrentPosActiveItem != v91 )
             v92 = v148;
           v144.DrawText2(pFontArrus, 0, v90, v92, *v79, 3u);
           v83 = pDialogueWindow;
@@ -2514,7 +2514,7 @@
           ++v79;
           _this = (Player *)((char *)_this + 1);
         }
-        while ( (signed int)_this < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
+        while ( (signed int)_this < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
       }
       return;
     }
@@ -2529,8 +2529,8 @@
       _this = (Player *)(v38 * (100 - v0->GetMerchant()) / 100);
       if ( (signed int)_this < v38 / 3 )
         _this = (Player *)(v38 / 3);
-      v39 = v37->field_38;
-      v40 = v37->field_28;
+      v39 = v37->pStartingPosActiveItem;
+      v40 = v37->pNumPresenceButton;
       v153 = 0;
       if ( (signed int)v39 < (signed int)(v39 + v40) )
       {
@@ -2545,7 +2545,7 @@
           }
           ++v39;
         }
-        while ( (signed int)v39 < v37->field_28 + v37->field_38 );
+        while ( (signed int)v39 < v37->pNumPresenceButton + v37->pStartingPosActiveItem );
         if ( v153 )
         {
           sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], _this);
@@ -2554,9 +2554,9 @@
           if ( (149 - v152) / v153 > 32 )
             _this = (Player *)32;
           v43 = (149 - v153 * (signed int)_this - v152) / 2 - (signed int)_this / 2 + 162;
-          v152 = v37->field_38;
+          v152 = v37->pStartingPosActiveItem;
           v146 = v43;
-          if ( v152 < v152 + v37->field_28 )
+          if ( v152 < v152 + v37->pNumPresenceButton )
           {
             v153 = 2;
             do
@@ -2583,13 +2583,13 @@
                 v45->uW = v51;
                 v146 = v51;
                 v52 = v147;
-                if ( pDialogueWindow->field_2C_focus_id != v50 )
+                if ( pDialogueWindow->pCurrentPosActiveItem != v50 )
                   v52 = v148;
                 v144.DrawText2(pFontArrus, 0, v49, v52, Str, 3u);
               }
-              v53 = v37->field_38;
+              v53 = v37->pStartingPosActiveItem;
               ++v152;
-              v54 = v37->field_28 + v53;
+              v54 = v37->pNumPresenceButton + v53;
               ++v153;
             }
             while ( v152 < v54 );
@@ -2816,11 +2816,11 @@
       while ( (signed int)v18 < (signed int)&unk_F8B1C8 );
       v20 = pDialogueWindow;
       v146 = (174 - v17) / 4;
-      v21 = pDialogueWindow->field_38;
-      v22 = v21 + pDialogueWindow->field_28;
+      v21 = pDialogueWindow->pStartingPosActiveItem;
+      v22 = v21 + pDialogueWindow->pNumPresenceButton;
       v23 = (174 - 4 * (174 - v17) / 4 - v17) / 2 - (174 - v17) / 4 / 2 + 138;
-      v24 = -pDialogueWindow->field_28 < 0;
-      v152 = pDialogueWindow->field_38;
+      v24 = -pDialogueWindow->pNumPresenceButton < 0;
+      v152 = pDialogueWindow->pStartingPosActiveItem;
       if ( v24 ^ __OFSUB__(v21, v22) )
       {
         _this = (Player *)2;
@@ -2836,7 +2836,7 @@
           v23 = v28 + v27 - 1;
           v26->uW = v23;
           v30 = v147;
-          if ( (Player *)pDialogueWindow->field_2C_focus_id != v29 )
+          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v29 )
             v30 = v148;
           v144.DrawText2(pFontArrus, 0, v28, v30, *v16, 3u);
           v20 = pDialogueWindow;
@@ -2844,7 +2844,7 @@
           ++v16;
           ++v152;
         }
-        while ( v152 < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
+        while ( v152 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
       }
     }
     return;
@@ -3160,8 +3160,8 @@
                  pGlobalTXT_LocalizationStrings[34],// "Cancel"
                  (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
-  pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
+  pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
   dword_F8B19C = -1;
   v0 = (int)((char *)ptr_507BC0->ptr_1C - 102);
@@ -3273,8 +3273,8 @@
       {
         uDialogueType = 90;
         pParty->vPosition.x = 3849;
-        pParty->vPosition.z = 5770;
-        pParty->vPosition.y = 1;
+        pParty->vPosition.y = 5770;
+        pParty->vPosition.z = 1;
         pParty->uFallStartY = 1;
         pParty->sRotationY = 512;
         pParty->sRotationX = 0;
@@ -3313,10 +3313,10 @@
                    pGlobalTXT_LocalizationStrings[79],
                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                    0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, nullstring, 0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, nullstring, 0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, nullstring, 0);
-    pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x58u, 0, nullstring, 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0);
+    pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x58u, 0, "", 0);
     pDialogueWindow->_41D08F(4, 1, 0, 1);
   }
 }
@@ -3440,7 +3440,7 @@
   window.uFrameWidth = 460;
   window.uFrameZ = 452;
   v0 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[575], &window, 13, 0) + 7;
-  pRenderer->SetGameRenderStates();
+  pRenderer->BeginSceneD3D();
 
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
     pIndoor->Draw();
@@ -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(
@@ -3471,8 +3470,8 @@
   pRenderer->EndScene();
   pRenderer->Present();
   pParty->vPosition.x = 3849;
-  pParty->vPosition.z = 5770;
-  pParty->vPosition.y = 1;
+  pParty->vPosition.y = 5770;
+  pParty->vPosition.z = 1;
   pParty->uFallStartY = 1;
   pParty->sRotationY = 512;
   pParty->sRotationX = 0;
@@ -3707,7 +3706,7 @@
                  pGlobalTXT_LocalizationStrings[74],
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  return pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  return pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
 }
 
 //----- (004BCACC) --------------------------------------------------------
@@ -3773,7 +3772,7 @@
   v1 = 0;
   v2 = a1;
   v55 = a1;
-  if ( !pDialogueWindow->field_28 )
+  if ( !pDialogueWindow->pNumPresenceButton )
     return;
   pRenderer->ClearZBuffer(0, 479);
   v3 = dword_F8B198;
@@ -3823,7 +3822,7 @@
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                    (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),
                    v1);
-    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, nullstring, (Texture *)v1);
+    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1);
 LABEL_10:
     v3 = dword_F8B198;
     v8 = ptr_507BC0;
@@ -4528,7 +4527,7 @@
 
   v0 = pPlayers[uActiveCharacter];
   v77 = pPlayers[uActiveCharacter];
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 14 )
+  if ( pCurrentScreen == 14 )
     goto LABEL_73;
   if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
   {
@@ -7547,7 +7546,7 @@
   char *v45; // [sp-4h] [bp-ECh]@9
   char Str; // [sp+Ch] [bp-DCh]@60
   char Str2; // [sp+2Ch] [bp-BCh]@29
-  char v48; // [sp+A4h] [bp-44h]@52
+  unsigned int uFaceID; // [sp+A4h] [bp-44h]@52
   void *Src; // [sp+A8h] [bp-40h]@50
   int v50; // [sp+ACh] [bp-3Ch]@47
   char Source; // [sp+B0h] [bp-38h]@20
@@ -7769,7 +7768,7 @@
       v37 = pIndoor->GetSector(v55, a4, v36);
       if ( v37 == v54 )
       {
-        v38 = _46CEC3_get_floor_level(v55, a4, a3, v37, (int *)&v48);
+        v38 = _46CEC3_get_floor_level(v55, a4, a3, v37, &uFaceID);
         v39 = v38;
         if ( v38 != -30000 )
         {
@@ -7814,7 +7813,7 @@
   const char *v15; // [sp-4h] [bp-24h]@2
   unsigned __int16 v16; // [sp+0h] [bp-20h]@1
   int v17; // [sp+4h] [bp-1Ch]@1
-  int v18; // [sp+8h] [bp-18h]@16
+  unsigned int uFaceID; // [sp+8h] [bp-18h]@16
   int v19; // [sp+Ch] [bp-14h]@16
   size_t v20; // [sp+10h] [bp-10h]@6
   int v21; // [sp+14h] [bp-Ch]@14
@@ -7853,9 +7852,9 @@
   if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) )
   {
     v21 = 0;
-    v22 = pParty->vPosition.y;
+    v22 = pParty->vPosition.z;
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+      v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     v6 = &pActors[v20];
     v7 = (char *)&pMonsterStats->pInfos[v23 + 1];
     v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
@@ -7874,10 +7873,10 @@
     v6->uMovementSpeed = v9;
     v10 = rand() % 2048;
     v11 = ((unsigned __int64)(stru_5C6E00->SinCos(v10) * (signed __int64)v19) >> 16) + pParty->vPosition.x;
-    v18 = stru_5C6E00->SinCos(v10 - stru_5C6E00->uIntegerHalfPi);
-    v23 = (unsigned __int64)(v18 * (signed __int64)v19) >> 16;
-    v12 = pParty->vPosition.z;
-    v13 = (unsigned __int64)(v18 * (signed __int64)v19) >> 16;
+    uFaceID = stru_5C6E00->SinCos(v10 - stru_5C6E00->uIntegerHalfPi);
+    v23 = (unsigned __int64)(uFaceID * (signed __int64)v19) >> 16;
+    v12 = pParty->vPosition.y;
+    v13 = (unsigned __int64)(uFaceID * (signed __int64)v19) >> 16;
     v6->vInitialPosition.x = v11;
     v14 = v13 + v12;
     LOWORD(v12) = v22;
@@ -7894,14 +7893,14 @@
     v6->uAlly = 9999;
     v6->uGroup = 0;
     v6->uCurrentActionTime = 0;
-    v6->uAIState = 17;
+    v6->uAIState = Summoned;
     v6->uCurrentActionLength = 256;
     v6->UpdateAnimation();
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor
-      || (v22 = pParty->vPosition.y,
-          result = pIndoor->GetSector(v11, v14, pParty->vPosition.y),
+      || (v22 = pParty->vPosition.z,
+          result = pIndoor->GetSector(v11, v14, pParty->vPosition.z),
           result == v21)
-      && (result = _46CEC3_get_floor_level(v11, v14, v22, result, &v18), result != -30000)
+      && (result = _46CEC3_get_floor_level(v11, v14, v22, result, &uFaceID), result != -30000)
       && (result = abs(result - v22), result <= 1024) )
     {
       if ( v20 == uNumActors )
@@ -8369,7 +8368,7 @@
   int v22; // [sp+2Ch] [bp-18h]@3
   int v23; // [sp+30h] [bp-14h]@11
   int v24; // [sp+34h] [bp-10h]@1
-  int v25; // [sp+38h] [bp-Ch]@10
+  unsigned int uFaceID; // [sp+38h] [bp-Ch]@10
   int v26; // [sp+3Ch] [bp-8h]@11
   int v27; // [sp+40h] [bp-4h]@11
 
@@ -8396,10 +8395,10 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
   {
     v22 = 0;
-    v25 = 0;
+    uFaceID = 0;
     while ( 1 )
     {
-      ++v25;
+      ++uFaceID;
       v6 = rand() % 1024 + 512;
       v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
       v20 = stru_5C6E00->SinCos(v7);
@@ -8409,14 +8408,14 @@
       v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16;
       v8 = 0;
       v19.uIndex = v24;
-      v19.vPosition.y = v23 + pParty->vPosition.z;
-      v19.vPosition.z = pParty->vPosition.y;
+      v19.vPosition.y = v23 + pParty->vPosition.y;
+      v19.vPosition.z = pParty->vPosition.z;
       v26 = 0;
       v27 = 0;
       v19.vPosition.z = sub_46D49E_prolly_get_world_y_under_party(
                           v19.vPosition.x,
-                          v23 + pParty->vPosition.z,
-                          pParty->vPosition.y,
+                          v23 + pParty->vPosition.y,
+                          pParty->vPosition.z,
                           0,
                           &v26,
                           &v27,
@@ -8438,12 +8437,12 @@
         v22 = 1;
       }
 LABEL_16:
-      v11 = v25 == 100;
-      if ( v25 >= 100 )
+      v11 = uFaceID == 100;
+      if ( uFaceID >= 100 )
         break;
       if ( v22 )
       {
-        v11 = v25 == 100;
+        v11 = uFaceID == 100;
         break;
       }
     }
@@ -8451,7 +8450,7 @@
   else
   {
     v26 = 0;
-    v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+    v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     do
     {
       ++v26;
@@ -8465,17 +8464,17 @@
       v16 = stru_5C6E00->SinCos(v14 - stru_5C6E00->uIntegerHalfPi);
       v20 = v16;
       v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16;
-      v19.vPosition.y = v23 + pParty->vPosition.z;
-      v19.vPosition.z = pParty->vPosition.y;
+      v19.vPosition.y = v23 + pParty->vPosition.y;
+      v19.vPosition.z = pParty->vPosition.z;
       v19.uIndex = v24;
-      v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.z, pParty->vPosition.y);
+      v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z);
       if ( v17 == v22 )
       {
-        v18 = _46CEC3_get_floor_level(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &v25);
+        v18 = _46CEC3_get_floor_level(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID);
         v19.vPosition.z = v18;
         if ( v18 != -30000 )
         {
-          if ( abs(v18 - pParty->vPosition.y) <= 1024 )
+          if ( abs(v18 - pParty->vPosition.z) <= 1024 )
             break;
         }
       }
@@ -9004,111 +9003,109 @@
 // return value: angle in integer format (multiplier of Pi/1024)  
 unsigned int stru193_math::Atan2(int x, int y)
 {
-  stru193_math *v3; // esi@1
-  int v4; // edi@1
-  int v5; // ebx@1
-  int v6; // eax@1
-  signed int v7; // ecx@1
-  unsigned int result; // eax@5
-  signed int v9; // ebx@14
-  signed __int64 v10; // qtt@20
-  unsigned int v11; // eax@20
-  int v12; // edx@20
-  int v13; // ecx@38
-  int v14; // eax@38
-  unsigned int v15; // eax@43
-  signed int v16; // [sp-4h] [bp-10h]@13
-
-  v3 = this;
-  v4 = y;
-  v5 = abs(x);
-  v6 = abs(y);
-  v7 = 0;
-  if ( v5 < 65536 && v6 >> 15 >= v5 )
-    x = 0;
-  if ( !x )
-  {
-    result = v3->uIntegerHalfPi;
-    if ( y <= 0 )
-      result += v3->uIntegerPi;
-    return result;
-  }
-  if ( y )
-  {
-    if ( x <= 0 )
-    {
-      x = -x;
-      if ( y >= 0 )
-      {
-        v16 = 4;
-        goto LABEL_19;
-      }
-      v16 = 3;
+  signed int quadrant;
+  __int64 dividend;
+  int quotient;
+  int lowIdx;
+  int highIdx;
+  int angle;
+
+  auto X = x;
+  auto Y = y;
+
+  if ( abs(X) < 65536 )
+  {
+    if ( (abs(Y) >> 15) >= abs(X) )
+      X = 0;
+  }
+
+  if ( !X )
+  {
+    if ( Y > 0 )
+    {
+      return uIntegerHalfPi;   //Pi/2
+    }
+    else
+    {
+      return uIntegerHalfPi + uIntegerPi; //3*(Pi/2)
+    }
+  }
+
+  if ( Y )
+  {
+    if ( X < 0 )
+    {
+      X = -X;
+      if ( Y > 0 )
+      {
+        quadrant = 4;        
+      }
+      else
+      {
+        quadrant = 3;        
+      }      
     }
     else
     {
-      if ( y >= 0 )
-      {
-        v9 = 1;
-        goto LABEL_20;
-      }
-      v16 = 2;
-    }
-    v4 = -y;
-LABEL_19:
-    v9 = v16;
-LABEL_20:
-    LODWORD(v10) = v4 << 16;
-    HIDWORD(v10) = v4 >> 16;
-    v11 = v3->uIntegerHalfPi;
-    v12 = v10 / x;
-    if ( v12 <= v3->pTanTable[(signed int)v3->uIntegerHalfPi >> 1] )
-      v11 = (signed int)v3->uIntegerHalfPi >> 1;
-    else
-      v7 = (signed int)v3->uIntegerHalfPi >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    if ( v12 <= v3->pTanTable[(signed int)(v7 + v11) >> 1] )
-      v11 = (signed int)(v7 + v11) >> 1;
-    else
-      v7 = (signed int)(v7 + v11) >> 1;
-    v13 = v7 + 1;
-    v14 = v11 - 1;
-    while ( v13 < v14 && v12 >= v3->pTanTable[v13] )
-      ++v13;
-    if ( v9 == 2 )
-    {
-      v15 = v3->uIntegerDoublePi;
-    }
-    else
-    {
-      if ( v9 == 3 )
-        return v13 + v3->uIntegerPi;
-      if ( v9 != 4 )
-        return v13;
-      v15 = v3->uIntegerPi;
-    }
-    return v15 - v13;
-  }
-  if ( x <= 0 )
-    result = v3->uIntegerPi;
-  else
-    result = 0;
-  return result;
+      if ( Y > 0 )
+      {
+        quadrant = 1;       
+      }
+      else
+      {
+        quadrant = 2;
+      }      
+    }
+
+    if ( Y < 0 )
+      Y = -Y;
+
+    LODWORD(dividend) = Y << 16;
+    HIDWORD(dividend) = Y >> 16;
+    quotient = dividend / X;        
+
+    //looks like binary search
+    {
+      int i;
+      highIdx = uIntegerHalfPi;
+      lowIdx = 0;
+
+      for (i = 0; i < 6; ++i)
+      {        
+        if (quotient <= pTanTable[(lowIdx + highIdx) / 2])      
+          highIdx = (lowIdx + highIdx) / 2;
+        else
+          lowIdx = (lowIdx + highIdx) / 2;    
+      }
+    }
+
+    angle = lowIdx + 1;
+    while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] )
+      ++angle;
+
+    switch (quadrant)
+    {
+    case 1: //X > 0, Y > 0
+      return angle;        
+
+    case 2: //X > 0, Y < 0
+      return uIntegerDoublePi - angle;   //2*Pi - angle
+
+    case 3: //X > 0, Y < 0
+      return uIntegerPi + angle;        //Pi + angle 
+
+    case 4: //X < 0, Y > 0
+      return uIntegerPi - angle;        //Pi - angle  
+    }
+
+    //should newer get here
+    return 0;
+  }
+
+  if ( X < 0 )    //Y == 0, X < 0
+    return uIntegerPi;  
+
+  return 0;
 }
 
 
@@ -9314,7 +9311,7 @@
 }
 
 //----- (00452C49) --------------------------------------------------------
-void __cdecl InitializeGameText()
+void InitializeGameText()
 {
   //char *v0; // ebx@1
   char *v1; // eax@3
@@ -11237,30 +11234,6 @@
 }
 
 
-
-
-
-
-
-
-
-//----- (0045BAA5) --------------------------------------------------------
-int __thiscall sub_45BAA5(int _this)
-{
-  sub_45BAB6(_this);
-  return 0;
-}
-
-//----- (0045BAB6) --------------------------------------------------------
-std::string *__fastcall sub_45BAB6(int a1)
-{
-  size_t v1; // eax@1
-
-  stru_69BD44 = "effpar03";
-  return &stru_69BD44;
-}
-
-
 //----- (0045E03A) --------------------------------------------------------
 unsigned __int16 *__fastcall MakeScreenshot(signed int width, signed int height)
 {
@@ -11302,7 +11275,7 @@
   v3 = pPixels;
   if ( pRenderer->pRenderD3D )
   {
-    pRenderer->SetGameRenderStates();
+    pRenderer->BeginSceneD3D();
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
     {
       pIndoor->Draw();
@@ -11745,7 +11718,7 @@
 
 
 //----- (0046086A) --------------------------------------------------------
-int __cdecl MaybeDoAutosave()
+bool Autosave()
 {
   int v0; // esi@3
   int v1; // eax@4
@@ -11762,7 +11735,7 @@
   if ( pVideoPlayer->AnyMovieLoaded() )
     pVideoPlayer->Unload();
   v0 = 0;
-  pSave = pAllocator->AllocNamedChunk(0, 0xF4240u, 0);
+  pSave = pAllocator->AllocNamedChunk(0, 0xF4240, 0);
   pNew_LOD->CloseWriteFile();
   remove("data\\new.lod");
   this_.Reset();
@@ -11772,7 +11745,7 @@
   this_.dword_0000A8 = 0;
   a3.dword_000018 = 0;
   a3.word_00001E = 0;
-  strcpy((char *)&a3, "current");
+  strcpy(a3.pFilename, "current");
   pNew_LOD->_461492(&this_, &a3, "data\\new.lod");
   if ( pNew_LOD->LoadFile("data\\new.lod", 0) )
   {
@@ -11808,12 +11781,12 @@
     pParty->vPrevPosition.y = v0;
     pParty->vPrevPosition.x = 12552;
     pParty->vPosition.x = 12552;
-    pParty->vPosition.y = v0;
+    pParty->vPosition.z = v0;
     pParty->uFallStartY = v0;
     pParty->sPrevRotationX = v0;
     pParty->sRotationX = v0;
     pParty->vPrevPosition.z = 1816;
-    pParty->vPosition.z = 1816;
+    pParty->vPosition.y = 1816;
     v0 = 1;
     pParty->sPrevRotationY = 512;
     pParty->sRotationY = 512;
@@ -12138,7 +12111,7 @@
   GUIButton *v14; // [sp+0h] [bp-3Ch]@27
   GUIWindow *v15; // [sp+4h] [bp-38h]@11
 
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+  pCurrentScreen = 0;
   if (pAsyncMouse)
     pAsyncMouse->Resume();
   if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard )
@@ -12208,8 +12181,8 @@
                                                     pExit,
                                                     0);
 
-  stru_506F20.Release();
-  stru_506F20.Load("title.pcx", 0);
+  pTexture_PCX.Release();
+  pTexture_PCX.Load("title.pcx", 0);
   SetCurrentMenuID(MENU_MAIN);
   SetForegroundWindow(hWnd);
   SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0);
@@ -12223,12 +12196,12 @@
     v15 = pWindow_MainMenu;
     if ( GetCurrentMenuID() == MENU_SAVELOAD)
     {
-      if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 12 )
-      {
-        stru_506F20.Release();
-        stru_506F20.Load("lsave640.pcx", 0);
+      if ( pCurrentScreen != 12 )
+      {
+        pTexture_PCX.Release();
+        pTexture_PCX.Load("lsave640.pcx", 0);
         pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
-        uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 12;
+        pCurrentScreen = 12;
         GameUI_DrawLoadMenu(0);
       }
       v15 = pGUIWindow_CurrentMenu;
@@ -12249,7 +12222,7 @@
     else
     {
       pRenderer->BeginScene();
-      pRenderer->DrawTextureRGB(0, 0, &stru_506F20);
+      pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
       if (pAsyncMouse)
         pAsyncMouse->_46B736_consume_click_lists(1);
       GUI_MainMenuMessageProc();
@@ -12264,7 +12237,7 @@
           pIcons_LOD->_4114F2();
           pGUIWindow_CurrentMenu->Release();
           pGUIWindow_CurrentMenu = 0;
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+          pCurrentScreen = 0;
           viewparams->bRedrawGameUI = 1;
         }
       }
@@ -12336,7 +12309,7 @@
   GUI_UpdateWindows();
   pRenderer->EndScene();
   pRenderer->Present();
-  stru_506F20.Release();
+  pTexture_PCX.Release();
   if ( pGUIWindow2 )
   {
     pGUIWindow2->Release();
@@ -12502,16 +12475,16 @@
 LABEL_240:
           if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 )
             pVideoPlayer->bStopBeforeSchedule = 1;
-          if ( pAsyncMouse == (void *)v31 )
+          if (!pAsyncMouse)
             pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-          if ( pGame != (Game *)v31 )
-          {
-            if ( pAsyncMouse != (void *)v31 )
+          if (pGame)
+          {
+            if (pAsyncMouse)
               goto _def_wnd_proc;
             v33 = GetPickDepth();
             pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &stru_F93E30, &a4);
           }
-          if ( pAsyncMouse == (void *)v31 )
+          if (!pAsyncMouse)
           {
             sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0);
             return DefWindowProcA(hWnd, Msg, wParam, v4);
@@ -12669,8 +12642,8 @@
           v35 = hWnd;
           goto LABEL_104;
         }
-        if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-          && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 21 )
+        if ( pCurrentScreen
+          && pCurrentScreen != 21 )
           return 0;
       }
       if ( !viewparams->field_4C )
@@ -13111,8 +13084,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
 
@@ -13152,20 +13125,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;
@@ -13198,11 +13164,11 @@
   cbData = 4;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v10, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v10, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v11, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    {
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v10, &dwDisposition) )
+      {
+        if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, 0xF003Fu, 0, &v11, &dwDisposition) )
         {
           if ( RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) )
           {
@@ -13240,11 +13206,11 @@
   phkResult = 0;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v8, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v8, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v9, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    {
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
+      {
+        if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, 0xF003Fu, 0, &v9, &dwDisposition) )
         {
           v2 = strlen(Str);
           RegSetValueExA(v9, lpValueName, 0, 1u, (const BYTE *)Str, v2 + 1);
@@ -13282,9 +13248,9 @@
   phkResult = 0;
   v4 = RegCloseKey;
   if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey)
-    || RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
-    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v13, &dwDisposition)
-    || RegCreateKeyExA(v13, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v14, &dwDisposition) )
+    || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
+    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
+    || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
     goto LABEL_7;
   if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
   {
@@ -13333,11 +13299,11 @@
   phkResult = 0;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, nullstring, 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, nullstring, 0, 0xF003Fu, 0, &v7, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v7, "1.0", 0, nullstring, 0, 0xF003Fu, 0, &v8, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    {
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v7, &dwDisposition) )
+      {
+        if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
         {
           RegSetValueExA(v8, lpValueName, 0, 4u, Data, 4u);
           RegCloseKey(v8);
@@ -13527,7 +13493,7 @@
       drive[0] = 'A' + i;
 
       if (GetDriveTypeA(drive) == DRIVE_CDROM)
-        if (CheckMM7CD(bGotCDFromRegistry))
+        if (CheckMM7CD(*drive))
         {
           cMM7GameCDDriveLetter = *drive;
           WriteWindowsRegistryString("CDDrive", drive);
@@ -13884,7 +13850,6 @@
     ClipCursor(nullptr);
     pRenderer->SwitchToWindow(hWnd);
   }
-  pRenderer->Present();
 
   uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9);
   if (uSoundVolumeMultiplier > 9)
@@ -14090,6 +14055,9 @@
   RECT Rect; // [sp+Ch] [bp-20h]@15
   int a2[4]; // [sp+1Ch] [bp-10h]@15
 
+  auto mm7text_dll = LoadLibraryW(L"mm7text.dll");
+  sprintfex = (int (__cdecl *)(char *a1, const char *a2, ...))GetProcAddress(mm7text_dll, "_sprintfex");
+
   if (pCmdLine && *pCmdLine)
   {
     if (wcsstr(pCmdLine, L"-usedefs"))
@@ -14187,9 +14155,9 @@
             goto LABEL_53;
           }
           DeleteCCharFont();
-          bFlashQuestBook = 1;
+          bFlashQuestBook = true;
           pGame->pCShow->PlayMovie(MOVIE_Emerald, 0);
-          MaybeDoAutosave();
+          Autosave();
           goto LABEL_48;
         }
         if (GetCurrentMenuID() == MENU_CREDITS)
@@ -15173,7 +15141,7 @@
   GUIWindow a1; // [sp+Ch] [bp-54h]@1
 
   memcpy(&a1, ptr_507BC4, sizeof(a1));
-  a1.str_48 = 0;
+  a1.Hint = 0;
   a1.uFrameX = 1;
   a1.uFrameY = 1;
   a1.uFrameWidth = 468;
@@ -15188,7 +15156,7 @@
   }
   a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1;
   a1.uFrameW = v0 + a1.uFrameY - 1;
-  a1._415551(0);
+  a1.DrawMessageBox(0);
   a1.uFrameX += 12;
   a1.uFrameWidth -= 24;
   a1.uFrameY += 12;
@@ -15671,7 +15639,7 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     if ( pRenderer->pRenderD3D )
-      v1 = pGame->pIndoorCameraD3D->flt_fov;
+      v1 = pGame->pIndoorCameraD3D->fov;
     else
       v1 = pIndoorCamera->flt_1C_fov;
     v3 = (signed __int64)v1;
@@ -15692,7 +15660,7 @@
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     if ( pRenderer->pRenderD3D )
-      v1 = pGame->pIndoorCameraD3D->flt_fov;
+      v1 = pGame->pIndoorCameraD3D->fov;
     else
       v1 = pIndoorCamera->flt_1C_fov;
     v3 = (signed __int64)v1;
@@ -15976,7 +15944,7 @@
       if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
       {
         if ( a1 >> 9 >= pOutdoor->uNumBModels
-          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uFaceAttributes) & 0x10)
+          || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
           || (v6 = v7->sCogTriggeredID) == 0 )
           return 1;
 LABEL_13:
@@ -15992,13 +15960,13 @@
       }
       if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 )
         return 1;
-      if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 19 )
+      if ( pCurrentScreen != 19 )
         goto LABEL_13;
       break;
   }
   return 0;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0046A6AC) --------------------------------------------------------
 int __fastcall sub_46A6AC(int a1, int a2, int a3)
@@ -16182,8 +16150,8 @@
     do
     {
       v5 = abs(*((short *)v4 - 17) - pParty->vPosition.x);
-      v17 = abs(*((short *)v4 - 16) - pParty->vPosition.z);
-      v18 = abs(*((short *)v4 - 15) - pParty->vPosition.y);
+      v17 = abs(*((short *)v4 - 16) - pParty->vPosition.y);
+      v18 = abs(*((short *)v4 - 15) - pParty->vPosition.z);
       v6 = v5;
       v7 = v17;
       v8 = v18;
@@ -16439,21 +16407,6 @@
   return v19;
 }
 
-//----- (0046AC59) --------------------------------------------------------
-std::string *__fastcall crt_intit_global_46AC59(int a1)
-{
-  size_t v1; // eax@1
-
-  //std__string_720990.field_0 = BYTE3(a1);
-  //std::string::dtor(&std__string_720990, 0);
-  //v1 = strlen("micon1");
-  //return std::stringoperator_assign__const_char_ptr__(&std__string_720990, "micon1", v1);
-  std__string_720990 = "micon1";
-  return &std__string_720990;
-}
-
-
-
 
 //----- (0046BDA8) --------------------------------------------------------
 unsigned int __cdecl GetGravityStrength()
@@ -16509,21 +16462,21 @@
   ODM_ProcessPartyActions();
   if ( pParty->vPosition.x < -22528
     || pParty->vPosition.x > 22528
-    || pParty->vPosition.z < -22528
-    || pParty->vPosition.z > 22528 )
+    || pParty->vPosition.y < -22528
+    || pParty->vPosition.y > 22528 )
   {
     strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
-    v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, (char *)&pOut, 32);
+    v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, (char *)&pOut, 32);
     if ( !bUnderwater && (pParty->uFlags & 0x8C || BYTE1(pParty->uFlags) & 2 || pParty->bFlying) || !v0 )
     {
       if ( pParty->vPosition.x < -22528 )
         pParty->vPosition.x = -22528;
       if ( pParty->vPosition.x > 22528 )
         pParty->vPosition.x = 22528;
-      if ( pParty->vPosition.z < -22528 )
-        pParty->vPosition.z = -22528;
-      if ( pParty->vPosition.z > 22528 )
-        pParty->vPosition.z = 22528;
+      if ( pParty->vPosition.y < -22528 )
+        pParty->vPosition.y = -22528;
+      if ( pParty->vPosition.y > 22528 )
+        pParty->vPosition.y = 22528;
     }
     else
     {
@@ -16916,7 +16869,7 @@
                   v138 = 0;
                   if ( v2->uItemType == 8030 )
                   {
-                    pActors[v108].uAIState = 0;
+                    pActors[v108].uAIState = Standing;
                     pActors[v108].UpdateAnimation();
                   }
                   ((SpellBuff *)((char *)&pActors[0].pActorBuffs[v136] + v108 * 836))->Apply(
--- a/mm7_3.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_3.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -122,7 +122,7 @@
     {
       v9 = &pIndoor->pSectors[v33[result]];
       v10 = 0;
-      v32 = v9->field_4 + v9->field_C + v9->field_14;
+      v32 = v9->uNumFloors + v9->field_C + v9->field_14;
       v26 = 0;
       if ( v32 > 0 )
         break;
@@ -346,7 +346,7 @@
       f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
       v6 = v4->pFacePlane.dist;
       f.pFacePlane_old.dist = v4->pFacePlane.dist;
-      v7 = v4->uFaceAttributes;
+      v7 = v4->uAttributes;
       f.uAttributes = v7;
       f.pBounding.x1 = v4->pBoundingBox.x1;
       f.pBounding.y1 = v4->pBoundingBox.y1;
@@ -518,25 +518,25 @@
 
 
 //----- (0046ED1B) --------------------------------------------------------
-int __fastcall _46ED1B_collide_against_floor(signed int a1, signed int a2, int a3, unsigned int *pSectorID, int *a5)
-{
-  unsigned int *v5; // edi@1
-  int result; // eax@1
-  int v7; // eax@3
-  int v8; // [sp+Ch] [bp-8h]@1
-  int v9; // [sp+10h] [bp-4h]@1
-
-  v5 = pSectorID;
-  v9 = a2;
-  v8 = a1;
-  result = _46CEC3_get_floor_level(a1, a2, a3, *pSectorID, (int *)&pSectorID);
-  if ( result != -30000 && result <= a3 + 50
-    || (v7 = pIndoor->GetSector(v8, v9, a3), (*v5 = v7) != 0)
-    && (result = _46CEC3_get_floor_level(v8, v9, a3, v7, (int *)&pSectorID), result != -30000) )
-    *a5 = (int)pSectorID;
-  else
-    result = -30000;
-  return result;
+int _46ED1B_collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
+{
+  uint uFaceID = -1;
+  int floor_level = _46CEC3_get_floor_level(x, y, z, *pSectorID, &uFaceID);
+
+  if (floor_level != -30000 && floor_level <= z + 50)
+  {
+    *pFaceID = uFaceID;
+    return floor_level;
+  }
+
+  uint uSectorID = pIndoor->GetSector(x, y, z);
+  *pSectorID = uSectorID;
+
+  floor_level = _46CEC3_get_floor_level(x, y, z, uSectorID, &uFaceID);
+  if (uSectorID && floor_level != -30000)
+    *pFaceID = uFaceID;
+  else return -30000;
+  return floor_level;
 }
 
 //----- (0046ED8A) --------------------------------------------------------
@@ -649,21 +649,21 @@
   {
     if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
     {
-      if ( stru_721530.sMaxY <= pParty->vPosition.z + v1 )
-      {
-        if ( stru_721530.sMinY >= pParty->vPosition.z - v1 )
-        {
-          if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.y + pParty->uPartyHeight) )
-          {
-            if ( stru_721530.sMinZ >= pParty->vPosition.y )
+      if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 )
+      {
+        if ( stru_721530.sMinY >= pParty->vPosition.y - v1 )
+        {
+          if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) )
+          {
+            if ( stru_721530.sMinZ >= pParty->vPosition.z )
             {
               v3 = stru_721530.prolly_normal_d + v1;
               v11 = pParty->vPosition.x - stru_721530.normal.x;
               v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
-                  - (pParty->vPosition.z - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
-              v10 = pParty->vPosition.z - stru_721530.normal.y;
+                  - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16;
+              v10 = pParty->vPosition.y - stru_721530.normal.y;
               result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.field_58.y
-                          - (pParty->vPosition.z - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
+                          - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.field_58.x) >> 16);
               if ( result <= v3 )
               {
                 result = v10 * stru_721530.field_58.y;
@@ -671,11 +671,11 @@
                 if ( v5 > 0 )
                 {
                   v6 = ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
-                  result = pParty->vPosition.y;
-                  if ( v6 >= pParty->vPosition.y )
+                  result = pParty->vPosition.z;
+                  if ( v6 >= pParty->vPosition.z )
                   {
-                    result = v9 + pParty->vPosition.y;
-                    if ( v6 <= (signed int)(v9 + pParty->vPosition.y) || v8 )
+                    result = v9 + pParty->vPosition.z;
+                    if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
                     {
                       result = sub_452A9E(v3 * v3 - v4 * v4);
                       v7 = v5 - result;
@@ -1011,7 +1011,7 @@
       v72 = 1;
     if ( v0->uAIState == 5 && v76 && !v72 )
     {
-      v0->uAIState = 11;
+      v0->uAIState = Removed;
       goto LABEL_121;
     }
     if ( v0->uCurrentActionAnimation == 1 )
@@ -1114,7 +1114,7 @@
       v0->vVelocity.y += rand() % 100 - 50;
       v0->vVelocity.z += rand() % 100 - 20;
       v25 = rand();
-      v0->uAIState = 8;
+      v0->uAIState = Stunned;
       v0->uYawAngle += v25 % 32 - 16;
       v0->UpdateAnimation();
     }
@@ -1191,7 +1191,7 @@
             else
               v61 = v68 + 60;
             sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61);
-            v0->uAIState = 11;
+            v0->uAIState = Removed;
             return;
           }
         }
@@ -1274,7 +1274,7 @@
         case 6:
           v40 = &pOutdoor->pBModels[v38 >> 9];
           v41 = &v40->pFaces[v39 & 0x3F];
-          if ( !(BYTE3(v41->uFaceAttributes) & 0x20) )
+          if ( !(BYTE3(v41->uAttributes) & 0x20) )
           {
             v42 = v41->uPolygonType;
             if ( v42 == 3 )
@@ -1372,7 +1372,7 @@
           v0->uYawAngle -= 32;
           v0->uCurrentActionTime = 0;
           v0->uCurrentActionLength = 128;
-          v0->uAIState = 7;
+          v0->uAIState = Fleeing;
         }
       }
     }
@@ -1381,10 +1381,6 @@
   }
   while ( (signed int)v75 < (signed int)uNumActors );
 }
-// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
-// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
-// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
-// 4F75D8: using guessed type int ai_arrays_size;
 
 
 
@@ -1428,7 +1424,7 @@
   Particle_ Dst; // [sp+Ch] [bp-84h]@18
   unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1
   ObjectDesc *v37; // [sp+78h] [bp-18h]@1
-  int v38; // [sp+7Ch] [bp-14h]@4
+  unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
   int v39; // [sp+80h] [bp-10h]@33
   int v40; // [sp+84h] [bp-Ch]@28
   int v41; // [sp+88h] [bp-8h]@34
@@ -1442,11 +1438,11 @@
   if ( abs(v3) > 32767
     || abs(v1->vPosition.y) > 32767
     || abs(v1->vPosition.z) > 20000
-    || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &v38),
+    || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v1->uSectorID, &uFaceID),
         v42 <= -30000)
     && ((v4 = pIndoor->GetSector(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z),
          (v1->uSectorID = v4) == 0)
-     || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &v38), v42 == -30000)) )
+     || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &uFaceID), v42 == -30000)) )
   {
     LayingItem::_42F933(uLayingItemID_);
     return;
@@ -1458,7 +1454,7 @@
     v8 = 0;
 LABEL_25:
     stru_721530.field_0 = v8;
-    v38 = v8;
+    uFaceID = v8;
     stru_721530.prolly_normal_d = v2->uRadius;
     v12 = v2->uHeight;
     stru_721530.field_84 = -1;
@@ -1559,7 +1555,7 @@
           v34 = (TEXTURE_TYPE)v8;
           v32 = "effpar03";
         }
-        Dst.field_20 = (unsigned __int8)(v30 & 0x80) + 128;
+        Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128;
         Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34);
         goto LABEL_71;
       }
@@ -1660,9 +1656,9 @@
       v1->vVelocity.y = v41;
       v41 = v1->vVelocity.z;
       v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
-      ++v38;
-      v28 = __OFSUB__(v38, 100);
-      v27 = v38 - 100 < 0;
+      ++uFaceID;
+      v28 = __OFSUB__(uFaceID, 100);
+      v27 = uFaceID - 100 < 0;
       v1->vVelocity.z = v41;
       if ( !(v27 ^ v28) )
         return;
@@ -1678,7 +1674,7 @@
   {
     v6 = pIndoor->pFaces;
     v1->vPosition.z = v42 + 1;
-    v7 = &v6[v38];
+    v7 = &v6[uFaceID];
     if ( v7->uPolygonType == 3 )
     {
       v8 = 0;
@@ -1691,15 +1687,15 @@
       v8 = 0;
     }
     v42 = v1->vVelocity.x;
-    v38 = 58500;
+    uFaceID = 58500;
     v42 = (unsigned __int64)(58500i64 * v42) >> 16;
     v1->vVelocity.x = v42;
     v42 = v1->vVelocity.y;
-    v42 = (unsigned __int64)(v38 * (signed __int64)v42) >> 16;
-    v38 = 58500;
+    v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16;
+    uFaceID = 58500;
     v1->vVelocity.y = v42;
     v42 = v1->vVelocity.z;
-    v42 = (unsigned __int64)(v38 * (signed __int64)v42) >> 16;
+    v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16;
     v9 = v1->vVelocity.x;
     v1->vVelocity.z = v42;
     if ( v9 * v9 + v1->vVelocity.y * v1->vVelocity.y < 400 )
@@ -1733,7 +1729,7 @@
 LABEL_70:
           Dst.bFree = 512;
           Dst.uDiffuse = rand();
-          Dst.field_20 = 64;
+          Dst.timeToLive = 64;
           Dst.uTextureID = v8;
 LABEL_71:
           Dst.flt_28 = 1.0;
@@ -1746,7 +1742,7 @@
         v33 = (TEXTURE_TYPE)v8;
         v31 = "effpar03";
       }
-      Dst.field_20 = (unsigned __int8)(v11 & 0x80) + 128;
+      Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128;
       Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33);
 LABEL_72:
       pGame->pParticleEngine->AddParticle(&Dst);
@@ -1927,7 +1923,7 @@
       {
         Dst.bFree = 512;
         Dst.uDiffuse = rand();
-        Dst.field_20 = 64;
+        Dst.timeToLive = 64;
         Dst.uTextureID = 0;
 LABEL_89:
         Dst.flt_28 = 1.0;
@@ -1941,7 +1937,7 @@
 LABEL_87:
       v47 = "effpar03";
     }
-    Dst.field_20 = (unsigned __int8)(v24 & 0x80) + 128;
+    Dst.timeToLive = (unsigned __int8)(v24 & 0x80) + 128;
     Dst.uTextureID = pBitmaps_LOD->LoadTexture(v47, v48);
     goto LABEL_89;
   }
@@ -2066,7 +2062,7 @@
           v46 = rand();
           Dst.uTextureID = 0;
           Dst.uDiffuse = v46;
-          Dst.field_20 = 64;
+          Dst.timeToLive = 64;
           goto LABEL_89;
         }
         Dst.bFree = 1032;
@@ -2127,7 +2123,7 @@
           }
           v1->vVelocity.z += v37;
 LABEL_70:
-          if ( BYTE3(v32->uFaceAttributes) & 0x10 )
+          if ( BYTE3(v32->uAttributes) & 0x10 )
             EventProcessor(v32->sCogTriggeredID, 0, 1);
           goto LABEL_74;
         }
@@ -2214,6 +2210,7 @@
   v20 = 0;
   if ( (signed int)uNumLayingItems > 0 )
   {
+    __debugbreak();
     v2 = (char *)&pLayingItems[0].uSpriteFrameID;
     do
     {
@@ -2272,8 +2269,8 @@
             if ( pParty->bTurnBasedModeOn != 1 || !(*(v2 - 4) & 4) )
               goto LABEL_36;
             v12 = abs(pParty->vPosition.x - *(int *)(v2 - 26));
-            v18 = abs(pParty->vPosition.z - *(int *)(v2 - 22));
-            v19 = abs(pParty->vPosition.y - *(int *)(v2 - 18));
+            v18 = abs(pParty->vPosition.y - *(int *)(v2 - 22));
+            v19 = abs(pParty->vPosition.z - *(int *)(v2 - 18));
             v13 = v12;
             v14 = v18;
             v15 = v19;
@@ -2316,34 +2313,35 @@
 }
 
 //----- (0047272C) --------------------------------------------------------
-int __fastcall _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, int *a5)
+int _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
 {
   signed int v5; // ebx@1
   int result; // eax@1
   int v7; // [sp+10h] [bp-8h]@1
   signed int v8; // [sp+14h] [bp-4h]@1
 
+  __debugbreak();
   v5 = x - 2;
   v7 = x;
   v8 = y;
   *pSectorID = pIndoor->GetSector(x - 2, y, z + 40);
-  result = _46ED1B_collide_against_floor(v5, v8, z + 40, pSectorID, a5);
+  result = _46ED1B_collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID);
   if ( result == -30000 || !*pSectorID )
   {
     *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40);
-    result = _46ED1B_collide_against_floor(v7 + 2, v8, z + 40, pSectorID, a5);
+    result = _46ED1B_collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID);
     if ( result == -30000 || !*pSectorID )
     {
       *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40);
-      result = _46ED1B_collide_against_floor(v7, v8 - 2, z + 40, pSectorID, a5);
+      result = _46ED1B_collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID);
       if ( result == -30000 || !*pSectorID )
       {
         *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40);
-        result = _46ED1B_collide_against_floor(v7, v8 + 2, z + 40, pSectorID, a5);
+        result = _46ED1B_collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID);
         if ( result == -30000 || !*pSectorID )
         {
           *pSectorID = pIndoor->GetSector(v7, v8, z + 140);
-          result = _46ED1B_collide_against_floor(v7, v8, z + 140, pSectorID, a5);
+          result = _46ED1B_collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID);
         }
       }
     }
@@ -2352,20 +2350,14 @@
 }
 
 //----- (00472866) --------------------------------------------------------
-void __cdecl BLV_ProcessPartyActions()
-{
-  int v0; // esi@1
+void BLV_ProcessPartyActions()
+{
   int v1; // ebx@1
   int v2; // edi@1
-  int v3; // esi@1
-  float v4; // ST40_4@8
-  Player **v5; // esi@15
   int v6; // eax@18
-  Player **v7; // esi@24
   signed __int64 v8; // qax@27
   int v9; // eax@27
   double v10; // st7@27
-  BLVFace *v11; // edx@41
   unsigned int v12; // eax@49
   double v13; // st7@50
   int v14; // eax@51
@@ -2383,15 +2375,9 @@
   int v26; // eax@67
   double v27; // st7@67
   int v28; // ST40_4@67
-  int v29; // eax@69
-  double v30; // st7@69
-  int v31; // ST3C_4@69
-  int v32; // eax@71
-  double v33; // st7@71
-  int v34; // ST3C_4@71
   unsigned int v35; // eax@74
   int v36; // ecx@88
-  int v37; // esi@96
+  int new_party_z; // esi@96
   int v38; // eax@96
   int v39; // ecx@106
   int v40; // eax@106
@@ -2421,160 +2407,151 @@
   unsigned int v64; // [sp-8h] [bp-68h]@161
   int v65; // [sp-4h] [bp-64h]@75
   int v66; // [sp-4h] [bp-64h]@161
-  double v67; // [sp+Ch] [bp-54h]@8
   int v68; // [sp+10h] [bp-50h]@45
   int v69; // [sp+10h] [bp-50h]@140
-  int v70; // [sp+14h] [bp-4Ch]@1
+  unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1
   signed int v71; // [sp+18h] [bp-48h]@1
   signed int v72; // [sp+1Ch] [bp-44h]@1
   signed int v73; // [sp+20h] [bp-40h]@100
   int v74; // [sp+20h] [bp-40h]@140
-  signed int bFeatherFall; // [sp+24h] [bp-3Ch]@15
-  bool bFeatherFalla; // [sp+24h] [bp-3Ch]@33
-  unsigned int v77; // [sp+28h] [bp-38h]@1
+  bool bFeatherFall; // [sp+24h] [bp-3Ch]@15
+  unsigned int uSectorID; // [sp+28h] [bp-38h]@1
   int v78; // [sp+2Ch] [bp-34h]@1
-  int v79; // [sp+30h] [bp-30h]@1
-  int i; // [sp+34h] [bp-2Ch]@1
+  unsigned int uFaceID; // [sp+30h] [bp-30h]@1
+  int v80; // [sp+34h] [bp-2Ch]@1
   int v81; // [sp+38h] [bp-28h]@47
   int v82; // [sp+3Ch] [bp-24h]@47
-  int v83; // [sp+40h] [bp-20h]@47
+  int _view_angle; // [sp+40h] [bp-20h]@47
   int bJumping; // [sp+44h] [bp-1Ch]@1
-  int v85; // [sp+48h] [bp-18h]@1
-  int v86; // [sp+4Ch] [bp-14h]@1
-  int v87; // [sp+50h] [bp-10h]@1
-  float v88; // [sp+54h] [bp-Ch]@62
+  int new_party_y; // [sp+48h] [bp-18h]@1
+  int new_party_x; // [sp+4Ch] [bp-14h]@1
+  int party_z; // [sp+50h] [bp-10h]@1
   int v89; // [sp+58h] [bp-8h]@1
   int angle; // [sp+5Ch] [bp-4h]@47
 
-  v0 = pParty->vPosition.y;
+  uFaceEvent = 0;
   v89 = pParty->uFallSpeed;
   v1 = 0;
-  v85 = pParty->vPosition.z;
-  v70 = 0;
+  new_party_y = pParty->vPosition.y;
   v2 = 0;
-  v86 = pParty->vPosition.x;
-  v87 = pParty->vPosition.y;
-  v77 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+  new_party_x = pParty->vPosition.x;
+  party_z = pParty->vPosition.z;
+  uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   v72 = 0;
   v78 = 0;
   v71 = 0;
   bJumping = 0;
-  v3 = v0 + 40;
-  i = _46ED1B_collide_against_floor(v86, v85, v3, &v77, &v79);
+  v80 = _46ED1B_collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
   if ( pParty->bFlying )
   {
     pParty->bFlying = 0;
-    if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
+    __debugbreak();
+    if (pParty->FlyActive())
       stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing]
   }
-  if ( i == -30000 )
-  {
-    i = _47272C_collide_agains_some_secotors_floors(v86, v85, v3, &v77, &v79);
-    if ( i == -30000 )
+  if ( v80 == -30000 )
+  {
+    v80 = _47272C_collide_agains_some_secotors_floors(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);
+    if ( v80 == -30000 )
     {
       pParty->vPosition.x = blv_prev_party_x;
-      pParty->vPosition.z = blv_prev_party_z;
-      pParty->vPosition.y = blv_prev_party_y;
+      pParty->vPosition.y = blv_prev_party_z;
+      pParty->vPosition.z = blv_prev_party_y;
       pParty->uFallStartY = blv_prev_party_y;
       return;
     }
   }
   blv_prev_party_x = pParty->vPosition.x;
-  blv_prev_party_z = pParty->vPosition.z;
-  blv_prev_party_y = pParty->vPosition.y;
-  if ( pParty->bTurnBasedModeOn != 1 )
-  {
-    v4 = (double)(GetTickCount() / 0x1F4);
-    v67 = v4 + 6.7553994e15;
-    if ( *(int *)&word_720C10_intercepts_xs[102] != LODWORD(v67) )
-    {
-      dword_4F8584[3 * dword_4F8580[0]] = pParty->vPosition.x;
-      dword_4F8588[3 * dword_4F8580[0]] = pParty->vPosition.z;
-      dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.y;
+  blv_prev_party_z = pParty->vPosition.y;
+  blv_prev_party_y = pParty->vPosition.z;
+  if (!pParty->bTurnBasedModeOn)
+  {
+    auto v67 = GetTickCount() / 500;
+    if (dword_720CDC != v67 )
+    {
+      dword_4F8580[3 * dword_4F8580[0] + 1] = pParty->vPosition.x;
+      dword_4F8580[3 * dword_4F8580[0] + 2] = pParty->vPosition.y;
+      dword_4F8580[3 * dword_4F8580[0]++ + 3] = pParty->vPosition.z;
       if ( dword_4F8580[0] > 60 )
         dword_4F8580[0] = 1;
     }
-    *(int *)&word_720C10_intercepts_xs[102] = LODWORD(v67);
-  }
-  if ( SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0
-    || SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 )
-  {
-    bFeatherFall = 0;
-    v5 = &pPlayers[1];
-    while ( !(*v5)->WearsItem(536, 16) )
-    {
-      ++v5;
-      if ( (signed int)v5 > (signed int)&pPlayers[4] )
-      {
-        v6 = pParty->uFallStartY;
-        goto LABEL_20;
-      }
-    }
-  }
-  v6 = i;
-  bFeatherFall = 1;
-  pParty->uFallStartY = i;
+    dword_720CDC = v67;
+  }
+  if (!pParty->FeatherFallActive())
+  {
+    bFeatherFall = false;
+    if (!pParty->pPlayers[0].WearsItem(536, 16) &&
+        !pParty->pPlayers[1].WearsItem(536, 16) &&
+        !pParty->pPlayers[2].WearsItem(536, 16) &&
+        !pParty->pPlayers[3].WearsItem(536, 16))
+    {
+      v6 = pParty->uFallStartY;
+    }
+  }
+  else
+  {
+    v6 = v80;
+    bFeatherFall = true;
+    pParty->uFallStartY = v80;
+  }
 LABEL_20:
-  if ( v6 - v87 > 512 && !bFeatherFall && v87 <= i + 1 )
+  if ( v6 - party_z > 512 && !bFeatherFall && party_z <= v80 + 1 )
   {
     if ( BYTE1(pParty->uFlags) & 1 )
     {
       BYTE1(pParty->uFlags) &= 0xFEu;
     }
-    else
-    {
-      v7 = &pPlayers[1];                        // receive falling damage
-      do
-      {
-        if ( !(*v7)->HasEnchantedItemEquipped(72) && !(*v7)->WearsItem(529, 8) )
-        {
-          v8 = (signed __int64)((double)(*v7)->GetMaxHealth() * 0.1);
-          (*v7)->ReceiveDamage((pParty->uFallStartY - v87) * (signed int)v8 / 256, 4);
-          v9 = (*v7)->GetActualEndurance();
-          v10 = (double)(20 - (*v7)->_48EA1B_get_static_effect(v9)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
-          (*v7)->SetRecoveryTime((signed __int64)v10);
-        }
-        ++v7;
-      }
-      while ( (signed int)v7 <= (signed int)&pPlayers[4] );
-    }
-  }
-  if ( v87 > i + 1 )
+    else for (uint i = 0; i < 4; ++i)
+    {                                      // receive falling damage
+      auto pPlayer = pParty->pPlayers + i;
+           
+      if (!pPlayer->HasEnchantedItemEquipped(72) &&
+          !pPlayer->WearsItem(529, 8))
+      {
+        v8 = (signed __int64)((double)pPlayer->GetMaxHealth() * 0.1);
+        pPlayer->ReceiveDamage((pParty->uFallStartY - party_z) * (signed int)v8 / 256, 4);
+        v9 = pPlayer->GetActualEndurance();
+        v10 = (double)(20 - pPlayer->_48EA1B_get_static_effect(v9)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333;
+        pPlayer->SetRecoveryTime((signed __int64)v10);
+      }
+    }
+  }
+  if ( party_z > v80 + 1 )
     bJumping = 1;
-  bFeatherFalla = v87 - i <= 32;
-  if ( v87 - i <= 32 )
-    pParty->uFallStartY = v87;
+  bFeatherFall = party_z - v80 <= 32;
+  if ( party_z - v80 <= 32 )
+    pParty->uFallStartY = party_z;
   if ( bWalkSound && pParty->field_6F8 > 0 )
     pParty->field_6F8 -= pEventTimer->uTimeElapsed;
-  if ( v87 > i + 1 )
+  if ( party_z > v80 + 1 )
   {
 LABEL_43:
     if ( bJumping )
       goto LABEL_45;
     goto LABEL_44;
   }
-  v87 = i + 1;
-  pParty->uFallStartY = i + 1;
+  party_z = v80 + 1;
+  pParty->uFallStartY = v80 + 1;
   if ( bJumping )
     goto LABEL_45;
-  if ( pParty->field_6F4_packedid != v79 )
-  {
-    v11 = &pIndoor->pFaces[v79];
-    if ( BYTE3(v11->uAttributes) & 4 )
-    {
-      v70 = pIndoor->pFaceExtras[v11->uFaceExtraID].uEventID;
+  if (pParty->field_6F4_packedid != uFaceID)
+  {
+    auto pFace = &pIndoor->pFaces[uFaceID];
+    if (pFace->uAttributes & 0x04000000 )
+    {
+      uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
       goto LABEL_43;
     }
   }
 LABEL_44:
-  pParty->field_6F4_packedid = v79;
+  pParty->field_6F4_packedid = uFaceID;
 LABEL_45:
-  v68 = v79;
-  if ( pIndoor->pFaces[v79].uAttributes & 0x10 )
+  v68 = uFaceID;
+  if ( pIndoor->pFaces[uFaceID].uAttributes & 0x10 )
     v71 = 1;
   v81 = pParty->uWalkSpeed;
   angle = pParty->sRotationY;
-  v83 = pParty->sRotationX;
+  _view_angle = pParty->sRotationX;
   v82 = (unsigned __int64)(pEventTimer->dt_in_some_format
                          * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed * stru_5C6E00->uIntegerPi)
                                           / 180)) >> 16;
@@ -2584,12 +2561,14 @@
     switch ( pPartyActionQueue->Next() )
     {
       case PARTY_TurnLeft:
+        __debugbreak();
         v12 = uTurnSpeed;
         if ( uTurnSpeed )
           goto LABEL_58;
         v13 = (double)v82 * fTurnSpeedMultiplier;
         goto LABEL_51;
       case PARTY_TurnRight:
+        __debugbreak();
         LODWORD(v15) = uTurnSpeed;
         if ( uTurnSpeed )
           goto LABEL_56;
@@ -2622,79 +2601,77 @@
         angle = stru_5C6E00->uDoublePiMask & (angle - v15);
         goto LABEL_87;
       case PARTY_StrafeLeft:
+        __debugbreak();
         v17 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
         v18 = (double)v81;
-        v88 = v18;
+        //v88 = v18;
         v78 = (unsigned __int64)(v17 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16;
         v2 -= v78;
         v19 = stru_5C6E00->SinCos(angle);
-        v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v88 * fWalkSpeedMultiplier) >> 1)) >> 16;
+        v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16;
         goto LABEL_63;
       case PARTY_StrafeRight:
+        __debugbreak();
         v20 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
         v21 = (double)v81;
-        v88 = v21;
+        //v88 = v21;
         v78 = (unsigned __int64)(v20 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16;
         v2 += v78;
         v22 = stru_5C6E00->SinCos(angle);
-        v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v88 * fWalkSpeedMultiplier) >> 1)) >> 16;
+        v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16;
         goto LABEL_68;
       case PARTY_WalkForward:
+        __debugbreak();
         v23 = stru_5C6E00->SinCos(angle);
         v24 = (double)v81;
-        v88 = v24;
+        //v88 = v24;
         v78 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
         v2 += v78;
         v25 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
-        v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v88 * fWalkSpeedMultiplier)) >> 16;
+        v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16;
 LABEL_63:
         v1 += v78;
         goto LABEL_64;
       case PARTY_WalkBackward:
+        __debugbreak();
         v26 = stru_5C6E00->SinCos(angle);
         v27 = (double)v81;
-        v88 = v27;
+        //v88 = v27;
         v78 = (unsigned __int64)(v26
-                               * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardMovementSlowdownMultiplier)) >> 16;
+                               * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16;
         v2 -= v78;
         v28 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
         v78 = (unsigned __int64)(v28
-                               * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16;
+                               * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16;
 LABEL_68:
         v1 -= v78;
 LABEL_64:
         v78 = 1;
         goto LABEL_87;
       case PARTY_RunForward:
-        v29 = stru_5C6E00->SinCos(angle);
-        v30 = (double)v81;
-        v88 = v30;
-        v2 += (unsigned __int64)(v29
-                               * (signed __int64)(signed int)(2
-                                                            * (unsigned __int64)(signed __int64)(v30
-                                                                                               * fWalkSpeedMultiplier))) >> 16;
-        v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
-        v1 += (unsigned __int64)(v31
-                               * (signed __int64)(signed int)(2
-                                                            * (unsigned __int64)(signed __int64)(v88
-                                                                                               * fWalkSpeedMultiplier))) >> 16;
-        goto LABEL_70;
+        //v29 = stru_5C6E00->SinCos(angle);
+        //v30 = (double)v81;
+        //v88 = (double)v81;
+        v2 += (unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16;
+        //v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
+        v1 += (unsigned __int64)(stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16;
+        v72 = 1;
+        goto LABEL_87;
       case PARTY_RunBackward:
-        v32 = stru_5C6E00->SinCos(angle);
-        v33 = (double)v81;
-        v88 = v33;
-        v2 -= (unsigned __int64)(v32
-                               * (signed __int64)(signed int)(signed __int64)(v33 * fBackwardMovementSlowdownMultiplier)) >> 16;
-        v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
-        v1 -= (unsigned __int64)(v34
-                               * (signed __int64)(signed int)(signed __int64)(v88 * fBackwardMovementSlowdownMultiplier)) >> 16;
-LABEL_70:
+        //v32 = stru_5C6E00->SinCos(angle);
+        //v33 = (double)v81;
+        //v88 = (double)v81;
+        v2 -= (unsigned __int64)(stru_5C6E00->SinCos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
+        //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi);
+        v1 -= (unsigned __int64)(stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16;
+//LABEL_70:
         v72 = 1;
         goto LABEL_87;
       case PARTY_LookUp:
-        v83 += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
-        if ( v83 > 128 )
-          v83 = 128;
+        __debugbreak();
+        _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
+        if ( _view_angle > 128 )
+          _view_angle = 128;
         v35 = uActiveCharacter;
         if ( !uActiveCharacter )
           goto LABEL_87;
@@ -2702,9 +2679,10 @@
         v63 = 63;
         goto LABEL_76;
       case PARTY_LookDown:
-        v83 += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
-        if ( v83 < -128 )
-          v83 = -128;
+        __debugbreak();
+        _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
+        if ( _view_angle < -128 )
+          _view_angle = -128;
         v35 = uActiveCharacter;
         if ( uActiveCharacter )
         {
@@ -2715,10 +2693,12 @@
         }
         break;
       case PARTY_CenterView:
-        v83 = 0;
+        __debugbreak();
+        _view_angle = 0;
         break;
       case PARTY_Jump:
-        if ( (!bJumping || v87 <= i + 6 && v89 <= 0) && pParty->field_24 )
+        __debugbreak();
+        if ( (!bJumping || party_z <= v80 + 6 && v89 <= 0) && pParty->field_24 )
         {
           bJumping = 1;
           v89 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v89);
@@ -2730,7 +2710,7 @@
   }
   v36 = 0;
   pParty->sRotationY = angle;
-  pParty->sRotationX = v83;
+  pParty->sRotationX = _view_angle;
   if ( bJumping )
   {
     v89 += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
@@ -2762,7 +2742,7 @@
     goto LABEL_93;
   }
 LABEL_92:
-  pParty->uFallStartY = v87;
+  pParty->uFallStartY = party_z;
 LABEL_93:
   if ( v2 * v2 + v1 * v1 < 400 )
   {
@@ -2773,22 +2753,22 @@
   stru_721530.field_70 = 0;
   stru_721530.prolly_normal_d = pParty->field_14;
   stru_721530.field_8 = pParty->field_14 >> 1;
-  v83 = 0;
+  auto v83 = 0;
   stru_721530.field_0 = 1;
   stru_721530.field_C = pParty->uPartyHeight - 32;
   while ( 1 )
   {
-    v37 = v87;
-    stru_721530.field_34.x = v86;
-    stru_721530.normal.x = v86;
+    new_party_z = party_z;
+    stru_721530.field_34.x = new_party_x;
+    stru_721530.normal.x = new_party_x;
     stru_721530.field_1C = v2;
-    stru_721530.field_34.y = v85;
-    stru_721530.normal.y = v85;
+    stru_721530.field_34.y = new_party_y;
+    stru_721530.normal.y = new_party_y;
     stru_721530.field_20 = v1;
-    stru_721530.normal.z = stru_721530.prolly_normal_d + v87 + 1;
-    stru_721530.field_34.z = stru_721530.field_C + v87 + 1;
+    stru_721530.normal.z = stru_721530.prolly_normal_d + party_z + 1;
+    stru_721530.field_34.z = stru_721530.field_C + party_z + 1;
     stru_721530.field_24 = v89;
-    stru_721530.uSectorID = v77;
+    stru_721530.uSectorID = uSectorID;
     v38 = 0;
     if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 )
       v38 = 13312;
@@ -2799,8 +2779,8 @@
     {
       _46E44E_collide_against_faces_and_portals(1u);
       _46E0B2_collide_against_decorations();
-      for ( i = 0; i < (signed int)uNumActors; ++i )
-        _46DF1A_collide_against_actor(i, 0);
+      for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 )
+        _46DF1A_collide_against_actor(v80, 0);
       if ( _46F04E_collide_against_portals() )
         break;
       ++v73;
@@ -2809,31 +2789,31 @@
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
       v39 = stru_721530.normal2.x;
-      v77 = stru_721530.normal2.y;
+      uSectorID = stru_721530.normal2.y;
       v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
     }
     else
     {
-      v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + v86;
-      v77 = v85 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
-      v40 = v37 + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
-    }
-    v42 = _46ED1B_collide_against_floor(v39, v77, v40 + 40, &stru_721530.uSectorID, &v79);
-    if ( v42 == -30000 || v42 - v37 > 128 )
+      v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16) + new_party_x;
+      uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
+      v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
+    }
+    v42 = _46ED1B_collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID);
+    if ( v42 == -30000 || v42 - new_party_z > 128 )
       return;
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
-      v86 = stru_721530.normal2.x;
-      v85 = stru_721530.normal2.y;
-      v37 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
+      new_party_x = stru_721530.normal2.x;
+      new_party_y = stru_721530.normal2.y;
+      new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
       break;
     }
-    v86 += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
-    v85 += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
+    new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16;
+    new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
     v43 = stru_721530.uFaceID;
-    v77 = stru_721530.uSectorID;
+    uSectorID = stru_721530.uSectorID;
     stru_721530.field_70 += stru_721530.field_7C;
-    v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + v37;
+    auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z;
     if ( (stru_721530.uFaceID & 7) == 3 )
     {
       if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0
@@ -2845,13 +2825,13 @@
     if ( (stru_721530.uFaceID & 7) == 5 )
     {
       v53 = sub_452A9E(v2 * v2 + v1 * v1);
-      i = v53;
+      v80 = v53;
       v54 = stru_5C6E00->Atan2(
-              v86 - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
-              v85 - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
+              new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x,
+              new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y);
       v2 = (unsigned __int64)(stru_5C6E00->SinCos(v54) * (signed __int64)v53) >> 16;
       v55 = stru_5C6E00->SinCos(v54 - stru_5C6E00->uIntegerHalfPi);
-      v1 = (unsigned __int64)(v55 * (signed __int64)i) >> 16;
+      v1 = (unsigned __int64)(v55 * (signed __int64)v80) >> 16;
     }
     else
     {
@@ -2878,43 +2858,43 @@
         v48 = v44->pFacePlane_old.vNormal.x;
         if ( !v47 )
         {
-          i = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-          if ( stru_721530.field_64 >> 3 > i )
-            i = stru_721530.field_64 >> 3;
-          v50 = (unsigned __int64)(i * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
+          v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
+          if ( stru_721530.field_64 >> 3 > v80 )
+            v80 = stru_721530.field_64 >> 3;
+          v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
           v81 = v44->pFacePlane_old.vNormal.y;
-          v81 = (unsigned __int64)(i * (signed __int64)v81) >> 16;
+          v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
           v82 = v44->pFacePlane_old.vNormal.z;
-          v82 = (unsigned __int64)(i * (signed __int64)v82) >> 16;
+          v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
           v2 += v50;
           v89 += v82;
           v74 = v44->pFacePlane_old.vNormal.z;
           v51 = v44->pFacePlane_old.vNormal.y;
           v69 = v44->pFacePlane_old.vNormal.x;
-          i = v51;
+          v80 = v51;
           v1 += v81;
-          v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + v85 * v51 + v86 * v69) >> 16);
+          v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
           if ( v52 > 0 )
           {
-            v86 += v52 * v69 >> 16;
-            v85 += v52 * i >> 16;
+            new_party_x += v52 * v69 >> 16;
+            new_party_y += v52 * v80 >> 16;
             v87 += v52 * v74 >> 16;
           }
 LABEL_142:
           v43 = stru_721530.uFaceID;
 LABEL_143:
           if ( pParty->field_6F4_packedid != v43 >> 3 && BYTE3(v44->uAttributes) & 4 )
-            v70 = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
+            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
           goto LABEL_152;
         }
-        i = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-        if ( stru_721530.field_64 >> 3 > i )
-          i = stru_721530.field_64 >> 3;
-        v49 = (unsigned __int64)(i * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
+        v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
+        if ( stru_721530.field_64 >> 3 > v80 )
+          v80 = stru_721530.field_64 >> 3;
+        v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
         v81 = v44->pFacePlane_old.vNormal.y;
-        v81 = (unsigned __int64)(i * (signed __int64)v81) >> 16;
+        v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
         v82 = v44->pFacePlane_old.vNormal.z;
-        v82 = (unsigned __int64)(i * (signed __int64)v82) >> 16;
+        v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
         v2 += v49;
         v1 += v81;
         v89 += v82;
@@ -2932,18 +2912,18 @@
     v89 = (unsigned __int64)(58500i64 * v89) >> 16;
     if ( v83 >= 100 )
     {
-      v37 = v87;
+      new_party_z = v87;
       break;
     }
   }
   if ( bWalkSound && pParty->field_6F8 <= 0 )
   {
-    if ( sub_452A9E((pParty->vPosition.x - v86) * (pParty->vPosition.x - v86) + (pParty->vPosition.z - v85)
-                                                                            * (pParty->vPosition.z - v85)
-                                                                            + (pParty->vPosition.y - v37)
-                                                                            * (pParty->vPosition.y - v37)) <= 16 )
+    if ( sub_452A9E((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y)
+                                                                            * (pParty->vPosition.y - new_party_y)
+                                                                            + (pParty->vPosition.z - new_party_z)
+                                                                            * (pParty->vPosition.z - new_party_z)) <= 16 )
       goto LABEL_188;
-    if ( v72 && (!bJumping || bFeatherFalla) )
+    if ( v72 && (!bJumping || bFeatherFall) )
     {
       v66 = 0;
       v64 = 0;
@@ -2955,7 +2935,7 @@
       if ( !v71 )
       {
         v56 = pAudioPlayer;
-        if ( BYTE2(pIndoor->pFaces[v79].uAttributes) & 0x20 )
+        if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
           v57 = (SoundID)50;
         else
           v57 = (SoundID)64;
@@ -2966,7 +2946,7 @@
       v56 = pAudioPlayer;
       goto LABEL_175;
     }
-    if ( v78 && (!bJumping || bFeatherFalla) )
+    if ( v78 && (!bJumping || bFeatherFall) )
     {
       v66 = 0;
       v64 = 0;
@@ -2981,7 +2961,7 @@
         goto LABEL_174;
       }
       v56 = pAudioPlayer;
-      if ( BYTE2(pIndoor->pFaces[v79].uAttributes) & 0x20 )
+      if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
         v57 = (SoundID)89;
       else
         v57 = (SoundID)103;
@@ -2995,19 +2975,19 @@
       pParty->field_6F8 = 64;
     }
   }
-  if ( !bJumping || bFeatherFalla )
+  if ( !bJumping || bFeatherFall )
     pParty->uFlags &= 0xFFFFFFF7u;
   else
     pParty->uFlags |= 8u;
   BYTE1(pParty->uFlags) &= 0xFDu;
-  pParty->vPosition.x = v86;
-  pParty->vPosition.y = v37;
-  pParty->vPosition.z = v85;
+  pParty->vPosition.x = new_party_x;
+  pParty->vPosition.z = new_party_z;
+  pParty->vPosition.y = new_party_y;
   pParty->uFallSpeed = v89;
-  if ( !bJumping && BYTE3(pIndoor->pFaces[v79].uAttributes) & 0x40 )
+  if ( !bJumping && BYTE3(pIndoor->pFaces[uFaceID].uAttributes) & 0x40 )
     BYTE1(pParty->uFlags) |= 2u;
-  if ( v70 )
-    EventProcessor(v70, 0, 1);
+  if (uFaceEvent)
+    EventProcessor(uFaceEvent, 0, 1);
 }
 
 
@@ -3147,17 +3127,17 @@
   int v130; // [sp+90h] [bp-4h]@14
 
   v121 = pParty->uFallSpeed;
-  v123 = pParty->vPosition.y;
+  v123 = pParty->vPosition.z;
   _zero = 0;
   v1 = 0;
   v103 = 0;
   v2 = 0;
   *(float *)&v128 = 0.0;
   v116 = pParty->vPosition.x;
-  v117 = pParty->vPosition.z;
+  v117 = pParty->vPosition.y;
   v113 = pParty->field_6F0;
   bJumping = 0;
-  v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.z);
+  v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.y);
   v114 = 0;
   v124 = 0;
   v108 = 0;
@@ -3286,7 +3266,7 @@
             || pParty->pPartyBuffs[7].uFlags & 1
             || *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 )
           {
-            if ( pParty->vPosition.y < 4000 || bJumping )
+            if ( pParty->vPosition.z < 4000 || bJumping )
             {
               v123 += 30;
               v113 += 30;
@@ -3306,7 +3286,7 @@
                 pParty->field_6E4 = 0;
                 pPartyActionQueue->uNumActions = 0;
                 BYTE1(pParty->uFlags) |= 1u;
-                pParty->vPosition.y = v109 - pParty->uPartyHeight - 31;
+                pParty->vPosition.z = v109 - pParty->uPartyHeight - 31;
                 pParty->field_6F0 = v123;
                 pParty->bFlying = 0;
                 v123 = v109 - pParty->uPartyHeight - 31;
@@ -3420,12 +3400,12 @@
         v126 = v19;
         *(float *)&v128 = v20;
         v124 = (unsigned __int64)(v19
-                                * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardMovementSlowdownMultiplier)) >> 16;
+                                * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardWalkSpeedMultiplier)) >> 16;
         v2 -= v124;
         v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
         v124 = (unsigned __int64)(v126
                                 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
-                                                                             * fBackwardMovementSlowdownMultiplier)) >> 16;
+                                                                             * fBackwardWalkSpeedMultiplier)) >> 16;
 LABEL_90:
         v1 -= v124;
         goto LABEL_86;
@@ -3486,7 +3466,7 @@
         v28 = (double)_walk_speed;
         v126 = v27;
         *(float *)&v128 = v28;
-        v29 = (signed __int64)(v28 * fBackwardMovementSlowdownMultiplier);
+        v29 = (signed __int64)(v28 * fBackwardWalkSpeedMultiplier);
         if ( pParty->bFlying )
         {
           v129 = (unsigned __int64)(v126 * (signed __int64)(4 * (signed int)v29)) >> 16;
@@ -3495,7 +3475,7 @@
           v129 = (unsigned __int64)(v126
                                   * (signed __int64)(signed int)(4
                                                                * (unsigned __int64)(signed __int64)(*(float *)&v128
-                                                                                                  * fBackwardMovementSlowdownMultiplier))) >> 16;
+                                                                                                  * fBackwardWalkSpeedMultiplier))) >> 16;
           v1 -= v129;
 LABEL_93:
           v128 = v1;
@@ -3507,7 +3487,7 @@
           v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi);
           v129 = (unsigned __int64)(v126
                                   * (signed __int64)(signed int)(signed __int64)(*(float *)&v128
-                                                                               * fBackwardMovementSlowdownMultiplier)) >> 16;
+                                                                               * fBackwardWalkSpeedMultiplier)) >> 16;
           v1 -= v129;
 LABEL_86:
           v128 = v1;
@@ -3635,7 +3615,7 @@
   {
     if ( v34 < -500
       && !pParty->bFlying
-      && pParty->vPosition.y - v111 > 1000
+      && pParty->vPosition.z - v111 > 1000
       && SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0
       && (SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 || !LODWORD(pParty->pPartyBuffs[5].uExpireTime)) )
     {
@@ -3683,7 +3663,7 @@
     if ( stru_721530._47050A(v36) )
       break;
     _46E889_collide_against_bmodels(1u);
-    v37 = WorldPosToGridCellZ(pParty->vPosition.z);
+    v37 = WorldPosToGridCellZ(pParty->vPosition.y);
     v38 = WorldPosToGridCellX(pParty->vPosition.x);
     _46E26D_collide_against_sprites(v38, v37);
     _46ED8A_collide_against_layingItems(4u);
@@ -3856,7 +3836,7 @@
 LABEL_220:
           v45 = stru_721530.uFaceID;
 LABEL_221:
-          if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uFaceAttributes) & 4 )
+          if ( pParty->field_6F4_packedid != v45 && BYTE3(v47->uAttributes) & 4 )
           {
             pParty->field_6F4_packedid = v45;
             v103 = v47->sCogTriggeredID;
@@ -3894,14 +3874,14 @@
   if ( bWalkSound && pParty->field_6F8 <= 0 )
   {
     v122 = abs(pParty->vPosition.x - v116);
-    v126 = abs(pParty->vPosition.z - v117);
-    v62 = abs(pParty->vPosition.y - v123);
+    v126 = abs(pParty->vPosition.y - v117);
+    v62 = abs(pParty->vPosition.z - v123);
     if ( sub_452A9E(v122 * v122 + v126 * v126 + v62 * v62) < 8 )
       goto LABEL_344;
     if ( v114 && (!bJumping || v101) )
     {
       if ( !v107
-        && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uFaceAttributes) & 0x20) )
+        && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20) )
       {
         v96 = 0;
         v94 = 0;
@@ -3922,7 +3902,7 @@
       v88 = 804;
       v86 = 1;
 LABEL_255:
-      v63 = WorldPosToGridCellZ(pParty->vPosition.z) - 1;
+      v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
       v64 = WorldPosToGridCellX(pParty->vPosition.x);
       v87 = pOutdoor->_47EE49(v64, v63, v86);
       goto LABEL_257;
@@ -3930,7 +3910,7 @@
     if ( v124 && (!bJumping || v101) )
     {
       if ( v107
-        || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uFaceAttributes) & 0x20 )
+        || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20 )
       {
         v96 = 0;
         v94 = 0;
@@ -3965,7 +3945,7 @@
   else
     pParty->uFlags |= 8u;
   v126 = WorldPosToGridCellX(pParty->vPosition.x);
-  v65 = WorldPosToGridCellZ(pParty->vPosition.z) - 1;
+  v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   v114 = WorldPosToGridCellX(v116);
   v66 = WorldPosToGridCellZ(v117) - 1;
   v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
@@ -3985,25 +3965,25 @@
     pParty->uFallSpeed = v121;
     v73 = v123;
     pParty->vPosition.x = v116;
-    pParty->vPosition.z = v117;
-    pParty->vPosition.y = v123;
+    pParty->vPosition.y = v117;
+    pParty->vPosition.z = v123;
     pParty->field_6F0 = v113;
     if ( v123 > 8160 )
     {
       v73 = 8160;
       pParty->uFallStartY = 8160;
-      pParty->vPosition.y = 8160;
+      pParty->vPosition.z = 8160;
     }
     if ( !v103
       || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
-      && pParty->vPosition.z == v72
-      && (v73 = pParty->vPosition.y, pParty->vPosition.y == v70) )
+      && pParty->vPosition.y == v72
+      && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) )
     {
       if ( v73 < v111 )
       {
         pParty->uFallSpeed = 0;
         v73 = v105;
-        pParty->vPosition.y = v105;
+        pParty->vPosition.z = v105;
         if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )
         {
           if ( pParty->uFlags & 0x100 )
@@ -4026,7 +4006,7 @@
               ++v74;
             }
             while ( (signed int)v74 <= (signed int)&pPlayers[4] );
-            v73 = pParty->vPosition.y;
+            v73 = pParty->vPosition.z;
           }
         }
         pParty->uFallStartY = v70;
@@ -4035,7 +4015,7 @@
       {
         if ( (signed int)(pParty->uPartyHeight + v73) >= v109 )
         {
-          pParty->vPosition.y = v109 - pParty->uPartyHeight - 1;
+          pParty->vPosition.z = v109 - pParty->uPartyHeight - 1;
           pParty->field_6F0 = v109 - pParty->uPartyHeight - 1;
         }
       }
@@ -4070,7 +4050,7 @@
   if ( v78 )
   {
 LABEL_312:
-    pParty->vPosition.z = v117;
+    pParty->vPosition.y = v117;
 LABEL_313:
     if ( bWaterWalk )
     {
@@ -4097,33 +4077,33 @@
 LABEL_318:
   v81 = v123;
   v82 = v123;
-  pParty->vPosition.y = v123;
+  pParty->vPosition.z = v123;
   if ( v123 > 8160 )
   {
     v82 = 8160;
     pParty->uFallStartY = 8160;
-    pParty->vPosition.y = 8160;
+    pParty->vPosition.z = 8160;
   }
   LOWORD(pParty->uFlags) &= 0xFDFBu;
   pParty->uFallSpeed = v121;
   pParty->field_6F0 = v113;
   if ( v114 )
   {
-    v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.z, &v110, 1);
-    v82 = pParty->vPosition.y;
-    if ( pParty->vPosition.y <= v83 )
+    v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
+    v82 = pParty->vPosition.z;
+    if ( pParty->vPosition.z <= v83 )
       pParty->uFlags |= 4u;
   }
   if ( !v103
     || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v116)
-    && pParty->vPosition.z == v117
-    && (v82 = pParty->vPosition.y, pParty->vPosition.y == v81) )
+    && pParty->vPosition.y == v117
+    && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) )
   {
     if ( v82 < v111 )
     {
       v82 = v105;
       pParty->uFallSpeed = 0;
-      pParty->vPosition.y = v105;
+      pParty->vPosition.z = v105;
       if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )
       {
         if ( pParty->uFlags & 0x100 )
@@ -4145,14 +4125,14 @@
             ++v84;
           }
           while ( (signed int)v84 <= (signed int)&pPlayers[4] );
-          v82 = pParty->vPosition.y;
+          v82 = pParty->vPosition.z;
         }
       }
       pParty->uFallStartY = v81;
     }
     if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 )
     {
-      pParty->vPosition.y = v82 + pParty->uPartyHeight - v109 + 1;
+      pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1;
       pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1;
     }
   }
@@ -4733,6 +4713,7 @@
 }
 
 //----- (00476395) --------------------------------------------------------
+//0x26 Wizard eye at skill level 2
 bool __thiscall CheckHiredNPCSpeciality(unsigned int uProfession)
 {
   bool result; // eax@2
@@ -6796,7 +6777,7 @@
     }
     while ( 1 )
     {
-      if ( pFace->uFaceAttributes & 0x2000 )
+      if (pFace->Invisible())
         goto LABEL_85;
       v5 = (int)*(v2 - 1);
       v6 = pFace->pVertexIDs[0];
@@ -6806,7 +6787,7 @@
       *(int *)&v7->flags = 0;
       pLightmapBuilder = v8;
       v9 = pFace->uTextureID;
-      v10 = (BYTE1(pFace->uFaceAttributes) & 0x40) == 0;
+      v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0;
       v48 = pFace->uTextureID;
       if ( !v10 )
       {
@@ -6818,14 +6799,14 @@
       v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
       v49 = v12;
       v49 = pFaceTexture->uTextureHeight;
-      v10 = (pFace->uFaceAttributes & 0x10) == 0;
+      v10 = (pFace->uAttributes & 0x10) == 0;
       v45 = 1.0 / (double)v12;
       v44 = 1.0 / (double)v49;
       if ( !v10 )
         *(int *)&v7->flags |= 2u;
-      if ( BYTE2(pFace->uFaceAttributes) & 0x40 )
+      if ( BYTE2(pFace->uAttributes) & 0x40 )
         HIBYTE(v7->flags) |= 4u;
-      v13 = pFace->uFaceAttributes;
+      v13 = pFace->uAttributes;
       if ( v13 & 4 )
       {
         HIBYTE(v7->flags) |= 4u;
@@ -6835,7 +6816,7 @@
         if ( v13 & 0x20 )
           HIBYTE(v7->flags) |= 8u;
       }
-      v14 = pFace->uFaceAttributes;
+      v14 = pFace->uAttributes;
       if ( BYTE1(v14) & 8 )
       {
         *(int *)&v7->flags |= 0x2000u;
@@ -6925,7 +6906,7 @@
           }
           else
           {
-            v47->_436BB7_project_and_stuff((RenderVertexSoft *)(v23 - 12), 1u, 0);
+            v47->Project((RenderVertexSoft *)(v23 - 12), 1u, 0);
           }
           v23 += 48;
           --v51;
@@ -7004,7 +6985,7 @@
         pDecalBuilder->ApplyDecals_OutdoorFace(pFace);
         v31->std__vector_000004_size = 0;
         LOBYTE(v31) = 0;
-        if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
         {
           v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0);
           static_RenderBuildingsD3D_stru_73C834._49B04D(pFace, (BSPVertexBuffer *)v56 - 1);
@@ -7026,13 +7007,13 @@
               -1);
           }
         }
-        if ( stru_F8AD28.field_AC > 0 )
+        if ( stru_F8AD28.uNumLightsApplied > 0 )
           pLightmapBuilder->ApplyLights(
             &stru_F8AD28,
             &static_RenderBuildingsD3D_stru_73C834,
             uNumVertices,
             array_50AC10,
-            0.0,
+            0,
             (char)v31);
         if ( v50 )
         {
@@ -7240,7 +7221,7 @@
             }
             else
             {
-              pGame->pIndoorCameraD3D->_436BB7_project_and_stuff((RenderVertexSoft *)(v9 - 12), 1u, 0);
+              pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0);
             }
             v81 += 2;
             v9 += 48;
@@ -7372,7 +7353,7 @@
         }*/
 
         pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
-        if ( stru_F8AD28.field_AC <= 0 )
+        if ( stru_F8AD28.uNumLightsApplied <= 0 )
         {
           v12->field_108 = 0;
         }
@@ -7382,9 +7363,9 @@
           v12->field_108 = 1;
 
           static_sub_004789DE_stru_73C818._49B04D((ODMFace *)v3, v35);
-          v55 = static_sub_004789DE_stru_73C818.vNormal.x;
-          v56 = static_sub_004789DE_stru_73C818.vNormal.y;
-          v57 = static_sub_004789DE_stru_73C818.vNormal.z;
+          v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x;
+          v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y;
+          v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z;
           pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55);
         }
         if ( v74 )
@@ -7906,7 +7887,7 @@
 
 
 //----- (00479A53) --------------------------------------------------------
-void __fastcall sub_479A53(unsigned int uNumVertices, unsigned int uFaceID)
+void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID)
 {
   BLVFace *pFace; // esi@1
   unsigned int v3; // edi@1
@@ -7989,6 +7970,8 @@
   float v80; // [sp+16Ch] [bp-8h]@3
   const void *v81; // [sp+170h] [bp-4h]@7
 
+  __debugbreak();
+
   pFace = &pIndoor->pFaces[uFaceID];
   v65 = uFaceID;
   v3 = uNumVertices;
@@ -8522,7 +8505,7 @@
       {
         v15 = 0;
       }
-      v17 = sub_43F55F(a1, v15);
+      v17 = _43F55F_get_billboard_light_level(a1, v15);
       if ( v17 > 27 )
         v17 = 27;
       if ( !a3 )
@@ -8539,7 +8522,7 @@
     a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20)
         * pOutdoor->fFogDensity;
     v13 = a3a + 6.7553994e15;
-    v10 = sub_43F55F(a1, LODWORD(v13) + v11);
+    v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11);
     if ( v10 > 27 )
       v10 = 27;
     if ( v10 < a4 )
@@ -8567,7 +8550,7 @@
     {
       v6 = 27;
     }
-    v10 = sub_43F55F(a1, v6);
+    v10 = _43F55F_get_billboard_light_level(a1, v6);
     if ( v10 > 27 || !a3 )
       v10 = 27;
     return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
@@ -9080,7 +9063,7 @@
     {
 LABEL_20:
       if ( a5 )
-        v6 = 8 * sub_43F55F(a5, v6 >> 3);
+        v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
       if ( v6 > 216 )
         v6 = 216;
       return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8);
@@ -9120,7 +9103,7 @@
     }
     v6 = a4a + v12;
     if ( a5 )
-      v6 = 8 * sub_43F55F(a5, v6 >> 3);
+      v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3);
     if ( v6 > 216 )
       v6 = 216;
     if ( v6 < v12 )
@@ -9346,7 +9329,7 @@
   pOutdoorCamera->uNumEdges = 0;
   pOutdoorCamera->uNumSpans = 0;
   pOutdoorCamera->uNumSurfs = 0;
-  pOutdoorCamera->field_3C = 0;
+  pOutdoorCamera->uNumBillboards = 0;
   pOutdoorCamera->field_44 = 0;
 }
 
@@ -12901,27 +12884,27 @@
 
 
 //----- (0043F953) --------------------------------------------------------
-int __cdecl PrepareWallsRenderList_BLV()
+void PrepareWallsRenderList_BLV()
 {
   pStru170->uNumFaceIDs = 0;
-  if ( pBLVRenderParams->uRadius )
-  {
-    pStru170->field_FA8[0].uSectorID = LOWORD(pBLVRenderParams->uRadius);
-    pStru170->field_FA8[0].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-    pStru170->field_FA8[0].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-    pStru170->field_FA8[0].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-    pStru170->field_FA8[0].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
+  if ( pBLVRenderParams->uPartySectorID )
+  {
+    pStru170->field_FA8[0].uSectorID = pBLVRenderParams->uPartySectorID;
+    pStru170->field_FA8[0].uViewportW = pBLVRenderParams->uViewportW;
+    pStru170->field_FA8[0].uViewportZ = pBLVRenderParams->uViewportZ;
+    pStru170->field_FA8[0].uViewportY = pBLVRenderParams->uViewportY;
+    pStru170->field_FA8[0].uViewportX = pBLVRenderParams->uViewportX;
     pStru170->field_FA8[0].field_C._43F9E1(
-      SLOWORD(pBLVRenderParams->uViewportX),
-      SLOWORD(pBLVRenderParams->uViewportY),
-      SLOWORD(pBLVRenderParams->uViewportZ),
-      SLOWORD(pBLVRenderParams->uViewportW));
+      pBLVRenderParams->uViewportX,
+      pBLVRenderParams->uViewportY,
+      pBLVRenderParams->uViewportZ,
+      pBLVRenderParams->uViewportW);
     pStru170->field_FA8[0].uFaceID = -1;
     pStru170->field_FA8[0].std__vector_0007A8 = -1;
     pStru170->std__vector_000FA8 = 1;
     sub_440639(0);
   }
-  return pStru170->RenderWalls();
+  pStru170->MakeVisibleSectorList();
 }
 
 //----- (0043F9E1) --------------------------------------------------------
@@ -13062,10 +13045,10 @@
               else
               {
                 v17 = &pGame->pIndoorCameraD3D;
-                v15->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-                v18 = (*v17)->flt_D4;
-                v19 = v15->flt_8;
-                v15->flt_C = v18;
+                v15->fov_x = pGame->pIndoorCameraD3D->fov_x;
+                v18 = (*v17)->fov_y;
+                v19 = v15->fov_x;
+                v15->fov_y = v18;
                 v31 = v19;
                 v25 = v19 + 6.7553994e15;
                 LODWORD(v20) = 0;
@@ -13074,7 +13057,7 @@
                 LODWORD(v31) = v12->scale;
                 v37 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
                 v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16;
-                v31 = v15->flt_C;
+                v31 = v15->fov_y;
                 v25 = v31 + 6.7553994e15;
                 LODWORD(v20) = 0;
                 HIDWORD(v20) = SLOWORD(v25);
@@ -13084,15 +13067,15 @@
               HIWORD(v22) = HIWORD(x);
               v15->field_4 = v37;
               v15->field_1E = v30;
-              v15->field_20 = a1;
-              v15->field_22 = a2;
-              v15->field_24 = a3;
-              v15->field_26 = a5;
-              v15->field_28 = a6;
+              v15->some_x = a1;
+              v15->some_y = a2;
+              v15->some_z = a3;
+              v15->uScreenSpaceX = a5;
+              v15->uScreenSpaceY = a6;
               v23 = 8 * v26;
               LOBYTE(v23) = 8 * v26 | 5;
               LOWORD(v22) = 0;
-              v15->field_2C_prolly_tint = 0;
+              v15->uTintColor = 0;
               v15->sZValue = v22 + v23;
               v15->pSpriteFrame = v12;
             }
@@ -13113,7 +13096,7 @@
       local_0.flt_14 = 0.0;
       local_0.flt_18 = 0.0;
       local_0.flt_28 = 1.0;
-      local_0.field_20 = (rand() & 0x80) + 128;
+      local_0.timeToLive = (rand() & 0x80) + 128;
       local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
       pGame->pParticleEngine->AddParticle(&local_0);
     }
@@ -13122,9 +13105,8 @@
 
 
 //----- (0044028F) --------------------------------------------------------
-void __cdecl PrepareItemsRenderList_BLV()
-{
-  char *v0; // edi@2
+void PrepareItemsRenderList_BLV()
+{
   ObjectDesc *v1; // ebx@4
   __int16 v2; // ax@5
   RenderBillboard *v3; // esi@12
@@ -13137,11 +13119,6 @@
   unsigned __int16 v10; // ax@12
   int *v11; // eax@20
   char v12; // zf@26
-  IndoorCameraD3D **v13; // eax@27
-  double v14; // st7@27
-  float v15; // eax@27
-  double v16; // ST30_8@27
-  signed __int64 v17; // qtt@27
   int v18; // ST5C_4@27
   signed __int64 v19; // qtt@28
   int v20; // ST5C_4@28
@@ -13149,14 +13126,12 @@
   __int16 v22; // ax@29
   int v23; // eax@29
   SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12
-  ObjectDesc *v25; // [sp+20h] [bp-3Ch]@4
   __int16 a5; // [sp+28h] [bp-34h]@12
   int a6; // [sp+2Ch] [bp-30h]@12
   int a2; // [sp+30h] [bp-2Ch]@12
   int a1; // [sp+34h] [bp-28h]@12
   int v30; // [sp+38h] [bp-24h]@12
   int v31; // [sp+38h] [bp-24h]@27
-  signed int v32; // [sp+3Ch] [bp-20h]@1
   int a3; // [sp+40h] [bp-1Ch]@12
   signed __int16 v34; // [sp+44h] [bp-18h]@14
   int v35; // [sp+48h] [bp-14h]@25
@@ -13165,37 +13140,33 @@
   signed int y; // [sp+54h] [bp-8h]@24
   signed int x; // [sp+58h] [bp-4h]@24
 
-  v32 = 0;
-  if ( (signed int)uNumLayingItems > 0 )
-  {
-    v0 = (char *)&pLayingItems[0].uSectorID;
-    do
-    {
-      if ( *((short *)v0 - 13) )
-      {
-        v1 = &pObjectList->pObjects[*((short *)v0 - 13)];
-        v25 = v1;
+  for (uint i = 0; i < uNumLayingItems; ++i)
+  {
+    auto p = pLayingItems + i;
+    if (p->uObjectDescID)
+    {
+      v1 = &pObjectList->pObjects[p->uObjectDescID];
         if ( !(v1->uFlags & 1) )
-        {
-          if ( ((v2 = *((short *)v0 - 14), v2 < 1000) || v2 >= 10000)
+         {
+          if ( ((v2 = p->uItemType, v2 < 1000) || v2 >= 10000)
             && (v2 < 500 || v2 >= 600)
             && (v2 < 811 || v2 >= 815)
-            || pGame->pStru6Instance->_4A81CA((LayingItem *)(v0 - 28)) )
-          {
-            a5 = *(short *)v0;
-            a1 = *((int *)v0 - 6);
-            a2 = *((int *)v0 - 5);
-            a3 = *((int *)v0 - 4);
+            || pGame->pStru6Instance->_4A81CA(p))
+          {
+            a5 = p->uSectorID;
+            a1 = p->vPosition.x;
+            a2 = p->vPosition.y;
+            a3 = p->vPosition.z;
             v3 = &pBillboardRenderList[uNumBillboardsToDraw];
-            v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1));
+            v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID);
             v5 = v4;
             v24 = v4;
             v30 = v4->uFlags;
-            a6 = v4->uGlowRadius * *((short *)v0 + 3);
+            a6 = v4->uGlowRadius * p->field_22;
             v6 = stru_5C6E00->Atan2(
-                   *((int *)v0 - 6) - pBLVRenderParams->vPartyPos.x,
-                   *((int *)v0 - 5) - pBLVRenderParams->vPartyPos.y);
-            LOWORD(v7) = *((short *)v0 - 3);
+                   p->vPosition.x - pBLVRenderParams->vPartyPos.x,
+                   p->vPosition.y - pBLVRenderParams->vPartyPos.y);
+            LOWORD(v7) = p->uFacing;
             v8 = v30;
             v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
             v10 = v5->pHwSpriteIDs[v9];
@@ -13225,10 +13196,10 @@
                 a3,
                 a5,
                 a6,
-                v25->uParticleTrailColorR,
-                v25->uParticleTrailColorG,
-                v25->uParticleTrailColorB,
-                v11);
+                v1->uParticleTrailColorR,
+                v1->uParticleTrailColorG,
+                v1->uParticleTrailColorB,
+                byte_4E94D3);
             }
             if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
                    a1,
@@ -13244,7 +13215,7 @@
                 return;
               ++uNumBillboardsToDraw;
               ++uNumSpritesDrawnThisFrame;
-              *(v0 - 2) |= 1u;
+              p->uAttributes |= 1u;
               v12 = pRenderer->pRenderD3D == 0;
               v3->uPalette = v24->uPaletteIndex;
               v3->uIndoorSectorID = a5;
@@ -13258,33 +13229,27 @@
               }
               else
               {
-                v13 = &pGame->pIndoorCameraD3D;
-                v3->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-                v14 = (*v13)->flt_D4;
-                v15 = v3->flt_8;
-                v3->flt_C = v14;
-                v16 = v15 + 6.7553994e15;
-                LODWORD(v17) = 0;
-                HIDWORD(v17) = SLOWORD(v16);
-                v18 = v17 / x;
-                v3->field_0 = (unsigned __int64)(v24->scale * v17 / x) >> 16;
-                v31 = (unsigned __int64)(v24->scale * (signed __int64)v18) >> 16;
+                v3->fov_x = pGame->pIndoorCameraD3D->fov_x;
+                v3->fov_y = pGame->pIndoorCameraD3D->fov_y;
+                v18 = (int)floorf(v3->fov_x + 0.5f) / x;
+                v3->field_0 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
+                v31 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16;
               }
               HIWORD(v21) = HIWORD(x);
               v3->field_4 = v31;
               v3->field_1E = v34;
-              v3->field_20 = a1;
-              v3->field_22 = a2;
-              v3->field_24 = a3;
-              v3->field_26 = v36;
+              v3->some_x = a1;
+              v3->some_y = a2;
+              v3->some_z = a3;
+              v3->uScreenSpaceX = v36;
               v22 = v35;
-              v3->field_2C_prolly_tint = 0;
-              v3->field_28 = v22;
+              v3->uTintColor = 0;
+              v3->uScreenSpaceY = v22;
               LOWORD(v21) = 0;
-              v23 = 8 * v32;
-              LOBYTE(v23) = 8 * v32 | 2;
+              v23 = 8 * i;
+              LOBYTE(v23) = 8 * i | 2;
               v3->pSpriteFrame = v24;
-              v12 = (*(v0 - 2) & 0x20) == 0;
+              v12 = (p->uAttributes & 0x20) == 0;
               v3->sZValue = v21 + v23;
               if ( !v12 )
               {
@@ -13295,10 +13260,6 @@
           }
         }
       }
-      ++v32;
-      v0 += 112;
-    }
-    while ( v32 < (signed int)uNumLayingItems );
   }
 }
 
@@ -13319,7 +13280,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 );
     }
   }
@@ -13328,7 +13292,7 @@
     if ( v3->uNumNonBSPFaces > 0 )
     {
       do
-        pStru170->_4AFB86(v1, v3->pFaceIDs[v2++]);
+        pStru170->PrepareFaceRenderList_sw(v1, v3->pFaceIDs[v2++]);
       while ( v2 < v3->uNumNonBSPFaces );
     }
   }
@@ -13351,6 +13315,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 )
@@ -13373,15 +13339,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 )
@@ -13393,20 +13362,18 @@
 //----- (00440DF5) --------------------------------------------------------
 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr)
 {
-  stru167_wrap *v6; // esi@1
   int result; // eax@1
 
-  v6 = this;
-  v6->pElements[v6->uNumElements].field_6 = a2;
-  this->pElements[this->uNumElements].field_8 = a3;
-  this->pElements[this->uNumElements].field_A = a4;
-  v6->pElements[v6->uNumElements].field_C = rand() % 64 + 256;
-  v6->pElements[v6->uNumElements].field_E = v6->pElements[v6->uNumElements].field_C;
-  result = 3 * v6->uNumElements;
-  v6->pElements[v6->uNumElements++].bgr16 = bgr;
-  if ( v6->uNumElements >= 100 )
-    v6->uNumElements = 0;
-  return result;
+  pElements[uNumElements].field_6_rnd_value = a2;
+  pElements[uNumElements].field_8_rnd_value = a3;
+  pElements[uNumElements].field_A_rnd_value = a4;
+  pElements[uNumElements].field_C_time_left = rand() % 64 + 256;
+  pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left;
+  result = 3 * uNumElements;
+  pElements[uNumElements++].bgr16 = bgr;
+  if (uNumElements >= 100 )
+    uNumElements = 0;
+   return result;
 }
 
 //----- (00440E91) --------------------------------------------------------
@@ -13431,38 +13398,30 @@
 //----- (00440F07) --------------------------------------------------------
 void stru167_wrap::_440F07()
 {
-  char *v1; // esi@1
-  signed int v2; // edi@1
-
-  v1 = (char *)&this->pElements[0].field_6;
-  v2 = 100;
-  do
-  {
-    if ( *((short *)v1 + 3) > 0 )
-    {
-      *((short *)v1 + 2) += rand() % 5 + 4;
-      *(short *)v1 += rand() % 5 - 2;
-      *((short *)v1 + 1) += rand() % 5 - 2;
-      *((short *)v1 + 3) -= LOWORD(pEventTimer->uTimeElapsed);
-    }
-    v1 += 24;
-    --v2;
-  }
-  while ( v2 );
+  for (uint i = 0; i < 100; ++i)
+  {
+    if (pElements[i].field_C_time_left > 0)
+    {
+      pElements[i].field_A_rnd_value += rand() % 5 + 4;
+      pElements[i].field_6_rnd_value += rand() % 5 - 2;
+      pElements[i].field_8_rnd_value += rand() % 5 - 2;
+      pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed;
+    }
+  }
 }
 
 //----- (0044100D) --------------------------------------------------------
 bool __cdecl sub_44100D()
 {
-  return uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4
-      || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 7
-      || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 12
-      && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 14
-       || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 16
-       && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 18
-        || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 23));
-}
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+  return pCurrentScreen == 4
+      || pCurrentScreen == 7
+      || pCurrentScreen > 12
+      && (pCurrentScreen <= 14
+       || pCurrentScreen > 16
+       && (pCurrentScreen <= 18
+        || pCurrentScreen == 23));
+}
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (00441498) --------------------------------------------------------
 void __cdecl GameUI_DrawTorchlightAndWizardEye()
@@ -13472,17 +13431,17 @@
   unsigned int v2; // eax@19
   IconFrame *v3; // eax@19
 
-  if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 1
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 2
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 5
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 8
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 12
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 15
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 3
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 19 )
+  if ( !pCurrentScreen
+    || pCurrentScreen == 1
+    || pCurrentScreen == 2
+    || pCurrentScreen == 5
+    || pCurrentScreen == 8
+    || pCurrentScreen == 10
+    || pCurrentScreen == 11
+    || pCurrentScreen == 12
+    || pCurrentScreen == 15
+    || pCurrentScreen == 3
+    || pCurrentScreen == 19 )
   {
     if ( SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) >= 0
       && (SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[16].uExpireTime)) )
@@ -13506,19 +13465,18 @@
     }
   }
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0044158F) --------------------------------------------------------
 void __cdecl GameUI_DrawCharacterSelectionFrame()
 {
   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()
@@ -13564,8 +13522,8 @@
       pRenderer->_4A65CC(
         pPartySpellbuffsUI_XYs[v1][0],
         pPartySpellbuffsUI_XYs[v1][1],
-        (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0),
-        (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0),
+        (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0),
+        (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0),
         v0 + 20 * pPartySpellbuffsUI_smthns[v1],
         0,
         63);
@@ -13573,8 +13531,8 @@
     ++v1;
   }
   while ( v1 < 14 );
-  if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-    || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4 )
+  if ( !pCurrentScreen
+    || pCurrentScreen == 4 )
   {
     if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
     {
@@ -13687,17 +13645,17 @@
             v11 = *((int *)v3 + 1);
             v13 = v6->scale;
             v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16;
-            v10.field_8 = *((short *)v3 - 2);
-            v10.field_C = *((short *)v3 - 1);
+            v10.uScreenSpaceX = *((short *)v3 - 2);
+            v10.uScreenSpaceY = *((short *)v3 - 1);
             v10.field_10 = v13;
             v10.field_14 = v13;
             v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1);
             v8 = *((short *)v3 - 5);
-            v10.field_28 = 0;
+            v10.sZValue = 0;
             v10.uFlags = 0;
             v9 = pOverlayList->pOverlays[v8].uOverlayType;
             if ( !v9 || v9 == 2 )
-              v10.field_C += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1;
+              v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1;
             result = pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]]._4AD2D1(&v10, 0);
             ++v12;
             if ( v12 == 5 )
@@ -13715,28 +13673,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
@@ -13786,30 +13739,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 uZb; // [sp+5Ch] [bp+8h]@27
-  signed int uZc; // [sp+5Ch] [bp+8h]@30
+  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 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
@@ -13818,25 +13764,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;
@@ -13844,58 +13791,58 @@
     v18 = (double)(1 << (16 - v17));
     v19 = v18;
     v20 = (double)(pParty->vPosition.x + 32768) / v18;
-    v21 = (double)(32768 - pParty->vPosition.z) / v19;
+    v21 = (double)(32768 - pParty->vPosition.y) / v19;
     uWb = v21;
     if ( uZoom == 512 )
     {
-      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;
@@ -13935,102 +13882,89 @@
     }
     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]);
-          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;
+  }
+  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;
+        //v10 = pIndoor->pFaces[pMapVertex->uFace2ID].uAttributes;
+      if (pFace1->Visible() && pFace2->Visible())
+      {
+        v11 = pOutline->uFlags;
+        if ( v11 & 1 )
+          goto LABEL_15;
+        if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80u != 0 )
+          goto LABEL_ABC;
+
+      }
+      continue;
+
+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)
-                        - 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)
-                            - 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)
-                        - 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)
-                        - uZoom * pParty->vPosition.z) >> 16);
-      v15 = abs(*((short *)v8 + 4) - pParty->vPosition.y) / 8;
+    //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
+    {
+      auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x);
+      auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16);
+      auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16);
+      v69 =     uCenterX + _c;
+      v69 =     uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
+      lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
+      uWa =     uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16);
+      v14 =     uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16);
+      v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8;
       if ( v15 > 100 )
         v15 = 100;
-      pRenderer->FillRect(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
-      v7 = pIndoor->pFaces;
-    }
-    goto LABEL_26;
-  }
-LABEL_27:
-  for ( uZb = 0; uZb < (signed int)uNumBlueFacesInBLVMinimap; ++uZb )
-  {
-    v16 = (uint *)&pIndoor->pMapVertices->pVertices[3 * pBlueFacesInBLVMinimapIDs[uZb]];
-    pRenderer->FillRect(
-      uWidth
+      pRenderer->Line2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]);
+    }
+  }
+
+
+  for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i)
+  {
+    //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]];
+    auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]];
+    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)
-                  - uZoom * pParty->vPosition.z) >> 16),
-      uWidth
+                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16)
+                  - uZoom * pParty->vPosition.y) >> 16),
+      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)
-                  - uZoom * pParty->vPosition.z) >> 16),
+                                                     * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16)
+                  - uZoom * pParty->vPosition.y) >> 16),
       uBlue);
   }
-LABEL_50:
+  }
+
+
+//_draw_party_arrow:
   v33 = 0;
   v34 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
   v35 = 0;
@@ -14082,27 +14016,28 @@
   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 )
+    //for (uint i = 0; i < uNumLayingItems; ++i)
+    if (uNumLayingItems > 0)
     {
       a2c = (char *)&pLayingItems[0].uObjectDescID;
       while ( 1 )
       {
         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,
-              v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16,
-              v38 = uHeight - v79,
+                  + uCenterX,
+              v79 = (unsigned __int64)((*(int *)(a2c + 6) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16,
+              v38 = uCenterY - v79,
               v37 < pRenderer->field_1C_clipx)
           || v37 > pRenderer->field_24_clipz
           || v38 < pRenderer->field_20_clipy
@@ -14112,22 +14047,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;
@@ -14139,10 +14074,10 @@
         }
       }
       v58 = v60;
-      v55 = uHeight - v79;
+      v55 = uCenterY - v79;
 LABEL_81:
       v53 = v37;
-      v51 = uHeight - v79;
+      v51 = uCenterY - v79;
       goto LABEL_82;
     }
 LABEL_85:
@@ -14160,10 +14095,10 @@
         {
           v40 = ((unsigned __int64)(((signed int)*((short *)flagsc - 17) - pParty->vPosition.x)
                                   * (signed __int64)(signed int)uZoom) >> 16)
-              + uWidth;
-          v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.z)
+              + uCenterX;
+          v76 = (unsigned __int64)(((signed int)*((short *)flagsc - 16) - pParty->vPosition.y)
                                  * (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 )
@@ -14175,13 +14110,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;
@@ -14190,13 +14125,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);
             }
           }
         }
@@ -14219,9 +14154,9 @@
       if ( *(v45 - 2) & 8 )
       {
         v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16)
-            + uWidth;
-        v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.z) * (signed __int64)(signed int)uZoom) >> 16;
-        v47 = uHeight - v77;
+            + uCenterX;
+        v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16;
+        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 )
@@ -14230,14 +14165,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);
             }
           }
         }
@@ -14252,14 +14187,14 @@
   pRenderer->DrawTextureTransparent(
     0x1D4u,
     v33,
-    (Texture *)(dword_5079D8 != -1 ? (int)&pIcons_LOD->pTextures[dword_5079D8] : 0));
+    (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
   uZooma = (double)pParty->sRotationY * 0.1171875;
   v50 = uZooma + 6.7553994e15;
   pRenderer->Clip(0x21Du, v33, 0x237u, 0x1E0u);
   pRenderer->DrawTextureIndexed(
     LODWORD(v50) + 285,
     0x88u,
-    (Texture *)(dword_5079B4 != -1 ? (int)&pIcons_LOD->pTextures[dword_5079B4] : 0));
+    (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
   pRenderer->ResetClip();
 }
 
@@ -14481,10 +14416,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) )
   {
@@ -14521,13 +14456,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;
@@ -14555,7 +14490,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),
@@ -14564,14 +14499,14 @@
       ++v21;
       if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
         break;
-      v7 = (uint *)pIndoor->pMapVertices;
+      v7 = (uint *)pIndoor->pMapOutlines;
     }
     v6 = v86;
   }
 LABEL_38:
   v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
-  v81 = pParty->vPosition.z - v84;
-  v97 = (const void *)((unsigned __int64)((pParty->vPosition.z - v84) * (signed __int64)v5) >> 16);
+  v81 = pParty->vPosition.y - v84;
+  v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
   v48 = 1;
   v49 = v90 - (int)v97 - 3;
   if ( v47 >= (signed int)x_ )
@@ -14686,8 +14621,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;
@@ -14700,7 +14635,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);
           }
         }
       }
@@ -14835,7 +14770,7 @@
   if ( v1 < 384 )
     this->field_2C = 384;
   this->sPartyPosX = pParty->vPosition.x;
-  this->sPartyPosZ = pParty->vPosition.z;
+  this->sPartyPosZ = pParty->vPosition.y;
   return _4432E7();
 }
 
@@ -14853,7 +14788,7 @@
   if ( v1 > v2 )
     this->field_2C = v2;
   this->sPartyPosX = pParty->vPosition.x;
-  this->sPartyPosZ = pParty->vPosition.z;
+  this->sPartyPosZ = pParty->vPosition.y;
   return _4432E7();
 }
 
@@ -14937,11 +14872,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];
@@ -15666,7 +15601,7 @@
   int pX; // [sp+28h] [bp-4h]@1
 
   v24 = pParty->vPosition.x;
-  v0 = pParty->vPosition.z;
+  v0 = pParty->vPosition.y;
   v1 = pOutdoor->uNumBModels;
   *(float *)&v23 = (double)(signed int)viewparams->uMinimapZoom * 0.000015258789;
   v2 = 0;
@@ -15711,13 +15646,13 @@
             v13 = v12->sCogTriggeredID;
             if ( v13 )
             {
-              if ( !(BYTE2(v12->uFaceAttributes) & 0x10) )
+              if ( !(BYTE2(v12->uAttributes) & 0x10) )
               {
                 v14 = _444732_GetEventHintString(v13);
                 v15 = v14;
                 if ( v14 )
                 {
-                  if ( _strcmpi(v14, nullstring) )
+                  if ( _strcmpi(v14, "") )
                     v21 = (char *)v15;
                 }
               }
@@ -15812,13 +15747,13 @@
             v12 = v11->sCogTriggeredID;
             if ( v12 )
             {
-              if ( !(BYTE2(v11->uFaceAttributes) & 0x10) )
+              if ( !(BYTE2(v11->uAttributes) & 0x10) )
               {
                 v13 = _444732_GetEventHintString(v12);
                 v14 = v13;
                 if ( v13 )
                 {
-                  if ( _strcmpi(v13, nullstring) )
+                  if ( _strcmpi(v13, "") )
                     v17 = v14;
                 }
               }
@@ -15910,12 +15845,12 @@
       v1 = pTmpBuf;
       goto LABEL_12;
     }
-    v1 = nullstring;
+    v1 = "";
   }
   if ( !v1 )
   {
     MessageBoxW(nullptr, L"No transition text found!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1410", 0);
-    v1 = nullstring;
+    v1 = "";
   }
 LABEL_12:
   v7 = 3;
@@ -16000,7 +15935,7 @@
 
   memcpy(&v7, pGUIWindow0, sizeof(v7));
   v9 = pMapStats->GetMapInfo(pCurrentMapName);
-  pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, pDestinationMapName, 20);
+  pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
   v0 = pMapStats->GetMapInfo(pDestinationMapName);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(0x1D4u, 0,
@@ -16127,10 +16062,10 @@
     dword_5C341C = v3;
     _591094_decoration = _5C3420_pDecoration;
     pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0);
-    pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, nullstring, 0);
-    pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, nullstring, 0);
-    pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, nullstring, 0);
-    pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, nullstring, 0);
+    pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
+    pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
+    pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
+    pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
   }
 }
 
@@ -16383,8 +16318,8 @@
   v52.uFrameX = 483;
   v52.uFrameWidth = 148;
   v52.uFrameZ = 334;
-  for ( pOutString = (GUIFont *)v52.field_38;
-        (signed int)pOutString < v52.field_38 + v52.field_28;
+  for ( pOutString = (GUIFont *)v52.pStartingPosActiveItem;
+        (signed int)pOutString < v52.pStartingPosActiveItem + v52.pNumPresenceButton;
         pOutString = (GUIFont *)((char *)pOutString + 1) )
   {
     v14 = v52.GetControl((unsigned int)pOutString);
@@ -16454,7 +16389,7 @@
         v24 = (&dword_721660)[8 * v23];
         if ( !v24 )
         {
-          v24 = nullstring;
+          v24 = "";
           v15->uControlParam = 0;
         }
         goto LABEL_79;
@@ -16498,7 +16433,7 @@
           goto LABEL_63;
         }
 LABEL_71:
-        v24 = nullstring;
+        v24 = "";
         goto LABEL_79;
       }
       if ( v0->uFlags & 0x80 )
@@ -16511,7 +16446,7 @@
       pInString = 0;
       if ( (signed int)uNumActors > 0 )
       {
-        v55 = &pActors[0].uAIState;
+        v55 = (unsigned short *)&pActors[0].uAIState;
         *(int *)v54 = uNumActors;
         do
         {
@@ -16533,8 +16468,8 @@
   v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   v34 = pDialogueWindow;
   *(int *)v54 = v33;
-  v35 = pDialogueWindow->field_38;
-  for ( i = v35 + pDialogueWindow->field_28; v35 < i; i = pDialogueWindow->field_28 + pDialogueWindow->field_38 )
+  v35 = pDialogueWindow->pStartingPosActiveItem;
+  for ( i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem )
   {
     v37 = v34->GetControl(v35);
     if ( !v37 )
@@ -16547,7 +16482,7 @@
     v32 += v38;
     ++v35;
   }
-  v39 = v34->field_28;
+  v39 = v34->pNumPresenceButton;
   if ( v39 )
   {
     pOutString = (GUIFont *)((174 - v32) / v39);
@@ -16555,7 +16490,7 @@
       pOutString = (GUIFont *)32;
     v55 = (unsigned __int16 *)1;
     v40 = 174 - (int)pOutString * v39 - v32;
-    v41 = v34->field_38;
+    v41 = v34->pStartingPosActiveItem;
     v42 = v40 / 2 - (signed int)pOutString / 2 + 138;
     if ( (signed int)v41 < (signed int)(v41 + v39) )
     {
@@ -16573,14 +16508,14 @@
         v42 = v45 + v44 - 1;
         v43->uW = v42;
         v47 = v54[0];
-        if ( (unsigned __int16 *)pDialogueWindow->field_2C_focus_id != v46 )
+        if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 )
           v47 = (unsigned __int16)pInString;
         v52.DrawText2(pFontArrus, 0, v45, v47, Str, 3u);
         v34 = pDialogueWindow;
         v55 = (unsigned __int16 *)((char *)v55 + 1);
         ++v41;
       }
-      while ( (signed int)v41 < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
+      while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
     }
   }
   pRenderer->DrawTextureIndexed(
@@ -17208,7 +17143,7 @@
   {
     //v5 = pSomeEVT;
     //v6 = v123;
-    //v7 = nullstring;
+    //v7 = "";
     //while ( 1 )
     //{
       if ( dword_5B65C4 )
@@ -17238,7 +17173,7 @@
             pVideoPlayer->field_40 = 0;
             if (pAsyncMouse)
               pAsyncMouse->Suspend();
-            v128 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+            v128 = pCurrentScreen;
             //v13 = &pSomeEVT[v9];
             //v14 = (unsigned __int8)v13[5];
             //v15 = (unsigned __int8)v13[6];
@@ -17271,7 +17206,7 @@
 LABEL_28:
             if ( !v15 || v128 == 3 )
             {
-              uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = v128;
+              pCurrentScreen = v128;
               if ( v128 == 3 )
                 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
               if ( v128 == 13 )
@@ -17573,7 +17508,7 @@
             //v4 = v124;
             //v5 = pSomeEVT;
             //v6 = v123;
-            //v7 = nullstring;
+            //v7 = "";
             break;
           case EVENT_CharacterAnimation:
             v54 = _evt->v5;
@@ -18140,8 +18075,8 @@
               if ( v100 )
               {
                 pParty->vPosition.x = v135;
-                pParty->vPosition.z = v132;
-                pParty->vPosition.y = v126;
+                pParty->vPosition.y = v132;
+                pParty->vPosition.z = v126;
                 pParty->uFallStartY = v126;
                 if ( _5B65B4_npcdata_loword_house_or_other != -1 )
                   pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other;
@@ -18171,7 +18106,7 @@
               pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((_5C3420_pDecoration == 0) + 1);
               sub_44987B(v99, 0);
               v133 = 1;
-              if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13 )
+              if ( pCurrentScreen == 13 )
               {
                 if ( uGameState == 2 )
                 {
@@ -18184,7 +18119,7 @@
                   ptr_507BC0 = 0;
                   if ( pMessageQueue_50CBD0->uNumMessages )
                     pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-                  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+                  pCurrentScreen = 0;
                   viewparams->bRedrawGameUI = 1;
                   array_5913D8[6] = 0;
                   pDialogueWindow->Release();
@@ -18344,7 +18279,7 @@
                 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4));
                 if ( v10->sCogNumber == v14 )
                 {
-                  if ( BYTE1(v10->uFaceAttributes) & 0x40 )
+                  if ( BYTE1(v10->uAttributes) & 0x40 )
                   {
                     *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
                                                                    Str2);
@@ -18511,9 +18446,9 @@
               if ( v9->sCogNumber == v10 )
               {
                 if ( on )
-                  v9->uFaceAttributes |= bit;
+                  v9->uAttributes |= bit;
                 else
-                  v9->uFaceAttributes &= ~bit;
+                  v9->uAttributes &= ~bit;
               }
               ++v8;
               v6 += 308;
@@ -18549,8 +18484,6 @@
 //----- (00448A40) --------------------------------------------------------
 void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle)
 {
-  unsigned __int16 *pState; // eax@6
-
   if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) )
   {
     if ( bToggle )
@@ -18561,9 +18494,8 @@
     {
       if ( uFlag == 0x10000 )
       {
-        pState = &pActors[uActorID].uAIState;
-        if ( *pState == Disabled )
-          *pState = Standing;
+        if (pActors[uActorID].uAIState == Disabled )
+          pActors[uActorID].uAIState = Standing;
       }
       pActors[uActorID].uAttributes &= ~uFlag;
     }
@@ -18888,9 +18820,9 @@
   {
     v10 = (double)pParty->vPosition.x - (double)fromx;
     v53 = v10;
-    v11 = (double)pParty->vPosition.z - (double)fromy;
+    v11 = (double)pParty->vPosition.y - (double)fromy;
     v54 = v11;
-    v12 = (double)(pParty->vPosition.y + pParty->sEyelevel);
+    v12 = (double)(pParty->vPosition.z + pParty->sEyelevel);
   }
   a7a = v12 - (double)fromz;
   toza = v11 * v11;
@@ -19452,9 +19384,9 @@
       }
       v7 = v5;
       pParty->vPosition.x = pLevelDecorations[v7].vPosition.x;
-      pParty->vPosition.z = pLevelDecorations[v7].vPosition.y;
-      pParty->vPosition.y = pLevelDecorations[v7].vPosition.z;
-      pParty->uFallStartY = pParty->vPosition.y;
+      pParty->vPosition.y = pLevelDecorations[v7].vPosition.y;
+      pParty->vPosition.z = pLevelDecorations[v7].vPosition.z;
+      pParty->uFallStartY = pParty->vPosition.z;
       v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90;
       v9 = pLevelDecorations[v7].field_10_y_rot;
       pParty->sRotationY = v8;
@@ -19469,10 +19401,10 @@
       if ( _5B65A8_npcdata_uflags_or_other )
         pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other;
       if ( _5B65AC_npcdata_fame_or_other )
-        pParty->vPosition.z = _5B65AC_npcdata_fame_or_other;
+        pParty->vPosition.y = _5B65AC_npcdata_fame_or_other;
       if ( _5B65B0_npcdata_rep_or_other )
       {
-        pParty->vPosition.y = _5B65B0_npcdata_rep_or_other;
+        pParty->vPosition.z = _5B65B0_npcdata_rep_or_other;
         pParty->uFallStartY = _5B65B0_npcdata_rep_or_other;
       }
       if ( _5B65B4_npcdata_loword_house_or_other )
@@ -19688,7 +19620,7 @@
     dword_5B65C0 = 0;
     pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
     sub_44987B("nwc.blv", 0);
-    uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+    pCurrentScreen = 0;
     result = 1;
   }
   return result;
@@ -20018,8 +19950,8 @@
       *(char *)(v0 + 1) &= 0xFBu;
       if ( ! ((Actor *)(v0 - offsetof(Actor, uAttributes)))->CanAct() )
         goto LABEL_37;
-      v22 = abs(pParty->vPosition.y - *(short *)(v0 + 110));
-      v21 = abs(pParty->vPosition.z - *(short *)(v0 + 108));
+      v22 = abs(pParty->vPosition.z - *(short *)(v0 + 110));
+      v21 = abs(pParty->vPosition.y - *(short *)(v0 + 108));
       v1 = abs(pParty->vPosition.x - *(short *)(v0 + 106));
       v2 = v21;
       v3 = v22;
@@ -20176,7 +20108,7 @@
   int v45; // [sp+20h] [bp-4h]@1
 
   pParty->uFlags &= 0xFFFFFFCFu;
-  v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
+  v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   v45 = 0;
   v43 = 0;
   if ( (signed int)uNumActors > 0 )
@@ -20187,8 +20119,8 @@
       v0[1] &= 0xFBu;
       if ( ! ((Actor *)(v0 - 36))->CanAct() )
         goto LABEL_60;
-      v39 = abs(pParty->vPosition.y - *((short *)v0 + 55));
-      v38 = abs(pParty->vPosition.z - *((short *)v0 + 54));
+      v39 = abs(pParty->vPosition.z - *((short *)v0 + 55));
+      v38 = abs(pParty->vPosition.y - *((short *)v0 + 54));
       v1 = abs(pParty->vPosition.x - *((short *)v0 + 53));
       v2 = v38;
       v3 = v39;
@@ -20616,7 +20548,7 @@
           Actor::_403F58(uActorID, Dying, 256, 0);
           goto LABEL_78;
         }
-        pActor->uAIState = 0;
+        pActor->uAIState = Standing;
       }
       pActor->uCurrentActionTime = 0;
       pActor->uCurrentActionLength = 0;
@@ -20701,7 +20633,7 @@
         && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < (signed int)v24
          || LODWORD(v21->pActorBuffs[2].uExpireTime) <= v24) )
       {
-        v21->uAIState = 11;
+        v21->uAIState = Removed;
         goto LABEL_254;
       }
       if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime )
@@ -21101,19 +21033,19 @@
 //----- (00402CAE) --------------------------------------------------------
 int stru193_math::SinCos(int angle)
 {
-  unsigned int v2; // edx@1
-  unsigned int v3; // eax@1
-  int result; // eax@4
-
-  v2 = this->uIntegerPi;
-  v3 = this->uDoublePiMask & angle;
-  if ( (signed int)v3 > (signed int)v2 )
-    v3 = this->uIntegerDoublePi - v3;
-  if ( (signed int)v3 >= (signed int)this->uIntegerHalfPi )
-    result = -this->pCosTable[v2 - v3];
-  else
-    result = this->pCosTable[v3];
-  return result;
+  int v2; // eax@1
+
+  //a2: (angle - uIntegerHalfPi)    for  sin(angle)
+  //    (angle)                     for  cos(angle)
+
+  v2 = uDoublePiMask & angle;
+  
+  if ( v2 > uIntegerPi )
+    v2 = uIntegerDoublePi - v2;
+  if ( v2 >= uIntegerHalfPi )
+    return -pCosTable[uIntegerPi - v2];
+  else
+    return pCosTable[v2];
 }
 
 
@@ -21269,16 +21201,13 @@
 }
 
 //----- (0040471C) --------------------------------------------------------
-int stru262_TurnBased::_40471C()
-{
-  int result; // eax@3
-
+void stru262_TurnBased::_40471C()
+{
   if ( pParty->bTurnBasedModeOn == 1 )
   {
     if ( pTurnEngine->field_4 == 2 )
-      result = _406457(0);
-  }
-  return result;
+      _406457(0);
+  }
 }
 
 
--- a/mm7_4.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_4.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -123,8 +123,8 @@
     if ( v1->field_2 & 1 )
     {
       v36 = abs(v1->vPosition.x - pParty->vPosition.x);
-      v25 = abs(v3 - pParty->vPosition.z);
-      v28 = abs(v35 - pParty->vPosition.y);
+      v25 = abs(v3 - pParty->vPosition.y);
+      v28 = abs(v35 - pParty->vPosition.z);
       v4 = v36;
       v5 = v25;
       v6 = v28;
@@ -234,15 +234,15 @@
 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8;
 
 //----- (0046CEC3) --------------------------------------------------------
-int __fastcall _46CEC3_get_floor_level(signed int a1, signed int a2, int a3, unsigned int uSectorID, int *a5)
-{
-  BLVSector *v5; // edi@1
-  int v6; // ecx@1
-  Vec3_short_ *v7; // edx@1
-  BLVFace *v8; // esi@2
-  int v9; // eax@8
-  int v10; // edi@8
-  int v11; // eax@10
+int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID)
+{
+  //BLVSector *v5; // edi@1
+  //int v6; // ecx@1
+  //Vec3_short_ *v7; // edx@1
+  //BLVFace *v8; // esi@2
+  //int v9; // eax@8
+  //int v10; // edi@8
+  //int v11; // eax@10
   int v12; // ecx@10
   int v13; // ecx@13
   signed int v14; // ebx@14
@@ -254,9 +254,9 @@
   PolygonType v20; // al@25
   int v21; // eax@27
   int v22; // ecx@29
-  BLVFace *v23; // eax@33
-  int v24; // esi@39
-  int v25; // edi@39
+  //BLVFace *v23; // eax@33
+  //int v24; // esi@39
+  //int v25; // edi@39
   int v26; // esi@41
   int v27; // ecx@43
   signed int v28; // eax@45
@@ -270,78 +270,86 @@
   int result; // eax@57
   int v37; // edi@61
   int v38; // edx@62
-  int v39; // [sp+Ch] [bp-34h]@1
-  int v40; // [sp+10h] [bp-30h]@2
+  //int v39; // [sp+Ch] [bp-34h]@1
+  //int v40; // [sp+10h] [bp-30h]@2
   int v41; // [sp+14h] [bp-2Ch]@12
-  unsigned __int16 *v42; // [sp+18h] [bp-28h]@1
-  BLVSector *v43; // [sp+1Ch] [bp-24h]@1
+  //unsigned __int16 *v42; // [sp+18h] [bp-28h]@1
+  //BLVSector *v43; // [sp+1Ch] [bp-24h]@1
   int v44; // [sp+20h] [bp-20h]@10
   int v45; // [sp+24h] [bp-1Ch]@10
-  signed int v46; // [sp+24h] [bp-1Ch]@38
+  //signed int v46; // [sp+24h] [bp-1Ch]@38
   bool v47; // [sp+24h] [bp-1Ch]@43
   bool v48; // [sp+28h] [bp-18h]@10
   bool v49; // [sp+28h] [bp-18h]@41
   bool v50; // [sp+2Ch] [bp-14h]@12
   int v51; // [sp+2Ch] [bp-14h]@41
-  signed int v52; // [sp+30h] [bp-10h]@7
+  //signed int v52; // [sp+30h] [bp-10h]@7
   signed int v53; // [sp+30h] [bp-10h]@10
   signed int v54; // [sp+30h] [bp-10h]@41
   signed int v55; // [sp+34h] [bp-Ch]@1
-  signed int v56; // [sp+38h] [bp-8h]@1
-  signed int v57; // [sp+3Ch] [bp-4h]@1
-  int uSectorIDa; // [sp+4Ch] [bp+Ch]@1
-  signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32
-
-  v5 = &pIndoor->pSectors[uSectorID];
-  v57 = a2;
-  v56 = a1;
-  v6 = 0;
+  //signed int v56; // [sp+38h] [bp-8h]@1
+  //signed int v57; // [sp+3Ch] [bp-4h]@1
+  //int uSectorIDa; // [sp+4Ch] [bp+Ch]@1
+  //signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32
+
+  LOG_DECOMPILATION_WARNING();
+
+  //auto a1 = x;
+  //auto a2 = y;
+  //auto a3 = z;
+
+  //v5 = &pIndoor->pSectors[uSectorID];
+  auto pSector = &pIndoor->pSectors[uSectorID];
+  //v57 = y;
+  //v56 = x;
+  //v6 = 0;
   v55 = 0;
-  v43 = v5;
-  v42 = v5->pFloors;
-  v7 = pIndoor->pVertices;
-  v39 = v5->field_4;
-  for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa )
-  {
-    v40 = (int)&v42[v6];
-    v8 = &pIndoor->pFaces[*(short *)v40];
-    if ( !(BYTE3(v8->uAttributes) & 0x20)
-      && v56 <= v8->pBounding.x2
-      && v56 >= v8->pBounding.x1
-      && v57 <= v8->pBounding.y2
-      && v57 >= v8->pBounding.y1 )
-    {
-      v52 = 0;
-      if ( v8->uNumVertices )
-      {
-        do
-        {
-          v9 = v52;
-          v10 = 2 * v52;
-          word_721460[2 * v52] = v8->pXInterceptDisplacements[v52] + v7[v8->pVertexIDs[v52]].x;
-          word_721390[2 * v52] = v8->pYInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9]].y;
-          word_721460[2 * v52++ + 1] = v8->pXInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9 + 1]].x;
-          word_721390[v10 + 1] = v8->pYInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9 + 1]].y;
-        }
-        while ( v52 < v8->uNumVertices );
-        v5 = v43;
-      }
-      v44 = 2 * v8->uNumVertices;
-      v11 = 2 * v8->uNumVertices;
-      word_721460[v11] = word_721460[0];
-      word_721390[v11] = word_721390[0];
-      v48 = word_721390[0] >= v57;
+  //v43 = v5;
+  //v42 = v5->pFloors;
+  //v7 = pIndoor->pVertices;
+  //v39 = v5->uNumFloors;
+  //for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa )
+  for (uint i = 0; i < pSector->uNumFloors; ++i)
+  {
+    //v40 = (int)&v42[v6];
+    //v8 = &pIndoor->pFaces[pSector->pFloors[i]];
+    auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]];
+    if (pFloor->Clickable())
+      continue;
+
+    if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 &&
+        y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1)
+    {
+      //v52 = 0;
+      for (uint j = 0; j < pFloor->uNumVertices; ++j)
+      {
+          //v9 = v52;
+          //v10 = 2 * v52;
+        word_721460[2 * j] =     pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x;
+        word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x;
+        word_721390[2 * j] =     pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y;
+        word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y;
+        //}
+        //while ( v52 < v8->uNumVertices );
+        //v5 = v43;
+      }
+      v44 = 2 * pFloor->uNumVertices;
+      //v11 = 2 * pFloor->uNumVertices;
+      word_721460[2 * pFloor->uNumVertices] = word_721460[0];
+      word_721390[2 * pFloor->uNumVertices] = word_721390[0];
+
+      v48 = word_721390[0] >= y;
       v12 = 0;
       v53 = 0;
       v45 = 0;
-      if ( v44 > 0 )
+      if ( pFloor->uNumVertices > 0 )
       {
         do
         {
           if ( v53 >= 2 )
             break;
           v41 = word_721390[v12 + 1];
-          v50 = word_721390[v12 + 1] >= v57;
+          v50 = word_721390[v12 + 1] >= y;
           if ( v48 == v50 )
           {
             v13 = v45;
@@ -349,24 +357,24 @@
           else
           {
             v13 = v45;
-            if ( word_721460[v45 + 1] >= v56 )
+            if ( word_721460[v45 + 1] >= x )
               v14 = 0;
             else
               v14 = 2;
-            v15 = v14 | word_721460[v45] < v56;
+            v15 = v14 | word_721460[v45] < x;
             if ( v15 != 3 )
             {
               if ( !v15
                 || (v16 = word_721390[v45],
                     v17 = v41 - v16,
-                    v18 = v57 - v16,
+                    v18 = y - v16,
                     LODWORD(v19) = v18 << 16,
                     HIDWORD(v19) = v18 >> 16,
-                    v7 = pIndoor->pVertices,
+                    //v7 = pIndoor->pVertices,
                     (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45])
                                                    * v19
                                                    / v17) >> 16)
-                               + word_721460[v45]) >= v56) )
+                               + word_721460[v45]) >= x) )
                 ++v53;
             }
           }
@@ -375,62 +383,66 @@
           v45 = v12;
         }
         while ( v12 < v44 );
+
         if ( v53 == 1 )
         {
           if ( v55 >= 50 )
             break;
-          v20 = v8->uPolygonType;
+          v20 = pFloor->uPolygonType;
           if ( v20 == 3 || v20 == 5 )
           {
-            v21 = v7[*v8->pVertexIDs].z;
+            v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z;
           }
           else
           {
-            v7 = pIndoor->pVertices;
-            v21 = ((unsigned __int64)(v8->zCalc1 * (signed __int64)v56) >> 16)
-                + ((unsigned __int64)(v8->zCalc2 * (signed __int64)v57) >> 16)
-                + HIWORD(v8->zCalc3);
+            //v7 = pIndoor->pVertices;
+            v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16)
+                + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16)
+                + HIWORD(pFloor->zCalc3);
           }
           v22 = v55++;
           dword_7212C8[v22] = v21;
-          dword_721200[v22] = *(short *)v40;
-        }
-      }
-    }
-    v6 = uSectorIDa + 1;
-  }
-  if ( v5->field_0 & 8 )
-  {
-    for ( uSectorIDb = 0; uSectorIDb < v5->uNumPortals; ++uSectorIDb )
-    {
-      v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]];
-      if ( v23->uPolygonType == 3
-        && v56 <= v23->pBounding.x2
-        && v56 >= v23->pBounding.x1
-        && v57 <= v23->pBounding.y2
-        && v57 >= v23->pBounding.y1 )
-      {
-        v46 = 0;
-        if ( v23->uNumVertices )
-        {
-          do
-          {
-            v24 = v46;
-            v25 = 2 * v46;
-            word_721460[2 * v46] = v23->pXInterceptDisplacements[v46] + v7[v23->pVertexIDs[v46]].x;
-            word_721390[2 * v46] = v23->pYInterceptDisplacements[v24] + v7[v23->pVertexIDs[v24]].y;
-            word_721460[2 * v46++ + 1] = v23->pXInterceptDisplacements[v24 + 1] + v7[v23->pVertexIDs[v24 + 1]].x;
-            word_721390[v25 + 1] = v23->pYInterceptDisplacements[v24 + 1] + v7[v23->pVertexIDs[v24 + 1]].y;
-          }
-          while ( v46 < v23->uNumVertices );
-          v5 = v43;
-        }
-        v26 = 2 * v23->uNumVertices;
-        word_721460[2 * v23->uNumVertices] = word_721460[0];
-        word_721390[v26] = word_721390[0];
+          dword_721200[v22] = pSector->pFloors[i];
+        }
+      }
+    }
+    //v6 = uSectorIDa + 1;
+  }
+
+  if ( pSector->field_0 & 8 )
+  {
+    for (uint i = 0; i < pSector->uNumPortals; ++i)
+    {
+      //v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]];
+      auto portal = &pIndoor->pFaces[pSector->pPortals[i]];
+      if (portal->uPolygonType != POLYGON_Floor)
+        continue;
+
+      if (x <= portal->pBounding.x2 &&
+          x >= portal->pBounding.x1 &&
+          y <= portal->pBounding.y2 &&
+          y >= portal->pBounding.y1 )
+      {
+        //v46 = 0;
+        for (uint j = 0; j < portal->uNumVertices; ++j)
+        {
+            //v24 = v46;
+            //v25 = 2 * v46;
+          word_721460[2 * j] =     portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x;
+          word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x;
+          word_721390[2 * j] =     portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y;
+          word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y;
+          //}
+          //while ( v46 < v23->uNumVertices );
+          //v5 = v43;
+        }
+
+        //v26 = 2 * v23->uNumVertices;
+        word_721460[2 * portal->uNumVertices] = word_721460[0];
+        word_721390[2 * portal->uNumVertices] = word_721390[0];
         v54 = 0;
         v51 = 0;
-        v49 = word_721390[0] >= v57;
+        v49 = word_721390[0] >= y;
         if ( v26 > 0 )
         {
           do
@@ -438,27 +450,27 @@
             if ( v54 >= 2 )
               break;
             v27 = v51;
-            v47 = word_721390[v51 + 1] >= v57;
+            v47 = word_721390[v51 + 1] >= y;
             if ( v49 != v47 )
             {
-              if ( word_721460[v27 + 1] >= v56 )
+              if ( word_721460[v27 + 1] >= x )
                 v28 = 0;
               else
                 v28 = 2;
-              v29 = v28 | word_721460[v27] < v56;
+              v29 = v28 | word_721460[v27] < x;
               if ( v29 != 3 )
               {
                 if ( !v29
                   || (v30 = word_721390[v27],
                       v31 = word_721390[v51 + 1] - v30,
-                      v32 = v57 - v30,
+                      v32 = y - v30,
                       LODWORD(v33) = v32 << 16,
                       HIDWORD(v33) = v32 >> 16,
-                      v7 = pIndoor->pVertices,
+                      //v7 = pIndoor->pVertices,
                       (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27])
                                                      * v33
                                                      / v31) >> 16)
-                                 + word_721460[v27]) >= v56) )
+                                 + word_721460[v27]) >= x) )
                   ++v54;
               }
             }
@@ -472,25 +484,26 @@
               break;
             v34 = v55++;
             dword_7212C8[v34] = -29000;
-            dword_721200[v34] = v5->pPortals[uSectorIDb];
-          }
-        }
-      }
-    }
-  }
+            dword_721200[v34] = pSector->pPortals[i];
+          }
+        }
+      }
+    }
+  }
+
   v35 = 1;
   if ( v55 == 1 )
   {
-    *a5 = dword_721200[0];
+    *pFaceID = dword_721200[0];
     return dword_7212C8[0];
   }
   if ( !v55 )
     return -30000;
-  *a5 = dword_721200[0];
+  *pFaceID = dword_721200[0];
   result = dword_7212C8[0];
   if ( v55 > 1 )
   {
-    v37 = a3 + 5;
+    v37 = z + 5;
     while ( 1 )
     {
       v38 = dword_7212C8[v35];
@@ -507,7 +520,7 @@
       goto LABEL_68;
 LABEL_67:
     result = dword_7212C8[v35];
-    *a5 = dword_721200[v35];
+    *pFaceID = dword_721200[v35];
     goto LABEL_68;
   }
   return result;
@@ -594,7 +607,7 @@
                 v11 = &v10->pFaces[v39];
                 v12 = v11->uPolygonType;
                 if ( (v12 == 3 || v12 == 4)
-                  && !(BYTE3(v11->uFaceAttributes) & 0x20)
+                  && !(v11->uAttributes & 0x20000000)
                   && v8 <= v11->pBoundingBox.x2
                   && v8 >= v11->pBoundingBox.x1
                   && v7 <= v11->pBoundingBox.y2
@@ -742,7 +755,7 @@
   {
     v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]];
     *a5 = 0;
-    if ( v32->uFaceAttributes & 0x10 )
+    if ( v32->uAttributes & 0x10 )
       *a5 = 1;
   }
   v33 = dword_7211B0[v27];
@@ -825,7 +838,7 @@
                   v7 = (ODMFace *)((char *)v6->pFaces + v30);
                   v8 = v7->uPolygonType;
                   if ( (v8 == 5 || v8 == 6)
-                    && !(BYTE3(v7->uFaceAttributes) & 0x20)
+                    && !(BYTE3(v7->uAttributes) & 0x20)
                     && v4 <= v7->pBoundingBox.x2
                     && v4 >= v7->pBoundingBox.x1
                     && v40 <= v7->pBoundingBox.y2
@@ -2813,47 +2826,26 @@
 
 
 //----- (0048A959) --------------------------------------------------------
-unsigned int sub_48A959(int _this, float a2, float a3, float a4)
-{
-  int v4; // esi@1
-  double v5; // st6@1
-  double v6; // st6@1
-  __int64 v8; // [sp+14h] [bp-20h]@1
-  double v9; // [sp+1Ch] [bp-18h]@1
-  int a6; // [sp+24h] [bp-10h]@1
-  float v11; // [sp+28h] [bp-Ch]@1
-  float v12; // [sp+2Ch] [bp-8h]@1
-  float a1; // [sp+30h] [bp-4h]@1
-  float a2a; // [sp+3Ch] [bp+8h]@7
-  float a2b; // [sp+3Ch] [bp+8h]@7
-  float a2c; // [sp+3Ch] [bp+8h]@7
-  int a3a; // [sp+40h] [bp+Ch]@7
-
-  v4 = _this;
-  v8 = ((unsigned int)_this >> 16) & 0xFFi64;
-  v5 = (double)v8 * 0.0039215689;
-  v8 = (unsigned __int16)_this >> 8;
-  a1 = v5;
-  v6 = (double)v8;
-  v8 = _this & 0xFFi64;
-  v12 = v6 * 0.0039215689;
-  v11 = (double)v8 * 0.0039215689;
-  RGB2HSV((float *)&v8 + 1, (float *)&v9 + 1, a1, v12, v11, (float *)&a6);
-  if ( a2 != -1.0 )
-    HIDWORD(v8) = LODWORD(a2);
-  if ( a3 != -1.0 )
-    HIDWORD(v9) = LODWORD(a3);
-  if ( a4 != -1.0 )
-    a6 = LODWORD(a4);
-  HSV2RGB(&a1, &v12, &v11, *((float *)&v8 + 1), *((float *)&v9 + 1), *(float *)&a6);
-  a2a = a1 * 255.0;
-  *(double *)&v8 = a2a + 6.7553994e15;
-  a3a = v8;
-  a2b = v12 * 255.0;
-  *(double *)&v8 = a2b + 6.7553994e15;
-  a2c = v11 * 255.0;
-  v9 = a2c + 6.7553994e15;
-  return LODWORD(v9) | v4 & 0xFF000000 | (((unsigned int)v8 | (a3a << 8)) << 8);
+unsigned int ReplaceHSV(unsigned int uColor, float h_replace, float s_replace, float v_replace)
+{
+  float r = ((uColor & 0x00FF0000) >> 16) / 255.0f,
+        g = ((uColor & 0x0000FF00) >> 8) / 255.0f,
+        b = (uColor & 0x000000FF) / 255.0f;
+
+  float h, s, v;
+  RGB2HSV(&h, &s, r, g, b, &v);
+
+  if ( h_replace != -1.0 )
+    h = h_replace;
+  if ( s_replace != -1.0 )
+    s = s_replace;
+  if ( v_replace != -1.0 )
+    v = v_replace;
+  HSV2RGB(&r, &g, &b, h, s, v);
+
+  return (((uint)floorf(r * 255.0f + 0.5f) & 0xFF) << 16) |
+         (((uint)floorf(g * 255.0f + 0.5f) & 0xFF) << 8) |
+         ((uint)floorf(b * 255.0f + 0.5f) & 0xFF);
 }
 
 
@@ -3065,12 +3057,6 @@
 //----- (00491F87) --------------------------------------------------------
 void __cdecl DrawHiredNPCs()
 {
-  int v0; // ecx@2
-  char *v1; // eax@2
-  int v2; // edx@4
-  signed int v3; // ebx@6
-  char *v4; // esi@7
-  int v5; // ecx@13
   int v6; // eax@15
   char v7; // al@17
   unsigned int v8; // eax@18
@@ -3081,7 +3067,7 @@
   unsigned int v13; // eax@23
   IconFrame *v14; // eax@24
   unsigned int v15; // eax@26
-  char pContainer; // [sp+Ch] [bp-30h]@18
+  char pContainer[20]; // [sp+Ch] [bp-30h]@18
   unsigned int v17; // [sp+20h] [bp-1Ch]@19
   signed int uFrameID; // [sp+24h] [bp-18h]@19
   int i; // [sp+28h] [bp-14h]@15
@@ -3094,38 +3080,24 @@
   {
     v23 = 0;
     v22 = 0;
-    v0 = 0;
-    v1 = (char *)pParty->pHirelings;
-    do
-    {
-      if ( *(int *)v1 )
-      {
-        v2 = v22++;
-        pTmpBuf[v2] = v0;
-      }
-      v1 += 76;
-      ++v0;
-    }
-    while ( (signed int)v1 < (signed int)&pParty->pPickedItem );
-    v3 = 0;
-    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
-    {
-      v4 = (char *)pNPCStats->pNewNPCData;
-      do
-      {
-        if ( v4[8] & 0x80 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v4, pParty->pHirelings[0].pName)) )
-        {
-          if ( !pParty->pHirelings[1].pName || strcmp(*(const char **)v4, pParty->pHirelings[1].pName) )
-          {
-            v5 = v22++;
-            pTmpBuf[v5] = v3 + 2;
-          }
-        }
-        ++v3;
-        v4 += 76;
-      }
-      while ( v3 < (signed int)pNPCStats->uNumNewNPCs );
-    }
+    for (uint i = 0; i < 2; ++i)
+    { 
+      if (pParty->pHirelings[i].pName)
+        pTmpBuf[v22++] = i;
+    }
+
+    for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+    {
+      if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
+      {
+        if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
+        {
+          if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName))
+            pTmpBuf[v22++] = i + 2;
+        }
+      }
+    }
+
     v6 = (unsigned __int8)pParty->field_709;
     for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 )
     {
@@ -3134,22 +3106,22 @@
       v7 = pTmpBuf[v6];
       if ( (unsigned __int8)v7 >= 2u )
       {
-        sprintfex(&pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
-        v15 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE);
+        sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
+        v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         pRenderer->DrawTextureIndexed(
           pHiredNPCsIconsOffsetsX[v23],
           pHiredNPCsIconsOffsetsY[v23],
-          (Texture *)(v15 != -1 ? 72 * v15 + 7145548 : 0));
+          (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
       }
       else
       {
-        sprintfex(&pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
-        v8 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE);
+        sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
+        v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v9 = v23;
         pRenderer->DrawTextureIndexed(
           pHiredNPCsIconsOffsetsX[v9],
           pHiredNPCsIconsOffsetsY[v9],
-          (Texture *)(v8 != -1 ? (int)&pIcons_LOD->pTextures[v8] : 0));
+          (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
         v10 = (unsigned __int8)pTmpBuf[i];
         if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 )
         {
@@ -3190,12 +3162,7 @@
 //----- (004921C1) --------------------------------------------------------
 void GameUI_DrawPortraits(unsigned int _this)
 {
-  signed int v1; // ebx@2
-  int v2; // ebp@7
-  char *v3; // esi@7
   Texture *v4; // eax@10
-  signed int v5; // edx@13
-  PlayerFrame *v6; // eax@14
   unsigned int v7; // eax@17
   PlayerFrame *v8; // eax@21
   unsigned int v9; // eax@27
@@ -3203,21 +3170,15 @@
   bool v11; // edi@40
   bool v12; // edx@43
   bool v13; // ecx@46
-  int v14; // esi@54
-  char *v15; // edi@55
   int v16; // eax@57
-  __int16 *v17; // esi@59
-  char *v18; // edi@59
   int v19; // eax@62
   Texture *v20; // [sp-4h] [bp-1Ch]@27
-  signed int v21; // [sp+10h] [bp-8h]@7
   unsigned int v22; // [sp+14h] [bp-4h]@1
 
   v22 = _this;
   if ( qword_A750D8 )
   {
     qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
-    v1 = 0;
     if ( qword_A750D8 <= 0 )
     {
       if ( pPlayers[word_A750E2]->CanAct() )
@@ -3225,95 +3186,80 @@
       qword_A750D8 = 0i64;
     }
   }
-  else
-  {
-    v1 = 0;
-  }
-  v2 = 0;
-  v21 = v1;
-  v3 = (char *)&pParty->pPlayers[0].pConditions[14];
-  while ( 1 )
-  {
-    if ( *((_QWORD *)v3 + 2) )
+
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto pPlayer = pParty->pPlayers + i;
+
+    if (pPlayer->Eradicated())
     {
       v4 = pTexture_PlayerFaceEradicated;
 LABEL_27:
       v20 = v4;
-      v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[v2];
+      v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
       if ( pParty->pPartyBuffs[11].uExpireTime )
         pRenderer->_4A6E7E(v9, 0x183u, v20);
       else
         pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, v20);
-      v10 = *((int *)v3 + 1541) >= v1 && (*((int *)v3 + 1541) > v1 || *((int *)v3 + 1540) > (unsigned int)v1);
-      if ( *((int *)v3 + 1489) >= v1 && (*((int *)v3 + 1489) > v1 || *((int *)v3 + 1488) > (unsigned int)v1) )
-        v1 = 1;
-      v11 = *((_QWORD *)v3 + 758) > 0i64;
-      v12 = *((_QWORD *)v3 + 756) > 0i64;
-      v13 = *((_QWORD *)v3 + 768) > 0i64;
-      if ( v13 | v12 | v11 | v1 | v10 )
-        sub_441A4E(v2);
+      auto _v1 = 0;
+      v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
+      if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
+        _v1 = 1;
+      v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
+      v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
+      v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
+      if ( v13 | v12 | v11 | _v1 | v10 )
+        sub_441A4E(i);
       goto LABEL_50;
     }
-    if ( *(_QWORD *)v3 )
+    if (pPlayer->Dead())
     {
       v4 = pTexture_PlayerFaceDead;
       goto LABEL_27;
     }
-    v5 = 0;
-    if ( (signed int)pPlayerFrameTable->uNumFrames <= v1 )
-    {
-LABEL_17:
+
       v7 = 0;
-    }
-    else
-    {
-      v6 = pPlayerFrameTable->pFrames;
-      while ( v6->uSequenceID != *((short *)v3 + 3350) )
-      {
-        ++v5;
-        ++v6;
-        if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames )
-          goto LABEL_17;
-      }
-      v7 = v5;
-    }
-    if ( v7 == v1 )
+      for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
+        if (pPlayerFrameTable->pFrames[j].uSequenceID == pPlayer->uExpressionID)
+        {
+          v7 = j;
+          break;
+        }
+
+    if ( v7 == 0 )
       v7 = 1;
-    if ( *((short *)v3 + 3350) == 21 )
+    if (pPlayer->uExpressionID == 21 )
       v8 = pPlayerFrameTable->GetFrameBy_y(
-             (int *)v3 + 1678,
-             (int *)v3 + 1677,
+             &pPlayer->field_1AA8,
+             &pPlayer->field_1AA4,
              pMiscTimer->uTimeElapsed);
     else
-      v8 = pPlayerFrameTable->GetFrameBy_x(v7, *((short *)v3 + 3351));
-    if ( *((short *)v3 + 3353) != v8->uTextureID - 1 || v22 )
-    {
-      *((short *)v3 + 3353) = v8->uTextureID - 1;
-      v1 = 0;
-      v4 = (Texture *)A74CEC_player_faces_minus1_indexing[v21 + v8->uTextureID];
+      v8 = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
+    if (pPlayer->field_1AA2 != v8->uTextureID - 1 || v22 )
+    {
+      pPlayer->field_1AA2 = v8->uTextureID - 1;
+      v4 = (Texture *)pTextures_PlayerFaces[i][v8->uTextureID];
       goto LABEL_27;
     }
 LABEL_50:
-    v21 += 56;
-    v3 += 6972;
-    ++v2;
-    if ( (signed int)v3 >= (signed int)&pParty->pHirelings[1].field_24 )
-      break;
-    v1 = 0;
-  }
+    ;
+  }
+
   if ( pParty->bTurnBasedModeOn == 1 )
   {
     if ( pTurnEngine->field_4 != 1 )
     {
       if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
       {
-        v14 = 0;
+        //v14 = 0;
         if ( pTurnEngine->uActorQueueSize > 0 )
         {
-          v15 = (char *)pTurnEngine->pQueue;
-          do
-          {
-            if ( (*v15 & 7) != 4 )
+          //v15 = (char *)pTurnEngine->pQueue;
+          for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i)
+          {
+            auto pElem = pTurnEngine->pQueue + i;
+
+            if ( (pElem->uPackedID & 7) != 4 )
               break;
             v16 = dword_5079D0;
             if ( pParty->uFlags & 0x10 )
@@ -3326,24 +3272,20 @@
                 v16 = dword_5079C8;
             }
             pRenderer->DrawTextureTransparent(
-              pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[*(int *)v15 >> 3] - 4,
+              pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4,
               0x181u,
-              (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0));
-            ++v14;
-            v15 += 16;
-          }
-          while ( v14 < pTurnEngine->uActorQueueSize );
-        }
-      }
-    }
-  }
-  else
-  {
-    v17 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
-    v18 = (char *)pParty->pPlayers;
-    do
-    {
-      if ( ((Player *)v18)->CanAct() && !*((short *)v18 + 3226) )
+              (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
+          }
+        }
+      }
+    }
+  }
+  else
+  {
+    for (uint i = 0; i < 4; ++i)
+    {
+      auto pPlayer = pParty->pPlayers + i;
+      if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery)
       {
         v19 = dword_5079D0;
         if ( pParty->uFlags & 0x10 )
@@ -3356,14 +3298,11 @@
             v19 = dword_5079C8;
         }
         pRenderer->DrawTextureTransparent(
-          *v17 - 4,
+          pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
           0x181u,
-          (Texture *)(v19 != -1 ? (int)&pIcons_LOD->pTextures[v19] : 0));
-      }
-      v18 += 6972;
-      ++v17;
-    }
-    while ( (signed int)v18 < (signed int)pParty->pHirelings );
+          (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
+      }
+    }
   }
 }
 
@@ -3457,7 +3396,7 @@
   signed int v20; // ebx@25
   Player *v21; // esi@25
   ITEM_EQUIP_TYPE v22; // edi@30
-  int v23; // edx@31
+  //int v23; // edx@31
   signed int v24; // ecx@32
   signed int v25; // eax@33
   int v26; // eax@35
@@ -3495,13 +3434,14 @@
   {
     v51 = 0;
     v4 = (v0 - v2) / 5;
-    if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 )
+    if (pParty->FlyActive())
     {
       if ( pParty->bFlying )
       {
         if ( !(pParty->pPartyBuffs[7].uFlags & 1) )
         {
           v5 = v4 * pParty->pPartyBuffs[7].uPower;
+          __debugbreak();
           v6 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[7].uCaster + 2000];
           v7 = *(int *)v6 - v5 < 0;
           *(int *)v6 -= v5;
@@ -3515,12 +3455,13 @@
         }
       }
     }
-    if ( (signed __int64)pParty->pPartyBuffs[18].uExpireTime > 0 )
-    {
-      if ( pParty->uFlags & 0x80 )
+    if (pParty->WaterWalkActive())
+    {
+      if (pParty->uFlags & 0x80 )
       {
         if ( !(pParty->pPartyBuffs[18].uFlags & 1) )
         {
+          __debugbreak();
           v8 = &stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[18].uCaster + 2000];
           v7 = *(int *)v8 - v4 < 0;
           *(int *)v8 -= v4;
@@ -3533,8 +3474,7 @@
         }
       }
     }
-    if ( SHIDWORD(pParty->pPartyBuffs[10].uExpireTime) >= 0
-      && (SHIDWORD(pParty->pPartyBuffs[10].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[10].uExpireTime)) )
+    if (pParty->ImmolationActive())
     {
       //LayingItem::LayingItem(&a1);
       v9 = 0;
@@ -3543,7 +3483,7 @@
       a3.x = 0;
       a1.stru_24.Reset();
       a1.field_4C = pParty->pPartyBuffs[10].uPower;
-      a1.field_50 = pParty->pPartyBuffs[10].uSkill;
+      a1.field_50 = pParty->ImmolationSkillLevel();
       v10 = 0;
       a1.uItemType = 1070;
       a1.field_48 = 8;
@@ -3616,7 +3556,9 @@
     {
       if ( v21->HasItemEquipped(v22) )
       {
-        v24 = *(int *)&v21->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v23 + 5];
+        //v23 = v21->pEquipment.pIndices;
+        auto _idx = v21->pEquipment.pIndices[v22];
+        v24 = v21->pInventoryItems[_idx].uItemID;
         if ( v24 > 134 )
         {
           if ( v24 == 529 )
@@ -3635,7 +3577,7 @@
         }
         else
         {
-          v25 = *(int *)&v21->field_1F5[36 * *(int *)v23 + 7];
+          v25 = v21->pInventoryItems[_idx].uAdditionalValue;
           if ( v25 <= 50 )
           {
             if ( v25 != 50 )
@@ -4254,7 +4196,7 @@
   v51 = v65;
   if ( v65 )
     goto LABEL_135;
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 5 )
+  if ( pCurrentScreen != 5 )
   {
     v52 = (signed int)&pPlayers[1];
     while ( 1 )
@@ -4270,13 +4212,13 @@
     *(int *)(v53 + 20) = 0;
     v51 = 1;
 LABEL_135:
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 5
+    if ( pCurrentScreen != 5
       && (!v51 || dword_5C35C0) )
       uGameState = 8;
   }
   if ( uActiveCharacter )
   {
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 5 )
+    if ( pCurrentScreen != 5 )
     {
       v54 = pPlayers[uActiveCharacter];
       if ( v54->pConditions[2]
@@ -5333,7 +5275,6 @@
 //----- (00495B39) --------------------------------------------------------
 void __cdecl PlayerCreationUI_Draw()
 {
-  Texture *v0; // edi@1
   const char *uTitleText; // ST10_4@3
   int v2; // eax@3
   IconFrame *v3; // eax@3
@@ -5387,63 +5328,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 v108; // ST08_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
@@ -5451,7 +5370,7 @@
   int v115; // eax@82
   const char *uRaceName; // [sp+0h] [bp-170h]@39
   char Str1[200]; // [sp+10h] [bp-160h]@14
-  GUIWindow v118; // [sp+D8h] [bp-98h]@83
+  GUIWindow pWindow; // [sp+D8h] [bp-98h]@83
   int v119; // [sp+12Ch] [bp-44h]@18
   size_t v120; // [sp+130h] [bp-40h]@25
   int uY; // [sp+134h] [bp-3Ch]@18
@@ -5468,29 +5387,31 @@
   int uX; // [sp+160h] [bp-10h]@18
   unsigned int v133; // [sp+164h] [bp-Ch]@25
   int v134; // [sp+168h] [bp-8h]@14
-  char *Str; // [sp+16Ch] [bp-4h]@18
+  Player *pPlayer;
+  const char *pSkillName;
 
   uColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xD1u, 0xBBu, 0x61u);
   uColorTeal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xF7u, 0xF7u);
   uColorGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
   uColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   pRenderer->BeginScene();
-  pRenderer->DrawTextureRGB(0, 0, &stru_506F20);
-  v0 = pTexture_MAKESKY;
-  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2u, pTexture_MAKESKY);
-  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos++ - 640, 2u, v0);
-  if ( (signed int)uPlayerCreationUI_SkySliderPos > 640 )
-    uPlayerCreationUI_SkySliderPos = 0;
+  pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
+
+  uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
+  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
+  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - 640, 2, pTexture_MAKESKY);
+  //if (uPlayerCreationUI_SkySliderPos > 640)
+    //uPlayerCreationUI_SkySliderPos = 0;
   pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP);
+
   uTitleText = pGlobalTXT_LocalizationStrings[51];
-  uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38)
-                                      / 7;
-  v2 = pFontCChar->AlignText_Center(640u, pGlobalTXT_LocalizationStrings[51]);
+  uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7;
+  v2 = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]);
   pGUIWindow_CurrentMenu->DrawText(pFontCChar, v2 + 1, 0, 0, uTitleText, 0, 0, 0);
-  pRenderer->DrawTextureTransparent(17u, 35u, pPlayerPortraits[(char)pParty->pPlayers[0].uFace]);
-  pRenderer->DrawTextureTransparent(176u, 35u, pPlayerPortraits[(char)pParty->pPlayers[1].uFace]);
-  pRenderer->DrawTextureTransparent(335u, 35u, pPlayerPortraits[(char)pParty->pPlayers[2].uFace]);
-  pRenderer->DrawTextureTransparent(494u, 35u, pPlayerPortraits[(char)pParty->pPlayers[3].uFace]);
+  pRenderer->DrawTextureTransparent(17u, 35u, pPlayerPortraits[pParty->pPlayers[0].uFace]);
+  pRenderer->DrawTextureTransparent(176u, 35u, pPlayerPortraits[pParty->pPlayers[1].uFace]);
+  pRenderer->DrawTextureTransparent(335u, 35u, pPlayerPortraits[pParty->pPlayers[2].uFace]);
+  pRenderer->DrawTextureTransparent(494u, 35u, pPlayerPortraits[pParty->pPlayers[3].uFace]);
   v3 = pIconsFrameTable->GetFrame(uIconID_CharacterFrame, pEventTimer->uStartTime);
   if ( uPlayerCreationUI_SelectedCharacter )
   {
@@ -5514,14 +5435,18 @@
   {
     v4 = 12;
   }
+
   pRenderer->DrawTextureTransparent(v4, 29, &pIcons_LOD->pTextures[v3->uTextureID]);
-  uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->field_2C_focus_id);
-  pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim + 1]);
-  pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim-- + 1]);
-  if ( uPlayerCreationUI_ArrowAnim < 0 )
-    uPlayerCreationUI_ArrowAnim = 18;
-  v6 = LOBYTE(pFontCreate->uFontHeight) - 2;
-  v128 = LOBYTE(pFontCreate->uFontHeight) - 2;
+  uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->pCurrentPosActiveItem);
+
+  uPlayerCreationUI_ArrowAnim = 19 - (GetTickCount() % 500) / 25;
+  pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]);
+  pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]);
+  //if (uPlayerCreationUI_ArrowAnim < 0)
+  //  uPlayerCreationUI_ArrowAnim = 18;
+
+  v6 = pFontCreate->uFontHeight - 2;
+  v128 = pFontCreate->uFontHeight - 2;
   strcpy(Str1, pGlobalTXT_LocalizationStrings[205]);// "Skills"
   uNumLet = strlen(Str1) - 1;
   v134 = uNumLet;
@@ -5545,7 +5470,7 @@
   v122 = 5 * v6 + 169;
   v123 = 3 * v6 + 311;
   v129 = 493;
-  Str = pParty->pPlayers[0].pName;
+  pPlayer = pParty->pPlayers;
   v119 = 6 * v6 + 169;
   do
   {
@@ -5554,14 +5479,14 @@
       v134 + 73,
       100,
       0,
-      pClassNames[(unsigned __int8)Str[17]],
+      pClassNames[(unsigned __int8)pPlayer->uClass],
       0,
       0,
       0);
     pRenderer->DrawTextureTransparent(
       v134 + 77,
       50u,
-      *(&pTexture_IC_KNIGHT + ((unsigned int)(unsigned __int8)Str[17] >> 2)));
+      pTexture_IC_KNIGHT[pPlayer->uClass/4]);
     v11 = pGUIWindow_CurrentMenu->field_40;
     if ( v11 && (v12 = pGUIWindow_CurrentMenu->ptr_1C, v12 == v124) )
     {
@@ -5599,7 +5524,7 @@
           if ( v120 && v126 != v120 )
             strcpy(Str, (const char *)pKeyActionMap->pPressedKeysBuffer);
           pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, v134, 0x7Cu, 0, Str, 130, 0);
-          *((short *)Str + 3323) = 1;
+          *((short *)pPlayer->pName + 3323) = 1;
         }
       }
       else
@@ -5620,58 +5545,60 @@
     }
     else
     {
-      pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, v134, 0x7Cu, 0, Str, 130, 0);
-    }
-    uNumRace = ((Player *)(Str - 168))->GetRace();
+      pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, v134, 0x7Cu, 0, pPlayer->pName, 130, 0);
+    }
+    uNumRace = pPlayer->GetRace();
      switch (uNumRace)
     {
       case 0:  uRaceName = pGlobalTXT_LocalizationStrings[99]; break; // "Human"       
-      case 1:  uRaceName = pGlobalTXT_LocalizationStrings[101]; break; // "Dwarf"
+      case 1:  uRaceName = pGlobalTXT_LocalizationStrings[103]; break; // "Dwarf"
       case 2:  uRaceName = pGlobalTXT_LocalizationStrings[106]; break; // "Goblin"
-	  case 3:  uRaceName = pGlobalTXT_LocalizationStrings[103]; break; // "Elf"   
+	  case 3:  uRaceName = pGlobalTXT_LocalizationStrings[101]; break; // "Elf"   
     }; 
 	strcpy(pTmpBuf, uRaceName);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, v134 + 72, v128 + 12, 0, pTmpBuf, 130, 0);
     v21 = uColor1;
     v22 = pFontCreate->AlignText_Center(0x96u, Str1);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, v22 + uX - 24, 291, v21, Str1, 0, 0, 0);
-    uNumMight = ((Player *)(Str - 168))->GetActualMight();
+    uNumMight = pPlayer->GetActualMight();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[144], v129, uNumMight);// "Might"
-    LOWORD(v24) = ((Player *)(Str - 168))->GetStatColor(0);
+    LOWORD(v24) = pPlayer->GetStatColor(0);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 169, v24, pTmpBuf, 0, 0, 0);
-    v25 = ((Player *)(Str - 168))->GetActualIntelligence();
+    v25 = pPlayer->GetActualIntelligence();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[116], v129, v25);// "Intellect"
-    LOWORD(v26) = ((Player *)(Str - 168))->GetStatColor(1u);
+    LOWORD(v26) = pPlayer->GetStatColor(1u);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, v128 + 169, v26, pTmpBuf, 0, 0, 0);
-    v27 = ((Player *)(Str - 168))->GetActualWillpower();
+    v27 = pPlayer->GetActualWillpower();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[163], v129, v27);// "Personality"
-    LOWORD(v28) = ((Player *)(Str - 168))->GetStatColor(2u);
+    LOWORD(v28) = pPlayer->GetStatColor(2u);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 2 * v128 + 169, v28, pTmpBuf, 0, 0, 0);
-    v29 = ((Player *)(Str - 168))->GetActualEndurance();
+    v29 = pPlayer->GetActualEndurance();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[75], v129, v29);// "Endurance"
-    LOWORD(v30) = ((Player *)(Str - 168))->GetStatColor(3u);
+    LOWORD(v30) = pPlayer->GetStatColor(3u);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, uY, v30, pTmpBuf, 0, 0, 0);
-    v31 = ((Player *)(Str - 168))->GetActualAccuracy();
+    v31 = pPlayer->GetActualAccuracy();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[1], v129, v31);// "Accuracy"
-    LOWORD(v32) = ((Player *)(Str - 168))->GetStatColor(4u);
+    LOWORD(v32) = pPlayer->GetStatColor(4u);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 4 * v128 + 169, v32, pTmpBuf, 0, 0, 0);
-    v33 = ((Player *)(Str - 168))->GetActualSpeed();
+    v33 = pPlayer->GetActualSpeed();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[211], v129, v33);// "Speed"
-    LOWORD(v34) = ((Player *)(Str - 168))->GetStatColor(5u);
+    LOWORD(v34) = pPlayer->GetStatColor(5u);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, v122, v34, pTmpBuf, 0, 0, 0);
-    v35 = ((Player *)(Str - 168))->GetActualLuck();
+    v35 = pPlayer->GetActualLuck();
     sprintf(pTmpBuf, "%s\r%03d%d", pGlobalTXT_LocalizationStrings[136], v129, v35);// "Luck"
-    LOWORD(v36) = ((Player *)(Str - 168))->GetStatColor(6u);
+    LOWORD(v36) = pPlayer->GetStatColor(6u);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, v119, v36, pTmpBuf, 0, 0, 0);
-    v37 = ((Player *)(Str - 168))->GetSkillIdxByOrder(0);
-    v38 = pFontCreate->AlignText_Center(0x96u, pSkillNames[v37]);
-    sprintf(pTmpBuf, "\t%03u%s", v38);
+    v37 = pPlayer->GetSkillIdxByOrder(0);
+	pSkillName = pSkillNames[v37];
+    v38 = pFontCreate->AlignText_Center(0x96u, pSkillName);
+    sprintf(pTmpBuf, "\t%03u%s", v38, pSkillName);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 311, uColorWhite, pTmpBuf, 0, 0, 0);
-    v39 = ((Player *)(Str - 168))->GetSkillIdxByOrder(1);
-    v40 = pFontCreate->AlignText_Center(0x96u, pSkillNames[v39]);
-    sprintf(pTmpBuf, "\t%03u%s", v40);
+    v39 = pPlayer->GetSkillIdxByOrder(1);
+	pSkillName = pSkillNames[v39];
+    v40 = pFontCreate->AlignText_Center(0x96u, pSkillName);
+    sprintf(pTmpBuf, "\t%03u%s", v40, pSkillName);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, v128 + 311, uColorWhite, pTmpBuf, 0, 0, 0);
-    v41 = ((Player *)(Str - 168))->GetSkillIdxByOrder(2);
+    v41 = pPlayer->GetSkillIdxByOrder(2);
     v42 = pSkillNames[v41];
     v43 = pSkillNames[v41];
     v133 = v41;
@@ -5681,7 +5608,7 @@
     if ( (signed int)v133 >= 37 )
       v45 = uColorTeal;
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 2 * v128 + 311, v45, pTmpBuf, 0, 0, 0);
-    v46 = ((Player *)(Str - 168))->GetSkillIdxByOrder(3);
+    v46 = pPlayer->GetSkillIdxByOrder(3);
     v47 = pSkillNames[v46];
     v48 = pSkillNames[v46];
     v133 = v46;
@@ -5691,13 +5618,13 @@
     if ( (signed int)v133 >= 37 )
       v50 = uColorTeal;
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, v123, v50, pTmpBuf, 0, 0, 0);
-    Str += 6972;
+    pPlayer++;
     v124 = (char *)v124 + 1;
     v134 += 159;
     v129 -= 158;
     uX += 158;
   }
-  while ( (signed int)Str < (signed int)&pParty->pPickedItem.uNumCharges );
+  while ( (signed int)pPlayer->pName < (signed int)&pParty->pPickedItem.uNumCharges );
   strcpy(Str1, pGlobalTXT_LocalizationStrings[41]);// "Class"
   v51 = strlen(Str1) - 1;
   v134 = v51;
@@ -5714,86 +5641,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
   {
@@ -5803,29 +5709,32 @@
     v104 = 0;
     if ( (signed int)v103 > 0 )
     {
-      while ( Str1[v104] != 32 )
-      {
-        ++v104;
-        if ( v104 >= (signed int)v103 )
-          goto LABEL_77;
-      }
-      Str1[v104] = 0;
-    }
-LABEL_77:
+	  if ( Str1[v104] == 32 )
+	  {
+		Str1[v104] = 0;
+	  }
+	  else
+	  {
+		while ( Str1[v104] != 32 )
+		{
+		  ++v104;
+		  if ( v104 >= (signed int)v103 )
+		   break;
+		}
+	  }
+    }
     uColorGreen = -5;
     if ( (signed int)v124 <= 3 )
       uColorGreen = 0;
     v105 = uColorTeal;
     if ( !pParty->pPlayers[0].pActiveSkills[v102 + 3486 * uPlayerCreationUI_SelectedCharacter] )
       v105 = uColorWhite;
-    v106 = v134 / 3;
     v107 = v105;
-    v108 = v128 * v134 % 3 + 417;
-    v109 = pFontCreate->AlignText_Center(100u, Str1);
+	v109 = pFontCreate->AlignText_Center(100u, Str1);
     pGUIWindow_CurrentMenu->DrawText(
       pFontCreate,
-      100 * v106 + v109 + uColorGreen + 17,
-      v108,
+      100 * (v134 / 3) + v109 + uColorGreen + 17,
+      v128 * (v134 % 3) + 417,
       v107,
       Str1,
       0,
@@ -5834,10 +5743,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;
@@ -5845,16 +5753,16 @@
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, v115 + 530, 410, v114, pTmpBuf, 0, 0, 0);
   if ( GameUI_StatusBar_TimedStringTimeLeft > GetTickCount() )
   {
-    v118.str_48 = pGlobalTXT_LocalizationStrings[412];// "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points."
+    pWindow.Hint = pGlobalTXT_LocalizationStrings[412];// "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points."
     if ( v113 < 0 )
-      v118.str_48 = pGlobalTXT_LocalizationStrings[413];// "You can't spend more than 50 points."
-    v118.uFrameWidth = 300;
-    v118.uFrameHeight = 100;
-    v118.uFrameX = 170;
-    v118.uFrameY = 140;
-    v118.uFrameZ = 469;
-    v118.uFrameW = 239;
-    v118._415551(0);
+      pWindow.Hint = pGlobalTXT_LocalizationStrings[413];// "You can't spend more than 50 points."
+    pWindow.uFrameWidth = 300;
+    pWindow.uFrameHeight = 100;
+    pWindow.uFrameX = 170;
+    pWindow.uFrameY = 140;
+    pWindow.uFrameZ = 469;
+    pWindow.uFrameW = 239;
+    pWindow.DrawMessageBox(0);
   }
   pRenderer->EndScene();
 }
@@ -5884,20 +5792,20 @@
   ++pIcons_LOD->uTexturePacksCount;
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 21;
+  pCurrentScreen = 21;
   uPlayerCreationUI_ArrowAnim = 0;
   uPlayerCreationUI_SkySliderPos = 0;
   uPlayerCreationUI_SelectedCharacter = 0;
   v0 = LOBYTE(pFontCreate->uFontHeight) - 2;
-  pTexture_IC_KNIGHT = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_KNIGHT", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_THIEF  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_THIEF", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_MONK   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_MONK", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_PALAD  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_PALAD", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_ARCH   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_ARCH", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_RANGER = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_RANGER", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_CLER   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_CLER", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_DRUID  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_DRUID", TEXTURE_16BIT_PALETTE)];
-  pTexture_IC_SORC   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_SORC", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_KNIGHT", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[1] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_THIEF", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[2] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_MONK", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[3] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_PALAD", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[4] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_ARCH", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[5] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_RANGER", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[6] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_CLER", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[7] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_DRUID", TEXTURE_16BIT_PALETTE)];
+  pTexture_IC_KNIGHT[8] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("IC_SORC", TEXTURE_16BIT_PALETTE)];
   pTexture_MAKETOP   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("MAKETOP", TEXTURE_16BIT_PALETTE)];
   uX = 0;
   pTexture_MAKESKY = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("MAKESKY", TEXTURE_16BIT_PALETTE)];
@@ -5931,7 +5839,7 @@
   uXa = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, 0x3Cu, uControlParama, 0, nullstring, 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, 0x3Cu, uControlParama, 0, "", 0);
     uXa += 158;
     ++uControlParama;
   }
@@ -5946,7 +5854,7 @@
                                   0xABu,
                                   0,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5959,7 +5867,7 @@
                                   0xABu,
                                   1u,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5972,7 +5880,7 @@
                                   0xABu,
                                   2u,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5985,7 +5893,7 @@
                                   0xABu,
                                   3u,
                                   0,
-                                  nullstring,
+                                  "",
                                   pTexture_presleft,
                                   0);
   pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(
@@ -5998,7 +5906,7 @@
                                    0xACu,
                                    0,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6011,7 +5919,7 @@
                                    0xACu,
                                    1u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6024,7 +5932,7 @@
                                    0xACu,
                                    2u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6037,7 +5945,7 @@
                                    0xACu,
                                    3u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_pressrigh,
                                    0);
   pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6050,7 +5958,7 @@
                                    0x90u,
                                    0,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6063,7 +5971,7 @@
                                    0x90u,
                                    1u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6076,7 +5984,7 @@
                                    0x90u,
                                    2u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6089,7 +5997,7 @@
                                    0x90u,
                                    3u,
                                    0,
-                                   nullstring,
+                                   "",
                                    pTexture_presleft,
                                    0);
   pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6102,7 +6010,7 @@
                                     0x91u,
                                     0,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6115,7 +6023,7 @@
                                     0x91u,
                                     1u,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6128,7 +6036,7 @@
                                     0x91u,
                                     2u,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(
@@ -6141,14 +6049,14 @@
                                     0x91u,
                                     3u,
                                     0,
-                                    nullstring,
+                                    "",
                                     pTexture_pressrigh,
                                     0);
   uControlParamb = 0;
   uXb = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 308u, 150u, v0, 1, 0, 0x48u, uControlParamb, 0, nullstring, 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 308u, 150u, v0, 1, 0, 0x48u, uControlParamb, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXb,
       v0 + 308,
@@ -6159,7 +6067,7 @@
       0x49u,
       uControlParamb,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXb,
@@ -6171,7 +6079,7 @@
       0x4Au,
       uControlParamb,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXb,
@@ -6183,21 +6091,21 @@
       0x4Bu,
       uControlParamb,
       0,
-      nullstring,
+      "",
       0);
     uXb += 158;
     ++uControlParamb;
   }
   while ( (signed int)uXb < 640 );
-  pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 0, 0x31u, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 1u, 0x32u, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 2u, 0x33u, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 3u, 0x34u, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 0, 0x31u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 1u, 0x32u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 2u, 0x33u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, 0x76u, 3u, 0x34u, "", 0);
   uXc = 23;
   uControlParamc = 2;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 169u, 120u, 20u, 1, 0, 0, uControlParamc - 2, 0, nullstring, 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXc, 169u, 120u, 20u, 1, 0, 0, uControlParamc - 2, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
       v0 + 169,
@@ -6208,7 +6116,7 @@
       0,
       uControlParamc - 1,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6220,7 +6128,7 @@
       0,
       uControlParamc,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6232,7 +6140,7 @@
       0,
       uControlParamc + 1,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6244,7 +6152,7 @@
       0,
       uControlParamc + 2,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6256,7 +6164,7 @@
       0,
       uControlParamc + 3,
       0,
-      nullstring,
+      "",
       0);
     pGUIWindow_CurrentMenu->CreateButton(
       uXc,
@@ -6268,22 +6176,22 @@
       0,
       uControlParamc + 4,
       0,
-      nullstring,
+      "",
       0);
     uControlParamc += 7;
     uXc += 158;
   }
   while ( (signed int)uControlParamc < 30 );
   pGUIWindow_CurrentMenu->_41D08F(28, 0, 7, 40);
-  pGUIWindow_CurrentMenu->CreateButton(323u, 417u, 65u, v0, 1, 0, 0x41u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(323u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0xCu, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(323u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x14u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(388u, 417u, 65u, v0, 1, 0, 0x41u, 0x18u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(388u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0x1Cu, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(388u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x20u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(453u, 417u, 65u, v0, 1, 0, 0x41u, 0x10u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(453u, v0 + 417, 65u, v0, 1, 0, 0x41u, 8u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(453u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 4u, 0, nullstring, 0);
+  pGUIWindow_CurrentMenu->CreateButton(323u, 417u, 65u, v0, 1, 0, 0x41u, 0, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0xCu, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x14u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388u, 417u, 65u, v0, 1, 0, 0x41u, 0x18u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388u, v0 + 417, 65u, v0, 1, 0, 0x41u, 0x1Cu, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 0x20u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453u, 417u, 65u, v0, 1, 0, 0x41u, 0x10u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453u, v0 + 417, 65u, v0, 1, 0, 0x41u, 8u, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453u, 2 * v0 + 417, 65u, v0, 1, 0, 0x41u, 4u, 0, "", 0);
   uControlParamd = 0;
   do
   {
@@ -6291,8 +6199,8 @@
     if ( uControlParamd <= 3 )
       uXd = 0;
     pGUIWindow_CurrentMenu->CreateButton(
-      100 * uControlParamd / 3 + uXd + 17,
-      v0 * uControlParamd % 3 + 417,
+      100 * (uControlParamd / 3) + uXd + 17,
+      v0 * (uControlParamd % 3) + 417,
       100u,
       v0,
       1,
@@ -6300,7 +6208,7 @@
       0x40u,
       uControlParamd,
       0,
-      nullstring,
+      "",
       0);
     ++uControlParamd;
   }
@@ -6315,7 +6223,7 @@
                               0x42u,
                               0,
                               0xDu,
-                              nullstring,
+                              "",
                               (Texture *)(uTextureID_BUTTMAKE != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE] : 0),
                               0);
   pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(
@@ -6328,7 +6236,7 @@
                                  0x43u,
                                  0,
                                  0x43u,
-                                 nullstring,
+                                 "",
                                  (Texture *)(uTextureID_BUTTMAKE2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0),
                                  0);
   pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(
@@ -6341,7 +6249,7 @@
                                  0x3Fu,
                                  0,
                                  0x2Du,
-                                 nullstring,
+                                 "",
                                  pTexture_buttminu,
                                  0);
   pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(
@@ -6354,12 +6262,12 @@
                                 0x3Eu,
                                 1u,
                                 0x2Bu,
-                                nullstring,
+                                "",
                                 pTexture_buttplus,
                                 0);
   pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0);
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0049750E) --------------------------------------------------------
 void __cdecl DeleteCCharFont()
@@ -6390,20 +6298,20 @@
   signed int v16; // ecx@70
   unsigned int v18; // [sp-4h] [bp-84h]@48
   ItemGen item; // [sp+Ch] [bp-74h]@37
-  char v20; // [sp+30h] [bp-50h]@29
-  char v21; // [sp+31h] [bp-4Fh]@29
-  __int16 v22; // [sp+4Dh] [bp-33h]@29
+  char v20[32]; // [sp+30h] [bp-50h]@29
+  //char v21; // [sp+31h] [bp-4Fh]@29
+  //__int16 v22; // [sp+4Dh] [bp-33h]@29
   char v23; // [sp+4Fh] [bp-31h]@29
   MSG Msg; // [sp+50h] [bp-30h]@17
   POINT v25; // [sp+6Ch] [bp-14h]@6
   bool v26; // [sp+74h] [bp-Ch]@1
   POINT v24; // [sp+78h] [bp-8h]@6
 
-  v0 = &stru_506F20;
+  v0 = &pTexture_PCX;
   v1 = 0;
   v26 = 0;
-  stru_506F20.Release();
-  stru_506F20.Load("makeme.pcx", 0);
+  pTexture_PCX.Release();
+  pTexture_PCX.Load("makeme.pcx", 0);
   if (pAsyncMouse)
     pAsyncMouse->Resume();
   v2 = 6;
@@ -6422,7 +6330,7 @@
       v6 = pMessageQueue_50CBD0->uNumMessages;
       do
       {
-        if ( uMouseX >= (signed int)v5->uX
+        if ( uMouseX >= (signed int)v5->uX //mouse movement
           && uMouseX <= (signed int)v5->uZ
           && uMouseY >= (signed int)v5->uY
           && uMouseY <= (signed int)v5->uW )
@@ -6431,7 +6339,7 @@
           if ( (signed int)v6 < 40 )
           {
             pMessageQueue_50CBD0->pMessages[v6].eType = (UIMessageType)v5->field_1C;
-            v0 = &stru_506F20;
+            v0 = &pTexture_PCX;
             pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v7;
             *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
             v6 = pMessageQueue_50CBD0->uNumMessages + 1;
@@ -6479,17 +6387,17 @@
   v0->Release();
   pGUIWindow_CurrentMenu->Release();
   pIcons_LOD->_4114F2();
-  v20 = 0;
-  memset(&v21, 0, 0x1Cu);
-  v22 = 0;
-  v23 = 0;
+  v20[0] = 0;
+  memset(&v20[1], 0, 0x1Cu);
+  *(_WORD*)&v20[29] = 0;
+  v20[31] = 0;
   do
   {
     v8 = 0;
     do
     {
       v9 = rand() % 32;
-      if ( !*(&v20 + v9) )
+      if ( !v20[v9] )
         break;
       ++v8;
     }
@@ -6497,15 +6405,15 @@
     if ( v8 == 10 )
     {
       v9 = 0;
-      if ( v20 )
+      if ( v20[0] )
       {
         do
           ++v9;
-        while ( *(&v20 + v9) );
+        while ( v20[v9] );
       }
     }
     pParty->field_854[v1++] = v9;
-    *(&v20 + v9) = 1;
+    v20[v9] = 1;
   }
   while ( (signed int)v1 < 32 );
   item.Reset();
@@ -6760,8 +6668,8 @@
     (signed __int16)v21.uWidth);
   free(pString);
   pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr);
-  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, nullstring, 0);
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 9;
+  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, "", 0);
+  pCurrentScreen = 9;
   SetCurrentMenuID(MENU_Credits);
   pRenderer->BeginScene();
   pRenderer->DrawTextureRGB(0, 0, &v16);
@@ -6901,16 +6809,16 @@
   {
     result = 1;
   }
-  v3->vNormal.x = v.x;
-  v3->vNormal.y = v.y;
-  v3->vNormal.z = v.z;
-  v3->field_10 = *(float *)&a3;
-  v3->field_14 = result;
+  v3->face_plane.vNormal.x = v.x;
+  v3->face_plane.vNormal.y = v.y;
+  v3->face_plane.vNormal.z = v.z;
+  v3->face_plane.dist = *(float *)&a3;
+  v3->polygonType = (PolygonType)result;
   return result;
 }
 
 //----- (0049B0C9) --------------------------------------------------------
-int stru154::_49B0C9(Vec3_float_ *pNormal, float a3)
+int stru154::_49B0C9(Vec3_float_ *pNormal, float dist)
 {
   signed int v3; // esi@1
   signed int result; // eax@9
@@ -6944,11 +6852,11 @@
   v5 = pNormal->z;
   v6 = pNormal->y;
   v7 = pNormal->x;
-  this->field_14 = result;
-  this->vNormal.x = v7;
-  this->field_10 = a3;
-  this->vNormal.y = v6;
-  this->vNormal.z = v5;
+  this->polygonType = (PolygonType)result;
+  this->face_plane.vNormal.x = v7;
+  this->face_plane.dist = dist;
+  this->face_plane.vNormal.y = v6;
+  this->face_plane.vNormal.z = v5;
   return result;
 }
 
@@ -7130,109 +7038,9 @@
 }
 
 
-//----- (004A1C1E) --------------------------------------------------------
-void __cdecl DoRenderBillboards_D3D()
-{
-  signed int v0; // ebp@1
-  signed int *v1; // esi@2
-  //IDirect3DDevice3Vtbl *v2; // esi@7
-  unsigned int v3; // eax@7
-  unsigned int v4; // [sp+58h] [bp-4h]@2
-
-  v0 = -1;
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
-  if ( ((pRenderer->uNumBillboardsToDraw - 1) & 0x80000000u) == 0 )
-  {
-    v1 = (signed int *)&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - 1].bOpaque;
-    v4 = pRenderer->uNumBillboardsToDraw;
-    do
-    {
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(
-        0,
-        (IDirect3DTexture2 *)*(v1 - 35)));
-      if ( *v1 != v0 )
-      {
-        v0 = *v1;
-        SetBillboardBlendOptions(*v1);
-      }
-      ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
-        D3DPT_TRIANGLEFAN,
-        452,
-        v1 - 33,
-        *(v1 - 34),
-        24));
-      v1 -= 39;
-      --v4;
-    }
-    while ( v4 );
-  }
-  if ( pRenderer->turnFogOn )
-  {
-    pRenderer->turnFogOn = 0;
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
-    //v2 = pRenderer->pRenderD3D->pDevice->lpVtbl;
-    v3 = GetLevelFogColor();
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v3 & 0xFFFFFF));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
-  }
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
-}
-
-//----- (004A1DA8) --------------------------------------------------------
-void __fastcall SetBillboardBlendOptions(signed int a1)
-{
-  //IDirect3DDevice3Vtbl *v1; // edi@9
-  unsigned int v2; // eax@9
-  int v3; // [sp+0h] [bp-4h]@0
-
-  if ( !a1 )
-  {
-    if ( pRenderer->turnFogOn )
-    {
-      pRenderer->turnFogOn = 0;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
-      //v1 = pRenderer->pRenderD3D->pDevice->lpVtbl;
-      v2 = GetLevelFogColor();
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v2 & 0xFFFFFF));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
-    }
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1));
-    return;
-  }
-  if ( a1 > 0 && a1 <= 3 )
-  {
-    if ( pRenderer->bUsingSpecular )
-    {
-      if ( !pRenderer->turnFogOn )
-      {
-        pRenderer->turnFogOn = 1;
-        ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
-      }
-    }
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
-  }
-}
-
-
-
-
-
-
 
 //----- (004A46E6) --------------------------------------------------------
-int __fastcall sub_4A46E6(unsigned int x, signed int y, signed int a3, int a4, unsigned int a5)
+int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
 {
   int v5; // eax@1
   int z; // eax@1
@@ -7255,7 +7063,7 @@
   signed int v23; // [sp+20h] [bp+Ch]@1
 
   v5 = a4;
-  v23 = a3 >> 16;
+  v23 = _z >> 16;
   z = x + v5;
   if ( z >= (signed int)pViewport->uViewportX
     && (signed int)x <= (signed int)pViewport->uViewportZ
@@ -7269,12 +7077,12 @@
     pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
     v22 = z - x;
     pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
-    v7 = a5 >> 3;
-    v8 = a5 & 0xF0;
+    v7 = lightColor >> 3;
+    v8 = lightColor & 0xF0;
     v9 = v7 & 0x1E0000;
     if ( pRenderer->uTargetGBits == 5 )
     {
-      v10 = (v8 | (((unsigned __int16)(a5 & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
+      v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
       v11 = (int *)pTarget;
       v12 = pTargetZ;
       v13 = v22;
@@ -7321,7 +7129,7 @@
     }
     else
     {
-      v15 = (v8 | (((unsigned __int16)(a5 & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
+      v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
       v16 = (int *)pTarget;
       v17 = pTargetZ;
       v18 = v22;
@@ -7482,12 +7290,13 @@
         v1 = pRenderer->pTargetSurface;
         v2 = Dst.lpSurface;
 
-        for (uint y = 0; y < 480; ++y)
+
+        /*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;
         auto pDst = (__int16 *)Dst.lpSurface;
@@ -7526,9 +7335,16 @@
         v13 = v24;
 
         for (uint y = pViewport->uViewportY; y < pViewport->uViewportW; ++y)
-          memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
-                 pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
-        
+        {
+          //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
+          //       pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
+          for (uint x = pViewport->uViewportX; x < pViewport->uViewportZ; ++x)
+          {
+            if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
+              pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
+          }
+        }
+
               ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
 
        /* while ( 1 )
@@ -8124,7 +7940,7 @@
               v6 = stru_F8AD28.pDeltaUV[0];
               v116 = stru_F8AD28.pDeltaUV[1];
               v7 = 0;
-              for ( i = bUseLoResSprites; v7 < stru_F8AD28.field_AC; *(int *)v9 = v10 )
+              for ( i = bUseLoResSprites; v7 < stru_F8AD28.uNumLightsApplied; *(int *)v9 = v10 )
               {
                 v8 = v116;
                 stru_F8AD28._blv_lights_xs[v7] += v6;
@@ -8623,7 +8439,7 @@
           v48 = v9;
           v50 = v10;
           sub_4AF412();
-          ++pBLVRenderParams->field_80;
+          ++pBLVRenderParams->uNumFacesRenderedThisFrame;
           v11 = sr_sub_47C24C_get_palette(v2, v4->palette_id2, 0, 1);
           v12 = stru_F8A590._viewport_space_y;
           v51 = v11;
@@ -8889,11 +8705,11 @@
 
   v2 = a1 >> SLOBYTE(stru_F8AD28.field_38);
   v3 = a2 >> SLOBYTE(stru_F8AD28.field_38);
-  v17 = stru_F8AD28.field_2C;
+  v17 = stru_F8AD28.uCurrentAmbientLightLevel;
   v4 = 0;
   v15 = v2;
   v16 = 0;
-  if ( stru_F8AD28.field_AC > 0 )
+  if ( stru_F8AD28.uNumLightsApplied > 0 )
   {
     do
     {
@@ -8926,7 +8742,7 @@
       ++v16;
       v2 = v15;
     }
-    while ( v16 < stru_F8AD28.field_AC );
+    while ( v16 < stru_F8AD28.uNumLightsApplied );
     v4 = 0;
   }
   if ( stru_F8AD28.field_3E4 != v4 )
@@ -9070,7 +8886,7 @@
   stru_F8AD28.vec_20.x = v66.x;
   stru_F8AD28.vec_20.y = v66.y;
   stru_F8AD28.vec_20.z = v66.z;
-  stru_F8AD28.field_3F8 = v2->field_22;
+  stru_F8AD28.uDefaultAmbientLightLevel = v2->field_22;
   if ( pBLVRenderParams->sPartyRotX )
   {
     v74 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16;
@@ -9191,11 +9007,11 @@
   v69 = v17;
   v74 = 0;
   v73 = 0;
-  stru_F8AD28.field_2C = (stru_F8AD28.field_3F8 + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16;
-  v70 = uNumMobileLightsApplied;
-  if ( uNumMobileLightsApplied > 0 )
-  {
-    v18 = (char *)&pMobileLights[0].vPosition.y;
+  stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16;
+  v70 = pMobileLightsStack->uNumLightsActive;
+  if ( pMobileLightsStack->uNumLightsActive > 0 )
+  {
+    v18 = (char *)&pMobileLightsStack->pLights[0].vPosition.y;
     do
     {
       if ( v74 >= 20 )
@@ -9244,7 +9060,7 @@
                     v28 = v74;
                     v29 = v18[9];
                     ++v74;
-                    stru_F8AD28._blv_lights_smthngs[v28] = v29;
+                    stru_F8AD28._blv_lights_types[v28] = v29;
                   }
                 }
               }
@@ -9312,7 +9128,7 @@
                         v16 = 0.0039215689;
                         stru_F8AD28._blv_lights_light_dot_faces[v39] = abs(v38);
                         v40 = v74++;
-                        stru_F8AD28._blv_lights_smthngs[v40] = 1;
+                        stru_F8AD28._blv_lights_types[v40] = 1;
                       }
                     }
                   }
@@ -9329,9 +9145,9 @@
     }
   }
   v73 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
-  {
-    v41 = (char *)&pStationaryLights[0].vPosition.y;
+  if ( pStationaryLightsStack->uNumLightsActive > 0 )
+  {
+    v41 = (char *)&pStationaryLightsStack->pLights[0].vPosition.y;
     do
     {
       if ( v74 >= 20 )
@@ -9380,7 +9196,7 @@
                       v16 = 0.0039215689;
                       stru_F8AD28._blv_lights_light_dot_faces[v48] = abs(v47);
                       v52 = v74++;
-                      stru_F8AD28._blv_lights_smthngs[v52] = 1;
+                      stru_F8AD28._blv_lights_types[v52] = 1;
                     }
                   }
                 }
@@ -9392,9 +9208,9 @@
       ++v73;
       v41 += 12;
     }
-    while ( v73 < uNumStationaryLightsApplied );
-  }
-  stru_F8AD28.field_AC = v74;
+    while ( v73 < pStationaryLightsStack->uNumLightsActive );
+  }
+  stru_F8AD28.uNumLightsApplied = v74;
   v53 = v1->pBounding.x2;
   if ( pBLVRenderParams->vPartyPos.x <= v53 )
   {
@@ -9497,7 +9313,7 @@
   stru_F8AD28.vec_14.z = 0;
   stru_F8AD28.vec_20.x = 0;
   stru_F8AD28.vec_20.z = 0;
-  stru_F8AD28.field_3F8 = 0;
+  stru_F8AD28.uDefaultAmbientLightLevel = 0;
   if ( pBLVRenderParams->sPartyRotX )
   {
     v0 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16)
@@ -9595,8 +9411,8 @@
                          + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v7) >> 16));
   stru_F8AD28.field_38 = 0;
   stru_F8AD28.field_3E4 = 0;
-  stru_F8AD28.field_2C = 0;
-  stru_F8AD28.field_AC = 0;
+  stru_F8AD28.uCurrentAmbientLightLevel = 0;
+  stru_F8AD28.uNumLightsApplied = 0;
   stru_F8AD28.field_34 = 0;
   return result;
 }
@@ -9702,7 +9518,7 @@
     v3 = pMouse->GetCursorPos(&a2)->y + 30;
   else
     v3 = 30;
-  a1.str_48 = 0;
+  a1.Hint = 0;
   a1.uFrameY = v3;
   a1.uFrameWidth = 328;
   a1.uFrameHeight = 68;
@@ -9745,7 +9561,7 @@
   if ( (signed int)a1.uFrameHeight < 150 )
     a1.uFrameHeight = 150;
   a1.uFrameWidth = 460;
-  a1._415551(0);
+  a1.DrawMessageBox(0);
   a1.uFrameWidth -= 12;
   a1.uFrameHeight -= 12;
   v7 = pSpellStats->pInfos[v1].pName;
@@ -9780,12 +9596,12 @@
   pPlayer = pPlayers[uActiveCharacter];
   if ( pPlayer->CanAct() )
   {
-    pDialogueWindow->field_28 = dword_F8B1E0;
+    pDialogueWindow->pNumPresenceButton = dword_F8B1E0;
     result = 1;
   }
   else
   {
-    pDialogueWindow->field_28 = 0;
+    pDialogueWindow->pNumPresenceButton = 0;
     memcpy(&v4, pGUIWindow0, sizeof(v4));
     v4.uFrameX = 483;
     v4.uFrameWidth = 148;
@@ -10908,8 +10724,8 @@
   v52.uFrameX = 483;
   v52.uFrameWidth = 148;
   v52.uFrameZ = 334;
-  v56 = v52.field_38;
-  if ( v52.field_38 < v52.field_38 + v52.field_28 )
+  v56 = v52.pStartingPosActiveItem;
+  if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton )
   {
     v15 = (char *)v54;
     while ( 1 )
@@ -10957,7 +10773,7 @@
           sprintfex(pTmpBuf, &byte_4F0F98, v32, v31, v30);
           sprintfex(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
           ptr_F8B1E8 = pTmpBuf2;
-          v15 = nullstring;
+          v15 = "";
           goto LABEL_45;
         }
         if ( v28 != 10 )
@@ -10973,7 +10789,7 @@
           if ( !v15 )
           {
             v16->uControlParam = 0;
-            v15 = nullstring;
+            v15 = "";
           }
           goto LABEL_49;
         }
@@ -10993,7 +10809,7 @@
             if ( !v15 )
             {
               v16->uControlParam = 0;
-              v15 = nullstring;
+              v15 = "";
             }
             if ( uDialogueType != 84 )
               goto LABEL_49;
@@ -11020,7 +10836,7 @@
             goto LABEL_33;
           }
 LABEL_41:
-          v15 = nullstring;
+          v15 = "";
           goto LABEL_49;
         }
         v15 = pGlobalTXT_LocalizationStrings[122];
@@ -11028,7 +10844,7 @@
 LABEL_49:
       strcpy(v16->pButtonName, v15);
       ++v56;
-      if ( v56 >= v52.field_38 + v52.field_28 )
+      if ( v56 >= v52.pStartingPosActiveItem + v52.pNumPresenceButton )
       {
         v14 = pDialogueWindow;
         break;
@@ -11038,10 +10854,10 @@
   v34 = 0;
   v54 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v35 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v36 = v14->field_38;
+  v36 = v14->pStartingPosActiveItem;
   v55 = v35;
-  for ( i = v36 + v14->field_28; (signed int)v36 < (signed int)i; i = pDialogueWindow->field_28
-                                                                    + pDialogueWindow->field_38 )
+  for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton
+                                                                    + pDialogueWindow->pStartingPosActiveItem )
   {
     v37 = v14->GetControl(v36);
     v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0);
@@ -11049,7 +10865,7 @@
     v34 += v38;
     ++v36;
   }
-  v39 = v14->field_28;
+  v39 = v14->pNumPresenceButton;
   if ( v39 )
   {
     v58 = (NPCData *)((174 - v34) / v39);
@@ -11057,7 +10873,7 @@
       v58 = (NPCData *)32;
     pInString = (char *)2;
     v40 = (174 - (signed int)v58 * v39 - v34) / 2 - (signed int)v58 / 2 + 138;
-    v56 = v14->field_38;
+    v56 = v14->pStartingPosActiveItem;
     i = v56;
     if ( (signed int)i < (signed int)(i + v39) )
     {
@@ -11073,13 +10889,13 @@
         v40 = v45 + v44 - 1;
         v42->uW = v40;
         v46 = v55;
-        if ( (char *)pDialogueWindow->field_2C_focus_id != pInString )
+        if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString )
           v46 = v54;
         v52.DrawText2(pFontArrus, 0, v45, v46, v43, 3u);
         v14 = pDialogueWindow;
         ++pInString;
         ++v56;
-        i = pDialogueWindow->field_28 + pDialogueWindow->field_38;
+        i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
         if ( v56 >= (signed int)i )
           break;
         i = v56;
@@ -11126,7 +10942,7 @@
            0x195u,
            a2,
            0,
-           nullstring,
+           "",
            0);
 }
 
@@ -11505,8 +11321,8 @@
   }
 LABEL_107:
   pDialogueWindow->_41D08F(a2, 1, 0, 2);
-  result = pDialogueWindow->field_28;
-  dword_F8B1E0 = pDialogueWindow->field_28;
+  result = pDialogueWindow->pNumPresenceButton;
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
   return result;
 }
 
@@ -11530,8 +11346,8 @@
     }
   }
   pDialogueWindow->_41D08F(v1, 1, 0, 2);
-  result = pDialogueWindow->field_28;
-  dword_F8B1E0 = pDialogueWindow->field_28;
+  result = pDialogueWindow->pNumPresenceButton;
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
   return result;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
@@ -11572,8 +11388,8 @@
     }
   }
 LABEL_7:
-  result = pDialogueWindow->field_28;
-  dword_F8B1E0 = pDialogueWindow->field_28;
+  result = pDialogueWindow->pNumPresenceButton;
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
   return result;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
@@ -11772,8 +11588,8 @@
       break;
   }
 LABEL_43:
-  result = pDialogueWindow->field_28;
-  dword_F8B1E0 = pDialogueWindow->field_28;
+  result = pDialogueWindow->pNumPresenceButton;
+  dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
   return result;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
@@ -11846,7 +11662,7 @@
                  pGlobalTXT_LocalizationStrings[34],
                  (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(
     0x1E0u,
     0xA0u,
@@ -11876,7 +11692,7 @@
   _4B254D_SkillMasteryTeacher(a4);
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
-  v2 = nullstring;
+  v2 = "";
   ptr_5076F4 = pDialogueWindow->CreateButton(
                  0x1D7u,
                  0x1BDu,
@@ -11890,7 +11706,7 @@
                  pGlobalTXT_LocalizationStrings[34],
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   if ( dword_F8B1A8 )
     v2 = pGlobalTXT_LocalizationStrings[535];
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x4Fu, 0, v2, 0);
@@ -11923,7 +11739,7 @@
                  pGlobalTXT_LocalizationStrings[34],
                  (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                  0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, nullstring, 0);
+  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   if ( *(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
   {
     pDialogueWindow->CreateButton(
@@ -12052,7 +11868,7 @@
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
                    0);
-    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, nullstring, 0);
+    pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
     if ( array_5913D8[6] == (NPCData *)1 && dword_591080 )
     {
       result = (GUIButton *)sub_4B3B42(dword_F8B198);
@@ -12062,7 +11878,7 @@
       if ( v17->joins )
       {
         v1 = 1;
-        pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, nullstring, 0);
+        pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, "", 0);
       }
       v5 = (void *)v17->bDrawSomeAnim;
       if ( v5 )
@@ -12081,7 +11897,7 @@
               0xAFu,
               0x13u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12102,7 +11918,7 @@
               0xAFu,
               0x14u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12123,7 +11939,7 @@
               0xAFu,
               0x15u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12144,7 +11960,7 @@
               0xAFu,
               0x16u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12165,7 +11981,7 @@
               0xAFu,
               0x17u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
@@ -12186,14 +12002,14 @@
               0xAFu,
               0x18u,
               0,
-              nullstring,
+              "",
               0);
         }
       }
       pDialogueWindow->_41D08F(v1, 1, 0, 2);
       v4 = 1;
-      result = (GUIButton *)pDialogueWindow->field_28;
-      dword_F8B1E0 = pDialogueWindow->field_28;
+      result = (GUIButton *)pDialogueWindow->pNumPresenceButton;
+      dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
     }
     dword_F8B19C = v4;
   }
@@ -12359,8 +12175,8 @@
             v73 = v14 * (100 - v0->GetMerchant()) / 100;
             if ( v73 < v14 / 3 )
               v73 = v14 / 3;
-            v15 = v13->field_38;
-            v16 = v13->field_28;
+            v15 = v13->pStartingPosActiveItem;
+            v16 = v13->pNumPresenceButton;
             v72 = 0;
             if ( (signed int)v15 >= (signed int)(v15 + v16) )
               goto LABEL_76;
@@ -12375,7 +12191,7 @@
               }
               ++v15;
             }
-            while ( (signed int)v15 < v13->field_28 + v13->field_38 );
+            while ( (signed int)v15 < v13->pNumPresenceButton + v13->pStartingPosActiveItem );
             if ( v72 )
             {
               sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
@@ -12383,11 +12199,11 @@
               v73 = (signed int)(149 - i) / v72;
               if ( v73 > 32 )
                 v73 = 32;
-              result = v13->field_38;
+              result = v13->pStartingPosActiveItem;
               v19 = (signed int)(149 - v72 * v73 - i) / 2 - v73 / 2 + 162;
               i = result;
               v68 = v19;
-              if ( result < result + v13->field_28 )
+              if ( result < result + v13->pNumPresenceButton )
               {
                 v72 = 2;
                 do
@@ -12413,13 +12229,13 @@
                     v21->uW = v26;
                     v68 = v26;
                     v27 = v71;
-                    if ( pDialogueWindow->field_2C_focus_id != v72 )
+                    if ( pDialogueWindow->pCurrentPosActiveItem != v72 )
                       v27 = white;
                     v65.DrawText2(pFontArrus, 0, v25, v27, (char *)HIDWORD(v66), 3u);
                   }
-                  v28 = v13->field_38;
+                  v28 = v13->pStartingPosActiveItem;
                   ++i;
-                  result = v13->field_28 + v28;
+                  result = v13->pNumPresenceButton + v28;
                   ++v72;
                 }
                 while ( (signed int)i < result );
@@ -12447,7 +12263,7 @@
         v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0);
         v65.DrawText2(pFontArrus, 0, (212 - v33) / 2 + 101, v32, v31, 3u);
         result = (int)pDialogueWindow;
-        pDialogueWindow->field_28 = 0;
+        pDialogueWindow->pNumPresenceButton = 0;
         return result;
       }
       v34 = v0->uLevel;
@@ -12537,8 +12353,8 @@
       v72 = 0;
       pShopOptions[0] = pTmpBuf;
       pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills"
-      v44 = pDialogueWindow->field_28;
-      v73 = pDialogueWindow->field_38;
+      v44 = pDialogueWindow->pNumPresenceButton;
+      v73 = pDialogueWindow->pStartingPosActiveItem;
       if ( v73 < v73 + v44 )
       {
         v45 = pShopOptions;
@@ -12576,14 +12392,14 @@
           ++v45;
           ++v73;
         }
-        while ( v73 < pDialogueWindow->field_28 + pDialogueWindow->field_38 );
+        while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
       }
       HIDWORD(v66) = (174 - v72) / 2;
-      result = v43->field_38;
-      v48 = result + v43->field_28;
+      result = v43->pStartingPosActiveItem;
+      v48 = result + v43->pNumPresenceButton;
       v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138;
-      v50 = -v43->field_28 < 0;
-      v73 = v43->field_38;
+      v50 = -v43->pNumPresenceButton < 0;
+      v73 = v43->pStartingPosActiveItem;
       if ( v50 ^ __OFSUB__(result, v48) )
       {
         i = 2;
@@ -12600,14 +12416,14 @@
           v53->uW = v56;
           v49 = v56;
           v57 = v71;
-          if ( pDialogueWindow->field_2C_focus_id != i )
+          if ( pDialogueWindow->pCurrentPosActiveItem != i )
             v57 = white;
           v65.DrawText2(pFontArrus, 0, v55, v57, *v51, 3u);
           v43 = pDialogueWindow;
           ++i;
           ++v51;
           ++v73;
-          result = pDialogueWindow->field_28 + pDialogueWindow->field_38;
+          result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
         }
         while ( v73 < result );
       }
@@ -12779,11 +12595,11 @@
       while ( (signed int)v77 < (signed int)&pShopOptions[3] );
       v79 = pDialogueWindow;
       _this = (Player *)((174 - v76) / 3);
-      result = pDialogueWindow->field_38;
-      v80 = result + pDialogueWindow->field_28;
+      result = pDialogueWindow->pStartingPosActiveItem;
+      v80 = result + pDialogueWindow->pNumPresenceButton;
       v81 = (3 * (58 - (signed int)_this) - v76) / 2 - (174 - v76) / 3 / 2 + 138;
-      v20 = -pDialogueWindow->field_28 < 0;
-      v118 = pDialogueWindow->field_38;
+      v20 = -pDialogueWindow->pNumPresenceButton < 0;
+      v118 = pDialogueWindow->pStartingPosActiveItem;
       if ( v20 ^ __OFSUB__(result, v80) )
       {
         v122 = 2;
@@ -12800,14 +12616,14 @@
           v81 = v84 + v85 - 1;
           v82->uW = v81;
           v87 = color2;
-          if ( pDialogueWindow->field_2C_focus_id != v86 )
+          if ( pDialogueWindow->pCurrentPosActiveItem != v86 )
             v87 = white;
           v112.DrawText2(pFontArrus, 0, v85, v87, *v119, 3u);
           v79 = pDialogueWindow;
           ++v122;
           ++v119;
           ++v118;
-          result = pDialogueWindow->field_28 + pDialogueWindow->field_38;
+          result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
         }
         while ( v118 < result );
       }
@@ -12830,8 +12646,8 @@
           v119 = (const char **)(v33 * (100 - _this->GetMerchant()) / 100);
           if ( (signed int)v119 < v33 / 3 )
             v119 = (const char **)(v33 / 3);
-          v34 = v31->field_38;
-          v35 = v34 + v31->field_28;
+          v34 = v31->pStartingPosActiveItem;
+          v35 = v34 + v31->pNumPresenceButton;
           v122 = 0;
           if ( (signed int)v34 >= v35 )
             goto LABEL_140;
@@ -12846,7 +12662,7 @@
             }
             ++v34;
           }
-          while ( (signed int)v34 < v31->field_28 + v31->field_38 );
+          while ( (signed int)v34 < v31->pNumPresenceButton + v31->pStartingPosActiveItem );
           if ( !v122 )
           {
 LABEL_140:
@@ -12868,11 +12684,11 @@
           v119 = (const char **)((149 - v118) / v122);
           if ( (149 - v118) / v122 > 32 )
             v119 = (const char **)32;
-          result = v31->field_38;
+          result = v31->pStartingPosActiveItem;
           v38 = (149 - v122 * (signed int)v119 - v118) / 2 - (signed int)v119 / 2 + 162;
           v118 = result;
           v114 = v38;
-          if ( result < result + v31->field_28 )
+          if ( result < result + v31->pNumPresenceButton )
           {
             v122 = 2;
             do
@@ -12899,13 +12715,13 @@
                 v40->uW = v46;
                 v114 = v46;
                 v47 = color2;
-                if ( pDialogueWindow->field_2C_focus_id != v45 )
+                if ( pDialogueWindow->pCurrentPosActiveItem != v45 )
                   v47 = white;
                 v112.DrawText2(pFontArrus, 0, v44, v47, Str, 3u);
               }
-              v48 = v31->field_38;
+              v48 = v31->pStartingPosActiveItem;
               ++v118;
-              result = v31->field_28 + v48;
+              result = v31->pNumPresenceButton + v48;
               ++v122;
             }
             while ( v118 < result );
@@ -12963,11 +12779,11 @@
         while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
         v17 = pDialogueWindow;
         v114 = (174 - v14) / 4;
-        result = pDialogueWindow->field_38;
-        v18 = result + pDialogueWindow->field_28;
+        result = pDialogueWindow->pStartingPosActiveItem;
+        v18 = result + pDialogueWindow->pNumPresenceButton;
         v19 = (174 - 4 * (174 - v14) / 4 - v14) / 2 - (174 - v14) / 4 / 2 + 138;
-        v20 = -pDialogueWindow->field_28 < 0;
-        v122 = pDialogueWindow->field_38;
+        v20 = -pDialogueWindow->pNumPresenceButton < 0;
+        v122 = pDialogueWindow->pStartingPosActiveItem;
         if ( v20 ^ __OFSUB__(result, v18) )
         {
           v119 = (const char **)2;
@@ -12984,14 +12800,14 @@
             v19 = v24 + v23 - 1;
             v21->uW = v19;
             v26 = color2;
-            if ( (const char **)pDialogueWindow->field_2C_focus_id != v25 )
+            if ( (const char **)pDialogueWindow->pCurrentPosActiveItem != v25 )
               v26 = white;
             v112.DrawText2(pFontArrus, 0, v24, v26, (const char *)LODWORD(_this->pConditions[0]), 3u);
             v17 = pDialogueWindow;
             v119 = (const char **)((char *)v119 + 1);
             _this = (Player *)((char *)_this + 4);
             ++v122;
-            result = pDialogueWindow->field_28 + pDialogueWindow->field_38;
+            result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
           }
           while ( v122 < result );
         }
@@ -13445,7 +13261,7 @@
       ++pMessageQueue_50CBD0->uNumMessages;
     }
     if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
-      pDialogue_SpeakingActor->uAIState = 11;
+      pDialogue_SpeakingActor->uAIState = Removed;
     if ( uActiveCharacter )
       pPlayers[uActiveCharacter]->PlaySound(61, 0);
     goto LABEL_87;
@@ -13705,11 +13521,11 @@
   v63 = v2 * (100 - v1->GetMerchant()) / 100;
   if ( v63 < v2 / 3 )
     v63 = v2 / 3;
-  strcpy(Dest, nullstring);
-  strcpy(v46, nullstring);
-  strcpy(v47, nullstring);
-  strcpy(v48, nullstring);
-  strcpy(v49, nullstring);
+  strcpy(Dest, "");
+  strcpy(v46, "");
+  strcpy(v47, "");
+  strcpy(v48, "");
+  strcpy(v49, "");
   if ( dword_F8B19C != 1 )
   {
     if ( dword_F8B19C != 18 )
@@ -13844,7 +13660,7 @@
     v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &v52, 0, 0);
     v52.DrawText2(pFontArrus, 0, (212 - v38) / 2 + 101, v37, v36, 3u);
     result = (int)pDialogueWindow;
-    pDialogueWindow->field_28 = 0;
+    pDialogueWindow->pNumPresenceButton = 0;
     return result;
   }
   result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
@@ -13854,8 +13670,8 @@
   v5 = 0;
   v62 = 0;
   Str = 0;
-  v21 = pDialogueWindow->field_38;
-  v22 = v21 + pDialogueWindow->field_28;
+  v21 = pDialogueWindow->pStartingPosActiveItem;
+  v22 = v21 + pDialogueWindow->pNumPresenceButton;
   v61 = 0;
   if ( v21 >= v22 )
     goto LABEL_64;
@@ -13887,7 +13703,7 @@
     }
     ++v21;
   }
-  while ( v21 < v20->field_28 + v20->field_38 );
+  while ( v21 < v20->pNumPresenceButton + v20->pStartingPosActiveItem );
   if ( !v61 )
   {
 LABEL_64:
@@ -13911,11 +13727,11 @@
   v63 = (signed int)(149 - v62) / v61;
   if ( v63 > 32 )
     v63 = 32;
-  result = v20->field_38;
+  result = v20->pStartingPosActiveItem;
   v26 = (signed int)(149 - v61 * v63 - v62) / 2 - v63 / 2 + 162;
   v62 = result;
   v55 = v26;
-  if ( result < result + v20->field_28 )
+  if ( result < result + v20->pNumPresenceButton )
   {
     v61 = 2;
     while ( 1 )
@@ -13946,7 +13762,7 @@
         v28->uW = v33;
         v55 = v33;
         v34 = v57;
-        if ( pDialogueWindow->field_2C_focus_id != v61 )
+        if ( pDialogueWindow->pCurrentPosActiveItem != v61 )
           v34 = v56;
         v52.DrawText2(pFontArrus, 0, v32, v34, Str, 3u);
         goto LABEL_58;
@@ -13955,9 +13771,9 @@
       v28->uHeight = 0;
       v28->uY = 0;
 LABEL_58:
-      v35 = v20->field_38;
+      v35 = v20->pStartingPosActiveItem;
       ++v62;
-      result = v20->field_28 + v35;
+      result = v20->pNumPresenceButton + v35;
       ++v61;
       if ( (signed int)v62 >= result )
         return result;
@@ -14074,8 +13890,8 @@
             v64 = (signed int)(v65 * (100 - v6)) / 100;
             if ( v64 < (signed int)v65 / 3 )
               v64 = (signed int)v65 / 3;
-            v7 = v4->field_38;
-            v8 = v7 + v4->field_28;
+            v7 = v4->pStartingPosActiveItem;
+            v8 = v7 + v4->pNumPresenceButton;
             v65 = 0;
             v62 = v7;
             if ( (signed int)v7 >= v8 )
@@ -14089,10 +13905,10 @@
                 v66 = (DDM_DLV_Header *)((char *)v66 + v10);
                 ++v65;
               }
-              v11 = v4->field_38;
+              v11 = v4->pStartingPosActiveItem;
               ++v62;
             }
-            while ( (signed int)v62 < v4->field_28 + v11 );
+            while ( (signed int)v62 < v4->pNumPresenceButton + v11 );
             if ( v65 )
             {
               sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v64);
@@ -14102,9 +13918,9 @@
                 v64 = 32;
               v65 = (signed int)(149 - v65 * v64 - (int)v66) / 2 - v64 / 2 + 162;
               v12 = v61;
-              result = v61->field_38;
-              v13 = result + v61->field_28;
-              v62 = v61->field_38;
+              result = v61->pStartingPosActiveItem;
+              v13 = result + v61->pNumPresenceButton;
+              v62 = v61->pStartingPosActiveItem;
               if ( result < v13 )
               {
                 v66 = (DDM_DLV_Header *)2;
@@ -14131,14 +13947,14 @@
                     v15->uW = v20;
                     v65 = v20;
                     v21 = WORD2(v59);
-                    if ( (DDM_DLV_Header *)pDialogueWindow->field_2C_focus_id != v66 )
+                    if ( (DDM_DLV_Header *)pDialogueWindow->pCurrentPosActiveItem != v66 )
                       v21 = WORD2(v58);
                     v57.DrawText2(pFontArrus, 0, v19, v21, (const char *)HIDWORD(v60), 3u);
                   }
                   result = (int)v61;
                   ++v62;
                   v66 = (DDM_DLV_Header *)((char *)v66 + 1);
-                  if ( (signed int)v62 >= v61->field_28 + v61->field_38 )
+                  if ( (signed int)v62 >= v61->pNumPresenceButton + v61->pStartingPosActiveItem )
                     break;
                   v12 = v61;
                 }
@@ -14295,8 +14111,8 @@
     return result;
   }
   v63 = 1;
-  v41 = pDialogueWindow->GetControl(pDialogueWindow->field_38);
-  strcpy(a1, nullstring);
+  v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem);
+  strcpy(a1, "");
   v41->uHeight = 0;
   v41->uY = 0;
   if ( v1->_4B6FF9() )
@@ -14310,7 +14126,7 @@
   v43 = pDialogueWindow;
   v44 = v63;
   v66 = 0;
-  if ( v63 < pDialogueWindow->field_28 )
+  if ( v63 < pDialogueWindow->pNumPresenceButton )
   {
     v61 = (GUIWindow *)&a1[100 * v63];
     do
@@ -14321,16 +14137,16 @@
       v61 = (GUIWindow *)((char *)v61 + 100);
       ++v44;
     }
-    while ( v44 < pDialogueWindow->field_28 );
-  }
-  v46 = v43->field_28 - v42;
+    while ( v44 < pDialogueWindow->pNumPresenceButton );
+  }
+  v46 = v43->pNumPresenceButton - v42;
   v64 = (174 - (signed int)v66) / v46;
   if ( v64 > 32 )
     v64 = 32;
-  result = v43->field_38;
+  result = v43->pStartingPosActiveItem;
   v47 = (174 - v64 * v46 - (signed int)v66) / 2 - v64 / 2 + 138;
   v65 = v42 + result;
-  if ( v42 + result < result + v43->field_28 )
+  if ( v42 + result < result + v43->pNumPresenceButton )
   {
     v61 = (GUIWindow *)(v42 + 2);
     v66 = (DDM_DLV_Header *)&a1[100 * v42];
@@ -14346,14 +14162,14 @@
       v47 = v52 + v51 - 1;
       v50->uW = v47;
       v53 = WORD2(v59);
-      if ( (GUIWindow *)pDialogueWindow->field_2C_focus_id != v61 )
+      if ( (GUIWindow *)pDialogueWindow->pCurrentPosActiveItem != v61 )
         v53 = WORD2(v58);
       v57.DrawText2(pFontArrus, 0, v52, v53, (const char *)v66, 3u);
       v43 = pDialogueWindow;
       v66 = (DDM_DLV_Header *)((char *)v66 + 100);
       v61 = (GUIWindow *)((char *)v61 + 1);
       ++v65;
-      result = pDialogueWindow->field_28 + pDialogueWindow->field_38;
+      result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
     }
     while ( (signed int)v65 < result );
   }
@@ -14565,7 +14381,7 @@
     v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0);
     v28.DrawText2(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u);
     result = (int)pDialogueWindow;
-    pDialogueWindow->field_28 = 0;
+    pDialogueWindow->pNumPresenceButton = 0;
     return result;
   }
   result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
@@ -14575,9 +14391,9 @@
   v33 = 0;
   v34 = 0;
   v29 = pDialogueWindow;
-  v9 = pDialogueWindow->field_38;
-  v10 = v9 + pDialogueWindow->field_28;
-  v35 = pDialogueWindow->field_38;
+  v9 = pDialogueWindow->pStartingPosActiveItem;
+  v10 = v9 + pDialogueWindow->pNumPresenceButton;
+  v35 = pDialogueWindow->pStartingPosActiveItem;
   if ( v9 >= v10 )
     goto LABEL_40;
   do
@@ -14589,10 +14405,10 @@
       v33 += v12;
       ++v34;
     }
-    v13 = v8->field_38;
+    v13 = v8->pStartingPosActiveItem;
     ++v35;
   }
-  while ( v35 < v8->field_28 + v13 );
+  while ( v35 < v8->pNumPresenceButton + v13 );
   if ( !v34 )
   {
 LABEL_40:
@@ -14608,10 +14424,10 @@
   v32 = (149 - v33) / v34;
   if ( (149 - v33) / v34 > 32 )
     v32 = 32;
-  result = v8->field_38;
+  result = v8->pStartingPosActiveItem;
   v35 = result;
   v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162;
-  if ( result < result + v8->field_28 )
+  if ( result < result + v8->pNumPresenceButton )
   {
     v33 = 2;
     do
@@ -14632,7 +14448,7 @@
           v14->uW = v20;
           v34 = v20;
           v21 = v31;
-          if ( pDialogueWindow->field_2C_focus_id != v33 )
+          if ( pDialogueWindow->pCurrentPosActiveItem != v33 )
             v21 = v30;
           v28.DrawText2(pFontArrus, 0, v19, v21, v17, 3u);
           goto LABEL_34;
@@ -14649,7 +14465,7 @@
       v8 = v29;
       ++v35;
       ++v33;
-      result = v29->field_28 + v29->field_38;
+      result = v29->pNumPresenceButton + v29->pStartingPosActiveItem;
     }
     while ( v35 < result );
   }
@@ -14757,12 +14573,12 @@
       v17 = LOBYTE(pFontArrus->uFontHeight) - 3;
       v59 = pDialogueWindow;
       v54 = v17;
-      strcpy(&Dest, nullstring);
+      strcpy(&Dest, "");
       sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1);
       v18 = pFontArrus->CalcTextHeight(pTmpBuf2, &v53, 0, 0);
-      v19 = v16->field_28;
+      v19 = v16->pNumPresenceButton;
       v20 = v18 + v17 + 146;
-      v21 = v16->field_38;
+      v21 = v16->pStartingPosActiveItem;
       v63 = v20;
       v55 = v20;
       v60 = v21;
@@ -14786,7 +14602,7 @@
         {
           v58 = v61;
           v27 = (const char *)v56;
-          if ( pDialogueWindow->field_2C_focus_id != s1 )
+          if ( pDialogueWindow->pCurrentPosActiveItem != s1 )
             v27 = *(const char **)v57;
           v47[1] = v27;
           sprintfex(a1, format_4E2DC8, v27);
@@ -14853,7 +14669,7 @@
           ++v62;
           ++s1;
           a1 += 100;
-          strcpy(v31, nullstring);
+          strcpy(v31, "");
           if ( v24 )
           {
             v24->uW = 0;
@@ -14862,7 +14678,7 @@
           }
         }
         ++v60;
-        if ( (signed int)v60 >= v59->field_28 + v59->field_38 )
+        if ( (signed int)v60 >= v59->pNumPresenceButton + v59->pStartingPosActiveItem )
           break;
         v16 = v59;
       }
@@ -14934,9 +14750,9 @@
           v7 = *((int *)v5 + 4);
           pIndoorCamera->sRotationY = 0;
           pParty->uFlags |= 2u;
-          pParty->vPosition.z = v7;
-          pParty->vPosition.y = *((int *)v5 + 5);
-          pParty->uFallStartY = pParty->vPosition.y;
+          pParty->vPosition.y = v7;
+          pParty->vPosition.z = *((int *)v5 + 5);
+          pParty->uFallStartY = pParty->vPosition.z;
           pParty->sRotationY = *((int *)v5 + 6);
         }
         HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
@@ -15170,7 +14986,7 @@
               {
                 v4->uCurrentActionTime = 0;
                 v4->uCurrentActionLength = 0;
-                v4->uAIState = 5;
+                v4->uAIState = Dead;
                 v4->UpdateAnimation();
               }
               v1 = v18;
@@ -15247,11 +15063,9 @@
 
 
 //----- (0043FDED) --------------------------------------------------------
-unsigned int __cdecl PrepareActorRenderList_BLV()
+void PrepareActorRenderList_BLV()
 {
   RenderBillboard *v0; // esi@0
-  unsigned int result; // eax@1
-  char *v2; // edi@2
   unsigned __int16 v3; // ax@3
   unsigned int v4; // eax@5
   unsigned __int16 v5; // cx@5
@@ -15260,13 +15074,12 @@
   int v8; // eax@10
   SpriteFrame *v9; // eax@16
   SpriteFrame *v10; // ebx@18
-  int *v11; // eax@18
+  //int *v11; // eax@18
   int v12; // ecx@28
-  Actor *v13; // ecx@35
-  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
@@ -15276,8 +15089,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
@@ -15288,8 +15101,6 @@
   __int16 a5; // [sp+2Ch] [bp-28h]@5
   int a5a; // [sp+2Ch] [bp-28h]@36
   int a5b; // [sp+2Ch] [bp-28h]@40
-  unsigned int v39; // [sp+30h] [bp-24h]@1
-  int v40; // [sp+34h] [bp-20h]@2
   __int16 v41; // [sp+3Ch] [bp-18h]@18
   int a6; // [sp+40h] [bp-14h]@34
   int v43; // [sp+44h] [bp-10h]@34
@@ -15297,36 +15108,21 @@
   signed int y; // [sp+4Ch] [bp-8h]@32
   int x; // [sp+50h] [bp-4h]@32
 
-  result = 0;
-  v39 = 0;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v40 = 0;
-    v2 = (char *)&pActors[0].uAttributes;
-    while ( 1 )
-    {
-      v3 = *((_WORD *)v2 + 70);
-      *(_DWORD *)v2 &= 0xFFFFFFF7u;
-      if ( v3 != 11 )
-      {
-        if ( v3 != 19 )
-          break;
-      }
-LABEL_48:
-      ++v39;
-      v40 += 32;
-      result = v39;
-      v2 += 836;
-      if ( (signed int)v39 >= (signed int)uNumActors )
-        return result;
-    }
-    a5 = *((_WORD *)v2 + 61);
-    a2 = *((_WORD *)v2 + 54);
-    a1a = *((_WORD *)v2 + 53);
-    a3 = *((_WORD *)v2 + 55);
+  for (uint i = 0; i < uNumActors; ++i)
+  {
+    auto p = pActors + i;
+
+    if (p->uAIState == Removed ||
+        p->uAIState == Disabled)
+      continue;
+
+    a5 = p->uSectorID;
+    a2 = p->vPosition.y;
+    a1a = p->vPosition.x;
+    a3 = p->vPosition.z;
     v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
-    LOWORD(v0) = *((_WORD *)v2 + 59);
-    v5 = *((_WORD *)v2 + 71);
+    LOWORD(v0) = p->uYawAngle;
+    v5 = p->uCurrentActionAnimation;
     v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7;
     v32 = v6;
     if ( pParty->bTurnBasedModeOn )
@@ -15343,34 +15139,34 @@
       {
         v7 = pBLVRenderParams->field_0_timer_;
 LABEL_10:
-        v8 = v40 + v7;
+        v8 = i * 32 + v7;
         goto LABEL_12;
       }
     }
-    v8 = *((_DWORD *)v2 + 37);
+    v8 = p->uCurrentActionTime;
 LABEL_12:
-    if ( *((_QWORD *)v2 + 32) > 0i64 || *((_QWORD *)v2 + 34) > 0i64 )
+    if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
       v8 = 0;
-    v31 = *(_WORD *)&v2[2 * (signed __int16)v5 + 152];
-    if ( *((_WORD *)v2 + 70) == 16 )
+    v31 = p->pSpriteIDs[v5];
+    if (p->uAIState == Resurrected)
       v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
     else
       v9 = pSpriteFrameTable->GetFrame(v31, v8);
     v41 = 0;
     v10 = v9;
-    v11 = (int *)v9->uFlags;
-    if ( (unsigned __int8)v11 & 2 )
+    //v11 = (int *)v9->uFlags;
+    if (v9->uFlags & 2)
       v41 = 2;
-    if ( (unsigned int)v11 & 0x40000 )
+    if (v9->uFlags & 0x40000)
       v41 |= 0x40u;
-    if ( (unsigned int)v11 & 0x20000 )
+    if (v9->uFlags & 0x20000)
       LOBYTE(v41) = v41 | 0x80;
     v0 = (RenderBillboard *)(256 << v6);
-    if ( (unsigned int)v0 & (unsigned int)v11 )
+    if ( (unsigned int)v0 & v9->uFlags)
       v41 |= 4u;
     if ( v10->uGlowRadius )
     {
-      LOBYTE(v11) = byte_4E94D3;
+      //LOBYTE(v11) = byte_4E94D3;
       pMobileLightsStack->AddLight(
         a1a,
         a2,
@@ -15380,29 +15176,28 @@
         0xFFu,
         0xFFu,
         0xFFu,
-        v11);
+        byte_4E94D3);
     }
     v12 = 0;
-    if ( pStru170->field_53730 <= 0 )
-      goto LABEL_48;
-    while ( pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != *((_WORD *)v2 + 61) )
+    if ( pStru170->uNumVisibleNotEmptySectors <= 0 )
+      continue;
+    while (pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID)
     {
       ++v12;
-      if ( v12 >= pStru170->field_53730 )
-        goto LABEL_48;
+      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)) )
-      goto LABEL_48;
+      continue;
     pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6);
-    result = uNumBillboardsToDraw;
+
     v0 = &pBillboardRenderList[uNumBillboardsToDraw];
-    if ( (signed int)uNumBillboardsToDraw >= 500 )
-      return result;
+    if (uNumBillboardsToDraw >= 500)
+      break;
     ++uNumBillboardsToDraw;
     ++uNumSpritesDrawnThisFrame;
-    v13 = (Actor *)(v2 - 36);
-    *(_DWORD *)v2 |= 8u;
+    p->uAttributes |= 8u;
     v29 = pRenderer->pRenderD3D == 0;
     v0->uHwSpriteID = v10->pHwSpriteIDs[v32];
     v0->uPalette = v10->uPaletteIndex;
@@ -15417,34 +15212,34 @@
     }
     else
     {
-      v14 = &pGame->pIndoorCameraD3D;
-      v0->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-      v15 = (*v14)->flt_D4;
-      v16 = v0->flt_8;
-      v0->flt_C = v15;
-      v17 = v16 + 6.7553994e15;
+      //v14 = &pGame->pIndoorCameraD3D;
+      v0->fov_x = pGame->pIndoorCameraD3D->fov_x;
+      v15 = pGame->pIndoorCameraD3D->fov_y;
+      v16 = v0->fov_x;
+      v0->fov_y = v15;
+      //v17 = v16 + 6.7553994e15;
       LODWORD(v18) = 0;
-      HIDWORD(v18) = 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;
     }
     v0->field_4 = a5a;
-    if ( (signed __int64)v13->pActorBuffs[3].uExpireTime <= 0 )
-    {
-      if ( (signed __int64)v13->pActorBuffs[10].uExpireTime > 0 )
-      {
-        a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F((Actor *)(v2 - 36)) * (signed __int64)v0->field_4) >> 16;
+    if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 )
+    {
+      if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 )
+      {
+        a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->field_4) >> 16;
         goto LABEL_43;
       }
     }
     else
     {
-      v22 = v13->pActorBuffs[3].uPower;
+      v22 = p->pActorBuffs[3].uPower;
       if ( v22 )
       {
         v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16;
-        v24 = *((_WORD *)v2 + 116);
+        v24 = p->pActorBuffs[3].uPower;
         v0->field_0 = v23;
         a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16;
 LABEL_43:
@@ -15454,29 +15249,30 @@
     }
 LABEL_44:
     HIWORD(v25) = HIWORD(x);
-    v0->field_20 = a1a;
-    v0->field_22 = a2;
-    v0->field_24 = a3;
-    v0->field_26 = v43;
-    v0->field_28 = a6;
+    v0->some_x = a1a;
+    v0->some_y = a2;
+    v0->some_z = a3;
+    v0->uScreenSpaceX = v43;
+    v0->uScreenSpaceY = a6;
     LOWORD(v25) = 0;
     LOBYTE(v26) = v41;
-    v0->sZValue = v25 + (8 * v39 | 3);
-    v27 = pMonsterList->pMonsters;
-    v28 = *((_WORD *)v2 + 30);
-    v29 = *((_DWORD *)v2 + 65) == 0;
-    v30 = *((_DWORD *)v2 + 65) < 0;
+    v0->sZValue = v25 + (8 * i | 3);
+    //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->field_2C_prolly_tint = *((_DWORD *)&v27[v28] - 36);
-    if ( !v30 && (!(v30 | v29) || *((_DWORD *)v2 + 64)) )
+    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;
     }
-    goto LABEL_48;
-  }
-  return result;
+    
+_continue:
+    ;
+  }
 }
 
 
@@ -15796,7 +15592,7 @@
   v25 = uHouseID;
   GameUI_StatusBar_TimedString[0] = 0;
   pStatusBarString[0] = 0;
-  ShowStatusBarString(nullstring, 2u);
+  ShowStatusBarString("", 2u);
   if ( pMessageQueue_50CBD0->uNumMessages )
     pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
   viewparams->bRedrawGameUI = 1;
--- a/mm7_5.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_5.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -304,9 +304,12 @@
   if ( pMessageQueue_50CBD0->uNumMessages )
   {
     v0 = 1;
-    v1 = nullstring;
+    v1 = "";
     while ( 2 )
     {
+      if ( !pMessageQueue_50CBD0->uNumMessages )
+        break;
+
       pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199);
       switch ( uMessage )
       {
@@ -330,7 +333,7 @@
         case UIMSG_Quit|0x2:
         case 0x87:
           if ( bNoNPCHiring != 1
-            && !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            && !pCurrentScreen )
           {
             if ( pMessageQueue_50CBD0->uNumMessages )
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -403,7 +406,7 @@
             pGUIWindow_CurrentMenu->Release();
             uGameState = 4;
 LABEL_188:
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             viewparams->bRedrawGameUI = v0;
           }
           else
@@ -421,7 +424,7 @@
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 12;
+          pCurrentScreen = 12;
           GameUI_DrawLoadMenu(v0);
           goto _continue;
         case UIMSG_Quit:
@@ -432,7 +435,7 @@
             if ( pMessageQueue_50CBD0->uNumMessages )
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
             pGUIWindow_CurrentMenu->Release();
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             viewparams->bRedrawGameUI = v0;
             if ( !uMessageParam )
               pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0);
@@ -449,7 +452,7 @@
           pIcons_LOD->_40F9C5();
           pIcons_LOD->_4114F2();
           pGUIWindow_CurrentMenu->Release();
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 2;
+          pCurrentScreen = 2;
           v162 = 0;
           v148 = 0;
           v141 = (WindowType)8;
@@ -496,7 +499,7 @@
         case UIMSG_A5:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
             pKeyActionMap->_459ED1(0);
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 11
+          if ( pCurrentScreen != 11
             || uLoadGameUI_SelectedSlot != dword_6A0C9C + uMessageParam )
           {
             v10 = dword_6A0C9C + uMessageParam;
@@ -554,7 +557,7 @@
           goto _release_tex_and_continue;
         case UIMSG_StartNewGame|0x2:
           pGUIWindow_CurrentMenu->Release();
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 11;
+          pCurrentScreen = 11;
           GameUI_DrawSaveMenu();
           goto _continue;
         case UIMSG_Game_OpenOptionsDialog:
@@ -562,7 +565,7 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = v0;
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 2;
+          pCurrentScreen = 2;
           uTextureID_507C60 = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
           uTextureID_507C6C = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
           uTextureID_507C68 = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
@@ -779,32 +782,32 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = 1;
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 26;
+          pCurrentScreen = 26;
           uTextureID_507BF4 = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE);
           uTextureID_507BF8 = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE);
           uTextureID_507BFC = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
           uTextureID_507C00 = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
           uTextureID_507C04 = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_KeyMappingOptions, 0, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, nullstring, 0);
-          pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, nullstring, 0);
+          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A1u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(127u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x1A2u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(19u, 0x144u, 0x6Cu, 0x14u, 1, 0, 0x7Fu, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0x94u, 0x46u, 0x13u, 1, 0, 0x1A3u, 0, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xA7u, 0x46u, 0x13u, 1, 0, 0x1A3u, 1u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xBAu, 0x46u, 0x13u, 1, 0, 0x1A3u, 2u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 0xCDu, 0x46u, 0x13u, 1, 0, 0x1A3u, 3u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 224u, 70u, 19u, 1, 0, 0x1A3u, 4u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 5u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(129u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 6u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 148u, 70u, 0x13u, 1, 0, 0x1A3u, 7u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 167u, 70u, 0x13u, 1, 0, 0x1A3u, 8u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 186u, 70u, 0x13u, 1, 0, 0x1A3u, 9u, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 205u, 70u, 0x13u, 1, 0, 0x1A3u, 0xAu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 224u, 70u, 0x13u, 1, 0, 0x1A3u, 0xBu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 243u, 70u, 0x13u, 1, 0, 0x1A3u, 0xCu, 0, "", 0);
+          pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, "", 0);
           dword_506E68 = -1;
           dword_506F08 = 1;
           memset(word_506E6C, 0, 0x1Cu);
@@ -871,7 +874,7 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = v0;
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 28;
+          pCurrentScreen = 28;
           uTextureID_507C10 = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE);
           uTextureID_507C14 = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE);
           uTextureID_507C18 = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE);
@@ -1184,7 +1187,7 @@
         case UIMSG_OpenQuestBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
@@ -1195,7 +1198,7 @@
         case UIMSG_OpenAutonotes:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
@@ -1206,11 +1209,11 @@
         case UIMSG_OpenMapBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           viewparams->sPartyPosX = pParty->vPosition.x;
-          viewparams->sPartyPosZ = pParty->vPosition.z;
+          viewparams->sPartyPosZ = pParty->vPosition.y;
           pAudioPlayer->StopChannels(-1, -1);
           v26 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
           v27 = 353;
@@ -1221,7 +1224,7 @@
         case UIMSG_OpenCalendar:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
@@ -1237,7 +1240,7 @@
         case UIMSG_OpenHistoryBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
@@ -1249,11 +1252,11 @@
           back_to_game();
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 15 )
-          {
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions >= 17
-              && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 18
-               || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 104) )
+          if ( pCurrentScreen > 15 )
+          {
+            if ( pCurrentScreen >= 17
+              && (pCurrentScreen <= 18
+               || pCurrentScreen == 104) )
             {
 LABEL_229:
               if ( dword_50CDC8 )
@@ -1264,11 +1267,11 @@
           }
           else
           {
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions >= 14
-              || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4
-              || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
+            if ( pCurrentScreen >= 14
+              || pCurrentScreen == 4
+              || pCurrentScreen == 10 )
               goto LABEL_229;
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13
+            if ( pCurrentScreen == 13
               && !dword_50CDC8
               && !dword_5C35C8 )
             {
@@ -1285,18 +1288,18 @@
             pRenderer->ClearZBuffer(0, 479);
             viewparams->bRedrawGameUI = v0;
             viewparams->field_48 = v0;
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
-            {
-              if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 103 )
+            if ( pCurrentScreen )
+            {
+              if ( pCurrentScreen > 103 )
               {
-                if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 104 )
+                if ( pCurrentScreen == 104 )
                   goto LABEL_321;
               }
               else
               {
-                if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions < 100 )
+                if ( pCurrentScreen < 100 )
                 {
-                  switch ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+                  switch ( pCurrentScreen )
                   {
                     case 23:
                       pIcons_LOD->_4114F2();
@@ -1330,7 +1333,7 @@
                       //crt_deconstruct_ptr_6A0118();
                       goto LABEL_291;
                     case 15:
-                      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 10;
+                      pCurrentScreen = 10;
                       goto _continue;
                     case 10:
                       v29 = ptr_507BB8;
@@ -1340,7 +1343,7 @@
 LABEL_249:
                       v29->Release();
                       pIcons_LOD->_4114F2();
-                      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+                      pCurrentScreen = 0;
                       viewparams->bRedrawGameUI = v0;
                       pEventTimer->Resume();
                       goto _continue;
@@ -1481,7 +1484,7 @@
                       goto LABEL_322;
                     case 14:
                       pGUIWindow_CurrentMenu->Release();
-                      uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 13;
+                      pCurrentScreen = 13;
                       pIcons_LOD->_4114F2();
                       goto _continue;
                     case 13:
@@ -1527,10 +1530,10 @@
                         pParty->vPosition.x = -22528;
                       if ( pParty->vPosition.x > 22528 )
                         pParty->vPosition.x = 22528;
-                      if ( pParty->vPosition.z < -22528 )
-                        pParty->vPosition.z = -22528;
-                      if ( pParty->vPosition.z > 22528 )
-                        pParty->vPosition.z = 22528;
+                      if ( pParty->vPosition.y < -22528 )
+                        pParty->vPosition.y = -22528;
+                      if ( pParty->vPosition.y > 22528 )
+                        pParty->vPosition.y = 22528;
                       goto LABEL_317;
                     case 16:
                       pVideoPlayer->Unload();
@@ -1551,7 +1554,7 @@
 LABEL_322:
               if ( ptr_507BD4 )
               {
-                if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 7 )
+                if ( pCurrentScreen == 7 )
                 {
                   pMouse->SetCursorBitmap("MICON2");
                 }
@@ -1572,7 +1575,7 @@
                 ptr_507BC0 = 0;
               pGUIWindow_CurrentMenu = 0;
               pEventTimer->Resume();
-              uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+              pCurrentScreen = 0;
               viewparams->bRedrawGameUI = v0;
               pIcons_LOD->_4355F7();
               goto _continue;
@@ -1585,7 +1588,7 @@
               pEventTimer->Pause();
               pAudioPlayer->StopChannels(-1, -1);
               ++pIcons_LOD->uTexturePacksCount;
-              uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = v0;
+              pCurrentScreen = v0;
               if ( !pIcons_LOD->uNumPrevLoadedFiles )
                 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
               pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)3, 0, 0);
@@ -1687,8 +1690,6 @@
           }
           sub_41426F();
 _continue:
-          if ( !pMessageQueue_50CBD0->uNumMessages )
-            break;
           continue;
         case UIMSG_BC:
           if ( uMessageParam )
@@ -1738,12 +1739,12 @@
             }
             if ( dword_591178_teleporty )
             {
-              pParty->vPosition.z = dword_591178_teleporty;
+              pParty->vPosition.y = dword_591178_teleporty;
               _5B65AC_npcdata_fame_or_other = dword_591178_teleporty;
             }
             if ( dword_591174_teleportz )
             {
-              pParty->vPosition.y = dword_591174_teleportz;
+              pParty->vPosition.z = dword_591174_teleportz;
               _5B65B0_npcdata_rep_or_other = dword_591174_teleportz;
               pParty->uFallStartY = dword_591174_teleportz;
             }
@@ -1799,7 +1800,7 @@
           v195 = (NPCData *)GetTravelTime();
           strcpy(pOutdoor->pLevelFilename, pCurrentMapName);
           if ( bUnderwater != 1 && pParty->bFlying
-            || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.z, &pOut, 20) != v0 )
+            || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, &pOut, 20) != v0 )
           {
             viewparams->bRedrawGameUI = v0;
 LABEL_387:
@@ -1808,13 +1809,13 @@
               pParty->vPosition.x = -22528;
             if ( pParty->vPosition.x > 22528 )
               pParty->vPosition.x = 22528;
-            if ( pParty->vPosition.z < -22528 )
-              pParty->vPosition.z = -22528;
-            if ( pParty->vPosition.z > 22528 )
-              pParty->vPosition.z = 22528;
+            if ( pParty->vPosition.y < -22528 )
+              pParty->vPosition.y = -22528;
+            if ( pParty->vPosition.y > 22528 )
+              pParty->vPosition.y = 22528;
 LABEL_317:
             sub_44603D();
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
           }
           else
           {
@@ -1882,12 +1883,12 @@
             OnMapLoad();
             pOutdoor->SetFog();
             TeleportToStartingPoint(uLevel_StartingPointType);
-            pParty->vPosition.y = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.z, (int *)&v213, 0);
-            pParty->uFallStartY = pParty->vPosition.y;
+            pParty->vPosition.z = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, (int *)&v213, 0);
+            pParty->uFallStartY = pParty->vPosition.z;
             sub_461103();
             pEventTimer->Resume();
             viewparams->bRedrawGameUI = 1;
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             pGameLoadingUI_ProgressBar->Release();
           }
           goto LABEL_422;
@@ -1932,7 +1933,7 @@
             if ( uCurrentlyLoadedLevelType != v0 )
             {
               v50 = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
-              if ( !(BYTE3(v50->uFaceAttributes) & 2) || !v50->sCogTriggeredID )
+              if ( !(v50->uAttributes & 0x02000000) || !v50->sCogTriggeredID )
                 goto _continue;
               v44 = uNumSeconds;
               goto LABEL_415;
@@ -2081,7 +2082,7 @@
           v158 = (unsigned int)thise;
           v146 = pGlobalTXT_LocalizationStrings[475];// "Set %s over %s"
 _sprintex_draw_status_and_continue:
-          sprintfex(pTmpBuf, v146, v158, v174);
+          sprintf(pTmpBuf, v146, v158, v174);
           goto _set_status_string_pTmpBuf_and_continue;
         case UIMSG_B5:
           dword_50CDC8 = v0;
@@ -2133,9 +2134,9 @@
             else
             {
               pParty->vPosition.x = v195->uFlags;
-              pParty->vPosition.z = v195->fame;
-              pParty->vPosition.y = v195->rep;
-              pParty->uFallStartY = pParty->vPosition.y;
+              pParty->vPosition.y = v195->fame;
+              pParty->vPosition.z = v195->rep;
+              pParty->uFallStartY = pParty->vPosition.z;
               pParty->sRotationY = LOWORD(v195->house);
               pParty->sRotationX = HIWORD(v195->house);
             }
@@ -2164,8 +2165,8 @@
             v195->pName = (char *)v62;
             v61->uPortraitID = HIDWORD(v62);
             v61->uFlags = pParty->vPosition.x;
-            v61->fame = pParty->vPosition.z;
-            v61->rep = pParty->vPosition.y;
+            v61->fame = pParty->vPosition.y;
+            v61->rep = pParty->vPosition.z;
             LOWORD(v61->house) = LOWORD(pParty->sRotationY);
             HIWORD(v61->house) = LOWORD(pParty->sRotationX);
             if ( (signed int)pGames_LOD->uNumSubIndices / 2 <= 0 )
@@ -2208,9 +2209,9 @@
                   if ( v64 == stru_4ECBB8[uMessageParam].uMapInfoID )
                   {
                     pParty->vPosition.x = stru_4ECBB8[v65].pos.x;
-                    pParty->vPosition.z = stru_4ECBB8[v65].pos.y;
-                    pParty->vPosition.y = stru_4ECBB8[v65].pos.z;
-                    pParty->uFallStartY = pParty->vPosition.y;
+                    pParty->vPosition.y = stru_4ECBB8[v65].pos.y;
+                    pParty->vPosition.z = stru_4ECBB8[v65].pos.z;
+                    pParty->uFallStartY = pParty->vPosition.z;
                     pParty->sRotationY = stru_4ECBB8[v65].rot_y;
                     pParty->sRotationX = stru_4ECBB8[v65].rot_x;
                   }
@@ -2230,7 +2231,7 @@
                     _5B65B8_npcdata_hiword_house_or_other = v66;
                     UpdateActors();
                   }
-                  v67 = pGUIWindow_CurrentMenu->str_48;
+                  v67 = pGUIWindow_CurrentMenu->Hint;
                   if ( v67 )
                     *((int *)v67 + 17) = v0;
                   else
@@ -2351,7 +2352,7 @@
             if ( v70 <= 0 || v70 >= 77 )
             {
 LABEL_90:
-              v1 = nullstring;
+              v1 = "";
 LABEL_91:
               v0 = 1;
               goto _continue;
@@ -2397,8 +2398,8 @@
                 v77 = thisi;
 LABEL_544:
                 pParty->vPosition.x = v74;
-                pParty->vPosition.z = v77;
-                pParty->vPosition.y = v76;
+                pParty->vPosition.y = v77;
+                pParty->vPosition.z = v76;
                 pParty->uFallStartY = v76;
                 goto LABEL_90;
               }
@@ -2466,10 +2467,10 @@
           goto LABEL_416;
         case 0x1C:
           if ( !uActiveCharacter
-            || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            || pCurrentScreen )
             goto LABEL_90;
           ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)104, uMessageParam, 0);
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 25;
+          pCurrentScreen = 25;
           pEventTimer->Pause();
           goto _continue;
         case 0x1B:
@@ -2544,7 +2545,7 @@
         case 0x68:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             goto _continue;
           if ( sub_42F4DA() )
             goto LABEL_594;
@@ -2670,10 +2671,10 @@
         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);
+            sprintf(pTmpBuf, v157, v173);
           }
           else
           {
@@ -2726,7 +2727,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 +2746,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 +2771,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:
@@ -2802,7 +2803,7 @@
                   pGUIWindow_CurrentMenu->Release();
                   pEventTimer->Resume();
                   viewparams->bRedrawGameUI = v0;
-                  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+                  pCurrentScreen = 0;
                   pIcons_LOD->_4114F2();
                   v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734);
                   if ( dword_50C9E8 < 40 )
@@ -2869,17 +2870,17 @@
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
             if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery )
             {
-              if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+              if ( !pCurrentScreen )
                 goto LABEL_693;
-              if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 5
-                && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 7
-                && (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 99
-                 || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions > 103) )
+              if ( pCurrentScreen != 5
+                && pCurrentScreen != 7
+                && (pCurrentScreen <= 99
+                 || pCurrentScreen > 103) )
               {
                 pGUIWindow_CurrentMenu->Release();
 LABEL_693:
                 GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)ptr_5079F8, 0);
-                uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 8;
+                pCurrentScreen = 8;
                 pEventTimer->Pause();
                 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0);
                 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
@@ -2892,7 +2893,7 @@
         case 0x6A:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           ++pIcons_LOD->uTexturePacksCount;
           if ( !pIcons_LOD->uNumPrevLoadedFiles )
@@ -2901,7 +2902,7 @@
           viewparams->bRedrawGameUI = v0;
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 104;
+          pCurrentScreen = 104;
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)12, 5, 0);
           papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE);
           ptr_5076F4 = pGUIWindow_CurrentMenu->CreateButton(
@@ -2920,11 +2921,11 @@
                          v179);
           goto _continue;
         case 0x6B:
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
           {
             pGUIWindow_CurrentMenu->Release();
             pEventTimer->Resume();
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             viewparams->bRedrawGameUI = v0;
           }
           stru_506E40.Release();
@@ -3154,7 +3155,7 @@
           }
           if ( pParty->uCurrentHour < 0xC || (uNumSeconds = v0, pParty->uCurrentHour >= 0x18) )
             uNumSeconds = 0;
-          sprintfex(
+          sprintf(
             pTmpBuf,
             "%d:%02d%s %s %d %s %d",
             v195,
@@ -3171,7 +3172,7 @@
           goto _sprintex_2args_draw_status_and_continue;
         case UIMSG_ShowStatus_Player:
           v106 = pPlayers[uMessageParam];
-          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v106->pName, pClassNames[v106->uClass]);// "%s the %s"
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v106->pName, pClassNames[v106->uClass]);// "%s the %s"
           strcat(pTmpBuf, ": ");
           v107 = v106->GetMajorConditionIdx();
           strcat(pTmpBuf, aCharacterConditionNames[v107]);
@@ -3187,10 +3188,10 @@
           v112 = v110->sMana;
           v113 = pGlobalTXT_LocalizationStrings[108];// "Hit Points"
           v114 = v110->GetMaxHealth();
-          sprintfex(pTmpBuf, "%d / %d %s    %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
+          sprintf(pTmpBuf, "%d / %d %s    %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109);
           goto _set_status_string_pTmpBuf_and_continue;
         case 0xC:
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 15 )
+          if ( pCurrentScreen == 15 )
             goto LABEL_762;
           sub_420E01();
           goto _continue;
@@ -3260,7 +3261,7 @@
           OnPressSpace();
           goto _continue;
         case UIMSG_ChangeSoundVolume|0x100:
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             goto _continue;
           pParty->uFlags |= 2u;
           GUIWindow::Create(0x207u, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A14, 0);
@@ -3283,7 +3284,7 @@
           viewparams->field_28 = 11;
           goto LABEL_788;
         case UIMSG_ChangeMusicVolume|0x100:
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          if ( pCurrentScreen )
             goto _continue;
           pParty->uFlags |= 2u;
           GUIWindow::Create(0x23Eu, 0x88u, 0, 0, (enum WindowType)90, (int)dword_507A18, 0);
@@ -3363,7 +3364,7 @@
   dword_50CDCC = 0;
   if ( ptr_507BC4 )
     free_book_subwindow();
-  if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+  if ( !pCurrentScreen
     && !ptr_507BD4 )
     pEventTimer->Resume();
   viewparams->bRedrawGameUI = 1;
@@ -3400,7 +3401,7 @@
   unsigned int v26; // ecx@127
   unsigned int v27; // eax@129
   unsigned __int8 v28; // of@129
-  SoundID v29; // [sp-2Ch] [bp-3Ch]@36
+  SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36
   signed int v30; // [sp-28h] [bp-38h]@36
   unsigned int v31; // [sp-24h] [bp-34h]@36
   signed int v32; // [sp-20h] [bp-30h]@36
@@ -3415,18 +3416,20 @@
   signed int v41; // [sp-10h] [bp-20h]@29
   int v42; // [sp-10h] [bp-20h]@36
   int v43; // [sp-10h] [bp-20h]@56
-  unsigned __int8 uClass[4]; // [sp+4h] [bp-Ch]@3
-  UIMessageType v45; // [sp+8h] [bp-8h]@3
+  int uNum; // [sp+4h] [bp-Ch]@3
+  UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
   int v46; // [sp+Ch] [bp-4h]@3
+  Player *pPlayer;
 
   if ( pMessageQueue_50CBD0->uNumMessages )
   {
     //v0 = pAudioPlayer;
     v1 = (char *)pParty->pPlayers;
+	pPlayer = pParty->pPlayers;
     do
     {
-      pMessageQueue_50CBD0->PopMessage(&v45, (int *)uClass, &v46);
-      switch (v45)
+      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &v46);
+      switch (pUIMessageType)
       {
         case UIMSG_MainMenu_ShowPartyCreationWnd:
         {
@@ -3467,19 +3470,18 @@
       }
 
 
-      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 ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 11
-              || uLoadGameUI_SelectedSlot != *(int *)uClass + dword_6A0C9C )
+          if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != uNum + dword_6A0C9C )
           {
             //load clicked line
-              v26 = *(int *)uClass + dword_6A0C9C;
-              if ( dword_6BE138 == *(int *)uClass + dword_6A0C9C )
+              v26 = uNum + dword_6A0C9C;
+              if ( dword_6BE138 == uNum + dword_6A0C9C )
               {
                 pMessageQueue_50CBD0->SendMessage(UIMSG_A4, 0, 0);
                 pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
@@ -3502,18 +3504,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 > UIMSG_PlayerCreationRemoveDownSkill )
+      {
+        if ( pUIMessageType > UIMSG_A3 )
+        {
+          if ( pUIMessageType == UIMSG_A6 )
           {
             v43 = 0;
             v39 = (int)ptr_69BD60;
@@ -3525,106 +3526,73 @@
             GUIWindow::Create(v18, v8, v33, v35, v37, v39, v43);
             continue;
           }
-          if ( v45 == UIMSG_AB )
-          {
-            v23 = (char *)&pParty->pPlayers[*(int *)uClass];
-            v24 = (int)(v23 + 186);
-            v12 = (char)(v23[186] - 1) < 0;
-            --*(char *)v24;
+          if ( pUIMessageType == UIMSG_SelectFacePlayerBack )
+          {
+            pPlayer = &pParty->pPlayers[uNum];
+            v12 = (char)((int)pPlayer->uFace - 1) < 0;
+            --pPlayer->uFace;
             if ( v12 )
-              *(char *)v24 = 19;
-            *((int *)v23 + 1608) = *(char *)v24;
-            ((Player *)v23)->SetInitialStats();
-            ((Player *)v23)->SetSexByVoice();
-            ((Player *)v23)->RandomizeName();
-            v25 = *(int *)uClass;
-            pGUIWindow_CurrentMenu->field_2C_focus_id = (pGUIWindow_CurrentMenu->field_2C_focus_id
-                                                       - pGUIWindow_CurrentMenu->field_38)
-                                                      % 7
-                                                      + pGUIWindow_CurrentMenu->field_38
-                                                      + 7 * *(int *)uClass;
+              pPlayer->uFace = 19;
+            pPlayer->uVoiceID = pPlayer->uFace;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v25 = 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 = (Player *)v23;
-            goto LABEL_117;
-          }
-          if ( v45 == UIMSG_AC )
-          {
-            v19 = (int)&v1[6972 * *(int *)uClass];
-            v20 = (char)(*(char *)(v19 + 186) + 1) % 20;
-            *(char *)(v19 + 186) = v20;
-            *(int *)(v19 + 6432) = v20;
-            ((Player *)v19)->SetInitialStats();
-            ((Player *)v19)->SetSexByVoice();
-            ((Player *)v19)->RandomizeName();
-            v21 = *(int *)uClass;
-            pGUIWindow_CurrentMenu->field_2C_focus_id = (pGUIWindow_CurrentMenu->field_2C_focus_id
-                                                       - pGUIWindow_CurrentMenu->field_38)
-                                                      % 7
-                                                      + pGUIWindow_CurrentMenu->field_38
-                                                      + 7 * *(int *)uClass;
-            uPlayerCreationUI_SelectedCharacter = v21;
-            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 = (Player *)v19;
-LABEL_117:
+            v22 = pPlayer;
             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_SelectFacePlayerForward )
+          {
+            pPlayer = &pParty->pPlayers[uNum];
+			v20 = (char)((int)pPlayer->uFace + 1) % 20;
+            pPlayer->uFace = v20;
+            pPlayer->uVoiceID = v20;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v21 = 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);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            v22 = pPlayer;
+            v22->PlaySound(102, 0);
+            v1 = (char *)pParty->pPlayers;
+            continue;
+          }
+          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 >= *(int *)uClass )
-            dword_6A0C9C = *(int *)uClass - 1;
+          if ( dword_6A0C9C >= uNum )
+            dword_6A0C9C = uNum - 1;
           if ( dword_6A0C9C < 1 )
             dword_6A0C9C = 0;
           v7 = pGUIWindow_CurrentMenu;
@@ -3633,22 +3601,22 @@
           v8 = pGUIWindow_CurrentMenu->uFrameY + 323;
           goto LABEL_105;
         }
-        if ( v45 == 107 )
-        {
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+        if ( pUIMessageType == UIMSG_6B )
+        {
+          if ( pCurrentScreen )
           {
             pGUIWindow_CurrentMenu->Release();
             pEventTimer->Resume();
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             viewparams->bRedrawGameUI = 1;
           }
-          GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)ptr_5079F0, 0);
+          GUIWindow::Create(602, 450, 0, 0, (enum WindowType)92, (int)ptr_5079F0, 0);
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseBook;
           goto LABEL_93;
         }
-        if ( v45 == UIMSG_CloseBook )
+        if ( pUIMessageType == UIMSG_CloseBook )
         {
           if ( ptr_507BDC )
           {
@@ -3663,7 +3631,7 @@
           viewparams->field_48 = 1;
           if ( !GetCurrentMenuID() || GetCurrentMenuID() == 6 || GetCurrentMenuID() == 7 )
           {
-            v17 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+            v17 = pCurrentScreen;
 LABEL_83:
             if ( v17 == 16 )
               pVideoPlayer->FastForwardToFrame(pVideoPlayer->field_40);
@@ -3689,16 +3657,15 @@
             continue;
           }
           v16 = GetCurrentMenuID() == 8;
-          v17 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-          if ( v16
-            && !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+          v17 = pCurrentScreen;
+          if ( v16 && !pCurrentScreen )
             goto LABEL_83;
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 12 )
+          if ( pCurrentScreen == 12 )
           {
             pIcons_LOD->_4114F2();
             //crt_deconstruct_ptr_6A0118();
-            stru_506F20.Release();
-            stru_506F20.Load("title.pcx", 0);
+            pTexture_PCX.Release();
+            pTexture_PCX.Load("title.pcx", 0);
             SetCurrentMenuID(MENU_MAIN);
             v15 = 1;
 LABEL_81:
@@ -3706,32 +3673,28 @@
             pGUIWindow2->Release();
             pGUIWindow2 = 0;
             pEventTimer->Resume();
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             viewparams->bRedrawGameUI = v15;
             continue;
           }
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16 )
+          if ( pCurrentScreen == 16 )
           {
             pVideoPlayer->Unload();
           }
           else
           {
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 27 )
+            if ( pCurrentScreen != 27 )
               goto LABEL_81;
             //VideoPlayer::dtor();
           }
         }
         else
         {
-          if ( v45 == 118 )
-          {
-            v14 = *(int *)uClass;
-            pGUIWindow_CurrentMenu->field_2C_focus_id = (pGUIWindow_CurrentMenu->field_2C_focus_id
-                                                       - pGUIWindow_CurrentMenu->field_38)
-                                                      % 7
-                                                      + pGUIWindow_CurrentMenu->field_38
-                                                      + 7 * *(int *)uClass;
-            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;
@@ -3740,14 +3703,14 @@
             v32 = -1;
             v31 = 0;
             v30 = 0;
-            v29 = (SoundID)66;
+            pSoundID = (SoundID)66;
 LABEL_40:
-            pAudioPlayer->PlaySound(v29, v30, v31, v32, v34, v36, v38, v42);
+            pAudioPlayer->PlaySound(pSoundID, v30, v31, v32, v34, v36, v38, v42);
             continue;
           }
-          if ( v45 == 144 )
-          {
-            v9 = (Player *)&v1[6972 * *(int *)uClass];
+          if ( pUIMessageType == UIMSG_PlayerCreationVoiceBack )
+          {
+            v9 = &pPlayer[uNum];
             v46 = v9->GetSexByVoice();
             do
             {
@@ -3757,12 +3720,12 @@
               v13 = v9->GetSexByVoice();
             }
             while ( v13 != v46 );
-            v11 = pCreationUI_BtnPressLeft2[*(int *)uClass];
+            v11 = pCreationUI_BtnPressLeft2[uNum];
             goto LABEL_60;
           }
-          if ( v45 == 145 )
-          {
-            v9 = (Player *)&v1[6972 * *(int *)uClass];
+          if ( pUIMessageType == UIMSG_PlayerCreationVoiceForward )
+          {
+            v9 = &pPlayer[uNum];
             v46 = v9->GetSexByVoice();
             do
             {
@@ -3770,14 +3733,14 @@
               v10 = v9->GetSexByVoice();
             }
             while ( v10 != v46 );
-            v11 = pCreationUI_BtnPressRight2[*(int *)uClass];
+            v11 = pCreationUI_BtnPressRight2[uNum];
 LABEL_60:
             GUIWindow::Create(v11->uX, v11->uY, 0, 0, (enum WindowType)92, (int)v11, 1);
             pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
             v9->PlaySound(102, 0);
             continue;
           }
-          if ( v45 == UIMSG_A2 )
+          if ( pUIMessageType == UIMSG_A2 )
           {
             --dword_6A0C9C;
             if ( dword_6A0C9C < 0 )
@@ -3787,34 +3750,29 @@
             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 )
-        {
-          uPlayerCreationUI_SelectedCharacter = *(int *)uClass;
+        if ( pUIMessageType == UIMSG_PlayerCreationRemoveDownSkill )
+        {
+          uPlayerCreationUI_SelectedCharacter = uNum;
           v41 = 3;
           v1 = (char *)pParty->pPlayers;
-          v5 = (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38) % 7
-             + pGUIWindow_CurrentMenu->field_38
-             + 7 * *(int *)uClass;
+          v5 = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7
+             + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
           goto LABEL_44;
         }
-        if ( (signed int)v45 > 60 )
-        {
-          if ( v45 == 62 )
-          {
-            GUIWindow::Create(0x265u, 0x189u, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnPlus, 1);
-            ((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->IncreaseAttribute(
-              (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38) % 7);
+        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(
+              (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
             v42 = 0;
             v38 = 0;
             v36 = 0;
@@ -3822,14 +3780,14 @@
             v32 = -1;
             v31 = 0;
             v30 = 0;
-            v29 = (SoundID)20;
+            pSoundID = (SoundID)20;
             goto LABEL_40;
           }
-          if ( v45 == 63 )
-          {
-            GUIWindow::Create(0x20Bu, 0x189u, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
-            ((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->DecreaseAttribute(
-              (pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38) % 7);
+          if ( pUIMessageType == UIMSG_PlayerCreationClickMinus )
+          {
+            GUIWindow::Create(523, 393, 0, 0, (enum WindowType)90, (int)pPlayerCreationUI_BtnMinus, 1);
+            (&pPlayer[uPlayerCreationUI_SelectedCharacter])->DecreaseAttribute(
+              (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7);
             v42 = 0;
             v38 = 0;
             v36 = 0;
@@ -3837,14 +3795,13 @@
             v32 = -1;
             v31 = 0;
             v30 = 0;
-            v29 = (SoundID)23;
+            pSoundID = (SoundID)23;
             goto LABEL_40;
           }
-          if ( v45 == 64 )
-          {
-            auto _t = (Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter];
-            v6 = _t->GetSkillIdxByOrder(
-                   *(int *)uClass + 4);
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectActiveSkill )
+          {
+            auto _t = &pPlayer[uPlayerCreationUI_SelectedCharacter];
+            v6 = _t->GetSkillIdxByOrder(uNum + 4);
             if ( _t->GetSkillIdxByOrder(3) == 37 )
               pParty->pPlayers[0].pActiveSkills[v6 + 3486 * uPlayerCreationUI_SelectedCharacter] = 1;
             v42 = 0;
@@ -3854,40 +3811,40 @@
             v32 = -1;
             v31 = 0;
             v30 = 0;
-            v29 = (SoundID)24;
+            pSoundID = (SoundID)24;
             goto LABEL_40;
           }
-          if ( v45 == 65 )
-          {
-            ((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->Reset(uClass[0]);
+          if ( pUIMessageType == UIMSG_PlayerCreationSelectClass )
+          {
+            (&pPlayer[uPlayerCreationUI_SelectedCharacter])->Reset(uNum);
             goto LABEL_36;
           }
-          if ( v45 == 66 )
-          {
-            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 )
-          {
-            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 )
-            {
-              uPlayerCreationUI_SelectedCharacter = *(int *)uClass;
-              v4 = pGUIWindow_CurrentMenu->field_2C_focus_id - pGUIWindow_CurrentMenu->field_38;
-              v46 = pGUIWindow_CurrentMenu->field_38;
+            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 * *(int *)uClass;
+              v5 = v4 % 7 + v46 + 7 * uNum;
 LABEL_44:
-              pGUIWindow_CurrentMenu->field_2C_focus_id = v5;
-              pParty->pPlayers[0].pActiveSkills[((Player *)&v1[6972 * uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
+              pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
+              pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(v41)
                                              + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
               continue;
             }
@@ -3895,12 +3852,12 @@
         }
         else
         {
-          switch ( v45 )
+          switch ( pUIMessageType )
           {
             case 60:
               pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0);
-              v3 = *(void **)uClass;
-              uPlayerCreationUI_SelectedCharacter = *(int *)uClass;
+              v3 = (void *)uNum;
+              uPlayerCreationUI_SelectedCharacter = uNum;
               pKeyActionMap->_459E5A(0, 15, pGUIWindow_CurrentMenu);
               pGUIWindow_CurrentMenu->ptr_1C = v3;
               break;
@@ -3911,7 +3868,7 @@
               pMouse->SetCursorBitmap("MICON2");
               break;
             default:
-              if ( v45 == 58 )
+              if ( pUIMessageType == 58 )
                 goto LABEL_114;
               break;
           }
@@ -3947,17 +3904,13 @@
 }
 
 //----- (0043648F) --------------------------------------------------------
-void __thiscall Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
-{
-  signed int v2; // edx@1
-  double v3; // st7@1
-
+void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
+{
   _this->flt_2C = 0.0;
-  v2 = a2->y;
-  v3 = (double)a2->z;
-  _this->vWorldPosition.x = (double)a2->x;
-  _this->vWorldPosition.y = (double)v2;
-  _this->vWorldPosition.z = v3;
+
+  _this->vWorldPosition.x = a2->x;
+  _this->vWorldPosition.y = a2->y;
+  _this->vWorldPosition.z = a2->z;
 }
 
 //----- (004369DB) --------------------------------------------------------
@@ -4713,18 +4666,18 @@
           if ( v8 == 1 )
           {
             v9 = *(short *)v1;
-            v10 = pParty->vPosition.z - *((short *)v1 - 100);
+            v10 = pParty->vPosition.y - *((short *)v1 - 100);
             a1 = pParty->vPosition.x - *((short *)v1 - 200);
             v48 = v10;
             if ( a1 * a1
                + v10 * v10
-               + ((signed int)(pParty->vPosition.y + pParty->uPartyHeight) >> (1 - v9))
-               * ((signed int)(pParty->vPosition.y + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
+               + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9))
+               * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - v9)) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
             {
               v11.z = *(short *)v1;
               v11.y = *((short *)v1 - 100);
               v11.x = *((short *)v1 - 200);
-              if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y + pParty->sEyelevel, v11) )
+              if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v11) )
               {
                 v12 = stru_50C198.which_player_would_attack(&pActors[v39]);
                 DamagePlayerFromMonster(*((short *)v1 - 300), stru_50FE08.field_450[v43], pVelocity, v12);
@@ -4772,16 +4725,16 @@
       }
       else
       {
-        v23 = pParty->vPosition.z - *((short *)v1 - 100);
+        v23 = pParty->vPosition.y - *((short *)v1 - 100);
         v24 = ((signed int)pParty->uPartyHeight >> 1) - *(short *)v1;
         a1 = pParty->vPosition.x - *((short *)v1 - 200);
         v48 = v23;
-        if ( a1 * a1 + v23 * v23 + (pParty->vPosition.y + v24) * (pParty->vPosition.y + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
+        if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((*((short *)v1 + 100) + 32) * (*((short *)v1 + 100) + 32)) )
         {
           v25.z = *(short *)v1;
           v25.y = *((short *)v1 - 100);
           v25.x = *((short *)v1 - 200);
-          if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y + pParty->sEyelevel, v25) )
+          if ( sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, v25) )
           {
             v26 = 0;
             v27 = (char *)&pParty->pPlayers[0].pConditions[15];
@@ -5011,9 +4964,9 @@
     v9 = (LayingItem *)uDamageAmount;
     v50 = pParty->vPosition.x - *(int *)(uDamageAmount + 4);
     v55 = abs(v50);
-    pMonsterName = (char *)(pParty->vPosition.z - v9->vPosition.y);
+    pMonsterName = (char *)(pParty->vPosition.y - v9->vPosition.y);
     v51 = (unsigned __int64 *)abs((int)pMonsterName);
-    pPlayerName = (char *)(pParty->vPosition.y - v9->vPosition.z);
+    pPlayerName = (char *)(pParty->vPosition.z - v9->vPosition.z);
     v52 = abs((int)pPlayerName);
     v61 = v55;
     v10 = v55;
@@ -6398,7 +6351,7 @@
     v15->field_C = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     _43C91D_FormItemTextureFilename(pContainer, 544, v14, 0);
     v15->field_10 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    if ( sub_43ED6F_get_some_race_sex_relation(1u) )
+    if ( _43ED6F_check_party_races(true) )
       papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE);
     v35 += 28;
     ++v14;
@@ -6555,9 +6508,11 @@
   int v8; // [sp-4h] [bp-10h]@61
   signed int v9; // [sp-4h] [bp-10h]@69
 
+  result = 0; //BUG   fn is void
   if ( a2 <= 500 )
   {
-    v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0;
+    //v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0;
+    v5 = byte_5111C0[(a2 - 100) + 32 + 2] == 0;
 LABEL_21:
     if ( v5 )
       return result;
@@ -8691,37 +8646,26 @@
 
 
 //----- (0043ED6F) --------------------------------------------------------
-bool __thiscall sub_43ED6F_get_some_race_sex_relation(unsigned int a1)
-{
-  unsigned int v1; // ebp@1
-  Player **v2; // ebx@1
-  Player *v3; // esi@2
-  enum CHARACTER_RACE v4; // edi@2
-  bool result; // eax@2
-  char v6; // zf@5
-
-  v1 = a1;
-  v2 = &pPlayers[1];
-  while ( 1 )
-  {
-    v3 = *v2;
-    v4 = v3->GetRace();
-    result = v3->GetSexByVoice();
-    if ( v4 && v4 != CHARACTER_RACE_ELF && v4 != CHARACTER_RACE_GOBLIN )
-      v6 = v1 == 1;
+bool _43ED6F_check_party_races(bool a1)
+{
+  bool v6; // zf@5
+
+  for (uint i = 0; i < 4; ++i)
+  {
+    auto player = pParty->pPlayers + i;
+    auto race = player->GetRace();
+
+    if (race != CHARACTER_RACE_HUMAN &&
+        race != CHARACTER_RACE_ELF &&
+        race != CHARACTER_RACE_GOBLIN)
+      v6 = a1 == 1;
     else
-      v6 = v1 == 0;
-    if ( v6 )
-      break;
-    ++v2;
-    if ( (signed int)v2 >= (signed int)&qword_A750D8 )
-    {
-      LOBYTE(result) = 0;
-      return result;
-    }
-  }
-  LOBYTE(result) = 1;
-  return result;
+      v6 = !a1;
+
+    if (v6)
+      return true;
+  }
+  return false;
 }
 // A750D8: using guessed type __int64 qword_A750D8;
 
@@ -8957,120 +8901,79 @@
 
 
 //----- (0043F333) --------------------------------------------------------
-int stru170::RenderWalls()
-{
-  signed int result; // eax@1
-  unsigned __int8 v2; // zf@1
-  unsigned __int8 v3; // sf@1
-  stru170_stru0 *v4; // edx@2
-  int v5; // eax@3
+void stru170::MakeVisibleSectorList()
+{
   int v6; // ebx@3
-  char *v7; // esi@4
-  signed int v8; // [sp+0h] [bp-4h]@1
-
-  result = 0;
-  v2 = this->std__vector_000FA8 == 0;
-  v3 = (this->std__vector_000FA8 & 0x80000000u) != 0;
-  this->field_53730 = 0;
-  v8 = 0;
-  if ( !(v3 | v2) )
-  {
-    v4 = this->field_FA8;
-    do
-    {
-      v5 = this->field_53730;
+
+  uNumVisibleNotEmptySectors = 0;
+  for (uint i = 0; i < std__vector_000FA8; ++i)
+  {
       v6 = 0;
-      if ( v5 <= 0 )
+      if (!uNumVisibleNotEmptySectors)
       {
 LABEL_7:
-        this->pSectorIDs_toDrawDecorationsFrom[v5] = v4->uSectorID;
-        ++this->field_53730;
+        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
       }
       else
       {
-        v7 = (char *)this->pSectorIDs_toDrawDecorationsFrom;
-        while ( *(short *)v7 != v4->uSectorID )
+        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != field_FA8[i].uSectorID )
         {
           ++v6;
-          v7 += 2;
-          if ( v6 >= v5 )
-            goto LABEL_7;
-        }
-      }
-      ++v8;
-      ++v4;
-      result = v8;
-    }
-    while ( v8 < (signed int)this->std__vector_000FA8 );
-  }
-  return result;
+          if ( v6 >= uNumVisibleNotEmptySectors)
+          {
+            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
+            continue;
+          }
+        }
+      }
+  }
 }
 
 
 //----- (0043F515) --------------------------------------------------------
-void __cdecl MessWithBillboards_BLV()
-{
-  signed int v0; // edi@1
-  char *v1; // esi@2
-
-  v0 = 0;
-  if ( (signed int)uNumBillboardsToDraw > 0 )
-  {
-    v1 = (char *)&pBillboardRenderList[0].field_2A;
-    do
-    {
-      if ( *(v1 - 12) & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !*((short *)v1 - 7) )
-        *(short *)v1 = 0;
-      else
-        *(short *)v1 = sub_43F55F((RenderBillboard *)(v1 - 42), -1);
-      ++v0;
-      v1 += 52;
-    }
-    while ( v0 < (signed int)uNumBillboardsToDraw );
+void MessWithBillboards_BLV()
+{
+  for (uint i = 0; i < uNumBillboardsToDraw; ++i)
+  {
+    auto p = pBillboardRenderList + i;
+
+    if (p->field_1E & 2 || uCurrentlyLoadedLevelType == LEVEL_Indoor && !p->uIndoorSectorID)
+      p->uPaletteSubindex = 0;
+    else
+      p->uPaletteSubindex = _43F55F_get_billboard_light_level(p, -1);
   }
 }
 
 //----- (0043F55F) --------------------------------------------------------
-signed int __fastcall sub_43F55F(RenderBillboard *a1, signed int a2)
-{
-  RenderBillboard *v2; // eax@1
+int __fastcall _43F55F_get_billboard_light_level(RenderBillboard *a1, int uBaseLightLevel)
+{
   signed int v3; // ecx@2
-  float v4; // ST08_4@6
-  float v5; // ST04_4@6
-  float v6; // ST00_4@6
-
-  v2 = a1;
+
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     v3 = pIndoor->pSectors[a1->uIndoorSectorID].uMinAmbientLightLevel;
   }
   else
   {
-    if ( a2 == -1 )
-      v3 = a1->field_2A;
+    if ( uBaseLightLevel == -1 )
+      v3 = a1->uPaletteSubindex;
     else
-      v3 = a2;
-  }
-  v4 = (double)v2->field_24;
-  v5 = (double)v2->field_22;
-  v6 = (double)v2->field_20;
-  return sub_43F5C8(v3, v2->uIndoorSectorID, v6, v5, v4);
+      v3 = uBaseLightLevel;
+  }
+  return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->some_x, a1->some_y, a1->some_z);
 }
 
 //----- (0043F5C8) --------------------------------------------------------
-signed int __fastcall sub_43F5C8(signed int a1, int a2, float a3, float a4, float a5)
+int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z)
 {
   int v5; // esi@1
   signed int v6; // edi@1
-  char *v7; // ebx@2
   int v8; // eax@6
   int v9; // ebx@6
   unsigned int v10; // ecx@6
   unsigned int v11; // edx@9
   unsigned int v12; // edx@11
   signed int v13; // ecx@12
-  BLVSector *v14; // esi@17
-  int v15; // ecx@17
   BLVLightMM7 *v16; // esi@20
   int v17; // ebx@21
   int v18; // eax@24
@@ -9080,7 +8983,6 @@
   unsigned int v22; // edx@27
   unsigned int v23; // edx@29
   signed int v24; // ecx@30
-  char *v25; // esi@34
   int v26; // ebx@35
   int v27; // eax@38
   int v28; // ebx@38
@@ -9089,53 +8991,41 @@
   unsigned int v31; // edx@41
   unsigned int v32; // edx@43
   signed int v33; // ecx@44
-  int v35; // [sp+Ch] [bp-18h]@4
-  BLVSector *v36; // [sp+Ch] [bp-18h]@17
   int v37; // [sp+Ch] [bp-18h]@37
   int v38; // [sp+10h] [bp-14h]@5
   int v39; // [sp+10h] [bp-14h]@23
   int v40; // [sp+10h] [bp-14h]@36
-  int v41; // [sp+14h] [bp-10h]@3
   int v42; // [sp+14h] [bp-10h]@22
   unsigned int v43; // [sp+18h] [bp-Ch]@12
   unsigned int v44; // [sp+18h] [bp-Ch]@30
   unsigned int v45; // [sp+18h] [bp-Ch]@44
-  char *v46; // [sp+1Ch] [bp-8h]@2
-  int v47; // [sp+1Ch] [bp-8h]@17
-  int v48; // [sp+20h] [bp-4h]@1
-  int v49; // [sp+20h] [bp-4h]@17
-  int v50; // [sp+20h] [bp-4h]@33
-
-  v48 = 0;
-  v5 = a2;
-  v6 = a1;
-  if ( uNumMobileLightsApplied > 0 )
-  {
-    v7 = (char *)&pMobileLights[0].uRadius;
-    v46 = (char *)&pMobileLights[0].uRadius;
-    do
-    {
-      v41 = abs((signed __int64)((double)*((short *)v7 - 3) - a3));
-      if ( v41 <= *(short *)v7 )
-      {
-        v35 = abs((signed __int64)((double)*((short *)v7 - 2) - a4));
-        if ( v35 <= *(short *)v7 )
-        {
-          v38 = abs((signed __int64)((double)*((short *)v7 - 1) - a5));
-          if ( v38 <= *(short *)v7 )
-          {
-            v8 = v41;
-            v9 = v35;
-            v10 = v38;
-            if ( v41 < v35 )
-            {
-              v8 = v35;
-              v9 = v41;
-            }
-            if ( v8 < v38 )
+
+  v6 = uBaseLightLevel;
+  for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i)
+  {
+    auto p = pMobileLightsStack->pLights + i;
+
+      auto distX = abs(p->vPosition.x - x);
+      if ( distX <= p->uRadius)
+      {
+        auto distY = abs(p->vPosition.y - y);
+        if ( distY <= p->uRadius)
+        {
+          auto distZ = abs(p->vPosition.z - z);
+          if ( distZ <= p->uRadius)
+          {
+            v8 = distX;
+            v9 = distY;
+            v10 = distZ;
+            if (distX < distY)
+            {
+              v8 = distY;
+              v9 = distX;
+            }
+            if ( v8 < distZ )
             {
               v11 = v8;
-              v8 = v38;
+              v8 = distZ;
               v10 = v11;
             }
             if ( v9 < (signed int)v10 )
@@ -9144,41 +9034,31 @@
               v10 = v9;
               v9 = v12;
             }
-            v43 = ((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8;
-            v13 = *(short *)v46;
+            v43 = ((unsigned int)(11 * v9) / 32) + (v10 / 4) + v8;
+            v13 = p->uRadius;
             if ( (signed int)v43 < v13 )
-              v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
-            v7 = v46;
-          }
-        }
-      }
-      ++v48;
-      v7 += 18;
-      v46 = v7;
-    }
-    while ( v48 < uNumMobileLightsApplied );
-  }
+              v6 += ((unsigned __int64)(30i64 * (signed int)(v43 << 16) / v13) >> 16) - 30;
+          }
+        }
+      }
+  }
+
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
-    v14 = &pIndoor->pSectors[v5];
-    v15 = 0;
-    v49 = 0;
-    v36 = v14;
-    v47 = v14->uNumLights;
-    if ( v14->uNumLights > 0 )
-    {
-      while ( 1 )
-      {
-        v16 = &pIndoor->pLights[*(&v14->pLights->vPosition.x + v15)];
-        if ( !(v16->uAtributes & 8) )
-        {
-          v17 = abs((signed __int64)((double)v16->vPosition.x - a3));
+    auto pSector = pIndoor->pSectors + uSectorID;
+
+    for (uint i = 0; i < pSector->uNumLights; ++i)
+    {
+        v16 = pIndoor->pLights + pSector->pLights[i];
+        if (~v16->uAtributes & 8)
+        {
+          v17 = abs(v16->vPosition.x - x);
           if ( v17 <= v16->uRadius )
           {
-            v42 = abs((signed __int64)((double)v16->vPosition.y - a4));
+            v42 = abs(v16->vPosition.y - y);
             if ( v42 <= v16->uRadius )
             {
-              v39 = abs((signed __int64)((double)v16->vPosition.z - a5));
+              v39 = abs(v16->vPosition.z - z);
               if ( v39 <= v16->uRadius )
               {
                 v18 = v17;
@@ -9205,32 +9085,25 @@
                 v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18;
                 v24 = v16->uRadius;
                 if ( (signed int)v44 < v24 )
-                  v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
+                  v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30;
               }
             }
           }
         }
-        v15 = v49++ + 1;
-        if ( v49 >= v47 )
-          break;
-        v14 = v36;
-      }
-    }
-  }
-  v50 = 0;
-  if ( uNumStationaryLightsApplied > 0 )
-  {
-    v25 = (char *)&pStationaryLights[0].uRadius;
-    do
-    {
-      v26 = abs((signed __int64)((double)*((short *)v25 - 3) - a3));
-      if ( v26 <= *(short *)v25 )
-      {
-        v40 = abs((signed __int64)((double)*((short *)v25 - 2) - a4));
-        if ( v40 <= *(short *)v25 )
-        {
-          v37 = abs((signed __int64)((double)*((short *)v25 - 1) - a5));
-          if ( v37 <= *(short *)v25 )
+    }
+  }
+
+  for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
+  {
+    auto p = pStationaryLightsStack->pLights + i;
+      v26 = abs(p->vPosition.x - x);
+      if ( v26 <= p->uRadius)
+      {
+        v40 = abs(p->vPosition.y - y);
+        if ( v40 <= p->uRadius)
+        {
+          v37 = abs(p->vPosition.z - z);
+          if ( v37 <= p->uRadius)
           {
             v27 = v26;
             v28 = v40;
@@ -9254,17 +9127,14 @@
               v28 = v32;
             }
             v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27;
-            v33 = *(short *)v25;
+            v33 = p->uRadius;
             if ( (signed int)v45 < v33 )
-              v6 = v6 + ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
-          }
-        }
-      }
-      ++v50;
-      v25 += 12;
-    }
-    while ( v50 < uNumStationaryLightsApplied );
-  }
+              v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;
+          }
+        }
+      }
+  }
+
   if ( v6 <= 31 )
   {
     if ( v6 < 0 )
@@ -9276,7 +9146,6 @@
   }
   return v6;
 }
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
 
 //----- (00406051) --------------------------------------------------------
 __int16 stru262_TurnBased::StartTurn()
@@ -9483,7 +9352,7 @@
         if ( (signed __int16)v6 == 4 )
         {
           v3 = 0;
-          v5->uAIState = 5;
+          v5->uAIState = Dead;
           v5->uCurrentActionTime = 0;
           v5->uCurrentActionLength = 0;
           v5->UpdateAnimation();
@@ -10235,7 +10104,7 @@
             {
               v6->uCurrentActionTime = 0;
               v6->uCurrentActionLength = 0;
-              v6->uAIState = 5;
+              v6->uAIState = Dead;
               v6->UpdateAnimation();
             }
             if ( !thisa->_406D10(a2) )
@@ -10506,11 +10375,11 @@
                 v5->uCurrentActionTime += pMiscTimer->uTimeElapsed;
                 if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength )
                 {
-                  if ( v5->uAIState == 4 )
+                  if (v5->uAIState == Dying)
                   {
                     v5->uCurrentActionTime = 0;
                     v5->uCurrentActionLength = 0;
-                    v5->uAIState = 5;
+                    v5->uAIState = Dead;
                     v5->UpdateAnimation();
                     return;
                   }
@@ -10660,10 +10529,10 @@
       else
       {
         v18 = pParty->vPosition.x;
-        v17 = pParty->sEyelevel + pParty->vPosition.y;
-        v60 = pParty->vPosition.z;
-        v44 = pParty->sEyelevel + pParty->vPosition.y;
-        v43 = pParty->vPosition.z;
+        v17 = pParty->sEyelevel + pParty->vPosition.z;
+        v60 = pParty->vPosition.y;
+        v44 = pParty->sEyelevel + pParty->vPosition.z;
+        v43 = pParty->vPosition.y;
       }
       v19 = pIndoor->GetSector(v18, v43, v44);
     }
@@ -10981,7 +10850,7 @@
   signed int a5a; // [sp+2Ch] [bp+10h]@14
 
   v5 = a4;
-  v6 = a4->uFaceAttributes;
+  v6 = a4->uAttributes;
   v7 = 0;
   if ( v6 & 0x100 )
   {
@@ -11350,7 +11219,7 @@
       sDepthb = 0;
       for ( i = 116 * v59;
             sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->field_C + v61)
-                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v61);
+                    + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
             ++sDepthb )
       {
         v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
@@ -11504,7 +11373,7 @@
       v162 = 0;
       v112 = v89;
       if ( *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
-         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v89) > 0 )
+         + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
         break;
 LABEL_148:
       ++a5c;
@@ -11584,7 +11453,7 @@
       v88 = pIndoor->pSectors;
       ++v162;
       if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->field_C + v89)
-                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->field_4 + v89) )
+                 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
         goto LABEL_148;
     }
   }
@@ -11915,7 +11784,7 @@
 }
 
 //----- (00408896) --------------------------------------------------------
-char *__cdecl UpdateLayingItems()
+void UpdateLayingItems()
 {
   unsigned int v0; // edi@1
   char *v1; // esi@1
@@ -11931,14 +11800,9 @@
     ++v0;
   }
   while ( (signed int)v1 < (signed int)((char *)&pObjectList->uNumObjects + 2) );
-  result = (char *)&array_5118E8.pElements[0].field_C;
-  do
-  {
-    *(short *)result = 0;
-    result += 24;
-  }
-  while ( (signed int)result < (signed int)&pBillboardRenderList[0].field_4 );
-  return result;
+
+  for (uint i = 0; i < 100; ++i)
+    array_5118E8.pElements[i].field_C_time_left = 0;
 }
 
 //----- (004088E9) --------------------------------------------------------
@@ -12190,14 +12054,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();
 }
@@ -12646,7 +12510,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
@@ -12657,7 +12521,7 @@
   a1.uFrameX = 90;
   a1.uFrameZ = 417;
   a1.uFrameW = v3 + 67;
-  a1.str_48 = 0;
+  a1.Hint = 0;
   a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);
   v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);
   v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);
@@ -12694,7 +12558,7 @@
   if ( (signed int)a1.uFrameHeight < 150 )
     a1.uFrameHeight = 150;
   a1.uFrameWidth = 460;
-  a1._415551(0);
+  a1.DrawMessageBox(0);
   a1.uFrameWidth -= 12;
   a1.uFrameHeight -= 12;
   v7 = v2->pName;
@@ -12705,14 +12569,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;
 }
@@ -13127,7 +12991,7 @@
 //----- (00411473) --------------------------------------------------------
 void __cdecl sub_411473()
 {
-  char *v0; // esi@1
+  Texture **v0; // esi@1
   Texture **v1; // edi@1
   Texture *v2; // ecx@2
   Texture *v3; // ecx@2
@@ -13135,7 +12999,7 @@
   pTexture_pagemask->Release();
   pTexture_506448->Release();
   pTexture_50643C->Release();
-  v0 = &pTextures_tabs[0][0].pName[4];
+  v0 = &pTextures_tabs[0][1];
   v1 = pTextures_5064A0;
   do
   {
@@ -13224,7 +13088,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);
@@ -13250,14 +13114,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);
           }
         }
@@ -13274,7 +13138,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 )
@@ -13292,9 +13156,9 @@
   {
     if ( *(short *)a2.x )
     {
-      if ( v0->field_1A4E == v13 )
-      {
-        v16 = *(Texture **)&pTextures_tabs[0][0].pName[8 * v13 + 4];
+      if ( v0->pNumSpellBookPage == v13 )
+      {
+        v16 = pTextures_tabs[v13][1];
         switch ( v13 )
         {
           case 0:
@@ -13334,7 +13198,7 @@
       }
       else
       {
-        v16 = *(Texture **)&pTextures_tabs[0][0].pName[8 * v13];
+        v16 = pTextures_tabs[v13][0];
         switch ( v13 )
         {
           case 0:
@@ -14039,7 +13903,7 @@
   if ( v7 )
     v22.DrawText2(pBook2Font, 0xFFFFFFF2u, 0xCu, 0, pMapStats->pInfos[v7].pName, 3u);
   v22.uFrameX = 0;
-  sprintfex(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.z);
+  sprintfex(Str, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y);
   return v22.DrawText2(pFontComic, 0, 0x140u, 0, Str, 0);
 }
 
@@ -14245,28 +14109,28 @@
   v2 = pStr;
   v3 = a4;
   pEventTimer->Pause();
-  dword_506F0C[0] = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+  dword_506F0C[0] = pCurrentScreen;
   result = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, v3, (int)v2);
   ptr_507BDC = result;
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 22;
+  pCurrentScreen = 22;
   return result;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (0041420D) --------------------------------------------------------
 void __cdecl sub_41420D_press_esc()
 {
   GUIWindow v0; // [sp+4h] [bp-54h]@1
 
-  sprintfex(pTmpBuf2, "%s\n \n%s", ptr_507BDC->str_48, pGlobalTXT_LocalizationStrings[61]);// Press Escape
-  v0.str_48 = pTmpBuf2;
+  sprintfex(pTmpBuf2, "%s\n \n%s", ptr_507BDC->Hint, pGlobalTXT_LocalizationStrings[61]);// Press Escape
+  v0.Hint = pTmpBuf2;
   v0.uFrameWidth = 400;
   v0.uFrameHeight = 100;
   v0.uFrameX = 120;
   v0.uFrameY = 140;
   v0.uFrameZ = 519;
   v0.uFrameW = 239;
-  v0._415551(0);
+  v0.DrawMessageBox(0);
 }
 
 //----- (0041426F) --------------------------------------------------------
@@ -14284,10 +14148,10 @@
   }
   v0->Release();
   ptr_507BDC = 0;
-  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = dword_506F0C[0];
+  pCurrentScreen = dword_506F0C[0];
   pEventTimer->Resume();
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+// 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (004142D3) --------------------------------------------------------
 char __cdecl GameMenuUI_DrawKeyBindings()
@@ -14835,7 +14699,7 @@
   Dst.uFrameY = 470 - Dst.uFrameHeight;
   Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
   Dst.uFrameW = 469;
-  Dst._415551(0);
+  Dst.DrawMessageBox(0);
   Dst.uFrameWidth -= 24;
   Dst.uFrameX += 12;
   Dst.uFrameY += 12;
@@ -14851,8 +14715,8 @@
 //----- (004156F0) --------------------------------------------------------
 void __cdecl GUI_UpdateWindows()
 {
-  GUIWindow *v0; // esi@4
-  unsigned int v1; // eax@4
+  GUIWindow *pWindow; // esi@4
+  unsigned int pWindowType; // eax@4
   int v2; // eax@10
   int v3; // eax@11
   int v4; // eax@12
@@ -14909,10 +14773,10 @@
   for ( i = 1; i <= uNumVisibleWindows; ++i )
   {
     //v0 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[i]];
-    v0 = &pWindowList[pVisibleWindowsIdxs[i] - 1];
-    v1 = v0->eWindowType;
-
-    switch (v0->eWindowType)
+    pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
+    pWindowType = pWindow->eWindowType;
+
+    switch (pWindow->eWindowType)
     {
       case WINDOW_MainMenu_Load:
         GameUI_MainMenu_DrawLoad();
@@ -14920,16 +14784,16 @@
 
       case WINDOW_5E: // window that initiates savegame loading
       {
-        if (v0->str_48 != (char *)1)
+        if (pWindow->Hint != (char *)1)
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        auto v20 = (GUIButton *)v0->ptr_1C;
-        pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, v20->pTextures[0]);
-        v21 = v0->str_48;
+        auto v20 = (GUIButton *)pWindow->ptr_1C;
+        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, v20->pTextures[0]);
+        v21 = pWindow->Hint;
         viewparams->bRedrawGameUI = 1;
         if ( v21 && v21 != (char *)1 )
           v20->DrawLabel(v21, pFontCreate, 0, 0);
-        v0->Release();
-        if (uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11)
+        pWindow->Release();
+        if (pCurrentScreen == 11)
           pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0);
         else
           pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0);
@@ -14938,22 +14802,22 @@
     }
 
 
-    if ( (signed int)v1 > 70 )
-    {
-      if ( (signed int)v1 > 95 )
-      {
-        v33 = v1 - 96;
+    if ( (signed int)pWindowType > 70 )
+    {
+      if ( (signed int)pWindowType > 95 )
+      {
+        v33 = pWindowType - 96;
         if ( !v33 )
         {
-          if ( v0->str_48 != (char *)1 )
+          if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-          v42 = (GUIButton *)v0->ptr_1C;
-          pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, v42->pTextures[0]);
-          v43 = v0->str_48;
+          v42 = (GUIButton *)pWindow->ptr_1C;
+          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, v42->pTextures[0]);
+          v43 = pWindow->Hint;
           viewparams->bRedrawGameUI = 1;
           if ( v43 && v43 != (char *)1 )
             v42->DrawLabel(v43, pFontCreate, 0, 0);
-          v0->Release();
+          pWindow->Release();
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           v41 = pMessageQueue_50CBD0->uNumMessages;
@@ -14990,15 +14854,15 @@
               }
               else
               {
-                v0->_415551(0);
-                v0->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
-                v0->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
+                pWindow->DrawMessageBox(0);
+                pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
+                pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
                 if ( !pKeyActionMap->field_204 )
                 {
                   v51.Reset();
-                  v0->Release();
+                  pWindow->Release();
                   pEventTimer->Resume();
-                  uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+                  pCurrentScreen = 0;
                   viewparams->bRedrawGameUI = 1;
                   v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
                   if ( v39 > 0 )
@@ -15010,9 +14874,9 @@
               }
               continue;
             }
-            v46 = (Texture *)*((_DWORD *)v0->ptr_1C + 15);
-            v45 = v0->uFrameY;
-            v44 = v0->uFrameX;
+            v46 = (Texture *)*((_DWORD *)pWindow->ptr_1C + 15);
+            v45 = pWindow->uFrameY;
+            v44 = pWindow->uFrameX;
 LABEL_18:
             pRenderer->DrawTextureIndexed(v44, v45, v46);
 LABEL_114:
@@ -15028,51 +14892,51 @@
           Dst.uHeight = 37;
           Dst.pParent = pButton_RestUI_WaitUntilDawn->pParent;
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-          pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, *((Texture **)v0->ptr_1C + 15));
+          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15));
           viewparams->bRedrawGameUI = 1;
           Dst.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);
           Dst.pParent = 0;
           goto LABEL_134;
         }
-        if ( v0->str_48 != (char *)1 )
+        if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        v32 = v0->ptr_1C;
-        pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, *((Texture **)v32 + 16));
+        v32 = pWindow->ptr_1C;
+        pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16));
         goto LABEL_138;
       }
-      if ( v1 == 95 )
-      {
-        if ( v0->str_48 != (char *)1 )
+      if ( pWindowType == 95 )
+      {
+        if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-        v32 = v0->ptr_1C;
-        pRenderer->DrawTextureTransparent(v0->uFrameX, v0->uFrameY, *((Texture **)v32 + 15));
+        v32 = pWindow->ptr_1C;
+        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 15));
 LABEL_138:
-        v40 = v0->str_48;
+        v40 = pWindow->Hint;
         viewparams->bRedrawGameUI = 1;
         if ( v40 && v40 != (char *)1 )
           ((GUIButton *)v32)->DrawLabel(v40, pFontCreate, 0, 0);
-        v0->Release();
+        pWindow->Release();
 LABEL_142:
         v41 = pMessageQueue_50CBD0->uNumMessages;
         if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           goto LABEL_151;
         continue;
       }
-      v14 = v1 - 80;
+      v14 = pWindowType - 80;
       if ( v14 )
       {
         v15 = v14 - 9;
         if ( !v15 )
         {
-          v0->_415551(0);
-          v0->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
-          v0->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
+          pWindow->DrawMessageBox(0);
+          pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0);
+          pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0);
           if ( !pKeyActionMap->field_204 )
           {
             _this.Reset();
-            v0->Release();
+            pWindow->Release();
             pEventTimer->Resume();
-            uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+            pCurrentScreen = 0;
             viewparams->bRedrawGameUI = 1;
             v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
             if ( v26 > 0 )
@@ -15101,9 +14965,9 @@
         v16 = v15 - 1;
         if ( !v16 )
         {
-          if ( v0->str_48 != (char *)1 )
+          if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-          v22 = (GUIButton *)v0->ptr_1C;
+          v22 = (GUIButton *)pWindow->ptr_1C;
           if ( (v22->uX & 0x80000000u) == 0 )
           {
             if ( (signed int)v22->uX <= 640 )
@@ -15119,7 +14983,7 @@
               }
             }
           }
-          v23 = v0->str_48;
+          v23 = pWindow->Hint;
           viewparams->bRedrawGameUI = 1;
           if ( v23 )
           {
@@ -15127,20 +14991,20 @@
             goto LABEL_82;
           }
 LABEL_134:
-          v28 = v0;
+          v28 = pWindow;
           goto LABEL_110;
         }
         v17 = v16 - 1;
         if ( !v17 )
         {
-          if ( v0->str_48 != (char *)1 )
+          if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-          v22 = (GUIButton *)v0->ptr_1C;
+          v22 = (GUIButton *)pWindow->ptr_1C;
           v47 = v22->pTextures[1];
 LABEL_94:
-          pRenderer->DrawTextureIndexed(v0->uFrameX, v0->uFrameY, v47);
+          pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, v47);
 LABEL_80:
-          v23 = v0->str_48;
+          v23 = pWindow->Hint;
           viewparams->bRedrawGameUI = 1;
           if ( v23 )
           {
@@ -15154,18 +15018,18 @@
         v18 = v17 - 1;
         if ( !v18 )
         {
-          if ( v0->str_48 != (char *)1 )
+          if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-          v22 = (GUIButton *)v0->ptr_1C;
-          pRenderer->DrawTextureTransparent(v0->uFrameX, v0->uFrameY, v22->pTextures[0]);
+          v22 = (GUIButton *)pWindow->ptr_1C;
+          pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, v22->pTextures[0]);
           goto LABEL_80;
         }
         v19 = v18 - 1;
         if ( !v19 )
         {
-          if ( v0->str_48 != (char *)1 )
+          if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
-          pRenderer->DrawTextureTransparent(v0->uFrameX, v0->uFrameY, *((Texture **)v0->ptr_1C + 16));
+          pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 16));
           viewparams->bRedrawGameUI = 1;
           goto LABEL_134;
         }
@@ -15175,7 +15039,7 @@
         v27 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
         if ( ptr_507BD0->field_40 == 1 )
         {
-          ptr_507BD0->_415551(0);
+          ptr_507BD0->DrawMessageBox(0);
           ptr_507BD0->DrawText(
             pFontCreate,
             30,
@@ -15193,7 +15057,7 @@
         if ( ptr_507BD0->field_40 == 2 )
         {
           v29 = pMessageQueue_50CBD0->uNumMessages;
-          v0->field_40 = 0;
+          pWindow->field_40 = 0;
           if ( (signed int)v29 < 40 )
           {
             pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C;
@@ -15203,12 +15067,12 @@
           }
           pEventTimer->Resume();
           ptr_507BD0->Release();
-          uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
+          pCurrentScreen = 0;
           goto LABEL_114;
         }
         if ( ptr_507BD0->field_40 == 3 )
         {
-          v0->field_40 = 0;
+          pWindow->field_40 = 0;
           pEventTimer->Resume();
           v28 = ptr_507BD0;
 LABEL_110:
@@ -15219,16 +15083,16 @@
     }
     else
     {
-      if ( v1 == 70 )
+      if ( pWindowType == 70 )
       {
         sub_41420D_press_esc();
         continue;
       }
-      if ( (signed int)v1 > 18 )
-      {
-        if ( (signed int)v1 > 25 )
-        {
-          v12 = v1 - 26;
+      if ( (signed int)pWindowType > 18 )
+      {
+        if ( (signed int)pWindowType > 25 )
+        {
+          v12 = pWindowType - 26;
           if ( v12 )
           {
             v13 = v12 - 4;
@@ -15257,9 +15121,9 @@
           }
           continue;
         }
-        if ( v1 != 25 )
-        {
-          v7 = v1 - 19;
+        if ( pWindowType != 25 )
+        {
+          v7 = pWindowType - 19;
           if ( v7 )
           {
             v8 = v7 - 1;
@@ -15278,13 +15142,13 @@
             }
             else
             {
-              if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
+              if ( pCurrentScreen == 10 )
               {
-                Chest::DrawChestUI((unsigned int)v0->ptr_1C);
+                Chest::DrawChestUI((unsigned int)pWindow->ptr_1C);
               }
               else
               {
-                if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 15 )
+                if ( pCurrentScreen == 15 )
                 {
                   pRenderer->ClearZBuffer(0, 479);
                   draw_leather();
@@ -15324,15 +15188,15 @@
         }
         goto LABEL_142;
       }
-      if ( v1 == 18 )
+      if ( pWindowType == 18 )
       {
         sub_412B58();
       }
       else
       {
-        if ( (signed int)v1 > 10 )
-        {
-          v5 = v1 - 12;
+        if ( (signed int)pWindowType > 10 )
+        {
+          v5 = pWindowType - 12;
           if ( v5 )
           {
             v6 = v5 - 4;
@@ -15352,9 +15216,9 @@
           }
           continue;
         }
-        if ( v1 != 10 )
-        {
-          v2 = v1 - 3;
+        if ( pWindowType != 10 )
+        {
+          v2 = pWindowType - 3;
           if ( v2 )
           {
             v3 = v2 - 1;
@@ -15364,7 +15228,7 @@
               if ( v4 )
               {
                 if ( v4 == 3 )
-                  DrawSpellbook((unsigned int)v0->ptr_1C);
+                  DrawSpellbook((unsigned int)pWindow->ptr_1C);
               }
               else
               {
@@ -15482,7 +15346,7 @@
   if ( !v0->CanAct() )
   {
     sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]);
-    v43.str_48 = pTmpBuf;
+    v43.Hint = pTmpBuf;
     v43.uFrameWidth = 384;
     v43.uFrameHeight = 180;
     v43.uFrameY = 40;
@@ -15491,7 +15355,7 @@
     else
       v38 = pMouse->GetCursorPos(&a2)->x - 414;
     v43.uFrameX = v38;
-    v43._415551(0);
+    v43.DrawMessageBox(0);
     return;
   }
   --pOut.z;
@@ -15695,7 +15559,7 @@
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
-      v39.z = pParty->vPosition.y + pParty->sEyelevel;
+      v39.z = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
@@ -15769,7 +15633,7 @@
       v42 = (int *)&a2.y;
       v41 = (int *)&y.y;
       v40 = (int *)&pOut;
-      v39.z = pParty->vPosition.y + pParty->sEyelevel;
+      v39.z = pParty->vPosition.z + pParty->sEyelevel;
     }
     *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x;
     Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42);
@@ -15898,9 +15762,9 @@
         {
           lpsz = (LPCSTR)*(&pNPCStats->field_13A64 + 5 * v6->uProfession);
           if ( !lpsz )
-            lpsz = nullstring;
-        }
-        a1.str_48 = 0;
+            lpsz = "";
+        }
+        a1.Hint = 0;
         a1.uFrameX = 38;
         a1.uFrameY = 60;
         a1.uFrameWidth = 276;
@@ -15912,7 +15776,7 @@
           a1.uFrameHeight = 130;
         a1.uFrameWidth = 400;
         a1.uFrameZ = a1.uFrameX + 399;
-        a1._415551(0);
+        a1.DrawMessageBox(0);
         sprintfex(pTmpBuf2, "NPC%03d", v6->uPortraitID);
         v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE);
         pRenderer->DrawTextureIndexed(
@@ -15980,7 +15844,7 @@
   unsigned int pX; // [sp+70h] [bp-8h]@3
   unsigned int pY; // [sp+74h] [bp-4h]@3
 
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16 )
+  if ( pCurrentScreen == 16 )
     return;
   if ( _this )
   {
@@ -16019,10 +15883,11 @@
     while ( v1 < 4 );
   }
   pEventTimer->Pause();
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 10 )
-  {
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 10 )
-    {
+  if ( pCurrentScreen <= 10 )
+  {
+    if ( pCurrentScreen == 10 )
+    {
+      __debugbreak();
       if ( !pPlayers[uActiveCharacter]->CanAct() )
       {
         sprintfex(
@@ -16030,7 +15895,7 @@
           pGlobalTXT_LocalizationStrings[427],
           pPlayers[uActiveCharacter]->pName,
           pGlobalTXT_LocalizationStrings[541]);
-        a1.str_48 = pTmpBuf;
+        a1.Hint = pTmpBuf;
         a1.uFrameWidth = 384;
         a1.uFrameHeight = 180;
         a1.uFrameY = 40;
@@ -16054,13 +15919,13 @@
     }
     else
     {
-      if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
-      {
-        if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 3 )
-        {
-          if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 7 )
-          {
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 8 )
+      if ( pCurrentScreen )
+      {
+        if ( pCurrentScreen != 3 )
+        {
+          if ( pCurrentScreen != 7 )
+          {
+            if ( pCurrentScreen == 8 )
             {
               if ( dword_507B00_spell_info_to_draw_in_popup )
                 DrawSpellDescriptionPopup((void *)(dword_507B00_spell_info_to_draw_in_popup - 1));
@@ -16069,7 +15934,7 @@
           }
 LABEL_119:
           if ( (signed int)pX > 467
-            && uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 14 )
+            && pCurrentScreen != 14 )
           {
 LABEL_126:
             identify_item();
@@ -16098,7 +15963,7 @@
           || (signed int)pX > (signed int)pViewport->uViewportZ
           || (signed int)pY < (signed int)pViewport->uViewportY
           || (signed int)pY > (signed int)pViewport->uViewportW
-          || (v2 = (char *)sub_444564(), (a1.str_48 = v2) == 0) )
+          || (v2 = (char *)sub_444564(), (a1.Hint = v2) == 0) )
           goto LABEL_132;
         v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
         v27 = v30 + 6.7553994e15;
@@ -16108,20 +15973,21 @@
         a1.uFrameY = pY + 5;
         goto LABEL_41;
       }
-      if ( (GetCurrentMenuID() & 0x80000000u) == 0 )
+      if (GetCurrentMenuID() > 0)
         goto LABEL_132;
+
       if ( (signed int)pY > (signed int)pViewport->uViewportW )
       {
         a1.ptr_1C = (void *)((signed int)pX / 118);
         if ( (signed int)pX / 118 < 4 )
         {
-          a1.str_48 = 0;
+          a1.Hint = 0;
           a1.uFrameWidth = 400;
           a1.uFrameHeight = 200;
           a1.uFrameX = 38;
           a1.uFrameY = 60;
           pAudioPlayer->StopChannels(-1, -1);
-          a1._41D3B7();
+          a1.DrawQuickCharRecord();
         }
         goto LABEL_132;
       }
@@ -16131,7 +15997,7 @@
         {
           if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )
           {
-            a1.str_48 = 0;
+            a1.Hint = 0;
             a1.uFrameWidth = 400;
             a1.uFrameHeight = 200;
             a1.uFrameX = 38;
@@ -16155,7 +16021,7 @@
           sub_416B01(v3);
           goto LABEL_132;
         }
-        a1.str_48 = _4443D5_GetMinimapRightClickText();
+        a1.Hint = _4443D5_GetMinimapRightClickText();
         a1.uFrameWidth = 256;
         a1.uFrameX = 130;
         a1.uFrameY = 140;
@@ -16163,10 +16029,10 @@
         a1.uFrameHeight = 64;
         pAudioPlayer->StopChannels(-1, -1);
 LABEL_42:
-        a1._415551(0);
+        a1.DrawMessageBox(0);
         goto LABEL_132;
       }
-      a1.str_48 = 0;
+      a1.Hint = 0;
       a1.uFrameWidth = 320;
       a1.uFrameHeight = 320;
       v4 = pX - 350;
@@ -16185,13 +16051,13 @@
         {
           if ( pRenderer->uNumSceneBegins )
           {
-            a1._415551(1);
+            a1.DrawMessageBox(1);
             MonsterPopup_Draw(v6 >> 3, &a1);
           }
           else
           {
             pRenderer->BeginScene();
-            a1._415551(1);
+            a1.DrawMessageBox(1);
             MonsterPopup_Draw(v6 >> 3, &a1);
             pRenderer->EndScene();
           }
@@ -16206,22 +16072,22 @@
     GameUI_DrawItemInfo(v8);
     goto LABEL_132;
   }
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 13 )
+  if ( pCurrentScreen == 13 )
   {
     if ( (signed int)pY < 345 && (signed int)pX < 469 )
       sub_4B1A2D();
     goto LABEL_132;
   }
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 13 )
+  if ( pCurrentScreen <= 13 )
     goto LABEL_132;
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions <= 15 )
+  if ( pCurrentScreen <= 15 )
     goto LABEL_119;
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 21 )
-  {
-    v11 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 23;
+  if ( pCurrentScreen != 21 )
+  {
+    v11 = pCurrentScreen == 23;
     goto LABEL_125;
   }
-  a1.str_48 = 0;
+  a1.Hint = 0;
   v12 = pGUIWindow_CurrentMenu->pControlsHead;
   if ( !v12 )
     goto LABEL_132;
@@ -16240,7 +16106,7 @@
     {
       if ( v15 == 65 )
       {
-        a1.str_48 = pClassDescriptions[v12->uControlParam];
+        a1.Hint = pClassDescriptions[v12->uControlParam];
         v14 = pClassNames[v12->uControlParam];
       }
       else
@@ -16258,7 +16124,7 @@
                 v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(
                         v12->uControlParam + 4);
                 v14 = pSkillNames[v18];
-                a1.str_48 = pSkillDesc[v18];
+                a1.Hint = pSkillDesc[v18];
                 v13 = pY;
               }
               goto LABEL_117;
@@ -16273,7 +16139,7 @@
           }
           goto LABEL_116;
         }
-        a1.str_48 = pAttributeDescriptions[(signed int)v12->uControlParam % 7];
+        a1.Hint = pAttributeDescriptions[(signed int)v12->uControlParam % 7];
         v14 = aAttributeNames[(signed int)v12->uControlParam % 7];
       }
       goto LABEL_117;
@@ -16305,7 +16171,7 @@
       v14 = pParty->pPlayers[v20].pName;
       v19 = pClassDescriptions[pParty->pPlayers[v20].uClass];
 LABEL_116:
-      a1.str_48 = v19;
+      a1.Hint = v19;
       goto LABEL_117;
     }
     goto LABEL_117;
@@ -16317,14 +16183,14 @@
     goto LABEL_117;
   v22 = CharacterUI_GetSkillDescText(v12->uControlParam, (enum PLAYER_SKILL_TYPE)v21);
   strcpy(pTmpBuf2, v22);
-  a1.str_48 = pTmpBuf2;
+  a1.Hint = pTmpBuf2;
   v14 = pSkillNames[pY];
 LABEL_112:
-  v23 = a1.str_48;
-  if ( a1.str_48 )
-  {
-    v24 = a1.str_48;
-    a1.str_48 = 0;
+  v23 = a1.Hint;
+  if ( a1.Hint )
+  {
+    v24 = a1.Hint;
+    a1.Hint = 0;
     a1.uFrameWidth = 384;
     a1.uFrameHeight = 256;
     a1.uFrameX = 128;
@@ -16334,7 +16200,7 @@
                     + 24;
     a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
     a1.uFrameW = a1.uFrameY + a1.uFrameHeight - 1;
-    a1._415551(0);
+    a1.DrawMessageBox(0);
     a1.uFrameX += 12;
     a1.uFrameWidth -= 24;
     a1.uFrameY += 12;
@@ -16370,7 +16236,7 @@
   unsigned int pY; // [sp+18h] [bp-4h]@7
 
   pXY_ = pXY;
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 16
+  if ( pCurrentScreen == 16
     || sub_4637E0_is_there_popup_onscreen() )
     return;
   if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 )
@@ -16391,7 +16257,7 @@
     y = pY;
     x = pX;
   }
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+  if ( pCurrentScreen
     || !dword_507B98_ctrl_pressed )
     goto LABEL_30;
   v4 = GetCurrentMenuID();
@@ -16528,7 +16394,7 @@
 }
 
 //----- (004178FE) --------------------------------------------------------
-unsigned int __fastcall sub_4178FE(signed int a1, signed int a2)
+unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2)
 {
   unsigned __int16 v2; // dx@2
   unsigned __int16 v3; // cx@2
@@ -16625,7 +16491,7 @@
   Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(v2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
   Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
   Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
-  Dst._415551(0);
+  Dst.DrawMessageBox(0);
   Dst.uFrameX += 12;
   Dst.uFrameWidth -= 24;
   Dst.uFrameY += 12;
@@ -17286,14 +17152,14 @@
     v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
   else
     v4 = 0xFFFFu;
-  sprintfex(pTmpBuf2, &byte_4E2F14, pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
+  sprintfex(pTmpBuf2, "\xC" "00000\xD" "180%s: \xC%05d%d\xC" "00000\n\n\n", pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);
   strcat(pTmpBuf, pTmpBuf2);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
   v5 = pPlayer->GetBaseStrength();
   v6 = pPlayer->GetActualMight();
   v7 = pPlayer->GetBaseStrength();
   v8 = pPlayer->GetActualMight();
-  v9 = sub_4178FE(v8, v7);
+  v9 = UI_GetHealthManaStringColor(v8, v7);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[144], v9, v6, v5);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 53, 0, pTmpBuf, 0, 0, 0);
   v10 = LOBYTE(pFontArrus->uFontHeight) + 51;
@@ -17301,7 +17167,7 @@
   v12 = pPlayer->GetActualIntelligence();
   v13 = pPlayer->GetBaseIntelligence();
   v14 = pPlayer->GetActualIntelligence();
-  v15 = sub_4178FE(v14, v13);
+  v15 = UI_GetHealthManaStringColor(v14, v13);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[116], v15, v12, v11);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
   v16 = LOBYTE(pFontArrus->uFontHeight) + v10 - 2;
@@ -17309,7 +17175,7 @@
   v18 = pPlayer->GetActualWillpower();
   v19 = pPlayer->GetBaseWillpower();
   v20 = pPlayer->GetActualWillpower();
-  v21 = sub_4178FE(v20, v19);
+  v21 = UI_GetHealthManaStringColor(v20, v19);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[163], v21, v18, v17);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v16, 0, pTmpBuf, 0, 0, 0);
   v22 = LOBYTE(pFontArrus->uFontHeight) + v16 - 2;
@@ -17317,7 +17183,7 @@
   v24 = pPlayer->GetActualEndurance();
   v25 = pPlayer->GetBaseEndurance();
   v26 = pPlayer->GetActualEndurance();
-  v27 = sub_4178FE(v26, v25);
+  v27 = UI_GetHealthManaStringColor(v26, v25);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[75], v27, v24, v23);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v22, 0, pTmpBuf, 0, 0, 0);
   v28 = LOBYTE(pFontArrus->uFontHeight) + v22 - 2;
@@ -17325,7 +17191,7 @@
   v30 = pPlayer->GetActualAccuracy();
   v31 = pPlayer->GetBaseAccuracy();
   v32 = pPlayer->GetActualAccuracy();
-  v33 = sub_4178FE(v32, v31);
+  v33 = UI_GetHealthManaStringColor(v32, v31);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[1], v33, v30, v29);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v28, 0, pTmpBuf, 0, 0, 0);
   v34 = LOBYTE(pFontArrus->uFontHeight) + v28 - 2;
@@ -17333,7 +17199,7 @@
   v36 = pPlayer->GetActualSpeed();
   v37 = pPlayer->GetBaseSpeed();
   v38 = pPlayer->GetActualSpeed();
-  v39 = sub_4178FE(v38, v37);
+  v39 = UI_GetHealthManaStringColor(v38, v37);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[211], v39, v36, v35);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v34, 0, pTmpBuf, 0, 0, 0);
   v40 = LOBYTE(pFontArrus->uFontHeight) + v34 - 2;
@@ -17341,7 +17207,7 @@
   v42 = pPlayer->GetActualLuck();
   v43 = pPlayer->GetBaseLuck();
   v44 = pPlayer->GetActualLuck();
-  v45 = sub_4178FE(v44, v43);
+  v45 = UI_GetHealthManaStringColor(v44, v43);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[136], v45, v42, v41);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v40, 0, pTmpBuf, 0, 0, 0);
   a2 = "%s";
@@ -17351,7 +17217,7 @@
   v47 = pPlayer->GetMaxHealth();
   v48 = pPlayer->sHealth;
   v49 = pPlayer->GetMaxHealth();
-  v50 = sub_4178FE(pPlayer->sHealth, v49);
+  v50 = UI_GetHealthManaStringColor(pPlayer->sHealth, v49);
   sprintfex(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, v48, v47);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v46, 0, pTmpBuf, 0, 0, 0);
   a2a = "%s";
@@ -17361,7 +17227,7 @@
   v51 = pPlayer->GetMaxMana();
   v52 = pPlayer->sMana;
   v53 = pPlayer->GetMaxMana();
-  v54 = sub_4178FE(pPlayer->sMana, v53);
+  v54 = UI_GetHealthManaStringColor(pPlayer->sMana, v53);
   sprintfex(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, v52, v51);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, uY, 0, pTmpBuf, 0, 0, 0);
   v55 = LOBYTE(pFontArrus->uFontHeight) + uY - 2;
@@ -17369,7 +17235,7 @@
   v57 = pPlayer->GetActualAC();
   v58 = pPlayer->GetBaseAC();
   v59 = pPlayer->GetActualAC();
-  v60 = sub_4178FE(v59, v58);
+  v60 = UI_GetHealthManaStringColor(v59, v58);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[12], v60, v57, v56);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v55, 0, pTmpBuf, 0, 0, 0);
   v61 = v55 + 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
@@ -17390,7 +17256,7 @@
   v69 = pPlayer->GetActualAge();
   v70 = pPlayer->GetBaseAge();
   v71 = pPlayer->GetActualAge();
-  v72 = sub_4178FE(v71, v70);
+  v72 = UI_GetHealthManaStringColor(v71, v70);
   sprintfex(pTmpBuf, "%s", pGlobalTXT_LocalizationStrings[5], v72, v69, v68);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, 50, 0, pTmpBuf, 0, 0, 0);
   a2b = "%s";
@@ -17401,7 +17267,7 @@
   v74 = pPlayer->GetActualLevel();
   v75 = pPlayer->GetBaseLevel();
   v76 = pPlayer->GetActualLevel();
-  v77 = sub_4178FE(v76, v75);
+  v77 = UI_GetHealthManaStringColor(v76, v75);
   sprintfex(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v74, v73);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYa, 0, pTmpBuf, 0, 0, 0);
   uYb = uYa + LOBYTE(pFontArrus->uFontHeight) - 2;
@@ -17437,7 +17303,7 @@
   if ( v131 > 99 || v90 > 99 )
     a2c = format_4E2E68;
   v91 = v90;
-  v92 = sub_4178FE(v131, v90);
+  v92 = UI_GetHealthManaStringColor(v131, v90);
   sprintfex(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v91);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYc, 0, pTmpBuf, 0, 0, 0);
   a2d = format_4E2E10;
@@ -17447,7 +17313,7 @@
   if ( v132 > 99 || v93 > 99 )
     a2d = format_4E2E68;
   v94 = v93;
-  v95 = sub_4178FE(v132, v93);
+  v95 = UI_GetHealthManaStringColor(v132, v93);
   sprintfex(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v94);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYd, 0, pTmpBuf, 0, 0, 0);
   a2e = format_4E2E10;
@@ -17457,7 +17323,7 @@
   if ( v133 > 99 || v96 > 99 )
     a2e = format_4E2E68;
   v97 = v96;
-  v98 = sub_4178FE(v133, v96);
+  v98 = UI_GetHealthManaStringColor(v133, v96);
   sprintfex(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v97);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYe, 0, pTmpBuf, 0, 0, 0);
   a2f = format_4E2E10;
@@ -17467,7 +17333,7 @@
   if ( v134 > 99 )
     a2f = format_4E2E68;
   v100 = v99;
-  v101 = sub_4178FE(v134, v99);
+  v101 = UI_GetHealthManaStringColor(v134, v99);
   sprintfex(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v100);
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYf, 0, pTmpBuf, 0, 0, 0);
   a2g = format_4E2E10;
@@ -17478,12 +17344,12 @@
   if ( v135 > 99 || v102 > 99 )
     a2g = format_4E2E68;
   v103 = v102;
-  v104 = sub_4178FE(v135, v102);
+  v104 = UI_GetHealthManaStringColor(v135, v102);
   sprintfex(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v103);
   if ( pPlayer->uClass == 35 && v137 == 200 )
   {
     v105 = pGlobalTXT_LocalizationStrings[625];
-    v106 = sub_4178FE(v135, 200);
+    v106 = UI_GetHealthManaStringColor(v135, 200);
     sprintfex(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, v105);
   }
   pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYg, 0, pTmpBuf, 0, 0, 0);
@@ -17495,12 +17361,12 @@
   if ( v136 > 99 || v107 > 99 )
     a2h = format_4E2E68;
   v108 = v107;
-  v109 = sub_4178FE(v136, v107);
+  v109 = UI_GetHealthManaStringColor(v136, v107);
   sprintfex(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v108);
   if ( pPlayer->uClass == 35 && v138 == 200 )
   {
     v110 = pGlobalTXT_LocalizationStrings[625];
-    v111 = sub_4178FE(v136, 200);
+    v111 = UI_GetHealthManaStringColor(v136, 200);
     sprintfex(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, v110);
   }
   return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYh, 0, pTmpBuf, 0, 0, 0);
@@ -17622,7 +17488,7 @@
                    0xA9u,
                    0,
                    0,
-                   nullstring,
+                   "",
                    (Texture *)(uTextureID_ar_up_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_up] : 0),
                    uTextureID_ar_up_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_up_dn] : 0,
                    0);
@@ -17636,7 +17502,7 @@
                    0xAAu,
                    0,
                    0,
-                   nullstring,
+                   "",
                    (Texture *)(uTextureID_ar_dn_up != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_up] : 0),
                    uTextureID_ar_dn_dn != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ar_dn_dn] : 0,
                    0);
@@ -17650,7 +17516,7 @@
                    0xC0u,
                    0,
                    0,
-                   nullstring,
+                   "",
                    0);
   }
 }
@@ -17753,7 +17619,7 @@
         0x79u,
         *v14,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17781,7 +17647,7 @@
         0x79u,
         *v15,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17809,7 +17675,7 @@
         0x79u,
         *v16,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
@@ -17837,7 +17703,7 @@
         0x79u,
         *v17,
         0,
-        nullstring,
+        "",
         0);
       v2 = pFontLucida;
     }
--- a/mm7_6.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_6.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -2343,10 +2343,10 @@
         if ( ptr_507BD4 )
           return result;
         ptr_507BD4 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
-        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 0, 0x31u, nullstring, 0);
-        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 1u, 0x32u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 2u, 0x33u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 3u, 0x34u, nullstring, 0);
+        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 0, 0x31u, "", 0);
+        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 1u, 0x32u, "", 0);
+        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 2u, 0x33u, "", 0);
+        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 3u, 0x34u, "", 0);
         return sub_421B2C_PlaceInInventory_or_DropPickedItem();
       }
       if ( v6 & 8 )
@@ -2355,7 +2355,7 @@
           return result;
         v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
         v29 = 0;
-        v28 = nullstring;
+        v28 = "";
         v27 = 0;
         v26 = 0;
         v25 = 70;
@@ -2378,7 +2378,7 @@
           return result;
         v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0);
         v29 = 0;
-        v28 = nullstring;
+        v28 = "";
         v27 = 0;
         v26 = 0;
         v25 = 190;
@@ -2401,12 +2401,12 @@
         if ( ptr_507BD4 )
           return result;
         ptr_507BD4 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), 20 * result + 5292232, 0);
-        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 0, 0x31u, nullstring, 0);
-        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, nullstring, 0);
-        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, nullstring, 0);
+        ptr_507BD4->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 0, 0x31u, "", 0);
+        ptr_507BD4->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, "", 0);
+        ptr_507BD4->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, "", 0);
+        ptr_507BD4->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, "", 0);
         v29 = 0;
-        v28 = nullstring;
+        v28 = "";
         v27 = 0;
         v26 = 0;
         v25 = 140;
@@ -2432,7 +2432,7 @@
                        0xBCu,
                        0,
                        0,
-                       nullstring,
+                       "",
                        (Texture *)(uTextureID_507990 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507990] : 0),
                        0);
         ptr_5079E8 = ptr_507BD4->CreateButton(
@@ -2445,10 +2445,10 @@
                        0xBCu,
                        1u,
                        0,
-                       nullstring,
+                       "",
                        (Texture *)(uTextureID_50798C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50798C] : 0),
                        0);
-        ptr_507BD4->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 4u, 0x35u, nullstring, 0);
+        ptr_507BD4->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 4u, 0x35u, "", 0);
         result = (bool)ptr_507BD4->CreateButton(
                          0x231u,
                          0x95u,
@@ -2459,7 +2459,7 @@
                          0x8Fu,
                          5u,
                          0x36u,
-                         nullstring,
+                         "",
                          0);
       }
     }
@@ -3490,10 +3490,10 @@
         if ( v17->WearsItem(510, 2) )
           a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = 0;
         a1.uSpriteFrameID = 0;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v19 = 8 * v3->uPlayerID;
         LOBYTE(v19) = v19 | 4;
         a1.field_58 = v19;
@@ -3528,10 +3528,10 @@
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = 0;
         a1.uSpriteFrameID = 0;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
         v22 = 8 * v3->uPlayerID;
         LOBYTE(v22) = v22 | 4;
         a1.field_58 = v22;
@@ -3545,7 +3545,7 @@
                                                                          * pParty->pPlayers[v3->uPlayerID].pEquipment.uMainHand
                                                                          + 5],
           sizeof(a1.stru_24));
-        v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, a1.vPosition.z);
+        v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, a1.vPosition.z);
         HIBYTE(a1.uAttributes) |= 1u;
         a1.uSectorID = v23;
         if ( pParty->bTurnBasedModeOn == 1 )
@@ -3629,14 +3629,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v34 = 8 * v3->uPlayerID;
         LOBYTE(v34) = v34 | 4;
@@ -3791,14 +3791,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v50 = 8 * v3->uPlayerID;
         LOBYTE(v50) = v50 | 4;
@@ -3823,10 +3823,10 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        v51 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
-        a1.vPosition.y = pParty->vPosition.z;
-        v671 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
-        v660 = pParty->vPosition.z;
+        v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
+        a1.vPosition.y = pParty->vPosition.y;
+        v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
+        v660 = pParty->vPosition.y;
         goto LABEL_153;
       case 87:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor
@@ -3937,13 +3937,13 @@
         a1.stru_24.Reset();
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v62 = 8 * v3->uPlayerID;
         LOBYTE(v62) = v62 | 4;
@@ -4308,8 +4308,8 @@
         {
           v730 = a2 >> 3;
           v112 = &pActors[a2 >> 3];
-          v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.y);
-          v721 = abs(v112->vPosition.y - pParty->vPosition.z);
+          v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z);
+          v721 = abs(v112->vPosition.y - pParty->vPosition.y);
           v113 = abs(v112->vPosition.x - pParty->vPosition.x);
           _this = (ItemGen *)v113;
           v114 = v721;
@@ -4504,8 +4504,8 @@
           v155 = stru_5C6E00->SinCos(pParty->sRotationY);
           uRequiredMana = pParty->vPosition.x + sub_42EBBE(2048, v155);
           v156 = stru_5C6E00->_42EBDB(pParty->sRotationY);
-          LODWORD(v727) = pParty->vPosition.z + sub_42EBBE(2048, v156);
-          v154 = pParty->vPosition.y;
+          LODWORD(v727) = pParty->vPosition.y + sub_42EBBE(2048, v156);
+          v154 = pParty->vPosition.z;
         }
         HIDWORD(v733) = v154;
         v713 = v154 + 2500;
@@ -4728,14 +4728,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v187 = 8 * v3->uPlayerID;
         LOBYTE(v187) = v187 | 4;
@@ -4909,8 +4909,8 @@
           LODWORD(v718) = pParty->vPosition.x + sub_42EBBE(2048, v212);
           v213 = stru_5C6E00->_42EBDB(pParty->sRotationY);
           v214 = sub_42EBBE(2048, v213);
-          v211 = pParty->vPosition.y;
-          v713 = pParty->vPosition.z + v214;
+          v211 = pParty->vPosition.z;
+          v713 = pParty->vPosition.y + v214;
           v208 = LODWORD(v725);
         }
         v726 = (Player *)v211;
@@ -5038,10 +5038,10 @@
           a1.field_50 = v731;
           a1.field_4C = v2;
           a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-          a1.vPosition.y = pParty->vPosition.z;
-          v51 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
-          v671 = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
-          v660 = pParty->vPosition.z;
+          a1.vPosition.y = pParty->vPosition.y;
+          v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+          v671 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
+          v660 = pParty->vPosition.y;
 LABEL_153:
           a1.uAttributes = v1;
           a1.vPosition.x = pParty->vPosition.x;
@@ -5076,14 +5076,14 @@
           a1.field_4C = v2;
           a1.field_50 = v731;
           a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-          a1.vPosition.y = pParty->vPosition.z;
+          a1.vPosition.y = pParty->vPosition.y;
           a1.vPosition.x = pParty->vPosition.x;
           a1.uAttributes = v1;
-          a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+          a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
           a1.uSectorID = pIndoor->GetSector(
                            pParty->vPosition.x,
-                           pParty->vPosition.z,
-                           pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                           pParty->vPosition.y,
+                           pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
           a1.uSpriteFrameID = v1;
           v226 = 8 * v3->uPlayerID;
           LOBYTE(v226) = v226 | 4;
@@ -5661,14 +5661,14 @@
         a1.field_4C = v2;
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.vPosition.x = pParty->vPosition.x;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3);
         a1.uSpriteFrameID = v1;
         v326 = 8 * v3->uPlayerID;
         LOBYTE(v326) = v326 | 4;
@@ -5695,11 +5695,11 @@
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = v1;
         a1.uSectorID = v1;
         a1.uSpriteFrameID = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 3;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3;
         v327 = 8 * v3->uPlayerID;
         LOBYTE(v327) = v327 | 4;
         a1.field_60_distance_related_prolly_lod = 0;
@@ -7360,13 +7360,13 @@
         a1.field_50 = v731;
         a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uItemType);
         a1.vPosition.x = pParty->vPosition.x;
-        a1.vPosition.y = pParty->vPosition.z;
+        a1.vPosition.y = pParty->vPosition.y;
         a1.uAttributes = v1;
-        a1.vPosition.z = pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2;
+        a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2;
         a1.uSectorID = pIndoor->GetSector(
                          pParty->vPosition.x,
-                         pParty->vPosition.z,
-                         pParty->vPosition.y + (signed int)pParty->uPartyHeight / 2);
+                         pParty->vPosition.y,
+                         pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2);
         a1.uSpriteFrameID = v1;
         v595 = 8 * v3->uPlayerID;
         LOBYTE(v595) = v595 | 4;
@@ -7694,7 +7694,7 @@
           v642 = rand() % 4096 - 2048;
           v643 = rand();
           v721 = v642 + pParty->vPosition.x;
-          y = (char *)(pParty->vPosition.z + v643 % 4096 - 2048);
+          y = (char *)(pParty->vPosition.y + v643 % 4096 - 2048);
           v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, v1);
           v644 = rand();
           sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, v1, v1, (ItemGen *)v1);
@@ -7909,7 +7909,7 @@
     {
       a2 = v34 >> 3;
       v8 = &pActors[v34 >> 3];
-      v34 = sub_452A9E((v8->vPosition.x - pParty->vPosition.x) * (v8->vPosition.x - pParty->vPosition.x) + (v8->vPosition.y - pParty->vPosition.z) * (v8->vPosition.y - pParty->vPosition.z) + (v8->vPosition.z - pParty->vPosition.y) * (v8->vPosition.z - pParty->vPosition.y))
+      v34 = sub_452A9E((v8->vPosition.x - pParty->vPosition.x) * (v8->vPosition.x - pParty->vPosition.x) + (v8->vPosition.y - pParty->vPosition.y) * (v8->vPosition.y - pParty->vPosition.y) + (v8->vPosition.z - pParty->vPosition.z) * (v8->vPosition.z - pParty->vPosition.z))
           - v8->uActorRadius;
       if ( v34 >= 0 )
       {
@@ -7956,8 +7956,8 @@
       if ( (double)v34 <= 407.2 )
       {
         a3.x = v8->vPosition.x - pParty->vPosition.x;
-        a3.y = v8->vPosition.y - pParty->vPosition.z;
-        a3.z = v8->vPosition.z - pParty->vPosition.y;
+        a3.y = v8->vPosition.y - pParty->vPosition.y;
+        a3.z = v8->vPosition.z - pParty->vPosition.z;
         Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
         DamageMonsterFromParty((8 * v0 - 8) | 4, a2, &a3);
         if ( v1->WearsItem(506, 1) || v1->WearsItem(506, 0) )
@@ -8321,8 +8321,8 @@
     while ( 1 )
     {
       v2 = abs(*((short *)v1 - 17) - pParty->vPosition.x);
-      v11 = abs(*((short *)v1 - 16) - pParty->vPosition.z);
-      v12 = abs(*((short *)v1 - 15) - pParty->vPosition.y);
+      v11 = abs(*((short *)v1 - 16) - pParty->vPosition.y);
+      v12 = abs(*((short *)v1 - 15) - pParty->vPosition.z);
       v3 = v2;
       v4 = v11;
       v5 = v12;
@@ -8862,8 +8862,6 @@
 //----- (0042FC4E) --------------------------------------------------------
 void __cdecl ProcessInputActions()
 {
-  Keyboard *v0; // ecx@1
-  signed int _1; // ebx@7
   ActionQueue *pActionQueue; // esi@7
   Keyboard *v3; // ecx@8
   char v4; // al@9
@@ -8889,24 +8887,27 @@
   int v24; // [sp+4h] [bp-4h]@87
 
   pGame->pKeyboardInstance->EnterCriticalSection();
-  v0 = pGame->pKeyboardInstance;
-  if ( !bAlwaysRun )
+  auto pKeyboard = pGame->pKeyboardInstance;
+  if (!bAlwaysRun)
   {
-    if ( v0->IsShiftHeld() )
-      goto _set_running;
-_set_not_running:
-    pParty->uFlags2 &= 0xFFFFFFFDu;
-    goto LABEL_6;
+    if (pKeyboard->IsShiftHeld())
+      pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING;
+    else
+      pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING;
+   }
+  else
+  {
+    if (pKeyboard->IsShiftHeld())
+      pParty->uFlags2 &= ~PARTY_FLAGS_2_RUNNING;
+    else
+      pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING;
   }
-  if ( v0->IsShiftHeld() )
-    goto _set_not_running;
-_set_running:
+
   pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING;
 LABEL_6:
   if ( !pEventTimer->bPaused )
   {
     inputAction = (InputAction)0;
-    _1 = 1;
     pActionQueue = pPartyActionQueue;
     while ( 1 )
     {
@@ -8921,11 +8922,11 @@
         switch ( inputAction )
         {
           case INPUT_MoveForward:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn != _1 )
+            if (!pParty->bTurnBasedModeOn)
               goto _do_move_forward;
-            if ( pTurnEngine->field_4 != _1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
+            if (pTurnEngine->field_4 != 1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
             {
               pTurnEngine->uActionPointsLeft -= 26;
 _do_move_forward:
@@ -8938,11 +8939,12 @@
             }
             break;
           case INPUT_MoveBackwards:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn != _1 )
+            if (!pParty->bTurnBasedModeOn)
               goto _do_move_backwards;
-            if ( pTurnEngine->field_4 != _1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
+            if ( pTurnEngine->field_4 != 1 && pTurnEngine->field_4 != 2 && pTurnEngine->uActionPointsLeft > 0 )
             {
               pTurnEngine->uActionPointsLeft -= 26;
 _do_move_backwards:
@@ -8955,35 +8957,37 @@
             }
             break;
           case INPUT_StrafeLeft:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn != _1 )
+            if (!pParty->bTurnBasedModeOn)
               goto _do_strafe_left;
-            if ( pTurnEngine->field_4 == _1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
+            if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
               break;
             pTurnEngine->uActionPointsLeft -= 26;
 _do_strafe_left:
             partyAction = PARTY_StrafeLeft;
             goto _add_action_and_continue_;
           case INPUT_StrafeRight:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn != _1 )
+            if (!pParty->bTurnBasedModeOn)
               goto _do_strafe_right;
-            if ( pTurnEngine->field_4 == _1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
+            if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
               break;
             pTurnEngine->uActionPointsLeft -= 26;
 _do_strafe_right:
             partyAction = PARTY_StrafeRight;
             goto _add_action_and_continue_;
           case INPUT_TurnLeft:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            if ( pCurrentScreen )
               break;
             if ( GetAsyncKeyState(VK_CONTROL) ) // strafing
             {
-              if ( pParty->bTurnBasedModeOn == _1 )
+              if (pParty->bTurnBasedModeOn)
               {
-                if ( pTurnEngine->field_4 == _1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
+                if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
                   break;
                 pTurnEngine->uActionPointsLeft -= 26;
               }
@@ -8994,23 +8998,23 @@
               if ( pParty->uFlags2 & 2 )
                 partyAction_ = PARTY_FastTurnLeft;
               else
-                partyAction_ = (PartyAction)_1;
+                partyAction_ = PARTY_TurnLeft;
             }
             pActionQueue->Add(partyAction_);
-            if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow == _1 )
+            if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow)
             {
               v20 = 10;
               goto LABEL_75;
             }
             break;
           case INPUT_TurnRight:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            if ( pCurrentScreen )
               break;
             if ( GetAsyncKeyState(17) )         // strafing
             {
-              if ( pParty->bTurnBasedModeOn == _1 )
+              if (pParty->bTurnBasedModeOn)
               {
-                if ( pTurnEngine->field_4 == _1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
+                if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 2 || pTurnEngine->uActionPointsLeft <= 0 )
                   break;
                 pTurnEngine->uActionPointsLeft -= 26;
               }
@@ -9024,7 +9028,7 @@
                 v21 = 2;
             }
             pActionQueue->Add((PartyAction)v21);
-            if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow == _1 )
+            if (uCurrentlyLoadedLevelType == LEVEL_Outdoor && pWeather->bRenderSnow)
             {
               v20 = -10;
 LABEL_75:
@@ -9032,13 +9036,15 @@
             }
             break;
           case INPUT_Jump:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
-              || pParty->bTurnBasedModeOn == _1 )
+            __debugbreak();
+            if ( pCurrentScreen
+              || pParty->bTurnBasedModeOn)
               break;
             partyAction = (PartyAction)12;
             goto _add_action_and_continue_;
           case INPUT_Yell:
-            if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+            __debugbreak();
+            if ( !pCurrentScreen
               && uActiveCharacter )
             {
               pParty->Yell();
@@ -9046,9 +9052,10 @@
             }
             break;
           case INPUT_Pass:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn == _1 && pTurnEngine->field_4 == 3 )
+            if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3)
               goto LABEL_118;
             if ( uActiveCharacter )
             {
@@ -9065,27 +9072,29 @@
             }
             break;
           case INPUT_Combat:
-            if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( !pCurrentScreen )
             {
-              if ( pParty->bTurnBasedModeOn == _1 )
+              if (pParty->bTurnBasedModeOn)
               {
                 if ( pTurnEngine->field_4 == 3 || (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
                 {
                   pParty->bTurnBasedModeOn = 0;
-                  pTurnEngine->End(_1);
+                  pTurnEngine->End(true);
                 }
               }
               else
               {
                 pTurnEngine->Start();
-                pParty->bTurnBasedModeOn = _1;
+                pParty->bTurnBasedModeOn = true;
               }
             }
             break;
           case INPUT_CastReady:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn == _1 && pTurnEngine->field_4 == 3 )
+            if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3)
               goto LABEL_118;
             if ( !uActiveCharacter )
               break;
@@ -9097,7 +9106,6 @@
                   v10 > v7->sMana) )
             {
               pActionQueue = pPartyActionQueue;
-              _1 = 1;
 LABEL_120:
               if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
               {
@@ -9115,36 +9123,37 @@
                 *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0;
                 ++dword_50C9E8;
               }
-              _1 = 1;
             }
             break;
           default:
+            __debugbreak();
             break;
           case INPUT_Attack:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            __debugbreak();
+            if ( pCurrentScreen )
               break;
-            if ( pParty->bTurnBasedModeOn != _1 || pTurnEngine->field_4 != 3 )
+            if (!pParty->bTurnBasedModeOn || pTurnEngine->field_4 != 3)
               goto LABEL_120;
 LABEL_118:
             pTurnEngine->field_18 |= 8u;
             break;
           case INPUT_EventTrigger:
-            if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+            if ( !pCurrentScreen )
             {
               if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
                 break;
               pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404;
               goto _send_message;
             }
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4 )
+            if ( pCurrentScreen == 4 )
             {
               v11 = pMessageQueue_50CBD0->uNumMessages;
               if ( pMessageQueue_50CBD0->uNumMessages )
               {
                 if ( pMessageQueue_50CBD0->pMessages[0].field_8 )
                 {
-                  v11 = _1;
-                  pMessageQueue_50CBD0->uNumMessages = _1;
+                  v11 = 1;
+                  pMessageQueue_50CBD0->uNumMessages = 1;
 LABEL_132:
                   pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)113;
 _send_message:
@@ -9161,40 +9170,47 @@
             }
             break;
           case INPUT_CharCycle:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 8
+            __debugbreak();
+            if ( pCurrentScreen == 8
               || dword_50C9E8 >= 40 )
               break;
             dword_50C9EC[3 * dword_50C9E8] = 176;
             goto LABEL_155;
           case INPUT_LookUp:
+            __debugbreak();
             if ( pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)7;
             goto _add_action_and_continue_;
           case INPUT_CenterView:
+            __debugbreak();
             if ( pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)9;
             goto _add_action_and_continue_;
           case INPUT_LookDown:
+            __debugbreak();
             if ( pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)8;
             goto _add_action_and_continue_;
           case INPUT_FlyUp:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+            __debugbreak();
+            if ( pCurrentScreen
               || pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)13;
             goto _add_action_and_continue_;
           case INPUT_Land:
-            if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+            __debugbreak();
+            if ( pCurrentScreen
               || pEventTimer->bPaused )
               break;
             partyAction = (PartyAction)15;
             goto _add_action_and_continue_;
           case INPUT_FlyDown:
-            if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions
+            __debugbreak();
+            if ( !pCurrentScreen
               && !pEventTimer->bPaused )
             {
               partyAction = (PartyAction)14;
@@ -9205,11 +9221,13 @@
             }
             break;
           case INPUT_ZoomIn:
+            __debugbreak();
             if ( dword_50C9E8 >= 40 )
               break;
             dword_50C9EC[3 * dword_50C9E8] = 367;
             goto LABEL_155;
           case INPUT_ZoomOut:
+            __debugbreak();
             if ( dword_50C9E8 < 40 )
             {
               dword_50C9EC[3 * dword_50C9E8] = 368;
@@ -9240,15 +9258,15 @@
       v14 = v13->IsKeyBeingHeld(v22);
     if ( v14 && v12 == 9 )
     {
-      if ( !uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions )
+      if ( !pCurrentScreen )
       {
         if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
           goto LABEL_175;
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404;
         goto LABEL_174;
       }
-      if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 4
-        || uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 19 )
+      if ( pCurrentScreen == 4
+        || pCurrentScreen == 19 )
       {
         v15 = pMessageQueue_50CBD0->uNumMessages;
         if ( pMessageQueue_50CBD0->uNumMessages )
@@ -9278,7 +9296,7 @@
   }
   while ( v12 < 30 );
 LABEL_176:
-  if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) )
+  if (pGame->pKeyboardInstance->bUsingAsynKeyboard)
   {
     AsyncKeyboard::LeaveCriticalSection();
     v16 = pAsyncKeyboard;
--- a/mm7_data.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_data.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -316,10 +316,11 @@
 
 
 
+#include "stru314.h"
 
 
 
-char nullstring[1] = {0};
+
 //-------------------------------------------------------------------------
 // Data declarations
 
@@ -330,9 +331,8 @@
 int dword_4C9920[16]; // weak
 _UNKNOWN unk_4D8548; // weak
 char byte_4D864C; // weak
-int dword_4D86CC; // weak
+float flt_4D86CC = 1.0f; // weak
 int dword_4D86D8; // weak
-int dword_4D86F0; // weak
 int dword_4DAFCC; // weak
 int (__stdcall *off_4DAFDC)(char); // weak
 char asc_4DB724[777]; // idb
@@ -351,6 +351,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
@@ -389,10 +390,10 @@
 int dword_4E20D0[777]; // idb
 char byte_4E2430[777]; // weak
 char byte_4E2431[777]; // weak
-unsigned int pLloydsBeaconsPreviewXs[5];
-int pLloydsBeaconsPreviewYs[5];
-unsigned int pLloydsBeacons_SomeXs[5];
-int pLloydsBeacons_SomeYs[777]; // idb
+unsigned int pLloydsBeaconsPreviewXs[5] = {61, 281,  61, 281, 171};
+unsigned int pLloydsBeaconsPreviewYs[5] = {84,  84, 228, 228, 155};
+unsigned int pLloydsBeacons_SomeXs[5] = {59, 279, 59, 279, 169};
+unsigned int pLloydsBeacons_SomeYs[5] = {82, 82, 226, 226, 153};
 char aSbwb00[7]; // weak
 char aW[2]; // idb
 char aA[2]; // idb
@@ -470,7 +471,7 @@
 char aS100110D[777]; // idb
 char aS100110DS[777]; // idb
 char aS100110D02dSS[777]; // idb
-int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions; // weak
+int pCurrentScreen; // weak
 char byte_4E28FC; // weak
 unsigned int uGammaPos;
 int dword_4E2910[777]; // weak
@@ -482,8 +483,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
@@ -543,270 +544,12 @@
 char aSS_0[777]; // idb
 char aS_5[4]; // idb
 _UNKNOWN unk_4E2EB8; // weak
-char aS_4[2]; // idb
-char aS_0[2]; // idb
-char byte_4E2F14; // idb
-char aFr_stats[777]; // idb
-char aS1772d[777]; // idb
-char aS_10[3]; // idb
-char aS177S[777]; // idb
-char aS4002d[777]; // idb
-char aS_9[3]; // idb
-char aS400S[777]; // idb
-char aS_8[38];
-char aFr_skill[777]; // idb
-char byte_4E2FD4[7];
-char aS_11[3]; // idb
-char aFr_award[777]; // idb
-char aSptext01[777]; // idb
-char aSp28a[6]; // weak
-char aSp30a[6]; // weak
-char aSp91a[6]; // weak
-char aFr_strip[777]; // idb
-char a261SD[777]; // idb
-char aS_12[4]; // idb
-char aD_2[4];
-char aLu[4];
-char aQuikref[777]; // idb
-char aIbCd1D[777]; // idb
-char aIbCd2D[777]; // idb
-char aIbCd4D[777]; // idb
-char aIbCd3D[777]; // idb
-char a028Lu[777]; // idb
-char a087Lu[777]; // idb
-char aComic_fnt[777]; // idb
-char aSmallnum_fnt[777]; // idb
-char aCreate_fnt[777]; // idb
-char aLucida_fnt[777]; // idb
-char aArrus_fnt[777]; // idb
-char aIbTd5A[777]; // idb
-char aIbTd4A[777]; // idb
-char aIbTd3A[777]; // idb
-char aIbTd2A[777]; // idb
-char aIbTd1A[777]; // idb
-char aButtmake2[777]; // idb
-char aButtmake[777]; // idb
-char aButtyes2[777]; // idb
-char aX_ok_u[777]; // idb
-char aButtesc2[777]; // idb
-char aX_x_u[777]; // idb
-char aIbground[777]; // idb
-char aLeather[777]; // idb
-char aMhp_yel[777]; // idb
-char aMhp_red[777]; // idb
-char aMhp_grn[777]; // idb
-char aMhp_capr[777]; // idb
-char aMhp_capl[777]; // idb
-char aMhp_bg[777]; // idb
-char aIbStatr[777]; // idb
-char aIbStaty[777]; // idb
-char aIbStatg[777]; // idb
-char aIbStatb[777]; // idb
-char aMapdir7[777]; // idb
-char aMapdir6[777]; // idb
-char aMapdir5[777]; // idb
-char aMapdir4[777]; // idb
-char aMapdir3[777]; // idb
-char aMapdir2[777]; // idb
-char aMapdir1[777]; // idb
-char aMapdir8[777]; // idb
-char aTorcha[777]; // idb
-char aTorchb[777]; // idb
-char aTorchc[777]; // idb
-char aWizeyea[777]; // idb
-char aWizeyeb[777]; // idb
-char aWizeyec[777]; // idb
-char aTest[777]; // idb
-char aMicon2[777]; // idb
-char aButton[777]; // idb
-char aDS[777]; // idb
-char a020[777]; // idb
-char aS_14[4]; // idb
-char aS_13[5]; // idb
 char string_4E3294[8];
-char aDMn[777]; // idb
-char aDHr[777]; // idb
-char aDDy[777]; // idb
-char aDMo[777]; // idb
-char aDYr[777]; // idb
-char aDuration[777]; // idb
-char aSLu[777]; // idb
-char aSSD[777]; // idb
-char aSD_1[777]; // idb
-char aD_0[777]; // idb
-char aSDSDdD[777]; // idb
-char aS_21[2]; // idb
-char byte_4E3318; // idb
-char aS_20[2]; // idb
-char aS_19[2]; // idb
-char aS_18[2]; // idb
-char aS_17[2]; // idb
-char aS_16[2]; // idb
-char aS_15[2]; // idb
-char aTerra03d[777]; // idb
-char aRestexit[777]; // idb
-char aRestb4[777]; // idb
-char aRestb3[777]; // idb
-char aRestb2[777]; // idb
-char aRestb1[777]; // idb
-char aRestmain[777]; // idb
-char aD29_blv[777]; // idb
-char aS190D[777]; // idb
-char aD02dS[777]; // idb
-char a408D[777]; // idb
-char aHglas03d[777]; // idb
-char aChest02d[777]; // idb
-char aMicon1[777]; // idb
-char aEndcapB[777]; // idb
-char aEdge_topB[777]; // idb
-char aEdge_rtB[777]; // idb
-char aEdge_lfB[777]; // idb
-char aEdge_btmB[777]; // idb
-char aCornr_urB[777]; // idb
-char aCornr_ulB[777]; // idb
-char aCornr_lrB[777]; // idb
-char aCornr_llB[777]; // idb
-char aFr_invenB[777]; // idb
-char aEvtnpcB[777]; // idb
-char aIbBcuB[777]; // idb
-char aIsg04B[777]; // idb
-char aIsg03B[777]; // idb
-char aIsg02B[777]; // idb
-char aIsg01B[777]; // idb
-char aIbM4dB[777]; // idb
-char aIbM3dB[777]; // idb
-char aIbM2dB[777]; // idb
-char aIbM1dB[777]; // idb
-char aIbSelecB[777]; // idb
-char aIbAutinB[777]; // idb
-char aIbAutoutB[777]; // idb
-char aIbNpcrdB[777]; // idb
-char aIbNpcldB[777]; // idb
-char aIbInitrB[777]; // idb
-char aIbInityB[777]; // idb
-char aIbInitgB[777]; // idb
-char aIbCompB[777]; // idb
-char aIbAutmaskB[777]; // idb
-char aIbMbB[777]; // idb
-char aIbFootB_pcx[777]; // idb
-char aIbLB_pcx[777]; // idb
-char aIbTB_pcx[777]; // idb
-char aIbBB_pcx[777]; // idb
-char aIbRB_pcx[777]; // idb
-char aIbSelecA_0[777]; // idb
-char aIbNpcrdA_0[777]; // idb
-char aIbNpcldA_0[777]; // idb
-char aIbCompA_0[777]; // idb
-char aIbMbA_0[777]; // idb
-char aIbLA_pcx_0[777]; // idb
-char aIbTA_pcx_0[777]; // idb
-char aIbBA_pcx_0[777]; // idb
-char aIbRA_pcx_0[777]; // idb
-char aEndcap[777]; // idb
-char aEdge_top[777]; // idb
-char aEdge_rt[777]; // idb
-char aEdge_lf[777]; // idb
-char aEdge_btm[777]; // idb
-char aCornr_ur[777]; // idb
-char aCornr_ul[777]; // idb
-char aCornr_lr[777]; // idb
-char aCornr_ll[777]; // idb
-char aEvtnpc[777]; // idb
-char aIsg04A[777]; // idb
-char aIsg03A[777]; // idb
-char aIsg02A[777]; // idb
-char aIsg01A[777]; // idb
-char aIbBcuA[777]; // idb
-char aIbAutinA[777]; // idb
-char aIbAutoutA[777]; // idb
-char aIbM4dA[777]; // idb
-char aIbM3dA[777]; // idb
-char aIbM2dA[777]; // idb
-char aIbM1dA[777]; // idb
-char aIbSelecA[777]; // idb
-char aIbNpcrdA[777]; // idb
-char aIbNpcldA[777]; // idb
-char aIbInitrA[777]; // idb
-char aIbInityA[777]; // idb
-char aIbInitgA[777]; // idb
-char aIbCompA[777]; // idb
-char aIbAutmaskA[777]; // idb
-char aIbMbA[777]; // idb
-char aIbFootA_pcx[777]; // idb
-char aIbLA_pcx[11]; // weak
-char aIbTA_pcx[11]; // weak
-char aIbBA_pcx[11]; // weak
-char aIbRA_pcx[11]; // weak
-char aEndcapC[777]; // idb
-char aEdge_topC[777]; // idb
-char aEdge_rtC[777]; // idb
-char aEdge_lfC[777]; // idb
-char aEdge_btmC[777]; // idb
-char aCornr_urC[777]; // idb
-char aCornr_ulC[777]; // idb
-char aCornr_lrC[777]; // idb
-char aCornr_llC[777]; // idb
-char aParchment[777]; // idb
-char pContainer[777]; // idb
-char aIbBC_pcx_0[777]; // idb
-char aFr_inven[777]; // idb
-char aEvtnpcC[777]; // idb
-char aIsg04C[777]; // idb
-char aIsg03C[777]; // idb
-char aIsg02C[777]; // idb
-char aIsg01C[777]; // idb
-char aIbBcuC[777]; // idb
-char aIbM4dC[777]; // idb
-char aIbM3dC[777]; // idb
-char aIbM2dC[777]; // idb
-char aIbM1dC[777]; // idb
-char aIbSelecC[777]; // idb
-char aIbAutinC[777]; // idb
-char aIbAutoutC[777]; // idb
-char aIbNpcrdC[777]; // idb
-char aIbNpcldC[777]; // idb
-char aIbInitrC[777]; // idb
-char aIbInityC[777]; // idb
-char aIbInitgC[777]; // idb
-char aIbCompC[777]; // idb
-char aIbAutmaskC[777]; // idb
-char aIbMbC[777]; // idb
-char aIbFootC_pcx[777]; // idb
-char aIbLC_pcx[777]; // idb
-char aIbTC_pcx[777]; // idb
-char aIbBC_pcx[11]; // weak
-char aIbRC_pcx[777]; // idb
-char a10i10iS[777]; // idb
-char aSizeIII[777]; // idb
-char aDwavailvirtual[777]; // idb
-char aDwtotalvirtual[777]; // idb
-char aDwavailpagefil[777]; // idb
-char aDwtotalpagefil[777]; // idb
-char aDwavailphysD[777]; // idb
-char aDwtotalphysD[777]; // idb
-char aDwmemoryloadD[777]; // idb
-char aDwlengthD[777]; // idb
 char Format[777]; // idb
 char aMem03i_txt[777]; // idb
 char aMemory[777]; // idb
 char aIdSSizeI[16]; // idb
 __int16 word_4E3C66[777]; // idb
-char aSpell96[777]; // idb
-char aNothing[777]; // idb
-char aS_22[5]; // weak
-char aDGold[777]; // idb
-char aSAndDGold[777]; // idb
-char aD05_blv[777]; // idb
-char aSpell11[777]; // idb
-char aAframe1[777]; // idb
-char aTurnstart[777]; // idb
-char aTurnhour[777]; // idb
-char aTurnstop[777]; // idb
-char aTurn4[777]; // idb
-char aTurn3[777]; // idb
-char aTurn2[777]; // idb
-char aTurn1[777]; // idb
-char aTurn0[777]; // idb
 int dword_4E455C; // weak
 int dword_4E4560[6];
 int dword_4E4578[6];
@@ -818,7 +561,7 @@
 char aButtexi1[777]; // idb
 char aCanTJumpToThat[777]; // idb
 char aNoMapFoundForS[777]; // idb
-char a2[777]; // idb
+char global_a2[777]; // idb
 char aSSS[777]; // idb
 char aNotInMapStats[17]; // weak
 char aD47_blv[777]; // idb
@@ -1396,9 +1139,10 @@
 char aInvalidLight_0[777]; // idb
 char aUknownStripTyp[777]; // idb
 char aInvalidLightma[777]; // idb
-char byte_4E94D0; // weak
-char byte_4E94D2; // weak
-char byte_4E94D3; // weak
+char byte_4E94D0 = 5; // weak
+char byte_4E94D1 = 9; // weak
+char _4E94D2_light_type = 6; // weak
+char byte_4E94D3 = 10; // weak
 unsigned int saveload_dlg_xs[2] = {82, 0};
 unsigned int saveload_dlg_ys[2] = {60, 0};
 unsigned int saveload_dlg_zs[2] = {460, 640};
@@ -1943,25 +1687,66 @@
   "pc21-", "pc22-", "pc23", "pc24-", "pc25-"
 };
 
-const char *dlad_texnames_by_face[25];
-const char *dlau_texnames_by_face[25];
-const char *dbod_texnames_by_face[25];
-const char *drh_texnames_by_face[25];
-const char *dlh_texnames_by_face[25];
-const char *dlhu_texnames_by_face[25];
+const char *dlad_texnames_by_face[25] =
+{
+  "pc01lad", "pc02lad", "pc03lad", "pc04lad", "pc05lad", "pc06lad",
+  "pc07lad", "pc08lad", "pc09lad", "pc10lad", "pc11lad", "pc12lad",
+  "pc13lad", "pc14lad", "pc15lad", "pc16lad", "pc17lad", "pc18lad",
+  "pc19lad", "pc20lad", "pc21lad", "pc22lad", "pc23lad", "pc24lad",
+  "pc25lad"
+};
+const char *dlau_texnames_by_face[25] =
+{
+  "pc01lau", "pc02lau", "pc03lau", "pc04lau", "pc05lau", "pc06lau",
+  "pc07lau", "pc08lau", "pc09lau", "pc10lau", "pc11lau", "pc12lau",
+  "pc13lau", "pc14lau", "pc15lau", "pc16lau", "pc17lau", "pc18lau",
+  "pc19lau", "pc20lau", "pc21lau", "pc22lau", "pc23lau", "pc24lau",
+  "pc25lau"
+};
+const char *dbod_texnames_by_face[25] =
+{
+  "pc01bod", "pc02bod", "pc03bod", "pc04bod", "pc05bod", "pc06bod",
+  "pc07bod", "pc08bod", "pc09bod", "pc10bod", "pc11bod", "pc12bod",
+  "pc13bod", "pc14bod", "pc15bod", "pc16bod", "pc17bod", "pc18bod",
+  "pc19bod", "pc20bod", "pc21bod", "pc22bod", "pc23bod", "pc24bod",
+  "pc25bod"
+};
+const char *drh_texnames_by_face[25] =
+{
+
+  "pc01rh", "pc02rh", "pc03rh", "pc04rh", "pc05rh", "pc06rh",
+  "pc07rh", "pc08rh", "pc09rh", "pc10rh", "pc11rh", "pc12rh",
+  "pc13rh", "pc14rh", "pc15rh", "pc16rh", "pc17rh", "pc18rh",
+  "pc19rh", "pc20rh", "pc21rh", "pc22rh", "pc23rh", "pc24rh",
+  "pc25rh"
+};
+const char *dlh_texnames_by_face[25] =
+{
+  "pc01lh", "pc02lh", "pc03lh", "pc04lh", "pc05lh", "pc06lh",
+  "pc07lh", "pc08lh", "pc09lh", "pc10lh", "pc11lh", "pc12lh",
+  "pc13lh", "pc14lh", "pc15lh", "pc16lh", "pc17lh", "pc18lh",
+  "pc19lh", "pc20lh", "pc21lh", "pc22lh", "pc23lh", "pc24lh",
+  "pc25lh"
+};
+const char *dlhu_texnames_by_face[25] =
+{
+  "pc01lhu", "pc02lhu", "pc03lhu", "pc04lhu", "pc05lhu", "pc06lhu",
+  "pc07lhu", "pc08lhu", "pc09lhu", "pc10lhu", "pc11lhu", "pc12lhu",
+  "pc13lhu", "pc14lhu", "pc15lhu", "pc16lhu", "pc17lhu", "pc18lhu",
+  "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu",
+  "pc25lhu"
+};
 _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
 int dword_4EDEC4[777]; // weak
-__int16 word_4EDED8[777]; // weak
-__int16 word_4EDEDC; // weak
+__int16 word_4EDED8[16] = {100, 90, 60, 100, 80, 100, 80, 30, 10, 10, 20, 30, 100, 0, 0, 0};
 _UNKNOWN unk_4EDF40; // weak
-unsigned int pHiredNPCsIconsOffsetsX[2];
-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] =
@@ -1985,81 +1770,6 @@
 
 char aDD[777]; // idb
 char off_4EE75C[777]; // idb
-char aFacemask[777]; // idb
-char aDead_0[777]; // idb
-char aEradcate[777]; // idb
-char aS02d[777]; // idb
-char aUnableToSaveDp[777]; // idb
-char aDataDpft_bin[777]; // idb
-char aPlayerframet_1[777]; // idb
-char aPlayerframet_0[777]; // idb
-char aPlayerframetab[777]; // idb
-char aUnableToSaveDi[777]; // idb
-char aDataDift_bin[777]; // idb
-char aIFrames[777]; // idb
-char aIconframetab_0[777]; // idb
-char aIconframetable[777]; // idb
-char aInvalidStrin_1[22]; // weak
-char a03uS[777]; // idb
-char aS03dD[777]; // idb
-char aCchar_fnt[777]; // idb
-char aArrowrD[777]; // idb
-char aArrowlD[777]; // idb
-char aPresleft[777]; // idb
-char aPresrigh[777]; // idb
-char aButtplus[777]; // idb
-char aButtminu[777]; // idb
-char aS01[777]; // idb
-char aMakesky[777]; // idb
-char aMaketop[777]; // idb
-char aIc_sorc[777]; // idb
-char aIc_druid[777]; // idb
-char aIc_cler[777]; // idb
-char aIc_ranger[777]; // idb
-char aIc_arch[777]; // idb
-char aIc_palad[777]; // idb
-char aIc_monk[777]; // idb
-char aIc_thief[777]; // idb
-char aIc_knight[777]; // idb
-char aScrollermap[777]; // idb
-char aCredits_txt[777]; // idb
-char aMm6title_pcx[13]; // weak
-char aQuick_fnt[777]; // idb
-char aL_map[777]; // idb
-char aL_bsp[777]; // idb
-char aL_d[777]; // idb
-char aL_l[777]; // idb
-char aL_r[777]; // idb
-char aL_fx[777]; // idb
-char aL_f[777]; // idb
-char aL_v[777]; // idb
-char aD29_dlv[777]; // idb
-char a_dlv[777]; // idb
-char aEWorkMsdevM_20[777]; // idb
-char a_blv[777]; // idb
-char aL_ddata[777]; // idb
-char aL_rldata[777]; // idb
-char aL_rdata[777]; // idb
-char aL_fdata[777]; // idb
-char aHwsplat04[777]; // idb
-char aErrorFailedT_0[777]; // idb
-char aEWorkMsdevM_21[777]; // idb
-char aReferenceRaste[777]; // idb
-char aRgbEmulation[777]; // idb
-char aInitFailedTo_7[777]; // idb
-char aInitFailedTo_6[777]; // idb
-char aInitFailedToAt[777]; // idb
-char aInitFailedTo_5[777]; // idb
-char aInitFailedToGe[37]; // weak
-char aInitFailedTo_4[39]; // weak
-char aInitFailedTo_3[36]; // weak
-char aInitFailedToEn[46]; // weak
-char aInitFailedTo_2[34]; // weak
-char aInitFailedTo_1[38]; // weak
-char aInitDesktopIsn[777]; // idb
-char aInitFailedToSe[777]; // idb
-char aInitFailedTo_0[777]; // idb
-char aInitFailedToCr[777]; // idb
 int dword_4EED78; // weak
 _UNKNOWN unk_4EED80; // weak
 int dword_4EFA80; // weak
@@ -2248,9 +1958,7 @@
 int ai_arrays_size; // weak
 int ai_array_4F75E0[500];
 unsigned int ai_array_4F7DB0_actor_ids[500];
-int dword_4F8580[777]; // weak
-int dword_4F8584[777]; // weak
-int dword_4F8588[777]; // weak
+int dword_4F8580[182]; // weak
 int dword_4FA9B0[777]; // weak
 int dword_4FA9B4[777]; // weak
 char byte_4FAA00; // weak
@@ -2332,7 +2040,6 @@
 int dword_506408[777]; // weak
 int dword_50640C[777]; // weak
 unsigned int uTextureID_506438;
-_UNKNOWN unk_506494; // weak
 int dword_50651C; // weak
 int dword_506520; // weak
 int dword_506524; // weak
@@ -2407,19 +2114,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
@@ -2609,9 +2315,8 @@
 int _6807E8_level_decorations_ids[777]; // idb
 int _6836C8_num_decorations_6807E8; // weak
 int dword_69B010[64];
-int dword_69B138; // weak
+float flt_69B138_dist; // weak
 char byte_69BD41_unused; // weak
-std::string stru_69BD44; // idb
 unsigned int uTextureID_x_u;
 unsigned int uTextureID_LS_saveU;
 unsigned int uTextureID_LS_loadU;
@@ -2671,7 +2376,7 @@
 int dword_6BE138; // weak
 int dword_6BE13C_uCurrentlyLoadedLocationID; // weak
 float fWalkSpeedMultiplier = 1.0f; // weak
-float fBackwardMovementSlowdownMultiplier = 1.0f; // weak
+float fBackwardWalkSpeedMultiplier = 1.0f; // weak
 float fTurnSpeedMultiplier = 1.0f; // weak
 float flt_6BE150_look_up_down_dangle = 1.0f; // weak
 HWND hWnd; // idb
@@ -2722,11 +2427,11 @@
 int uTextureID_720980; // weak
 int _720984_unused; // weak
 char _72098C_unused; // weak
-std::string std__string_720990; // idb
 __int16 word_7209A0_intercepts_ys_plus_ys[104];
 __int16 word_720A70_intercepts_xs_plus_xs[104];
 __int16 word_720B40_intercepts_zs[104];
-__int16 word_720C10_intercepts_xs[104];
+__int16 word_720C10_intercepts_xs[102];
+int dword_720CDC;
 __int16 word_720CE0_ys[777]; // idb
 __int16 word_720DB0_xs[777]; // idb
 int dword_720E80[20];
@@ -2739,8 +2444,8 @@
 int dword_7211B0[777]; // idb
 int dword_721200[777]; // idb
 int dword_7212C8[777]; // idb
-__int16 word_721390[777]; // idb
-__int16 word_721460[777]; // idb
+__int16 word_721390[104]; // idb
+__int16 word_721460[104]; // idb
 int blv_prev_party_x; // weak
 int blv_prev_party_z; // weak
 int blv_prev_party_y; // weak
@@ -2829,7 +2534,6 @@
 struct Texture *pTexture_PlayerFaceMask;
 struct Texture *pTexture_PlayerFaceEradicated;
 struct Texture *pTexture_PlayerFaceDead;
-int A74CEC_player_faces_minus1_indexing[777]; // weak
 struct Texture *pTextures_PlayerFaces[4][56];
 int dword_A75070; // weak
 struct Player *pPlayers[5];
@@ -2845,12 +2549,7 @@
 char byte_AE336B; // weak
 int dword_AE336C; // weak
 int dword_AE3370; // weak
-Vec3_float_ stru_AE4F64; // idb
-Vec3_float_ stru_AE4F70; // idb
-Vec3_float_ stru_AE4F7C; // idb
-int dword_AE4F88; // weak
 char byte_AE5B91; // weak
-std::string std__string_AE5B94; // idb
 int dword_F1B430[32]; // weak
 int dword_F8B144; // idb
 char byte_F8B148[16];
@@ -2889,5 +2588,4 @@
 
 //int crt_F94004; // weak
 //int crtdword_F9400C; // weak
-FARPROC lpfn; // idb
-float flt_F942B0; // weak
\ No newline at end of file
+FARPROC lpfn; // idb
\ No newline at end of file
--- a/mm7_data.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/mm7_data.h	Mon Oct 29 09:28:08 2012 +0600
@@ -317,9 +317,8 @@
 extern int dword_4C9920[16]; // weak
 extern _UNKNOWN unk_4D8548; // weak
 extern char byte_4D864C; // weak
-extern int dword_4D86CC; // weak
+extern float flt_4D86CC; // weak
 extern int dword_4D86D8; // weak
-extern int dword_4D86F0; // weak
 extern int dword_4DAFCC; // weak
 extern int (__stdcall *off_4DAFDC)(char); // weak
 extern char asc_4DB724[]; // idb
@@ -338,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
@@ -377,9 +377,9 @@
 extern char byte_4E2430[]; // weak
 extern char byte_4E2431[]; // weak
 extern unsigned int pLloydsBeaconsPreviewXs[5];
-extern int pLloydsBeaconsPreviewYs[5];
+extern unsigned int pLloydsBeaconsPreviewYs[5];
 extern unsigned int pLloydsBeacons_SomeXs[5];
-extern int pLloydsBeacons_SomeYs[]; // idb
+extern unsigned int pLloydsBeacons_SomeYs[5]; // idb
 extern char aSbwb00[7]; // weak
 extern char aW[2]; // idb
 extern char aA[2]; // idb
@@ -457,7 +457,7 @@
 extern char aS100110D[]; // idb
 extern char aS100110DS[]; // idb
 extern char aS100110D02dSS[]; // idb
-extern int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions; // weak
+extern int pCurrentScreen; // weak
 extern char byte_4E28FC; // weak
 extern unsigned int uGammaPos;
 extern int dword_4E2910[]; // weak
@@ -530,270 +530,12 @@
 extern char aSS_0[]; // idb
 extern char aS_5[4]; // idb
 extern _UNKNOWN unk_4E2EB8; // weak
-extern char aS_4[2]; // idb
-extern char aS_0[2]; // idb
-extern char byte_4E2F14; // idb
-extern char aFr_stats[]; // idb
-extern char aS1772d[]; // idb
-extern char aS_10[3]; // idb
-extern char aS177S[]; // idb
-extern char aS4002d[]; // idb
-extern char aS_9[3]; // idb
-extern char aS400S[]; // idb
-extern char aS_8[38];
-extern char aFr_skill[]; // idb
-extern char byte_4E2FD4[7];
-extern char aS_11[3]; // idb
-extern char aFr_award[]; // idb
-extern char aSptext01[]; // idb
-extern char aSp28a[6]; // weak
-extern char aSp30a[6]; // weak
-extern char aSp91a[6]; // weak
-extern char aFr_strip[]; // idb
-extern char a261SD[]; // idb
-extern char aS_12[4]; // idb
-extern char aD_2[4];
-extern char aLu[4];
-extern char aQuikref[]; // idb
-extern char aIbCd1D[]; // idb
-extern char aIbCd2D[]; // idb
-extern char aIbCd4D[]; // idb
-extern char aIbCd3D[]; // idb
-extern char a028Lu[]; // idb
-extern char a087Lu[]; // idb
-extern char aComic_fnt[]; // idb
-extern char aSmallnum_fnt[]; // idb
-extern char aCreate_fnt[]; // idb
-extern char aLucida_fnt[]; // idb
-extern char aArrus_fnt[]; // idb
-extern char aIbTd5A[]; // idb
-extern char aIbTd4A[]; // idb
-extern char aIbTd3A[]; // idb
-extern char aIbTd2A[]; // idb
-extern char aIbTd1A[]; // idb
-extern char aButtmake2[]; // idb
-extern char aButtmake[]; // idb
-extern char aButtyes2[]; // idb
-extern char aX_ok_u[]; // idb
-extern char aButtesc2[]; // idb
-extern char aX_x_u[]; // idb
-extern char aIbground[]; // idb
-extern char aLeather[]; // idb
-extern char aMhp_yel[]; // idb
-extern char aMhp_red[]; // idb
-extern char aMhp_grn[]; // idb
-extern char aMhp_capr[]; // idb
-extern char aMhp_capl[]; // idb
-extern char aMhp_bg[]; // idb
-extern char aIbStatr[]; // idb
-extern char aIbStaty[]; // idb
-extern char aIbStatg[]; // idb
-extern char aIbStatb[]; // idb
-extern char aMapdir7[]; // idb
-extern char aMapdir6[]; // idb
-extern char aMapdir5[]; // idb
-extern char aMapdir4[]; // idb
-extern char aMapdir3[]; // idb
-extern char aMapdir2[]; // idb
-extern char aMapdir1[]; // idb
-extern char aMapdir8[]; // idb
-extern char aTorcha[]; // idb
-extern char aTorchb[]; // idb
-extern char aTorchc[]; // idb
-extern char aWizeyea[]; // idb
-extern char aWizeyeb[]; // idb
-extern char aWizeyec[]; // idb
-extern char aTest[]; // idb
-extern char aMicon2[]; // idb
-extern char aButton[]; // idb
-extern char aDS[]; // idb
-extern char a020[]; // idb
-extern char aS_14[4]; // idb
-extern char aS_13[5]; // idb
 extern char string_4E3294[8];
-extern char aDMn[]; // idb
-extern char aDHr[]; // idb
-extern char aDDy[]; // idb
-extern char aDMo[]; // idb
-extern char aDYr[]; // idb
-extern char aDuration[]; // idb
-extern char aSLu[]; // idb
-extern char aSSD[]; // idb
-extern char aSD_1[]; // idb
-extern char aD_0[]; // idb
-extern char aSDSDdD[]; // idb
-extern char aS_21[2]; // idb
-extern char byte_4E3318; // idb
-extern char aS_20[2]; // idb
-extern char aS_19[2]; // idb
-extern char aS_18[2]; // idb
-extern char aS_17[2]; // idb
-extern char aS_16[2]; // idb
-extern char aS_15[2]; // idb
-extern char aTerra03d[]; // idb
-extern char aRestexit[]; // idb
-extern char aRestb4[]; // idb
-extern char aRestb3[]; // idb
-extern char aRestb2[]; // idb
-extern char aRestb1[]; // idb
-extern char aRestmain[]; // idb
-extern char aD29_blv[]; // idb
-extern char aS190D[]; // idb
-extern char aD02dS[]; // idb
-extern char a408D[]; // idb
-extern char aHglas03d[]; // idb
-extern char aChest02d[]; // idb
-extern char aMicon1[]; // idb
-extern char aEndcapB[]; // idb
-extern char aEdge_topB[]; // idb
-extern char aEdge_rtB[]; // idb
-extern char aEdge_lfB[]; // idb
-extern char aEdge_btmB[]; // idb
-extern char aCornr_urB[]; // idb
-extern char aCornr_ulB[]; // idb
-extern char aCornr_lrB[]; // idb
-extern char aCornr_llB[]; // idb
-extern char aFr_invenB[]; // idb
-extern char aEvtnpcB[]; // idb
-extern char aIbBcuB[]; // idb
-extern char aIsg04B[]; // idb
-extern char aIsg03B[]; // idb
-extern char aIsg02B[]; // idb
-extern char aIsg01B[]; // idb
-extern char aIbM4dB[]; // idb
-extern char aIbM3dB[]; // idb
-extern char aIbM2dB[]; // idb
-extern char aIbM1dB[]; // idb
-extern char aIbSelecB[]; // idb
-extern char aIbAutinB[]; // idb
-extern char aIbAutoutB[]; // idb
-extern char aIbNpcrdB[]; // idb
-extern char aIbNpcldB[]; // idb
-extern char aIbInitrB[]; // idb
-extern char aIbInityB[]; // idb
-extern char aIbInitgB[]; // idb
-extern char aIbCompB[]; // idb
-extern char aIbAutmaskB[]; // idb
-extern char aIbMbB[]; // idb
-extern char aIbFootB_pcx[]; // idb
-extern char aIbLB_pcx[]; // idb
-extern char aIbTB_pcx[]; // idb
-extern char aIbBB_pcx[]; // idb
-extern char aIbRB_pcx[]; // idb
-extern char aIbSelecA_0[]; // idb
-extern char aIbNpcrdA_0[]; // idb
-extern char aIbNpcldA_0[]; // idb
-extern char aIbCompA_0[]; // idb
-extern char aIbMbA_0[]; // idb
-extern char aIbLA_pcx_0[]; // idb
-extern char aIbTA_pcx_0[]; // idb
-extern char aIbBA_pcx_0[]; // idb
-extern char aIbRA_pcx_0[]; // idb
-extern char aEndcap[]; // idb
-extern char aEdge_top[]; // idb
-extern char aEdge_rt[]; // idb
-extern char aEdge_lf[]; // idb
-extern char aEdge_btm[]; // idb
-extern char aCornr_ur[]; // idb
-extern char aCornr_ul[]; // idb
-extern char aCornr_lr[]; // idb
-extern char aCornr_ll[]; // idb
-extern char aEvtnpc[]; // idb
-extern char aIsg04A[]; // idb
-extern char aIsg03A[]; // idb
-extern char aIsg02A[]; // idb
-extern char aIsg01A[]; // idb
-extern char aIbBcuA[]; // idb
-extern char aIbAutinA[]; // idb
-extern char aIbAutoutA[]; // idb
-extern char aIbM4dA[]; // idb
-extern char aIbM3dA[]; // idb
-extern char aIbM2dA[]; // idb
-extern char aIbM1dA[]; // idb
-extern char aIbSelecA[]; // idb
-extern char aIbNpcrdA[]; // idb
-extern char aIbNpcldA[]; // idb
-extern char aIbInitrA[]; // idb
-extern char aIbInityA[]; // idb
-extern char aIbInitgA[]; // idb
-extern char aIbCompA[]; // idb
-extern char aIbAutmaskA[]; // idb
-extern char aIbMbA[]; // idb
-extern char aIbFootA_pcx[]; // idb
-extern char aIbLA_pcx[11]; // weak
-extern char aIbTA_pcx[11]; // weak
-extern char aIbBA_pcx[11]; // weak
-extern char aIbRA_pcx[11]; // weak
-extern char aEndcapC[]; // idb
-extern char aEdge_topC[]; // idb
-extern char aEdge_rtC[]; // idb
-extern char aEdge_lfC[]; // idb
-extern char aEdge_btmC[]; // idb
-extern char aCornr_urC[]; // idb
-extern char aCornr_ulC[]; // idb
-extern char aCornr_lrC[]; // idb
-extern char aCornr_llC[]; // idb
-extern char aParchment[]; // idb
-extern char pContainer[]; // idb
-extern char aIbBC_pcx_0[]; // idb
-extern char aFr_inven[]; // idb
-extern char aEvtnpcC[]; // idb
-extern char aIsg04C[]; // idb
-extern char aIsg03C[]; // idb
-extern char aIsg02C[]; // idb
-extern char aIsg01C[]; // idb
-extern char aIbBcuC[]; // idb
-extern char aIbM4dC[]; // idb
-extern char aIbM3dC[]; // idb
-extern char aIbM2dC[]; // idb
-extern char aIbM1dC[]; // idb
-extern char aIbSelecC[]; // idb
-extern char aIbAutinC[]; // idb
-extern char aIbAutoutC[]; // idb
-extern char aIbNpcrdC[]; // idb
-extern char aIbNpcldC[]; // idb
-extern char aIbInitrC[]; // idb
-extern char aIbInityC[]; // idb
-extern char aIbInitgC[]; // idb
-extern char aIbCompC[]; // idb
-extern char aIbAutmaskC[]; // idb
-extern char aIbMbC[]; // idb
-extern char aIbFootC_pcx[]; // idb
-extern char aIbLC_pcx[]; // idb
-extern char aIbTC_pcx[]; // idb
-extern char aIbBC_pcx[11]; // weak
-extern char aIbRC_pcx[]; // idb
-extern char a10i10iS[]; // idb
-extern char aSizeIII[]; // idb
-extern char aDwavailvirtual[]; // idb
-extern char aDwtotalvirtual[]; // idb
-extern char aDwavailpagefil[]; // idb
-extern char aDwtotalpagefil[]; // idb
-extern char aDwavailphysD[]; // idb
-extern char aDwtotalphysD[]; // idb
-extern char aDwmemoryloadD[]; // idb
-extern char aDwlengthD[]; // idb
 extern char Format[]; // idb
 extern char aMem03i_txt[]; // idb
 extern char aMemory[]; // idb
 extern char aIdSSizeI[16]; // idb
 extern __int16 word_4E3C66[]; // idb
-extern char aSpell96[]; // idb
-extern char aNothing[]; // idb
-extern char aS_22[5]; // weak
-extern char aDGold[]; // idb
-extern char aSAndDGold[]; // idb
-extern char aD05_blv[]; // idb
-extern char aSpell11[]; // idb
-extern char aAframe1[]; // idb
-extern char aTurnstart[]; // idb
-extern char aTurnhour[]; // idb
-extern char aTurnstop[]; // idb
-extern char aTurn4[]; // idb
-extern char aTurn3[]; // idb
-extern char aTurn2[]; // idb
-extern char aTurn1[]; // idb
-extern char aTurn0[]; // idb
 extern int dword_4E455C; // weak
 extern int dword_4E4560[6];
 extern int dword_4E4578[6];
@@ -805,7 +547,7 @@
 extern char aButtexi1[]; // idb
 extern char aCanTJumpToThat[]; // idb
 extern char aNoMapFoundForS[]; // idb
-extern char a2[]; // idb
+extern char global_a2[]; // idb
 extern char aSSS[]; // idb
 extern char aNotInMapStats[17]; // weak
 extern char aD47_blv[]; // idb
@@ -1374,7 +1116,7 @@
 extern char aUknownStripTyp[]; // idb
 extern char aInvalidLightma[]; // idb
 extern char byte_4E94D0; // weak
-extern char byte_4E94D2; // weak
+extern char _4E94D2_light_type; // weak
 extern char byte_4E94D3; // weak
 extern unsigned int saveload_dlg_xs[2];
 extern unsigned int saveload_dlg_ys[2];
@@ -1920,14 +1662,12 @@
 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
 extern int dword_4EDEB4[]; // weak
 extern int dword_4EDEC4[]; // weak
 extern __int16 word_4EDED8[]; // weak
-extern __int16 word_4EDEDC; // weak
 extern _UNKNOWN unk_4EDF40; // weak
 extern unsigned int pHiredNPCsIconsOffsetsX[2];
 extern unsigned int pHiredNPCsIconsOffsetsY[2];
@@ -1937,81 +1677,6 @@
 extern short word_4EE150[];
 extern char aDD[]; // idb
 extern char off_4EE75C[]; // idb
-extern char aFacemask[]; // idb
-extern char aDead_0[]; // idb
-extern char aEradcate[]; // idb
-extern char aS02d[]; // idb
-extern char aUnableToSaveDp[]; // idb
-extern char aDataDpft_bin[]; // idb
-extern char aPlayerframet_1[]; // idb
-extern char aPlayerframet_0[]; // idb
-extern char aPlayerframetab[]; // idb
-extern char aUnableToSaveDi[]; // idb
-extern char aDataDift_bin[]; // idb
-extern char aIFrames[]; // idb
-extern char aIconframetab_0[]; // idb
-extern char aIconframetable[]; // idb
-extern char aInvalidStrin_1[22]; // weak
-extern char a03uS[]; // idb
-extern char aS03dD[]; // idb
-extern char aCchar_fnt[]; // idb
-extern char aArrowrD[]; // idb
-extern char aArrowlD[]; // idb
-extern char aPresleft[]; // idb
-extern char aPresrigh[]; // idb
-extern char aButtplus[]; // idb
-extern char aButtminu[]; // idb
-extern char aS01[]; // idb
-extern char aMakesky[]; // idb
-extern char aMaketop[]; // idb
-extern char aIc_sorc[]; // idb
-extern char aIc_druid[]; // idb
-extern char aIc_cler[]; // idb
-extern char aIc_ranger[]; // idb
-extern char aIc_arch[]; // idb
-extern char aIc_palad[]; // idb
-extern char aIc_monk[]; // idb
-extern char aIc_thief[]; // idb
-extern char aIc_knight[]; // idb
-extern char aScrollermap[]; // idb
-extern char aCredits_txt[]; // idb
-extern char aMm6title_pcx[13]; // weak
-extern char aQuick_fnt[]; // idb
-extern char aL_map[]; // idb
-extern char aL_bsp[]; // idb
-extern char aL_d[]; // idb
-extern char aL_l[]; // idb
-extern char aL_r[]; // idb
-extern char aL_fx[]; // idb
-extern char aL_f[]; // idb
-extern char aL_v[]; // idb
-extern char aD29_dlv[]; // idb
-extern char a_dlv[]; // idb
-extern char aEWorkMsdevM_20[]; // idb
-extern char a_blv[]; // idb
-extern char aL_ddata[]; // idb
-extern char aL_rldata[]; // idb
-extern char aL_rdata[]; // idb
-extern char aL_fdata[]; // idb
-extern char aHwsplat04[]; // idb
-extern char aErrorFailedT_0[]; // idb
-extern char aEWorkMsdevM_21[]; // idb
-extern char aReferenceRaste[]; // idb
-extern char aRgbEmulation[]; // idb
-extern char aInitFailedTo_7[]; // idb
-extern char aInitFailedTo_6[]; // idb
-extern char aInitFailedToAt[]; // idb
-extern char aInitFailedTo_5[]; // idb
-extern char aInitFailedToGe[37]; // weak
-extern char aInitFailedTo_4[39]; // weak
-extern char aInitFailedTo_3[36]; // weak
-extern char aInitFailedToEn[46]; // weak
-extern char aInitFailedTo_2[34]; // weak
-extern char aInitFailedTo_1[38]; // weak
-extern char aInitDesktopIsn[]; // idb
-extern char aInitFailedToSe[]; // idb
-extern char aInitFailedTo_0[]; // idb
-extern char aInitFailedToCr[]; // idb
 extern int dword_4EED78; // weak
 extern _UNKNOWN unk_4EED80; // weak
 extern int dword_4EFA80; // weak
@@ -2201,8 +1866,6 @@
 extern int ai_array_4F75E0[500];
 extern unsigned int ai_array_4F7DB0_actor_ids[500];
 extern int dword_4F8580[]; // weak
-extern int dword_4F8584[]; // weak
-extern int dword_4F8588[]; // weak
 extern int dword_4FA9B0[]; // weak
 extern int dword_4FA9B4[]; // weak
 extern char byte_4FAA00; // weak
@@ -2284,7 +1947,6 @@
 extern int dword_506408[]; // weak
 extern int dword_50640C[]; // weak
 extern unsigned int uTextureID_506438;
-extern _UNKNOWN unk_506494; // weak
 extern int dword_50651C; // weak
 extern int dword_506520; // weak
 extern int dword_506524; // weak
@@ -2302,7 +1964,6 @@
 extern char *aMoonPhaseNames[5];
 extern int dword_506568; // weak
 extern char bRecallingBeacon; // weak
-extern char nullstring[];
 extern int uLastPointedObjectID; // weak
 //extern unsigned __int8 bMonsterInfoUI_bDollInitialized;
 extern char *aSpellNames[44];
@@ -2360,19 +2021,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
@@ -2562,9 +2222,8 @@
 extern int _6807E8_level_decorations_ids[]; // idb
 extern int _6836C8_num_decorations_6807E8; // weak
 extern int dword_69B010[64];
-extern int dword_69B138; // weak
+extern float flt_69B138_dist; // weak
 extern char byte_69BD41_unused; // weak
-extern std::string stru_69BD44; // idb
 extern struct SavegameHeader *pSavegameHeader;
 extern unsigned int uTextureID_x_u;
 extern unsigned int uTextureID_LS_saveU;
@@ -2625,7 +2284,7 @@
 extern int dword_6BE138; // weak
 extern int dword_6BE13C_uCurrentlyLoadedLocationID; // weak
 extern float fWalkSpeedMultiplier; // weak
-extern float fBackwardMovementSlowdownMultiplier; // weak
+extern float fBackwardWalkSpeedMultiplier; // weak
 extern float fTurnSpeedMultiplier; // weak
 extern float flt_6BE150_look_up_down_dangle; // weak
 //extern char pMM7WindowClassName[]; // idb
@@ -2679,11 +2338,11 @@
 extern int uTextureID_720980; // weak
 extern int _720984_unused; // weak
 extern char _72098C_unused; // weak
-extern std::string std__string_720990; // idb
 extern __int16 word_7209A0_intercepts_ys_plus_ys[104];
 extern __int16 word_720A70_intercepts_xs_plus_xs[104];
 extern __int16 word_720B40_intercepts_zs[104];
-extern __int16 word_720C10_intercepts_xs[104];
+extern __int16 word_720C10_intercepts_xs[102];
+extern int dword_720CDC;
 extern __int16 word_720CE0_ys[]; // idb
 extern __int16 word_720DB0_xs[]; // idb
 extern int dword_720E80[20];
@@ -2785,7 +2444,6 @@
 extern struct Texture *pTexture_PlayerFaceMask;
 extern struct Texture *pTexture_PlayerFaceEradicated;
 extern struct Texture *pTexture_PlayerFaceDead;
-extern int A74CEC_player_faces_minus1_indexing[]; // weak
 extern struct Texture *pTextures_PlayerFaces[4][56];
 extern int dword_A75070; // weak
 extern struct Player *pPlayers[5];
@@ -2801,12 +2459,7 @@
 extern char byte_AE336B; // weak
 extern int dword_AE336C; // weak
 extern int dword_AE3370; // weak
-extern Vec3_float_ stru_AE4F64; // idb
-extern Vec3_float_ stru_AE4F70; // idb
-extern Vec3_float_ stru_AE4F7C; // idb
-extern int dword_AE4F88; // weak
 extern char byte_AE5B91; // weak
-extern std::string std__string_AE5B94; // idb
 extern int dword_F1B430[32]; // weak
 extern int dword_F8B144; // idb
 extern char byte_F8B148[16];
@@ -2849,7 +2502,6 @@
 //extern int crt_F94004; // weak
 //extern int crtdword_F9400C; // weak
 extern FARPROC lpfn; // idb
-extern float flt_F942B0; // weak
 //extern int crt_F944EC; // weak
 //extern int crtdword_F944F0; // weak
 //extern void *crt_F944F4; // idb
@@ -2885,8 +2537,8 @@
 bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *a4);
 bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *a4, struct BSPVertexBuffer *a5);
 bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb
-char __cdecl UpdateActors();
-char *__cdecl UpdateLayingItems();
+char UpdateActors();
+void UpdateLayingItems();
 int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6);
 unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors);
 unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID);
@@ -2987,7 +2639,7 @@
 void __thiscall sub_417871(int *pXY);
 void __cdecl sub_4178C4();
 void __cdecl sub_4178E1();
-unsigned int __fastcall sub_4178FE(signed int a1, signed int a2);
+unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2);
 signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb
 char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb
 unsigned int __fastcall sub_417AD4(unsigned int uPlayerClass, enum PLAYER_SKILL_TYPE uPlayerSkillType, signed int a3);
@@ -3078,7 +2730,7 @@
 void __cdecl GUI_MainMenuMessageProc();
 double __cdecl get_shading_dist_mist();
 double __cdecl GetPickDepth();
-void __thiscall Vec3_short__to_RenderVertexSoft(struct RenderVertexSoft *_this, struct Vec3_short_ *a2);
+void Vec3_short__to_RenderVertexSoft(struct RenderVertexSoft *_this, struct Vec3_short_ *a2);
 void __cdecl nullsub_4(); // idb
 void __cdecl nullsub_5(); // idb
 void __cdecl nullsub_6(); // idb
@@ -3100,7 +2752,7 @@
 int __fastcall _43C91D_FormItemTextureFilename(char *a1, signed int a2, int a3, int a4);
 void __fastcall CharacterUI_DrawPaperdoll(unsigned int uPlayerID); // idb
 void __fastcall CharacterUI_DrawPaperdollWithRingOverlay(unsigned int uPlayerID); // idb
-bool __thiscall sub_43ED6F_get_some_race_sex_relation(unsigned int a1);
+bool _43ED6F_check_party_races(bool b);
 bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int _this);
 bool __fastcall sub_43EE15_player_has_item(unsigned int uItemID, struct Player *pPlayer, char a3);
 bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1);
@@ -3110,22 +2762,22 @@
 int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(struct stru315 *a1/*<ebp>*/);
 int /*__usercall*/ sr_sub_4D705A/*<eax>*/(struct stru315 *a1/*<ebp>*/);
 void __cdecl MessWithBillboards_BLV();
-signed int __fastcall sub_43F55F(struct RenderBillboard *a1, signed int a2);
-signed int __fastcall sub_43F5C8(signed int a1, int a2, float a3, float a4, float a5);
-int __cdecl PrepareWallsRenderList_BLV();
+int __fastcall _43F55F_get_billboard_light_level(struct RenderBillboard *a1, int uBaseLightLevel);
+int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z);
+void PrepareWallsRenderList_BLV();
 void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID);
-unsigned int __cdecl PrepareActorRenderList_BLV();
-void __cdecl PrepareItemsRenderList_BLV();
+void PrepareActorRenderList_BLV();
+void PrepareItemsRenderList_BLV();
 void __fastcall sub_440639(int a1);
 void __fastcall sub_4406BC(int a1, unsigned int uFirstNode); // idb
 void __fastcall sub_440BED(struct IndoorLocation_drawstru *_this);
-bool __cdecl sub_44100D();
-void __cdecl GameUI_DrawTorchlightAndWizardEye();
-void __cdecl GameUI_DrawCharacterSelectionFrame();
-void __cdecl Load_isn_spells_21_27();
-void __cdecl GameUI_DrawPartySpells();
+bool sub_44100D();
+void GameUI_DrawTorchlightAndWizardEye();
+void GameUI_DrawCharacterSelectionFrame();
+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);
@@ -3212,9 +2864,6 @@
 int __fastcall ParseMissleAttackType(const char *Str1);
 unsigned int __fastcall SkillToMastery(unsigned __int16 a1);
 unsigned int __fastcall GetSpellColor(signed int a1);
-int __thiscall sub_45BAA5(int _this);
-std::string *__fastcall sub_45BAB6(int a1);
-// void __cdecl crt_45BAE9(); idb
 void *__thiscall unknown_vdtor_6(void *_this, bool a2);
 unsigned __int16 *__fastcall MakeScreenshot(signed int width, signed int height);
 void __thiscall SaveScreenshot(const char *pFilename);
@@ -3229,7 +2878,7 @@
 void __cdecl TryLoadLevelFromLOD();
 void __cdecl sub_46080D();
 bool __cdecl Initialize_GamesLOD_NewLOD();
-int __cdecl MaybeDoAutosave();
+bool Autosave();
 void __thiscall PrepareToLoadBLV(unsigned int bLoading);
 void __fastcall PrepareToLoadODM(unsigned int bLoading, struct OutdoorCamera *a2);
 void __cdecl sub_461103();
@@ -3281,17 +2930,14 @@
 int __fastcall sub_46A7C8(int a1, int a2, signed int a3);
 int __fastcall sub_46A89E(int a1, int a2, signed int a3);
 int __cdecl sub_46A99B();
-// int __thiscall crt_construct_46AC48_ptr_720990(int this);
-std::string *__fastcall crt_intit_global_46AC59(int a1);
 void *__thiscall unknown_libname_8(void *_this, char a2);
-// void __cdecl crt_init_globals_46BD9F();
 unsigned int __cdecl GetGravityStrength();
 void __cdecl sub_46BDC0_UpdateUserInput_and_MapSpecificStuff();
 void __cdecl BLV_UpdateUserInputAndOther();
 void __cdecl ODM_UpdateUserInputAndOther();
 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2);
 void __cdecl _46CC4B_check_event_triggers();
-int __fastcall _46CEC3_get_floor_level(signed int a1, signed int a2, int a3, unsigned int uSectorID, int *a5);
+int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID);
 int __fastcall sub_46D49E_prolly_get_world_y_under_party(int a1, signed int a2, int a3, int a4, int *a5, int *a6, int a7);
 int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4);
 signed __int64 __fastcall _46DCC8_get_gravity_direction_outdoor(int a1, int a2, Vec3_int_ *a3);
@@ -3301,7 +2947,7 @@
 void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2);
 int __thiscall _46E44E_collide_against_faces_and_portals(unsigned int b1); // idb
 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0);
-int __fastcall _46ED1B_collide_against_floor(signed int a1, signed int a2, int a3, unsigned int *pSectorID, int *a5); // idb
+int _46ED1B_collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
 void __fastcall _46ED8A_collide_against_layingItems(unsigned int _this);
 int __thiscall _46EF01_collision_chech_player(int a1); // idb
 signed int __cdecl _46F04E_collide_against_portals();
@@ -3309,7 +2955,7 @@
 void __cdecl UpdateActors_BLV();
 void __cdecl UpdateActors_ODM();
 void __cdecl UpdateObjects();
-int __fastcall _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, int *a5); // idb
+int _47272C_collide_agains_some_secotors_floors(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
 void __cdecl BLV_ProcessPartyActions();
 void __cdecl ODM_ProcessPartyActions();
 bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10);
@@ -3332,7 +2978,7 @@
 void __cdecl loc_4789D4(); // idb
 void __cdecl loc_47907F(); // idb
 bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused);
-void __fastcall sub_479A53(unsigned int uNumVertices, unsigned int uFaceID); // idb
+void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID); // idb
 void __thiscall ODM_LoadAndInitialize(const char *pLevelFilename, struct OutdoorCamera *thisa);
 unsigned __int16 *__fastcall GetBillboardPalette(struct RenderBillboard *a1, int a2, signed int a3, int a4);
 int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8);
@@ -3383,7 +3029,7 @@
 int __stdcall loc_489BB3(struct stru320 *a2, int thisa, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char uClipFlag); // weak
 bool __fastcall HSV2RGB(float *a1, float *a2, float *a3, float a4, float a5, float a6);
 void __fastcall RGB2HSV(float *a1, float *a2, float a3, float a4, float a5, float *a6);
-unsigned int __thiscall sub_48A959(int _this, float a2, float a3, float a4);
+unsigned int ReplaceHSV(unsigned int uColor, float a2, float gamma, float a4);
 int _48B561_mess_with_scaling_along_z(/*int a1, */float a2);
 signed int __cdecl sub_4908DE();
 signed int __cdecl PlayerCreation_ComputeAttributeBonus();
@@ -3411,8 +3057,7 @@
 bool __cdecl AreRenderSurfacesOk();
 int __fastcall sub_4A19D8(unsigned int, unsigned int); // weak
 void __cdecl DoRenderBillboards_D3D();
-void __fastcall SetBillboardBlendOptions(signed int a1);
-int __fastcall sub_4A46E6(unsigned int x, signed int y, signed int a3, int a4, unsigned int a5);
+int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int z, int a4, unsigned int lightColor);
 void __cdecl Present_ColorKey();
 void __cdecl Present_NoColorKey();
 int __thiscall sub_4A7063(unsigned int uDiffuse, float a2); // idb
--- a/stru10.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru10.cpp	Mon Oct 29 09:28:08 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.y;
+        v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel;
+
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, arg0, 0xFF0000u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, arg0 + 1, 0xFF00u, 0, 0);
+        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	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru10.h	Mon Oct 29 09:28:08 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/stru314.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru314.h	Mon Oct 29 09:28:08 2012 +0600
@@ -29,6 +29,6 @@
   Vec3_float_ field_4;
   Vec3_float_ field_10;
   Vec3_float_ field_1C;
-  int field_28;
+  float dist;
 };
 #pragma pack(pop)
--- a/stru346.h	Mon Oct 22 09:20:49 2012 +0600
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#pragma once
-
-
-/*  386 */
-#pragma pack(push, 1)
-struct stru346
-{
-  int field_0;
-  int field_4;
-  int field_8;
-  int field_C;
-  int field_10;
-  int field_14;
-  int field_18;
-  int field_1C;
-  int field_20;
-  int field_24;
-  int field_28;
-  int field_2C;
-  int field_30;
-  int field_34;
-  int field_38;
-  int field_3C;
-  int field_40;
-  int field_44;
-  int uParentBillboardID;
-};
-#pragma pack(pop)
-
--- a/stru6.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru6.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -88,92 +88,61 @@
 {
   int v8; // eax@1
 
-  v8 = this->uNumProjectiles;
+  v8 = uNumProjectiles;
   if ( v8 != 32 )
   {
-    this->pProjectiles[v8].srcX = srcX;
-    *((float *)&this->array_0[0].uSpellAnimLength + 7 * (this->uNumProjectiles + 21)) = srcY;
-    this->pProjectiles[this->uNumProjectiles].srcZ = srcZ;
-    this->pProjectiles[this->uNumProjectiles].dstX = dstX;
-    this->pProjectiles[this->uNumProjectiles].dstY = dstY;
-    this->pProjectiles[this->uNumProjectiles].dstZ = dstZ;
-    this->pProjectiles[this->uNumProjectiles++].uTextureID = uTextureID;
+    pProjectiles[v8].srcX = srcX;
+    *((float *)&this->array_0[0].uSpellAnimLength + 7 * (uNumProjectiles + 21)) = srcY;
+    pProjectiles[uNumProjectiles].srcZ = srcZ;
+    pProjectiles[uNumProjectiles].dstX = dstX;
+    pProjectiles[uNumProjectiles].dstY = dstY;
+    pProjectiles[uNumProjectiles].dstZ = dstZ;
+    pProjectiles[uNumProjectiles++].uTextureID = uTextureID;
   }
 }
 
 //----- (004A7298) --------------------------------------------------------
-int stru6::DrawProjectiles()
+void stru6::DrawProjectiles()
 {
-  stru6 *v1; // ebx@1
-  char *v2; // eax@1
-  signed int v3; // ecx@1
-  unsigned __int8 v4; // zf@3
-  unsigned __int8 v5; // sf@3
-  IndoorCameraD3D *v6; // edi@3
-  int result; // eax@3
-  int v8; // esi@4
-  int v9; // eax@5
   float v10; // ST1C_4@8
   float v11; // ST0C_4@8
   IDirect3DTexture2 *v12; // [sp+20h] [bp-78h]@6
-  RenderVertexSoft v13[2]; // [sp+30h] [bp-68h]@1
-  float v14; // [sp+90h] [bp-8h]@3
-  int v15; // [sp+94h] [bp-4h]@3
-
-  v1 = this;
-  v2 = (char *)&v13[0].flt_2C;
-  v3 = 2;
-  do
-  {
-    *(float *)v2 = 0.0;
-    v2 += 48;
-    --v3;
-  }
-  while ( v3 );
-  v15 = 0;
-  v4 = v1->uNumProjectiles == 0;
-  v5 = v1->uNumProjectiles < 0;
-  v6 = pGame->pIndoorCameraD3D;
-  result = LODWORD(v6->flt_D0);
-  v14 = v6->flt_D0;
-  if ( !(v5 | v4) )
+  RenderVertexSoft v[2]; // [sp+30h] [bp-68h]@1
+  
+  for (uint i = 0; i < uNumProjectiles; ++i)
   {
-    v8 = (int)&v1->pProjectiles[0].srcY;
-    do
-    {
-      v13[0].vWorldPosition.x = *(float *)(v8 - 4);
-      v13[0].vWorldPosition.y = *(float *)v8;
-      v13[0].vWorldPosition.z = *(float *)(v8 + 4);
-      v13[1].vWorldPosition.x = *(float *)(v8 + 8);
-      v13[1].vWorldPosition.y = *(float *)(v8 + 12);
-      v13[1].vWorldPosition.z = *(float *)(v8 + 16);
-      v6->ViewTransform(v13, 2u);
-      sr_42620A(v13);
-      v6->_436BB7_project_and_stuff(v13, 2u, 0);
-      v9 = *(int *)(v8 + 20);
-      if ( v9 == -1 )
-        v12 = 0;
-      else
-        v12 = pBitmaps_LOD->pHardwareTextures[v9];
-      v10 = v14 / v13[1].vWorldViewPosition.x * 20.0;
-      v11 = v14 / v13[0].vWorldViewPosition.x * 20.0;
-      pRenderer->DrawProjectile(
-        v13[0].vWorldViewProjX,
-        v13[0].vWorldViewProjY,
-        v13[0].vWorldViewPosition.x,
-        v11,
-        v13[1].vWorldViewProjX,
-        v13[1].vWorldViewProjY,
-        v13[1].vWorldViewPosition.x,
-        v10,
-        v12);
-      ++v15;
-      v8 += 28;
-      result = v15;
-    }
-    while ( v15 < v1->uNumProjectiles );
-  }
-  return result;
+    auto p = pProjectiles + i;
+
+    v[0].vWorldPosition.x = p->srcX;
+    v[0].vWorldPosition.y = p->srcY;
+    v[0].vWorldPosition.z = p->srcZ;
+    v[1].vWorldPosition.x = p->dstX;
+    v[1].vWorldPosition.y = p->dstY;
+    v[1].vWorldPosition.z = p->dstZ;
+    pGame->pIndoorCameraD3D->ViewTransform(v, 2);
+
+    sr_42620A(v);
+
+    pGame->pIndoorCameraD3D->Project(v, 2, 0);
+
+    if (p->uTextureID != -1)
+      v12 = pBitmaps_LOD->pHardwareTextures[p->uTextureID];
+    else
+      v12 = 0;
+
+    v10 = pGame->pIndoorCameraD3D->fov_x / v[1].vWorldViewPosition.x * 20.0;
+    v11 = pGame->pIndoorCameraD3D->fov_x / v[0].vWorldViewPosition.x * 20.0;
+    pRenderer->DrawProjectile(
+        v[0].vWorldViewProjX,
+        v[0].vWorldViewProjY,
+        v[0].vWorldViewPosition.x,
+         v11,
+        v[1].vWorldViewProjX,
+        v[1].vWorldViewProjY,
+        v[1].vWorldViewPosition.x,
+         v10,
+         v12);
+   }
 }
 
 //----- (004A73AA) --------------------------------------------------------
@@ -207,7 +176,7 @@
     local_0.flt_10 = 0.0;
     local_0.flt_14 = 0.0;
     local_0.flt_18 = 0.0;
-    local_0.field_20 = (rand() & 0x40) + 96;
+    local_0.timeToLive = (rand() & 0x40) + 96;
     local_0.uTextureID = uTextureID;
     local_0.flt_28 = 1.0;
     pGame->pParticleEngine->AddParticle(&local_0);
@@ -239,7 +208,7 @@
     local_0.flt_14 = 0.0;
     local_0.flt_18 = 0.0;
     local_0.flt_28 = 1.0;
-    local_0.field_20 = (rand() & 0x7F) + 128;
+    local_0.timeToLive = (rand() & 0x7F) + 128;
     local_0.uTextureID = uTextureID;
     pGame->pParticleEngine->AddParticle(&local_0);
     local_0.x = (double)a2->vPosition.x - 4.0;
@@ -262,7 +231,7 @@
   local_0.uDiffuse = uDiffuse;
   local_0.z = v4;
   v5 = 10;
-  local_0.field_20 = (rand() & 0x7F) + 128;
+  local_0.timeToLive = (rand() & 0x7F) + 128;
   local_0.uTextureID = uTextureID;
   local_0.flt_28 = 1.0;
   do
@@ -312,7 +281,7 @@
   local_0.x = v5;
   local_0.y = (double)a2->vPosition.y;
   local_0.z = (double)a2->vPosition.z;
-  local_0.field_20 = (rand() & 0x7F) + 128;
+  local_0.timeToLive = (rand() & 0x7F) + 128;
   local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
   i = 10;
   local_0.flt_28 = 1.0;
@@ -388,7 +357,7 @@
   v4 = (double)a1->vPosition.y;
   local_0.bFree = 2048;
   local_0.uDiffuse = 0x7F7F7Fu;
-  local_0.field_20 = 1;
+  local_0.timeToLive = 1;
   local_0.y = v4;
   local_0.z = (double)a1->vPosition.z;
   local_0.flt_10 = 0.0;
@@ -422,7 +391,7 @@
   v5 = rand();
   v6 = 10;
   Dst.flt_28 = 1.0;
-  Dst.field_20 = (v5 & 0x7F) + 128;
+  Dst.timeToLive = (v5 & 0x7F) + 128;
   do
   {
     Dst.flt_10 = (double)(rand() & 0x1FF) - 255.0;
@@ -443,10 +412,10 @@
            a1->vPosition.z,
            a1->uSectorID,
            uRadius,
-           uDiffuse >> 16,
-           BYTE1(uDiffuse),
-           uDiffuse != 0,
-           (int *)byte_4E94D3);
+           (uDiffuse & 0x00FF0000) >> 16,
+           (uDiffuse & 0x0000FF00) >> 8,
+           uDiffuse & 0x000000FF,
+           byte_4E94D3);
 }
 // 4E94D3: using guessed type char byte_4E94D3;
 
@@ -475,7 +444,7 @@
   v6 = rand();
   local_0.flt_28 = 1.0;
   v7 = 0.0 * a4;
-  local_0.field_20 = (v6 & 0x7F) + 128;
+  local_0.timeToLive = (v6 & 0x7F) + 128;
   local_0.uTextureID = uTextureID;
   a1a = v7;
   local_0.flt_10 = v7;
@@ -557,7 +526,7 @@
     local_0.flt_18 = 0.0;
     v10 = rand();
     LODWORD(local_0.flt_28) = 0x40400000u;
-    local_0.field_20 = (v10 & 0x3F) + 64;
+    local_0.timeToLive = (v10 & 0x3F) + 64;
     local_0.uTextureID = pSpriteFrameTable->GetFrame(v5->uSpriteID, v3->uSpriteFrameID)->pHwSpriteIDs[0];
     pGame->pParticleEngine->AddParticle(&local_0);
     v11 = (double)v3->vPosition.x;
@@ -565,7 +534,7 @@
     local_0.x = v11;
     local_0.y = (double)v3->vPosition.y;
     local_0.z = (double)v3->vPosition.z;
-    local_0.field_20 = (rand() & 0x3F) + 64;
+    local_0.timeToLive = (rand() & 0x3F) + 64;
     pGame->pParticleEngine->AddParticle(&local_0);
     v2->array_0[v3->field_54 & 0x1F].flt_4 = (double)v3->vPosition.x;
     v2->array_0[v3->field_54 & 0x1F].flt_8 = (double)v3->vPosition.y;
@@ -587,7 +556,7 @@
     local_0.flt_10 = 0.0;
     local_0.flt_14 = 0.0;
     local_0.flt_18 = 0.0;
-    local_0.field_20 = (rand() & 0x3F) + 64;
+    local_0.timeToLive = (rand() & 0x3F) + 64;
     local_0.uTextureID = pSpriteFrameTable->GetFrame(v5->uSpriteID, a2->uSpriteFrameID)->pHwSpriteIDs[0];
     pGame->pParticleEngine->AddParticle(&local_0);
   }
@@ -637,7 +606,7 @@
 
   memset(&Dst, 0, 0x68u);
   Dst.bFree = 1036;
-  Dst.field_20 = (rand() & 0x7F) + 128;
+  Dst.timeToLive = (rand() & 0x7F) + 128;
   v3 = pActor;
   Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar02", TEXTURE_DEFAULT);
   pActora = 50;
@@ -687,7 +656,7 @@
   v5 = rand();
   local_0.flt_28 = 1.0;
   v6 = 8;
-  local_0.field_20 = (v5 & 0x7F) + 128;
+  local_0.timeToLive = (v5 & 0x7F) + 128;
   v7 = v4->uTextureID_effpar1;
   v12 = (double)x;
   local_0.uTextureID = v7;
@@ -752,7 +721,7 @@
   memset(&local_0, 0, 0x68u);
   local_0.bFree = 1029;
   local_0.uDiffuse = 0x7E7E7Eu;
-  local_0.field_20 = (rand() & 0x7F) + 128;
+  local_0.timeToLive = (rand() & 0x7F) + 128;
   local_0.uTextureID = v2->uTextureID_effpar1;
   v3 = 8;
   local_0.flt_28 = 1.0;
@@ -1489,11 +1458,8 @@
 }
 
 //----- (004A8C27) --------------------------------------------------------
-HRESULT stru6::RenderSpecialEffects()
+void stru6::RenderSpecialEffects()
 {
-  stru6 *v1; // ebx@1
-  int *v2; // edi@1
-  HRESULT result; // eax@3
   double v4; // st7@4
   double v5; // st6@4
   double v6; // st7@4
@@ -1518,41 +1484,36 @@
   SpriteFrame *v70; // [sp+E4h] [bp-8h]@8
   unsigned int v26; // [sp+E8h] [bp-4h]@3
 
-  //by the time we first get in this function, dword_0005D4  is still not initialized in the original exe
-  //maybe the following code in never executed at all
-
-  v1 = this;
-  v2 = &this->uNumProjectiles;
-  if ( this->uNumProjectiles )
+  if (uNumProjectiles)
   {
     DrawProjectiles();
-    *v2 = 0;
+    uNumProjectiles = 0;
   }
-  result = v1->uFadeTime;
-  v1->field_204 = 0;
-  v26 = result;
-  if ( result > 0 )
+
+  field_204 = 0;
+  v26 = uFadeTime;
+  if ( v26 > 0 )
   {
-    v4 = (double)(signed int)v26 / (double)v1->uFadeTime2;
+    v4 = (double)(signed int)v26 / (double)uFadeTime2;
     v5 = 1.0 - v4 * v4;
     v6 = v5;
     if ( v5 > 0.9 )
       v6 = 1.0 - (v5 - 0.9) * 10.0;
     v7 = v6;
-    pRenderer->_4A52F1(v1->uFadeColor, v7);
-    result = pEventTimer->uTimeElapsed;
-    v1->uFadeTime -= pEventTimer->uTimeElapsed;
+    pRenderer->_4A52F1(uFadeColor, v7);
+    uFadeTime -= pEventTimer->uTimeElapsed;
   }
-  if ( v1->uAnimLength > 0 )
+
+  if (uAnimLength > 0)
   {
     v8 = 8
        * pSpriteFrameTable->pSpriteSFrames[pSpriteFrameTable->FastFindSprite("spell84")].uAnimLength
-       - v1->uAnimLength;
+       - uAnimLength;
     v9 = pSpriteFrameTable->FastFindSprite("spell84");
     v10 = pSpriteFrameTable->GetFrame(v9, v8);
     v11 = v10->pHwSpriteIDs[0];
     v70 = v10;
-    v1->uAnimLength -= pEventTimer->uTimeElapsed;
+    uAnimLength -= pEventTimer->uTimeElapsed;
     if ( pRenderer->pRenderD3D )
     {
       v12 = (double)(signed int)pViewport->uViewportX;
@@ -1604,7 +1565,7 @@
       pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u);
       pRenderer->pRenderD3D->pDevice->DrawPrimitive(
         D3DPT_TRIANGLEFAN,
-        452,
+        D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
         vd3d,
         4,
         28);
@@ -1615,15 +1576,15 @@
       pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0);
       pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
       pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, true);
-      result = pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2);
+      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2);
     }
     else
     {
       vsr.pTarget = pRenderer->pTargetSurface;
       vsr.uParentBillboardID = -1;
       vsr.pTargetZ = pRenderer->pActiveZBuffer;
-      vsr.field_8 = (signed int)(pViewport->uViewportZ - pViewport->uViewportX) / 2;
-      vsr.field_C = pViewport->uViewportW;
+      vsr.uScreenSpaceX = (signed int)(pViewport->uViewportZ - pViewport->uViewportX) / 2;
+      vsr.uScreenSpaceY = pViewport->uViewportW;
       v24 = 16777216;
       LODWORD(v18) = 0;
       HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportZ) - LOWORD(pViewport->uViewportX));
@@ -1638,15 +1599,13 @@
       vsr.uViewportX = pViewport->uViewportX;
       vsr.uViewportZ = pViewport->uViewportZ;
       vsr.uViewportY = pViewport->uViewportY;
-      result = pViewport->uViewportW;
-      vsr.field_28 = 0;
+      vsr.sZValue = 0;
       vsr.uViewportW = pViewport->uViewportW;
       vsr.uFlags = 0;
       if ( v11 >= 0 )
-        result = pSprites_LOD->pSpriteHeaders[v11]._4ACC38(&vsr, 1);
+        pSprites_LOD->pSpriteHeaders[v11]._4ACC38(&vsr, 1);
     }
   }
-  return result;
 }
 
 //----- (004A902A) --------------------------------------------------------
--- a/stru6.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru6.h	Mon Oct 29 09:28:08 2012 +0600
@@ -117,7 +117,7 @@
   }
 
   void DoAddProjectile(float srcX, float srcY, float srcZ, float dstX, float dstY, float dstZ, unsigned int uTextureID);
-  int DrawProjectiles();
+  void DrawProjectiles();
   void _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(struct LayingItem *a2, unsigned int uDiffuse, unsigned int uTextureID);
   void _4A75CC_single_spell_collision_particle(struct LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID);
   void _4A7688_fireball_collision_particle(struct LayingItem *a2);
@@ -136,7 +136,7 @@
   int SetPlayerBuffAnim(unsigned __int16 uSpellID, unsigned __int16 uPlayerID);
   void FadeScreen__like_Turn_Undead_and_mb_Armageddon(unsigned int uDiffuseColor, unsigned int uFadeTime);
   int _4A8BFC();
-  HRESULT RenderSpecialEffects();
+  void RenderSpecialEffects();
   void DrawPlayerBuffAnims();
   void LoadAnimations();
 
--- a/stru9.cpp	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru9.cpp	Mon Oct 29 09:28:08 2012 +0600
@@ -29,6 +29,8 @@
   signed int a3a; // [sp+38h] [bp+10h]@12
   int a3b; // [sp+38h] [bp+10h]@25
 
+  __debugbreak();
+
   thisa = this;
 
   static RenderVertexSoft static_AE3FB4;
@@ -78,11 +80,11 @@
       v11 = *(float *)v8;
       ++v21;
       result = 0;
-      static_AE3FA4.flt_0 = *((float *)v8 - 1);
+      static_AE3FA4.x = *((float *)v8 - 1);
       static_AE33A0.uNumVertices = 0;
       a3a = 0;
-      static_AE3FA4.flt_4 = v11;
-      static_AE3FA4.flt_8 = v10;
+      static_AE3FA4.y = v11;
+      static_AE3FA4.z = v10;
       if ( (signed int)*v7 <= 0 )
         goto LABEL_32;
       do
@@ -99,7 +101,7 @@
           v19 = &pVertices[result];
         }
         v20 = v12;
-        if ( _49895A(v12, a2, &static_AE3FA4) )
+        if ( AreVectorsCollinear(v12, a2, &static_AE3FA4) )
           AddVertex(&static_AE33A0, v12);
         v7 = pOutNumVertices;
         result = a3a++ + 1;
@@ -155,10 +157,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,65 +171,63 @@
 
   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) --------------------------------------------------------
 void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex)
 {
+  __debugbreak();
   RenderVertexSoft *v3; // eax@1
 
   v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices];
@@ -253,31 +253,22 @@
   char v14; // c2@24
   char v15; // c3@24
   float a1a; // [sp+10h] [bp+8h]@5
+
+  __debugbreak();
   
   static stru312 static_AE3388;
-  /*if ( !(static_init_flag__AE3388_bit1__AE3378_bit2 & 1) )
-  {
-    static_init_flag__AE3388_bit1__AE3378_bit2 |= 1u;
-    stru312::stru312(&static_AE3388);
-    atexit(nullsub_16);
-  }*/
   static stru312 static_AE3378;
-  /*if ( !(static_init_flag__AE3388_bit1__AE3378_bit2 & 2) )
-  {
-    static_init_flag__AE3388_bit1__AE3378_bit2 |= 2u;
-    stru312::stru312(&static_AE3378);
-    atexit(nullsub_15);
-  }*/
+
   v6 = a1;
-  static_AE3378.flt_0 = a1->vWorldPosition.x - a3->vWorldPosition.x;
-  static_AE3378.flt_4 = a1->vWorldPosition.y - a3->vWorldPosition.y;
+  static_AE3378.x = a1->vWorldPosition.x - a3->vWorldPosition.x;
+  static_AE3378.y = a1->vWorldPosition.y - a3->vWorldPosition.y;
   HIWORD(result) = HIWORD(a4);
-  static_AE3378.flt_8 = a1->vWorldPosition.z - a3->vWorldPosition.z;
-  static_AE3388.flt_0 = a2->vWorldPosition.x - a1->vWorldPosition.x;
-  static_AE3388.flt_4 = a2->vWorldPosition.y - a1->vWorldPosition.y;
-  static_AE3388.flt_8 = a2->vWorldPosition.z - a1->vWorldPosition.z;
-  a1a = static_AE3388.flt_0 * a4->flt_0 + static_AE3388.flt_8 * a4->flt_8 + static_AE3388.flt_4 * a4->flt_4;
-  v8 = static_AE3378.flt_0 * a4->flt_0 + static_AE3378.flt_8 * a4->flt_8 + static_AE3378.flt_4 * a4->flt_4;
+  static_AE3378.z = a1->vWorldPosition.z - a3->vWorldPosition.z;
+  static_AE3388.x = a2->vWorldPosition.x - a1->vWorldPosition.x;
+  static_AE3388.y = a2->vWorldPosition.y - a1->vWorldPosition.y;
+  static_AE3388.z = a2->vWorldPosition.z - a1->vWorldPosition.z;
+  a1a = static_AE3388.x * a4->x + static_AE3388.z * a4->z + static_AE3388.y * a4->y;
+  v8 = static_AE3378.x * a4->x + static_AE3378.z * a4->z + static_AE3378.y * a4->y;
   //UNDEF(v9);
   if ( a1a != 0.0 )
   {
@@ -338,39 +329,18 @@
 // AE3398: using guessed type char static_init_flag__AE3388_bit1__AE3378_bit2;
 
 //----- (0049895A) --------------------------------------------------------
-bool stru9::_49895A(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3)
+bool stru9::AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3)
 {
-  double v4; // st7@3
-  double v5; // st7@3
-  __int16 v6; // fps@3
-  char v7; // c0@3
-  char v8; // c2@3
-  char v9; // c3@3
-  bool result; // eax@3
-  
   static stru312 static_F942A0;
-  /*static bool __init_flag1 = false;
-  if (!__init_flag1)
-  {
-    __init_flag1 = true;
 
-    stru312::stru312(&static_F942A0);
-  }*/
+  static_F942A0.x = a1->vWorldPosition.x - a2->vWorldPosition.x;
+  static_F942A0.y = a1->vWorldPosition.y - a2->vWorldPosition.y;
+  static_F942A0.z = a1->vWorldPosition.z - a2->vWorldPosition.z;
 
-  static_F942A0.flt_0 = a1->vWorldPosition.x - a2->vWorldPosition.x;
-  static_F942A0.flt_4 = a1->vWorldPosition.y - a2->vWorldPosition.y;
-  v4 = a1->vWorldPosition.z - a2->vWorldPosition.z;
-  HIWORD(result) = HIWORD(a3);
-  static_F942A0.flt_8 = v4;
-  v5 = v4 * a3->flt_8 + static_F942A0.flt_4 * a3->flt_4 + static_F942A0.flt_0 * a3->flt_0;
-  //UNDEF(v6);
-  flt_F942B0 = v5;
-  v7 = v5 < 0.0;
-  v8 = 0;
-  v9 = v5 == 0.0;
-  BYTE1(result) = HIBYTE(v6);
-  LOBYTE(result) = v5 >= 0.0;
-  return result;
+  static float flt_F942B4 = static_F942A0.z * a3->z + static_F942A0.y * a3->y + static_F942A0.x * a3->x;
+  if (flt_F942B4 >= 0)
+    return true;
+  return false;
 }
 
 
@@ -380,155 +350,88 @@
   bool r1;
   bool r2;
 
-  r1 = _49895A(a1, a3, a4);
-  r2 = _49895A(a2, a3, a4);
+  r1 = AreVectorsCollinear(a1, a3, a4);
+  r2 = AreVectorsCollinear(a2, a3, a4);
   return !r1 && r2 == 1 ||
          r1 == 1 && !r2;
 }
 
 //----- (004980B9) --------------------------------------------------------
-bool stru9::_4980B9(RenderVertexSoft *a1, signed int a2, float a3, float a4, float a5, RenderVertexSoft *a6, unsigned int *pOutNumVertices)
+bool stru9::_4980B9(RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices)
 {
-  bool result; // eax@7
-  unsigned int *v9; // ebx@7
-  char *v10; // edi@8
-  RenderVertexSoft *v11; // esi@9
   RenderVertexSoft *v12; // ecx@9
   double v13; // st7@12
   double v14; // st6@12
   double v15; // st5@12
-  RenderVertexSoft *v16; // edi@13
-  int v17; // ecx@25
-  VertexBuffer *v18; // edx@26
-  char *v19; // eax@26
-  unsigned int i; // ecx@26
-  bool v21; // [sp+0h] [bp-24h]@9
-  char *v22; // [sp+Ch] [bp-18h]@8
-  RenderVertexSoft *a2a; // [sp+10h] [bp-14h]@0
-  RenderVertexSoft *a1a; // [sp+14h] [bp-10h]@0
   signed int v25; // [sp+18h] [bp-Ch]@7
-  signed int v26; // [sp+1Ch] [bp-8h]@12
-  int v27; // [sp+1Ch] [bp-8h]@25
-  stru9 *thisa; // [sp+20h] [bp-4h]@1
-
-  thisa = this;
 
   static RenderVertexSoft stru_AE4BFC;
-  static bool __init_flag1 = false;
-  if (!__init_flag1)
-  {
-    __init_flag1 = true;
+  static stru312 static_sub_4980B9_stru_AE4BEC; // idb
+  static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb
 
-    stru_AE4BFC.flt_2C = 0.0;
-  }
-
-  static stru312 static_sub_4980B9_stru_AE4BEC; // idb
-  static bool __init_flag2 = false;
-  if (!__init_flag2)
+  v25 = 0;
+  if (uNumVertices <= 0)
   {
-    __init_flag2 = true;
-
-    //stru312::stru312(&static_sub_4980B9_stru_AE4BEC);
-  }
-  
-  static VertexBuffer static_sub_4980B9_stru_AE3FE8; // idb
-  static bool __init_flag3 = false;
-  if (!__init_flag3)
-  {
-    __init_flag3 = true;
-
-    //VertexBuffer::VertexBuffer(&static_sub_4980B9_stru_AE3FE8);
+    *pOutNumVertices = 0;
+    return true;
   }
 
-  result = 0;
-  v9 = pOutNumVertices;
-  v25 = 0;
-  if ( a2 <= 0 )
-    goto LABEL_32;
-  v10 = (char *)&a1->vWorldPosition.z;
-  v22 = (char *)&a1->vWorldPosition.z;
-  do
+  for (uint i = 0; i < uNumVertices; ++i)
   {
-    v11 = (RenderVertexSoft *)(v10 - 8);
-    v21 = result + 1;
-    v12 = &a1[(result + 1) % a2];
-    if ( *((float *)v10 - 2) != v12->vWorldPosition.x
-      || *((float *)v10 - 1) != v12->vWorldPosition.y
-      || *(float *)v10 != v12->vWorldPosition.z )
+    v12 = &a1[(i + 1) % uNumVertices];
+    if (a1[i].vWorldPosition.x != v12->vWorldPosition.x ||
+        a1[i].vWorldPosition.y != v12->vWorldPosition.y ||
+        a1[i].vWorldPosition.z!= v12->vWorldPosition.z)
     {
-      v13 = v12->vWorldPosition.x - v11->vWorldPosition.x;
-      v14 = v12->vWorldPosition.y - *((float *)v10 - 1);
-      v15 = v12->vWorldPosition.z - *(float *)v10;
+      v13 = v12->vWorldPosition.x - a1[i].vWorldPosition.x;
+      v14 = v12->vWorldPosition.y - a1[i].vWorldPosition.y;
+      v15 = v12->vWorldPosition.z - a1[i].vWorldPosition.z;
       ++v25;
-      result = 0;
+
       static_sub_4980B9_stru_AE3FE8.uNumVertices = 0;
-      v26 = 0;
-      static_sub_4980B9_stru_AE4BEC.flt_0 = a4 * v15 - v14 * a5;
-      static_sub_4980B9_stru_AE4BEC.flt_4 = v13 * a5 - v15 * a3;
-      static_sub_4980B9_stru_AE4BEC.flt_8 = v14 * a3 - v13 * a4;
-      if ( (signed int)*v9 <= 0 )
-        goto LABEL_32;
-      do
+      static_sub_4980B9_stru_AE4BEC.x = a4 * v15 - v14 * a5;
+      static_sub_4980B9_stru_AE4BEC.y = v13 * a5 - v15 * a3;
+      static_sub_4980B9_stru_AE4BEC.z = v14 * a3 - v13 * a4;
+      if (*pOutNumVertices == 0)
+        return true;
+
+      for (uint j = 0; j < *pOutNumVertices; ++j)
       {
-        v16 = &a6[result];
-        if ( result )
+        if (j)
         {
-          if ( _4989E1(a1a, &a6[result], v11, &static_sub_4980B9_stru_AE4BEC)
-            && _498774(a1a, v16, v11, &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) )
-            AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
-        }
-        else
-        {
-          a2a = &a6[result];
+          if (_4989E1(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC) &&
+              _498774(&pOutVertices[j - 1], &pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC))
+              AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
         }
-        a1a = v16;
-        if ( _49895A(v16, v11, &static_sub_4980B9_stru_AE4BEC) )
-          AddVertex(&static_sub_4980B9_stru_AE3FE8, v16);
-        v9 = pOutNumVertices;
-        result = v26++ + 1;
+
+        if (AreVectorsCollinear(&pOutVertices[j], &a1[i], &static_sub_4980B9_stru_AE4BEC))
+          AddVertex(&static_sub_4980B9_stru_AE3FE8, &pOutVertices[j]);
       }
-      while ( v26 < (signed int)*pOutNumVertices );
-      if ( !static_sub_4980B9_stru_AE3FE8.uNumVertices )
-        goto LABEL_32;
-      if ( _4989E1(v16, a2a, v11, &static_sub_4980B9_stru_AE4BEC)
-        && _498774(v16, a2a, v11, &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) )
-        AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
-      v17 = static_sub_4980B9_stru_AE3FE8.uNumVertices;
-      v27 = 0;
-      if ( static_sub_4980B9_stru_AE3FE8.uNumVertices > 0 )
+
+      if (!static_sub_4980B9_stru_AE3FE8.uNumVertices)
       {
-        v18 = &static_sub_4980B9_stru_AE3FE8;
-        v19 = (char *)&a6->vWorldPosition.y;
-        for ( i = (char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].flt_20 - (char *)a6;
-              ;
-              i = (char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].flt_20 - (char *)a6 )
-        {
-          ++v27;
-          *((int *)v19 - 1) = LODWORD(v18->pVertices[0].vWorldPosition.x);
-          v18 = (VertexBuffer *)((char *)v18 + 48);
-          *(float *)v19 = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8 - (char *)a6];
-          *((float *)v19 + 1) = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].vWorldPosition.y
-                                             - (char *)a6];
-          *((float *)v19 + 8) = *(float *)&v19[i];
-          *((float *)v19 + 9) = *(float *)&v19[(char *)&static_sub_4980B9_stru_AE3FE8.pVertices[0].u - (char *)a6];
-          v17 = static_sub_4980B9_stru_AE3FE8.uNumVertices;
-          v19 += 48;
-          if ( v27 >= static_sub_4980B9_stru_AE3FE8.uNumVertices )
-            break;
-        }
+        *pOutNumVertices = 0;
+        return true;
       }
-      v9 = pOutNumVertices;
-      v10 = v22;
-      *pOutNumVertices = v17;
+      if (_4989E1(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC) &&
+          _498774(&pOutVertices[*pOutNumVertices - 1], &pOutVertices[0], &a1[i], &static_sub_4980B9_stru_AE4BEC, &stru_AE4BFC) )
+        AddVertex(&static_sub_4980B9_stru_AE3FE8, &stru_AE4BFC);
+
+      for (uint j = 0; j < static_sub_4980B9_stru_AE3FE8.uNumVertices; ++j)
+      {
+          pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.x;
+          pOutVertices[j].vWorldPosition.y = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.y;
+          pOutVertices[j].vWorldPosition.z = static_sub_4980B9_stru_AE3FE8.pVertices[j].vWorldPosition.z;
+          pOutVertices[j].u = static_sub_4980B9_stru_AE3FE8.pVertices[j].u;
+          pOutVertices[j].v = static_sub_4980B9_stru_AE3FE8.pVertices[j].v;
+      }
+      *pOutNumVertices = static_sub_4980B9_stru_AE3FE8.uNumVertices;
     }
-    result = v21;
-    v10 += 48;
-    v22 = v10;
   }
-  while ( v21 < a2 );
-  if ( v25 < 3 )
-LABEL_32:
-    *v9 = 0;
-  return 1;
+
+  if (v25 < 3)
+    *pOutNumVertices = 0;
+
+  return true;
 }
 // AE4C2C: using guessed type char static_sub_4980B9_byte_AE4C2C_init_flag;
\ No newline at end of file
--- a/stru9.h	Mon Oct 22 09:20:49 2012 +0600
+++ b/stru9.h	Mon Oct 29 09:28:08 2012 +0600
@@ -32,10 +32,11 @@
   {
   }
 
-  float flt_0;
-  float flt_4;
-  float flt_8;
+  float x;
+  float y;
+  float z;
   char field_C;
+  char pad[3];
 };
 #pragma pack(pop)
 
@@ -49,12 +50,12 @@
   inline stru9()
   {}
 
-  bool _4980B9(struct RenderVertexSoft *a1, signed int a2, float a3, float a4, float a5, struct RenderVertexSoft *a6, unsigned int *pOutNumVertices);
+  bool _4980B9(struct RenderVertexSoft *a1, unsigned int uNumVertices, float a3, float a4, float a5, struct RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices);
   bool _498377(struct RenderVertexSoft *a1, unsigned int uNumVertices, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices);
   bool _4985FB(struct RenderVertexSoft *a1, signed int a2, struct RenderVertexSoft *a3, unsigned int *pOutNumVertices, struct Vec3_float_ *a5, float a6, char *a7, int unused);
   void AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex);
   bool _498774(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4, struct RenderVertexSoft *a5);
-  bool _49895A(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3);
+  bool AreVectorsCollinear(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct stru312 *a3);
   bool _4989E1(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct RenderVertexSoft *a3, struct stru312 *a4);
 
   void (__thiscall ***vdestructor_ptr)(stru9 *, bool);