changeset 1289:772f805df4f7

m
author Ritor1
date Tue, 11 Jun 2013 17:30:54 +0600
parents 7adc8b9b6a25
children 93911045d8f1
files Events.cpp Events2D.h UIHouses.cpp UITransition.cpp mm7_1.cpp mm7_3.cpp
diffstat 6 files changed, 587 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Mon Jun 10 09:30:21 2013 +0600
+++ b/Events.cpp	Tue Jun 11 17:30:54 2013 +0600
@@ -55,8 +55,7 @@
 std::array<char, 9216> pLevelEVT;
 std::array<EventIndex, 4400> pLevelEVT_Index;
 
-
-std::array<_2devent, 525> p2DEvents; // weak
+_2devent p2DEvents[525];
 
 
 
--- a/Events2D.h	Mon Jun 10 09:30:21 2013 +0600
+++ b/Events2D.h	Tue Jun 11 17:30:54 2013 +0600
@@ -63,5 +63,4 @@
 };
 #pragma pack(pop)
 
-
-extern std::array<_2devent, 525> p2DEvents; // weak
\ No newline at end of file
+extern _2devent p2DEvents[525];
\ No newline at end of file
--- a/UIHouses.cpp	Mon Jun 10 09:30:21 2013 +0600
+++ b/UIHouses.cpp	Tue Jun 11 17:30:54 2013 +0600
@@ -565,10 +565,10 @@
 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound)
 {
     //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
-    if ( pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uRoomSoundId )
+    if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId )
         pAudioPlayer->PlaySound(
         //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
-        (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uRoomSoundId + 300)),
+        (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
         806, 0, -1, 0, 0, 0, 0);
 }
 
--- a/UITransition.cpp	Mon Jun 10 09:30:21 2013 +0600
+++ b/UITransition.cpp	Tue Jun 11 17:30:54 2013 +0600
@@ -132,7 +132,7 @@
 LABEL_20:
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, (int)sHouseName.data());
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
-  if ( pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].uRoomSoundId )
+  if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
     PlayHouseSound(anim_id, HouseSound_Greeting);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
     pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
--- a/mm7_1.cpp	Mon Jun 10 09:30:21 2013 +0600
+++ b/mm7_1.cpp	Tue Jun 11 17:30:54 2013 +0600
@@ -1488,6 +1488,464 @@
 int __fastcall sub_423B5D(unsigned int uFaceID)
 {
   BLVFace *pFace; // ebx@1
+  //Vec3_short_ *v2; // esi@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
+  //int v10; // eax@10
+  //int v11; // edx@11
+  //int v12; // ST28_4@12
+  //signed int v13; // edx@12
+  //signed __int64 v14; // qtt@12
+  //int *v15; // ebx@12
+  //int v16; // ST28_4@14
+  //signed int v17; // eax@14
+  //signed __int64 v18; // qtt@14
+  signed int v19; // edx@15
+  signed int v20; // edx@17
+  signed int v21; // ebx@19
+  //signed int v22; // esi@20
+  int v23; // edi@21
+  int v24; // eax@21
+  //int v25; // eax@22
+  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 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
+  //unsigned int i; // [sp+24h] [bp-4h]@19
+  //signed int ix; // [sp+24h] [bp-4h]@31
+  //signed int iz; // [sp+24h] [bp-4h]@41
+  //signed int iy; // [sp+24h] [bp-4h]@51
+  //signed int iw; // [sp+24h] [bp-4h]@61
+
+  pFace = &pIndoor->pFaces[uFaceID];
+  //v2 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
+  //v4 = pIndoor->pVertices[pFace->pVertexIDs[0]].z;
+  if ( pFace->pFacePlane.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)//maybe it's length = n * direction vector
+     + pFace->pFacePlane.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
+     + pFace->pFacePlane.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 )
+  {
+    stru_50B700.field_0 = 1;
+  }
+  else
+  {
+    stru_50B700.field_0 = 0;
+    if ( !pFace->Portal() )
+      return 0;
+  }
+  for (uint i = 0; i < pFace->uNumVertices; ++i)
+  {
+      //auto v6 = &pIndoor->pVertices[pFace->pVertexIDs[i]];
+      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x,
+                         pIndoor->pVertices[pFace->pVertexIDs[i]].y, pIndoor->pVertices[pFace->pVertexIDs[i]].z,
+        &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0);
+  }
+
+  if (pFace->uNumVertices <= 0)
+    return 0;
+
+  bool bFound = false;
+  for (uint i = 0; i < pFace->uNumVertices; ++i)
+    if (stru_50B700._view_transformed_xs[i] >= 0x80000u)
+    {
+      bFound = true;
+      break;
+    }
+  if (!bFound)
+    return 0;
+
+  v79 = 0;
+  stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0];
+  stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0];
+  stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0];
+
+  //maybe for near clip plane
+  thisa = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;
+  for ( uint i = 1; i <= pFace->uNumVertices; ++i)
+  {
+    v81 = stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u;
+    if ( thisa ^ v81 )
+    {
+      if ( stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u )
+      {
+        //v12 = stru_50B700._view_transformed_xs[i] - stru_50B700._view_transformed_xs[i - 1];
+        //v13 = 0x80000 - stru_50B700._view_transformed_xs[i - 1];
+        //LODWORD(v14) = v13 << 16;
+        //HIDWORD(v14) = v13 >> 16;
+        //v15 = &stru_50B700._view_transformed_ys[i - 1];
+        stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1])
+                                     * (0x80000 - stru_50B700._view_transformed_xs[i - 1])
+                                     / (stru_50B700._view_transformed_xs[i] - stru_50B700._view_transformed_xs[i - 1])))
+                                     + stru_50B700._view_transformed_zs[i - 1];
+        thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1])
+                * (0x80000 - stru_50B700._view_transformed_xs[i - 1])
+                / (stru_50B700._view_transformed_xs[i] - stru_50B700._view_transformed_xs[i - 1]));
+      }
+      else
+      {
+        //v16 = stru_50B700._view_transformed_xs[i - 1] - stru_50B700._view_transformed_xs[i];
+        //v17 = 0x80000 - stru_50B700._view_transformed_xs[i];
+        //LODWORD(v18) = v17 << 16;
+        //HIDWORD(v18) = v17 >> 16;
+        //v15 = &stru_50B700._view_transformed_ys[i];
+        stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i])
+                                     * (0x80000 - stru_50B700._view_transformed_xs[i])
+                                     / (stru_50B700._view_transformed_xs[i - 1] - stru_50B700._view_transformed_xs[i])))
+                                     + stru_50B700._view_transformed_zs[i];
+        thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i])
+                * (0x80000 - stru_50B700._view_transformed_xs[i])
+                / (stru_50B700._view_transformed_xs[i - 1] - stru_50B700._view_transformed_xs[i]));
+      }
+      v19 = v79++;
+      stru_50B700.field_38[v19] = thisb + stru_50B700._view_transformed_ys[i];
+      stru_50B700.field_218[v19] = 0x80000u;
+    }
+    if ( v81 )
+    {
+      v20 = v79++;
+      stru_50B700.field_218[v20] = stru_50B700._view_transformed_xs[i];
+      stru_50B700.field_128[v20] = stru_50B700._view_transformed_zs[i];
+      stru_50B700.field_38[v20] = stru_50B700._view_transformed_ys[i];
+    }
+    thisa = v81;
+  }
+  v21 = v79;
+  stru_50B700.field_218[v79] = stru_50B700.field_218[0];
+  stru_50B700.field_128[v79] = stru_50B700.field_128[0];
+  stru_50B700.field_38[v79] = stru_50B700.field_38[0];
+
+  //maybe for far clip plane
+  for ( uint i = 0; i < v79; ++i )
+  {
+    if ( abs(stru_50B700.field_128[i]) <= abs(stru_50B700.field_218[i]) )
+    {
+      //LODWORD(v28) = stru_50B700.field_128[i] << 16;
+      //HIDWORD(v28) = stru_50B700.field_128[i] >> 16;
+      v26 = stru_50B700.field_128[i] / stru_50B700.field_218[i];
+      v23 = 0;
+    }
+    else
+    {
+      v23 = 0;
+      v24 = 0;
+      if ( stru_50B700.field_128[i] >= 0 )
+      {
+        LOBYTE(v24) = stru_50B700.field_218[i] >= 0;
+        v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
+      }
+      else
+      {
+        LOBYTE(v24) = stru_50B700.field_218[i] >= 0;
+        //v25 = v24 - 1;
+        v26 = ((v24 - 1) & 0x800000) - 0x400000;
+      }
+    }
+    stru_50B700._xs3[i] = v26;
+    if ( abs(stru_50B700.field_38[i]) <= abs(stru_50B700.field_218[i]) )
+    {
+      //LODWORD(v34) = stru_50B700.field_38[i] << 16;
+      //HIDWORD(v34) = stru_50B700.field_38[i] >> 16;
+      v32 = stru_50B700.field_38[i] / stru_50B700.field_218[i];
+    }
+    else
+    {
+      v30 = 0;
+      if ( stru_50B700.field_38[i] >= v23 )
+      {
+        LOBYTE(v30) = stru_50B700.field_218[i] >= v23;
+        v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
+      }
+      else
+      {
+        LOBYTE(v30) = stru_50B700.field_218[i] >= v23;
+        v32 = ((v30 - 1) & 0x800000) - 0x400000;
+      }
+    }
+    stru_50B700._ys2[i] = v32;
+    stru_50B700._xs3[i] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._xs3[i]);
+    stru_50B700._xs3[i] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[i];
+    stru_50B700._ys2[i] = pBLVRenderParams->uViewportCenterY - (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
+                           * (signed __int64)stru_50B700._ys2[i]);
+  }
+  v36 = 0;
+  stru_50B700._xs3[v21] = stru_50B700._xs3[0];
+  stru_50B700._ys2[v21] = stru_50B700._ys2[0];
+  v38 = stru_50B700._xs3[0] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
+  if ( v79 < 1 )
+    return 0;
+
+  //maybe for left clip plane
+  for ( uint i = 1; i <= v79; i++ )
+  {
+    v82 = stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX;
+    if ( v38 ^ v82 )
+    {
+      if ( stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX )
+      {
+		  //v67 = (a-b)*(c-d)/(e-f)
+        v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i - 1])
+            * (signed __int64)(stru_50B700._ys2[i] - stru_50B700._ys2[i - 1]) / (stru_50B700._xs3[i] - stru_50B700._xs3[i - 1]);
+        v42 = stru_50B700._ys2[i - 1];//d
+      }
+      else
+      {
+		  //v67 = (a-e)*(d-c)/(f-e)
+        v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i])
+            * (signed __int64)(stru_50B700._ys2[i - 1] - stru_50B700._ys2[i]) / (stru_50B700._xs3[i - 1] - stru_50B700._xs3[i]);
+        v42 = stru_50B700._ys2[i];//c
+      }
+      stru_50B700._ys[v36] = v67 + v42;
+      stru_50B700._xs2[v36] = pBLVRenderParams->uViewportX;
+      ++v36;
+    }
+    v38 = v82;
+    if ( v82 )
+    {
+      stru_50B700._xs2[v36] = stru_50B700._xs3[i];
+      stru_50B700._ys[v36] = stru_50B700._ys2[i];
+      ++v36;
+    }
+  }
+
+  if (v36 < 1)
+    return 0;
+
+  v43 = 0;
+  stru_50B700._xs2[v36] = stru_50B700._xs2[0];
+  stru_50B700._ys[v36] = stru_50B700._ys[0];
+
+  //maybe for right clip plane
+  thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
+  for ( uint i = 1; i <= v36; ++i )
+  {
+    v83 = stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ;
+    if ( thisd ^ v83 )
+    {
+      if ( stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ )
+      {
+		  //v68 = (a-b)*(c-d)/(e-b)
+        v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i - 1])
+            * (signed __int64)(stru_50B700._ys[i] - stru_50B700._ys[i - 1]) / (stru_50B700._xs2[i] - stru_50B700._xs2[i - 1]);
+        v47 = stru_50B700._ys[i - 1];//d
+      }
+      else
+      {
+		  //v68 = (a-e)*(d-c)/(b-e)
+        v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i])
+            * (signed __int64)(stru_50B700._ys[i - 1] - stru_50B700._ys[i]) / (stru_50B700._xs2[i - 1] - stru_50B700._xs2[i]);
+        v47 = stru_50B700._ys[i];//c
+      }
+      stru_50B700.field_2F0[v43] = v68 + v47;
+      stru_50B700._xs[v43] = pBLVRenderParams->uViewportZ;
+      ++v43;
+    }
+    if ( v83 )
+    {
+      stru_50B700._xs[v43] = stru_50B700._xs2[i];
+      stru_50B700.field_2F0[v43++] = stru_50B700._ys[i];
+    }
+    thisd = v83;
+  }
+
+  if (v43 < 1)
+    return 0;
+
+  v48 = 0;
+  stru_50B700._xs[v43] = stru_50B700._xs[0];
+  stru_50B700.field_2F0[v43] = stru_50B700.field_2F0[0];
+  v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY;
+
+  //maybr for top clip plane
+  LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
+  for ( uint i = 1; i <= v43; i++ )
+  {
+    v84 = stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY;
+    if ( v50 ^ v84 )
+    {
+      if ( stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY )
+      {
+		  //v69 = (a-b)*(c-d)/(e-b)
+        v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i - 1])
+            * (signed __int64)(stru_50B700._xs[i] - stru_50B700._xs[i - 1]) / (stru_50B700.field_2F0[i] - stru_50B700.field_2F0[i - 1]);
+        v54 = stru_50B700._xs[i - 1];//d
+      }
+      else
+      {
+		  //v69 = (a-e)*(d-c)/(b-e)
+        v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i])
+            * (signed __int64)(stru_50B700._xs[i - 1] - stru_50B700._xs[i]) / (stru_50B700.field_2F0[i - 1] - stru_50B700.field_2F0[i]);
+        v54 = stru_50B700._xs[i];//c
+      }
+      stru_50B700.field_3D4[v48] = v69 + v54;
+      stru_50B700._xs[v48 + 1] = pBLVRenderParams->uViewportY;
+      ++v48;
+    }
+    v50 = v84;
+    if ( v84 )
+    {
+      stru_50B700.field_3D4[v48] = stru_50B700._xs[i];
+      stru_50B700._xs[v48 + 1] = stru_50B700.field_2F0[i];
+      v48++;
+    }
+  }
+
+  if (v48 < 1)
+    return 0;
+
+  v55 = 0;
+  stru_50B700.field_3D4[v48] = stru_50B700.field_3D4[0];
+  stru_50B700._xs[v48 + 1] = stru_50B700._xs[1];
+
+  //maybe for bottom clip plane
+  thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
+  for ( uint i = 1; i <= v48; ++i )
+  {
+    v85 = stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW;
+    if ( thise ^ v85 )
+    {
+      if ( stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW )
+      {
+		  //v70 = (a-b)*(c-d)/(e-b)
+        v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i])
+            * (signed __int64)(stru_50B700.field_3D4[i] - stru_50B700.field_3D4[i - 1]) / (stru_50B700._xs[i + 1] - stru_50B700._xs[i]);
+        v59 = stru_50B700.field_3D4[i - 1];//d
+      }
+      else
+      {
+		  //v70 = (a-e)*(d-c)/(b-e)
+        v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i + 1])
+            * (signed __int64)(stru_50B700.field_3D4[i - 1] - stru_50B700.field_3D4[i]) / (stru_50B700._xs[i] - stru_50B700._xs[i + 1]);
+        v59 = stru_50B700.field_3D4[i];//c
+      }
+      stru_50B700._screen_space_x[v55] = v70 + v59;
+      stru_50B700._screen_space_y[v55] = pBLVRenderParams->uViewportW;
+      ++v55;
+    }
+    if ( v85 )
+    {
+      stru_50B700._screen_space_x[v55] = stru_50B700.field_3D4[i];
+      stru_50B700._screen_space_y[v55++] = stru_50B700._xs[i + 1];
+    }
+    thise = v85;
+  }
+
+  if ( !v55 )
+    return 0;
+  v61 = pRenderer->pRenderD3D == 0;
+  stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
+  stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
+  if ( v61 && v55 > 3 )
+  {
+    stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
+    stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
+    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
+    if ( v55 > 0 )
+    {
+      v62 = 1;
+      v71 = 1;
+      do
+      {
+        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 * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
+                   * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
+                   - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
+                   * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
+        {
+          v62 = v80;
+          v71 = v80;
+        }
+        else
+        {
+          v62 = v71;
+          v65 = v71;
+          if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
+          {
+            memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+          }
+          --v55;
+        }
+      }
+      while ( v62 - 1 < v55 );
+    }
+    stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
+    stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
+  }
+  return v55;
+}
+
+//old function
+/*int __fastcall sub_423B5D(unsigned int uFaceID)
+{
+  BLVFace *v1; // ebx@1
   Vec3_short_ *v2; // esi@1
   //int v3; // ST28_4@1
   __int16 v4; // ST2C_2@1
@@ -1577,40 +2035,46 @@
   signed int id; // [sp+24h] [bp-4h]@51
   signed int ie; // [sp+24h] [bp-4h]@61
 
-  pFace = &pIndoor->pFaces[uFaceID];
+  v1 = &pIndoor->pFaces[uFaceID];
   //this = pGame->pIndoorCameraD3D;
-  v2 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
+  v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
   //v3 = *(_DWORD *)&v2->x;
   v4 = v2->z;
   //v5 = 0;
-  if ( pFace->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
-     + pFace->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
-     + pFace->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 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 )
   {
-    stru_50B700.field_0 = 1;
+    dword_50B700 = 1;
   }
   else
   {
-    stru_50B700.field_0 = 0;
-    if ( !pFace->Portal() )
+    dword_50B700 = 0;
+    if ( !v1->Portal() )
       return 0;
   }
   //v66 = v1->uNumVertices;
-  for (uint i = 0; i < pFace->uNumVertices; ++i)
+  for (uint i = 0; i < v1->uNumVertices; ++i)
   {
-      auto v6 = &pIndoor->pVertices[pFace->pVertexIDs[i]];
-      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(v6->x, v6->y, v6->z,
-        &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0);
+      auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
+      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
+        v6->x,
+        v6->y,
+        v6->z,
+        &_50B924_view_transformed_xs[i],
+        &_50B834_view_transformed_zs[i],
+        &_50B744_view_transformed_ys[i],
+        0);
   }
 
   //v7 = v1->uNumVertices;
   //v8 = 0;
-  if (pFace->uNumVertices <= 0)
+  if (v1->uNumVertices <= 0)
     return 0;
 
   bool bFound = false;
-  for (uint i = 0; i < pFace->uNumVertices; ++i)
-    if (stru_50B700._view_transformed_xs[i] >= 0x80000u)
+  for (uint i = 0; i < v1->uNumVertices; ++i)
+    if (_50B924_view_transformed_xs[i] >= 0x80000u)
     {
       bFound = true;
       break;
@@ -1619,27 +2083,27 @@
     return 0;
 
   v79 = 0;
-  stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0];
-  stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0];
-  stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0];
-  thisa = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;
+  _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] >= (signed int)0x80000u;
   //int i = 1;
-  for (uint i = 1; i <= pFace->uNumVertices; ++i)
+  for (uint i = 1; i <= v1->uNumVertices; ++i)
   {
-      v10 = stru_50B700._view_transformed_xs[i];
+      v10 = _50B924_view_transformed_xs[i];
       v81 = v10 >= (signed int)0x80000u;
       if ( thisa ^ v81 )
       {
-        v11 = stru_50B700._view_transformed_xs[i - 1];
+        v11 = _50B924_view_transformed_xs[i - 1];
         if ( v10 >= (signed int)0x80000u )
         {
           v12 = v10 - v11;
           v13 = 0x80000 - v11;
           LODWORD(v14) = v13 << 16;
           HIDWORD(v14) = v13 >> 16;
-          v15 = &stru_50B700._view_transformed_ys[i - 1];
-          stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1]) * v14 / v12) >> 16) + stru_50B700._view_transformed_zs[i - 1];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1]) * v14 / v12) >> 16;
+          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[i - 1];
+          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
         }
         else
         {
@@ -1647,93 +2111,93 @@
           v17 = 0x80000 - v10;
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
-          v15 = &stru_50B700._view_transformed_ys[i];
-          stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i]) * v18 / v16) >> 16) + stru_50B700._view_transformed_zs[i];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i]) * v18 / v16) >> 16;
+          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[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
         }
         v19 = v79++;
         //v7 = v66;
-        stru_50B700.field_38[v19] = thisb + *v15;
-        stru_50B700.field_218[v19] = 0x80000u;
+        dword_50B738[v19] = thisb + *v15;
+        dword_50B918[v19] = 0x80000u;
       }
       if ( v81 )
       {
         v20 = v79++;
-        stru_50B700.field_218[v20] = stru_50B700._view_transformed_xs[i];
-        stru_50B700.field_128[v20] = stru_50B700._view_transformed_zs[i];
-        stru_50B700.field_38[v20] = stru_50B700._view_transformed_ys[i];
+        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;
   }
   v21 = v79;
-  stru_50B700.field_218[v79] = stru_50B700.field_218[0];
-  stru_50B700.field_128[v79] = stru_50B700.field_128[0];
-  stru_50B700.field_38[v79] = stru_50B700.field_38[0];
+  dword_50B918[v79] = dword_50B918[0];
+  dword_50B828[v79] = dword_50B828[0];
+  dword_50B738[v79] = dword_50B738[0];
   for (ia = 0; ia < v79; ++ia)
   {
     v22 = ia;
-    thisc = abs(stru_50B700.field_218[ia]);
-    if ( abs(stru_50B700.field_128[ia]) >> 13 <= thisc )
+    thisc = abs(dword_50B918[ia]);
+    if ( abs(dword_50B828[ia]) >> 13 <= thisc )
     {
-      v27 = stru_50B700.field_128[v22];
+      v27 = dword_50B828[v22];
       LODWORD(v28) = v27 << 16;
       HIDWORD(v28) = v27 >> 16;
-      v26 = v28 / stru_50B700.field_218[v22];
+      v26 = v28 / dword_50B918[v22];
       v23 = 0;
     }
     else
     {
       v23 = 0;
       v24 = 0;
-      if ( stru_50B700.field_128[v22] >= 0 )
+      if ( dword_50B828[v22] >= 0 )
       {
-        LOBYTE(v24) = stru_50B700.field_218[v22] >= 0;
+        LOBYTE(v24) = dword_50B918[v22] >= 0;
         v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v24) = stru_50B700.field_218[v22] >= 0;
+        LOBYTE(v24) = dword_50B918[v22] >= 0;
         v25 = v24 - 1;
         v26 = (v25 & 0x800000) - 0x400000;
       }
     }
-    v29 = stru_50B700.field_38[v22];
-    stru_50B700._xs3[v22] = v26;
+    v29 = dword_50B738[v22];
+    dword_50BAF8_xs[v22] = v26;
     if ( abs(v29) >> 13 <= thisc )
     {
-      v33 = stru_50B700.field_38[v22];
+      v33 = dword_50B738[v22];
       LODWORD(v34) = v33 << 16;
       HIDWORD(v34) = v33 >> 16;
-      v32 = v34 / stru_50B700.field_218[v22];
+      v32 = v34 / dword_50B918[v22];
     }
     else
     {
       v30 = 0;
-      if ( stru_50B700.field_38[v22] >= v23 )
+      if ( dword_50B738[v22] >= v23 )
       {
-        LOBYTE(v30) = stru_50B700.field_218[v22] >= v23;
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
         v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v30) = stru_50B700.field_218[v22] >= v23;
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
         v31 = v30 - 1;
         v32 = (v31 & 0x800000) - 0x400000;
       }
     }
-    stru_50B700._ys2[v22] = v32;
-    stru_50B700._xs3[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._xs3[v22]) >> 16;
-    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._ys2[v22]) >> 16;
-    stru_50B700._xs3[v22] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[v22];
-    stru_50B700._ys2[v22] = pBLVRenderParams->uViewportCenterY - v35;
+    dword_50BA08_ys[v22] = v32;
+    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08_ys[v22]) >> 16;
+    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
+    dword_50BA08_ys[v22] = pBLVRenderParams->uViewportCenterY - v35;
   }
   v36 = 0;
-  stru_50B700._xs3[v21] = stru_50B700._xs3[0];
-  stru_50B700._ys2[v21] = stru_50B700._ys2[0];
+  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
+  dword_50BA08_ys[v21] = dword_50BA08_ys[0];
   v37 = pBLVRenderParams->uViewportX;
-  v38 = stru_50B700._xs3[0] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v38) = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
+  v38 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
   v39 = 1;
   ib = 1;
   if ( v79 < 1 )
@@ -1741,30 +2205,30 @@
   do
   {
     v40 = v39;
-    v41 = stru_50B700._xs3[v40];
+    v41 = dword_50BAF8_xs[v40];
     v82 = v41 >= (signed int)v37;
     if ( v38 ^ v82 )
     {
       if ( v41 >= (signed int)v37 )
       {
-        v67 = (signed int)(v37 - stru_50B700._xs3[v40 - 1]) * (signed __int64)(stru_50B700._ys2[v40] - stru_50B700._ys2[v40 - 1]) / (v41 - stru_50B700._xs3[v40 - 1]);
-        v42 = stru_50B700._ys2[v40 - 1];
+        v67 = (signed int)(v37 - dword_50BAF8_xs[v40 - 1]) * (signed __int64)(dword_50BA08_ys[v40] - dword_50BA08_ys[v40 - 1]) / (v41 - dword_50BAF8_xs[v40 - 1]);
+        v42 = dword_50BA08_ys[v40 - 1];
       }
       else
       {
-        v67 = (signed int)(v37 - v41) * (signed __int64)(stru_50B700._ys2[v40 - 1] - stru_50B700._ys2[v40]) / (stru_50B700._xs3[v40 - 1] - v41);
-        v42 = stru_50B700._ys2[v40];
+        v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50BA08_ys[v40 - 1] - dword_50BA08_ys[v40]) / (dword_50BAF8_xs[v40 - 1] - v41);
+        v42 = dword_50BA08_ys[v40];
       }
-      stru_50B700._ys[v36] = v67 + v42;
+      dword_50B9FC_ys[v36] = v67 + v42;
       v37 = pBLVRenderParams->uViewportX;
-      stru_50B700._xs2[v36] = pBLVRenderParams->uViewportX;
+      dword_50BAEC_xs[v36] = pBLVRenderParams->uViewportX;
       ++v36;
     }
     v38 = v82;
     if ( v82 )
     {
-      stru_50B700._xs2[v36] = stru_50B700._xs3[v40];
-      stru_50B700._ys[v36] = stru_50B700._ys2[v40];
+      dword_50BAEC_xs[v36] = dword_50BAF8_xs[v40];
+      dword_50B9FC_ys[v36] = dword_50BA08_ys[v40];
       ++v36;
     }
     v39 = ib++ + 1;
@@ -1775,38 +2239,38 @@
     return 0;
 
   v43 = 0;
-  stru_50B700._xs2[v36] = stru_50B700._xs2[0];
-  stru_50B700._ys[v36] = stru_50B700._ys[0];
+  dword_50BAEC_xs[v36] = dword_50BAEC_xs[0];
+  dword_50B9FC_ys[v36] = dword_50B9FC_ys[0];
   v44 = pBLVRenderParams->uViewportZ;
-  thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
+  thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ;
   ic = 1;
 
   do
   {
     v45 = ic;
-    v46 = stru_50B700._xs2[ic];
+    v46 = dword_50BAEC_xs[ic];
     v83 = v46 <= (signed int)v44;
     if ( thisd ^ v83 )
     {
       if ( v46 <= (signed int)v44 )
       {
-        v68 = (signed int)(v44 - stru_50B700._xs2[v45 - 1]) * (signed __int64)(stru_50B700._ys[v45] - stru_50B700._ys[v45 - 1]) / (v46 - stru_50B700._xs2[v45 - 1]);
-        v47 = stru_50B700._ys[v45 - 1];
+        v68 = (signed int)(v44 - dword_50BAEC_xs[v45 - 1]) * (signed __int64)(dword_50B9FC_ys[v45] - dword_50B9FC_ys[v45 - 1]) / (v46 - dword_50BAEC_xs[v45 - 1]);
+        v47 = dword_50B9FC_ys[v45 - 1];
       }
       else
       {
-        v68 = (signed int)(v44 - v46) * (signed __int64)(stru_50B700._ys[v45 - 1] - stru_50B700._ys[v45]) / (stru_50B700._xs2[v45 - 1] - v46);
-        v47 = stru_50B700._ys[v45];
+        v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9FC_ys[v45 - 1] - dword_50B9FC_ys[v45]) / (dword_50BAEC_xs[v45 - 1] - v46);
+        v47 = dword_50B9FC_ys[v45];
       }
-      stru_50B700.field_2F0[v43] = v68 + v47;
+      dword_50B9F0[v43] = v68 + v47;
       v44 = pBLVRenderParams->uViewportZ;
-      stru_50B700._xs[v43] = pBLVRenderParams->uViewportZ;
+      dword_50BAE0[v43] = pBLVRenderParams->uViewportZ;
       ++v43;
     }
     if ( v83 )
     {
-      stru_50B700._xs[v43] = stru_50B700._xs2[v45];
-      stru_50B700.field_2F0[v43++] = stru_50B700._ys[v45];
+      dword_50BAE0[v43] = dword_50BAEC_xs[v45];
+      dword_50B9F0[v43++] = dword_50B9FC_ys[v45];
     }
     ++ic;
     thisd = v83;
@@ -1817,41 +2281,40 @@
     return 0;
 
   v48 = 0;
-  stru_50B700._xs[v43] = stru_50B700._xs[0];
-  stru_50B700.field_2F0[v43] = stru_50B700.field_2F0[0];
+  dword_50BAE0[v43] = dword_50BAE0[0];
+  dword_50B9F0[v43] = dword_50B9F0[0];
   v49 = pBLVRenderParams->uViewportY;
-  v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY;
-  LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
+  v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY;
+  LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY;
   v51 = 1;
   id = 1;
   do
   {
     v52 = v51;
-    v53 = stru_50B700.field_2F0[v52];
+    v53 = dword_50B9F0[v52];
     v84 = v53 >= (signed int)v49;
     if ( v50 ^ v84 )
     {
       if ( v53 >= (signed int)v49 )
       {
-        v69 = (signed int)(v49 - stru_50B700.field_2F0[v52 - 1]) * (signed __int64)(stru_50B700._xs[v52] - stru_50B700._xs[v52 - 1]) / (v53 - stru_50B700.field_2F0[v52 - 1]);
-        v54 = stru_50B700._xs[v52 - 1];
+        v69 = (signed int)(v49 - dword_50B9F0[v52 - 1]) * (signed __int64)(dword_50BAE0[v52] - dword_50BAE0[v52 - 1]) / (v53 - dword_50B9F0[v52 - 1]);
+        v54 = dword_50BAE0[v52 - 1];
       }
       else
       {
-        v69 = (signed int)(v49 - v53) * (signed __int64)(stru_50B700._xs[v52 - 1] - stru_50B700._xs[v52]) / (stru_50B700.field_2F0[v52 - 1] - v53);
-        v54 = stru_50B700._xs[v52];
+        v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BAE0[v52 - 1] - dword_50BAE0[v52]) / (dword_50B9F0[v52 - 1] - v53);
+        v54 = dword_50BAE0[v52];
       }
-      stru_50B700.field_3D4[v48] = v69 + v54;
+      dword_50BAD4[v48] = v69 + v54;
       v49 = pBLVRenderParams->uViewportY;
-      stru_50B700._xs[v48+1] = pBLVRenderParams->uViewportY;
+      dword_50B9E4[v48] = pBLVRenderParams->uViewportY;
       ++v48;
     }
     v50 = v84;
     if ( v84 )
     {
-      stru_50B700.field_3D4[v48] = stru_50B700._xs[v52];
-      stru_50B700._xs[v48+1] = stru_50B700.field_2F0[v52];
-	  v48++;
+      dword_50BAD4[v48] = dword_50BAE0[v52];
+      dword_50B9E4[v48++] = dword_50B9F0[v52];
     }
     v51 = id++ + 1;
   }
@@ -1861,37 +2324,37 @@
     return 0;
 
   v55 = 0;
-  stru_50B700.field_3D4[v48] = stru_50B700.field_3D4[0];
-  stru_50B700._xs[v48+1] = stru_50B700._xs[1];
+  dword_50BAD4[v48] = dword_50BAD4[0];
+  dword_50B9E4[v48] = dword_50B9E4[0];
   v56 = pBLVRenderParams->uViewportW;
-  thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
+  thise = dword_50B9E4[0] <= (signed int)pBLVRenderParams->uViewportW;
   ie = 1;
   do
   {
     v57 = ie;
-    v58 = stru_50B700._xs[ie+1];
+    v58 = dword_50B9E4[ie];
     v85 = v58 <= (signed int)v56;
     if ( thise ^ v85 )
     {
       if ( v58 <= (signed int)v56 )
       {
-        v70 = (signed int)(v56 - stru_50B700._xs[v57]) * (signed __int64)(stru_50B700.field_3D4[v57] - stru_50B700.field_3D4[v57 - 1]) / (v58 - stru_50B700._xs[v57]);
-        v59 = stru_50B700.field_3D4[v57 - 1];
+        v70 = (signed int)(v56 - dword_50B9E4[v57 - 1]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD4[v57 - 1]) / (v58 - dword_50B9E4[v57 - 1]);
+        v59 = dword_50BAD4[v57 - 1];
       }
       else
       {
-        v70 = (signed int)(v56 - v58) * (signed __int64)(stru_50B700.field_3D4[v57 - 1] - stru_50B700.field_3D4[v57]) / (stru_50B700._xs[v57] - v58);
-        v59 = stru_50B700.field_3D4[v57];
+        v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD4[v57 - 1] - dword_50BAD4[v57]) / (dword_50B9E4[v57 - 1] - v58);
+        v59 = dword_50BAD4[v57];
       }
-      stru_50B700._screen_space_x[v55] = v70 + v59;
+      _50BAC8_screen_space_x[v55] = v70 + v59;
       v56 = pBLVRenderParams->uViewportW;
-      stru_50B700._screen_space_y[v55] = pBLVRenderParams->uViewportW;
+      _50B9D8_screen_space_y[v55] = pBLVRenderParams->uViewportW;
       ++v55;
     }
     if ( v85 )
     {
-      stru_50B700._screen_space_x[v55] = stru_50B700.field_3D4[v57];
-      stru_50B700._screen_space_y[v55++] = stru_50B700._xs[v57+1];
+      _50BAC8_screen_space_x[v55] = dword_50BAD4[v57];
+      _50B9D8_screen_space_y[v55++] = dword_50B9E4[v57];
     }
     ++ie;
     thise = v85;
@@ -1901,13 +2364,13 @@
   if ( !v55 )
     return 0;
   v61 = pRenderer->pRenderD3D == 0;
-  stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
-  stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
+  _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
+  _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
   if ( v61 && v55 > 3 )
   {
-    stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
-    stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
-    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
+    _50BAC8_screen_space_x[v55 + 1] = _50BAC8_screen_space_x[1];
+    _50B9D8_screen_space_y[v55 + 1] = _50B9D8_screen_space_y[1];
+    thisf = 2 * (dword_50B700 != 0) - 1;
     if ( v55 > 0 )
     {
       v62 = 1;
@@ -1924,8 +2387,8 @@
         if ( v64 >= v55 )
           v64 -= v55;
         if ( thisf
-           * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
-            - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
+           * ((_50B9D8_screen_space_y[v64] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v62] - _50BAC8_screen_space_x[v63])
+            - (_50B9D8_screen_space_y[v62] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v64] - _50BAC8_screen_space_x[v63])) < 0 )
         {
           v62 = v80;
           v71 = v80;
@@ -1936,19 +2399,19 @@
           v65 = v71;
           if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
           {
-            memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
-            memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&_50B9D8_screen_space_y[v65], &_50B9D8_screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&_50BAC8_screen_space_x[v65], &_50BAC8_screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
           }
           --v55;
         }
       }
       while ( v62 - 1 < v55 );
     }
-    stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
-    stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
+    _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
+    _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
   }
   return v55;
-}
+}*/
 
 //----- (00424579) --------------------------------------------------------
 int __fastcall sub_424579(int uFaceID, stru320 *a2)
--- a/mm7_3.cpp	Mon Jun 10 09:30:21 2013 +0600
+++ b/mm7_3.cpp	Tue Jun 11 17:30:54 2013 +0600
@@ -11427,7 +11427,7 @@
     pNode = &pIndoor->pNodes[uFirstNode];
     pFace = &pIndoor->pFaces[pSector->pFaceIDs[pNode->uCoplanarOffset]];
     v5 = 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;
+       + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z;//plane equation
     if (pFace->Portal() && pFace->uSectorID != node->uSectorID )
       v5 = -v5;
     //v11 = v5 > 0;