changeset 1180:b542660e7302

Слияние
author Ritor1
date Wed, 05 Jun 2013 17:40:17 +0600
parents 883eaee77094 (diff) 8b3e7d5ba069 (current diff)
children 64cda98b739c 02e2a5c1ebc0
files
diffstat 4 files changed, 232 insertions(+), 228 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Wed Jun 05 01:00:40 2013 +0400
+++ b/Events.cpp	Wed Jun 05 17:40:17 2013 +0600
@@ -1099,7 +1099,7 @@
                 if (v83 == 21 ||  // gold well on emerald isle
                     v83 == 22 || v83 == 23 || v83 == 24 )
                 {
-                  __debugbreak(); // find out what these decorations are
+                  //__debugbreak(); // bonfire
                     viewparams->bRedrawGameUI = true;
                 }
                 ++curr_seq_num;
--- a/Render.cpp	Wed Jun 05 01:00:40 2013 +0400
+++ b/Render.cpp	Wed Jun 05 17:40:17 2013 +0600
@@ -908,7 +908,7 @@
   int v30; // ecx@64
   int v31; // ecx@68
   int v32; // eax@70
-  int v33; // ecx@71
+  //int v33; // ecx@71
   int v34; // eax@73
   int v35; // ecx@77
   int v36; // ecx@81
@@ -917,7 +917,7 @@
   int v39; // ecx@88
   int v40; // eax@90
   int v41; // edx@94
-  int v42; // ecx@95
+  //int v42; // ecx@95
   int v43; // ecx@98
   int v44; // ecx@102
   int v45; // eax@104
@@ -935,7 +935,7 @@
   int v57; // ecx@140
   int v58; // eax@142
   int v59; // ecx@146
-  int v60; // ecx@147
+  //int v60; // ecx@147
   int v61; // ecx@150
   int v62; // ecx@155
   int v63; // eax@157
@@ -950,7 +950,7 @@
   //int v72; // ecx@178
   //int x; // ebx@180
   //int v74; // eax@182
-  int v75; // eax@184
+  //int v75; // eax@184
   IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184
   int uStartZ; // ecx@184
   int v79; // ebx@185
@@ -996,11 +996,11 @@
   v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2
   pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536
   pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512
-  v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;
-  v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;
+  v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88
+  v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66
   v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X
   v119 = pOutdoorCamera->outdoor_grid_band_3 + v123;
-  v2 = pOutdoorCamera->uCameraFovInDegrees + 15;
+  v2 = pOutdoorCamera->uCameraFovInDegrees + 15;//90
   i = v124 - pOutdoorCamera->outdoor_grid_band_3;
   v122 = v123 - pOutdoorCamera->outdoor_grid_band_3;
 
@@ -1009,42 +1009,50 @@
   v3 = (v2 << 11) / 720;
   v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3);
   v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1);
+
   v106 = stru_5C6E00->Cos(v4);
   uEndZ = stru_5C6E00->Sin(v4);
+
   v111 = stru_5C6E00->Cos(v5);
   v6 = stru_5C6E00->Sin(v5);
+
   v7 = v4 & stru_5C6E00->uPiMask;
-
   if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi )
     v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7];
   else
     v8 = stru_5C6E00->pTanTable[v7];
   v112 = abs(v8);
+
   v9 = v5 & stru_5C6E00->uPiMask;
   if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi )
     v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9];
   else
     v10 = stru_5C6E00->pTanTable[v9];
   v108 = abs(v10);
+
   //v11 = v124;
   //v12 = v123;
   v114 = 0;
   v115 = 0;
   pIndoorCameraD3D_4 = 0;
   v125 = 0;
-  v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1;
   v126 = v124;
   v118 = v123;
+
+  v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1;
   v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1;
   uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1;
-  terrain_76E1C8[0] = 65535;
+  v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1;
+
   uint _i = 1;
-  v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1;
   uint j = 1;
-  terrain_76E3C8[0] = 65535;
-  terrain_76DDC8[0] = 65535;
-  terrain_76DFC8[0] = 65535;
-  for( _i = 1; _i < 128; _i++)
+
+  terrain_76DDC8[0] = -1;
+  terrain_76DFC8[0] = -1;
+  terrain_76E1C8[0] = -1;
+  terrain_76E3C8[0] = -1;
+
+  for( uint _i = 1; _i < 128; _i++)
   {
     if ( v112 >= 0x10000 )
     {
@@ -1116,6 +1124,7 @@
   v126 = 0;
   v17 = j - 1;
   v18 = _i - 1;
+
   switch ( v105 )
   {
     case 0:
@@ -1227,13 +1236,8 @@
       {
         v106 = v122;
         memset32(terrain_76DBC8, v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1));
-        v32 = v122;
-        do
-        {
-          v33 = v126++;
-          terrain_76D9C8[v33] = v32++;
-        }
-        while ( v32 <= terrain_76DDC8[v17] );
+        for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++)
+          terrain_76D9C8[v126++] = v32;
         if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
         {
           do
@@ -1300,10 +1304,9 @@
       v41 = terrain_76E1C8[v18];
       while ( v41 <= v123 )
       {
-        v42 = terrain_76E3C8[v18];
         terrain_76D5C8[v16] = v41;
-        terrain_76D7C8[v16] = v42;
-        if ( v42 == 65535 )
+        terrain_76D7C8[v16] = terrain_76E3C8[v18];
+        if ( terrain_76E3C8[v18] == 65535 )
         {
           terrain_76D7C8[v16] = v124;
           break;
@@ -1330,10 +1333,8 @@
       {
         v106 = v119;
         memset32(terrain_76DBC8, i, 4 * (v119 - terrain_76DDC8[v17] + 1));
-        v45 = v119;
-        do
-          terrain_76D9C8[v126++] = v45--;
-        while ( v45 >= terrain_76DDC8[v17] );
+        for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--)
+          terrain_76D9C8[v126++] = v45;
         if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
         {
           do
@@ -1454,9 +1455,9 @@
         if ( v59 > v124 )
           break;
         terrain_76DBC8[v16] = v59;
-        v60 = terrain_76DDC8[v17];
-        terrain_76D9C8[v16] = v60;
-        if ( v60 == 65535 )
+        //v60 = terrain_76DDC8[v17];
+        terrain_76D9C8[v16] = terrain_76DDC8[v17];
+        if ( terrain_76DDC8[v17] == 65535 )
         {
           terrain_76D9C8[v16] = v123;
           break;
@@ -1553,30 +1554,33 @@
       //v74 = terrain_76D7C8[i];
       if ( terrain_76D7C8[i] <= 0 )
         terrain_76D7C8[i] = -terrain_76D7C8[i];
-      v75 = terrain_76D7C8[i] + 2;
+      uEndZ = terrain_76D7C8[i] + 2;
       //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D;
-      uEndZ = v75;
+      //uEndZ = v75;
       //pIndoorCameraD3D_4 = pIndoorCameraD3D_3;
       uStartZ = terrain_76DBC8[i] - 2;
-      if ( terrain_76DBC8[i] - 2 < v75 )
+      if ( terrain_76DBC8[i] - 2 < uEndZ )
       {
         v127 = 0;
         //v79 = (v73 - 66) << 9;
         //v116 = v77;
         //pHeight = v79;
-        v111 = v75 - uStartZ;
+        v111 = uEndZ - uStartZ;
         for (int z = uStartZ; z < uEndZ; ++z)
         {
           ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
           ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512;
           ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]);
+
           ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;
           ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512;
           ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1);
+
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
             pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1);
             pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1);
+
             pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0);
             pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0);
           }
@@ -1590,7 +1594,8 @@
       v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
       v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]);
       if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
-        Render::DrawTerrainD3D(v111, 0, v103, v104);//Render::RenderTerrainD3D();
+        Render::DrawTerrainD3D(v111, 0, v103, v104);
+        //Render::RenderTerrainD3D();
       else
         Render::DrawTerrainSW(v111, 0, v103, v104);
     }
@@ -1626,18 +1631,12 @@
         //do
         for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 )
         {
-          //v93 = v116;
-          //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
           ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9;
-          //*(float *)&pHeight = (double)pHeight;
           ptr_801A08[v86].vWorldPosition.y = v92;
-          //v106 = ;
-          //v97 = v116;
           ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116);
-          //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
+
           ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9;
           ptr_801A04[v86].vWorldPosition.y = v92;
-          //pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
           ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116);
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
@@ -1986,7 +1985,7 @@
   v90 = (float)pOutdoor->vSunlight.x / 65536.0;
   v91 = (float)pOutdoor->vSunlight.y / 65536.0;
   v92 = (float)pOutdoor->vSunlight.z / 65536.0;
-  if ( a1 - 1 > 0 )
+/*  if ( a1 - 1 > 0 )
   {
     while ( 1 )
     {
@@ -2016,11 +2015,11 @@
                !byte_4D864C)
            || !(pGame->uFlags & 0x80))
           && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/
-      if ( !&stru_76E5C8[(v5 << 7) + v6] )
-        goto LABEL_162;
+      /*if ( !&stru_76E5C8[(v5 << 7) + v6] )
+        goto LABEL_162*/
       v8 = &pVerticesSR_806210[v4];
-      pVertices2 = &pVerticesSR_801A10[v4 + 1];
-      v102 = v8;
+      //pVertices2 = &pVerticesSR_801A10[v4 + 1];
+      //v102 = v8;
       if (!v82)
       {
         pVertices = &pVerticesSR_801A10[v4];
@@ -2035,12 +2034,12 @@
       sY = floorf(v8->vWorldPosition.z + 0.5f);
       v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));
       v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f));
-      WorldPosToGridCellX(sX);
+      /*WorldPosToGridCellX(sX);
       WorldPosToGridCellZ(sY);
       if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1))
         if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y 
              || pVertices2->vWorldPosition.y != v101->vWorldPosition.y )
-          break;
+          break;*/
         v16 = &array_77EC08[pOutdoorCamera->numStru148s];
         v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
         if ( v16->uTileBitmapID != -1 )
@@ -2178,7 +2177,7 @@
         if ( ++v88 >= v84 )
           return;
       }
-      v40 = &array_77EC08[pOutdoorCamera->numStru148s];
+    /*  v40 = &array_77EC08[pOutdoorCamera->numStru148s];
       v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
       if ( v40->uTileBitmapID == -1 )
         goto LABEL_162;
@@ -2215,7 +2214,7 @@
           --pOutdoorCamera->numStru148s;
           goto LABEL_112;
         }*/
-      memcpy(&array_50AC10[0], v102, 0x30u);
+      /*memcpy(&array_50AC10[0], v102, 0x30u);
       array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
       array_50AC10[0].u = 0.0;
       array_50AC10[0].v = 0.0;
@@ -2240,7 +2239,7 @@
         stru148(stru_76D590);
         atexit(loc_48118F);
       }*/
-      v96 = pGame->pLightmapBuilder;
+      /*v96 = pGame->pLightmapBuilder;
       pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0);
       pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0);
       uNumVertices = 3;
@@ -2363,7 +2362,7 @@
         __init_flag1 = true;
         stru154::stru154(&static_sub_0048034E_stru_76D578);
       }*/
-      v96 = pGame->pLightmapBuilder;
+     /* v96 = pGame->pLightmapBuilder;
       pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1);
       pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1);
       v100 = 3;
@@ -2443,7 +2442,7 @@
       OutdoorCamera::Project(v73);
       goto LABEL_154;
     }
-  }
+  }*/
 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
 // 4D864C: using guessed type char byte_4D864C;
--- a/Vis.cpp	Wed Jun 05 01:00:40 2013 +0400
+++ b/Vis.cpp	Wed Jun 05 17:40:17 2013 +0600
@@ -34,7 +34,7 @@
   RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17
   int v20; // [sp+84h] [bp-Ch]@10
 
-  static Vis_SelectionList SelectedPointersList;
+  static Vis_SelectionList SelectedPointersList;//stru_F8FE00
   SelectedPointersList.uNumPointers = 0;
 
   static bool _init_flag = false;
@@ -74,7 +74,6 @@
   pGame->pIndoorCameraD3D->ViewTransform(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices);
   pGame->pIndoorCameraD3D->Project(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, 1);
 
-  //v15 = this;
   SortVectors_x(static_DetermineFacetIntersection_array_F8F200, 0, face->uNumVertices - 1);
   if (static_DetermineFacetIntersection_array_F8F200[0].vWorldViewPosition.x > pick_depth)
     return nullptr;
@@ -902,6 +901,12 @@
 //----- (004C2551) --------------------------------------------------------
 Vis_ObjectInfo *Vis_SelectionList::SelectionPointers(int pVisObjectType, int pid)
 {
+  //unsigned int v3; // esi@1
+  //signed int v4; // edx@1
+  //char *v5; // eax@2
+  //Vis_ObjectInfo *result; // eax@6
+
+  //v3 = this->uNumPointers;
   if ( this->uNumPointers > 0 )
   {
     for ( uint i = 0; i < this->uNumPointers; ++i )
@@ -911,6 +916,22 @@
     }
   }
   return false;
+  /*v4 = 0;
+  if ( this->uNumPointers <= 0 )
+    return false;
+  else
+  {
+    //v5 = (char *)&this->object_pool[0].sZValue;
+    while ( this->object_pool[v4].object_type != a2 || (this->object_pool[v4].sZValue & 0xFFFF) != a3 )
+    {
+      ++v4;
+      //v5 += 12;
+      if ( v4 >= this->uNumPointers )
+       return false;
+    }
+    result = &this->object_pool[v4];
+  }
+  return result;*/
 }
 
 //----- (004C2591) --------------------------------------------------------
@@ -954,56 +975,54 @@
 //----- (004C264A) --------------------------------------------------------
 void Vis::sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right)
 {
-  //int v4; // edx@1
-  //int v5; // ebx@1
+  int v4; // edx@1
+  int v5; // ebx@1
   int v6; // esi@2
   signed int i; // ecx@2
-  //int v8; // eax@3
-  //int v9; // ebx@4
-  //int v10; // ebx@6
+  int v8; // eax@3
+  int v9; // ebx@4
+  int v10; // ebx@6
   Vis_ObjectInfo *v11; // eax@7
-  //Vis *thisa; // [sp+4h] [bp-4h]@1
-  //Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2
+  Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2
 
-  //v4 = left;
-  //v5 = right;
-  //thisa = this;
+  v4 = left;
+  v5 = right;
   if ( right > left )
   {
     do
     {
-      v6 = left - 1;
-      //a3a = pPointers[right];
-      for ( i = right; ; pPointers[i] = v11 )
+      v6 = v4 - 1;
+      a3a = pPointers[v5];
+      for ( i = v5; ; pPointers[i] = v11 )
       {
-        //v8 = a3a->sZValue;
-        //LOWORD(v8) = 0;
+        v8 = a3a->sZValue;
+        LOWORD(v8) = 0;
         do
         {
           ++v6;
-          //v9 = pPointers[v6]->sZValue;
-          //LOWORD(v9) = 0;
+          v9 = pPointers[v6]->sZValue;
+          LOWORD(v9) = 0;
         }
-        while ( pPointers[v6]->sZValue < pPointers[right]->sZValue );
+        while ( v9 < (unsigned int)v8 );
         do
         {
           if ( i < 1 )
             break;
           --i;
-          //v10 = pPointers[i]->sZValue;
-          //LOWORD(v10) = 0;
+          v10 = pPointers[i]->sZValue;
+          LOWORD(v10) = 0;
         }
-        while ( pPointers[i]->sZValue > pPointers[right]->sZValue );
+        while ( v10 > (unsigned int)v8 );
         v11 = pPointers[v6];
         if ( v6 >= i )
           break;
         pPointers[v6] = pPointers[i];
       }
-      //v5 = right;
+      v5 = right;
       pPointers[v6] = pPointers[right];
       pPointers[right] = v11;
-      sort_object_pointers(pPointers, left, v6 - 1);
-      left = v6 + 1;
+      sort_object_pointers(pPointers, v4, v6 - 1);
+      v4 = v6 + 1;
     }
     while ( right > v6 + 1 );
   }
--- a/mm7_1.cpp	Wed Jun 05 01:00:40 2013 +0400
+++ b/mm7_1.cpp	Wed Jun 05 17:40:17 2013 +0600
@@ -2238,71 +2238,71 @@
   int v8; // edx@5
   //int v9; // ecx@6
   int v10; // eax@12
-  int v11; // edi@13
+  //int v11; // edi@13
   //int v12; // edx@18
   int v13; // eax@22
   //int v14; // edi@28
   int v15; // ecx@29
-  int v16; // edi@30
+  //int v16; // edi@30
   //int v17; // edx@35
   int v18; // eax@39
   int v19; // eax@44
   int v20; // ecx@44
   //int v21; // edi@45
   int v22; // edi@46
-  __int16 *v23; // ecx@47
+  //__int16 *v23; // ecx@47
   int v24; // edx@48
-  int v25; // eax@50
+  //int v25; // eax@50
   int v26; // eax@55
   signed int v27; // edi@55
   //int v28; // edx@56
   int v29; // edx@57
-  int v30; // eax@59
+  //int v30; // eax@59
   int v31; // eax@64
   signed int v32; // edi@64
   //int v33; // edx@65
-  __int16 *v34; // eax@66
-  __int16 v35; // dx@66
+  int v34; // eax@66
+  int v35; // dx@66
   __int16 v36; // dx@67
   __int16 v37; // di@67
   __int16 v38; // dx@67
   //BspRenderer_stru2 *v39; // ecx@69
-  int v40; // edx@69
-  int v41; // edi@70
-  __int16 *v42; // eax@76
-  __int16 *v43; // eax@81
-  __int16 *v45; // eax@87
+  //int v40; // edx@69
+  //int v41; // edi@70
+  //__int16 *v42; // eax@76
+  //__int16 *v43; // eax@81
+  //__int16 *v45; // eax@87
   int v46; // edx@87
-  __int16 v47; // cx@88
-  int v48; // eax@93
+  //__int16 v47; // cx@88
+  //int v48; // eax@93
   int v49; // esi@93
-  __int16 *v50; // ecx@94
-  int v51; // eax@95
+  //__int16 *v50; // ecx@94
+  //int v51; // eax@95
   //int v52; // eax@97
   int v53; // [sp+Ch] [bp-34h]@44
   int v54; // [sp+10h] [bp-30h]@0
   int v55; // [sp+14h] [bp-2Ch]@12
-  __int16 *v56; // [sp+14h] [bp-2Ch]@47
-  __int16 *v57; // [sp+14h] [bp-2Ch]@76
-  __int16 *v58; // [sp+14h] [bp-2Ch]@81
-  __int16 *v59; // [sp+14h] [bp-2Ch]@87
+  //__int16 *v56; // [sp+14h] [bp-2Ch]@47
+  //__int16 v57; // [sp+14h] [bp-2Ch]@76
+  //__int16 v58; // [sp+14h] [bp-2Ch]@81
+  int v59; // [sp+14h] [bp-2Ch]@87
   //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
   int v61; // [sp+1Ch] [bp-24h]@29
   int v62; // [sp+20h] [bp-20h]@0
   signed int v63; // [sp+24h] [bp-1Ch]@3
   signed int v64; // [sp+28h] [bp-18h]@3
   int v65; // [sp+2Ch] [bp-14h]@5
-  int v66; // [sp+2Ch] [bp-14h]@39
-  int v67; // [sp+30h] [bp-10h]@22
+  //int v66; // [sp+2Ch] [bp-14h]@39
+  //int v67; // [sp+30h] [bp-10h]@22
   int v68; // [sp+34h] [bp-Ch]@12
   int v69; // [sp+34h] [bp-Ch]@29
   int v70; // [sp+34h] [bp-Ch]@46
   int v71; // [sp+34h] [bp-Ch]@75
   int v72; // [sp+34h] [bp-Ch]@80
-  int v73; // [sp+38h] [bp-8h]@11
+  //int v73; // [sp+38h] [bp-8h]@11
   //int v74; // [sp+3Ch] [bp-4h]@1
-  int a3a; // [sp+48h] [bp+8h]@76
-  int a3b; // [sp+48h] [bp+8h]@87
+  //int a3a; // [sp+48h] [bp+8h]@76
+  //int a3b; // [sp+48h] [bp+8h]@87
 
   //try graphic engine with function returning 1 always, and without
   //return true;
@@ -2336,7 +2336,6 @@
       v7 = stru_50B700._screen_space_y[v6];
     }
   }
-  v73 = v8;
   if ( v8 == v7 )
     return false;
   v10 = v65;
@@ -2345,7 +2344,7 @@
   v55 = v65;
   if ( pNumVertices > 0 )
   {
-    v11 = v65;
+    //v11 = v65;
     for ( v68 = 0; v68 < pNumVertices; ++v68 )
     {
       v10 += v64;
@@ -2358,29 +2357,25 @@
       {
         v10 -= pNumVertices;
       }
-      if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v11] )
+      if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] )
       {
         v55 = v10;
-        v11 = v10;
+        v65 = v10;
       }
-      if ( stru_50B700._screen_space_y[v10] == v73 )
+      if ( stru_50B700._screen_space_y[v10] == v8 )
         break;
     }
   }
   v13 = v55 + v64;
-  v67 = v55 + v64;
-  if ( v55 + v64 < pNumVertices )
+  if ( v13 < pNumVertices )
   {
-    if ( v13 >= 0 )
-      goto LABEL_27;
-    v13 += pNumVertices;
+    if ( v13 < 0 )
+      v13 += pNumVertices;
   }
   else
   {
     v13 -= pNumVertices;
   }
-  v67 = v13;
-LABEL_27:
   if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
   {
     v62 = stru_50B700._screen_space_x[v55] << 16;
@@ -2391,7 +2386,7 @@
   v61 = v65;
   if ( pNumVertices > 0 )
   {
-    v16 = v65;
+    //v16 = v65;
     for ( v69 = 0; v69 < pNumVertices; ++v69 )
     {
       v15 += v63;
@@ -2404,86 +2399,75 @@
       {
         v15 -= pNumVertices;
       }
-      if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v16] )
+      if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] )
       {
         v61 = v15;
-        v16 = v15;
+        v65 = v15;
       }
-      if ( stru_50B700._screen_space_y[v15] == v73 )
+      if ( stru_50B700._screen_space_y[v15] == v8 )
         break;
     }
   }
   v18 = v63 + v61;
-  v66 = v63 + v61;
-  if ( v63 + v61 < pNumVertices )
+  if ( v18 < pNumVertices )
   {
-    if ( v18 >= 0 )
-      goto LABEL_44;
-    v18 += pNumVertices;
+    if ( v18 < 0 )
+      v18 += pNumVertices;
   }
   else
   {
     v18 -= pNumVertices;
   }
-  v66 = v18;
-LABEL_44:
   v19 = v18;
   v20 = v61;
   if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
   {
     v61 = stru_50B700._screen_space_x[v20] << 16;
     v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
-    a2->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]);
+    a2->array_3D8[v8] = LOWORD(stru_50B700._screen_space_x[v20]);
   }
   v22 = v7;
-  if ( v7 <= v73 )
+  if ( v7 <= v8 )
   {
-    v56 = &a2->array_3D8[v7];
-    v23 = &a2->array_18[v7];
-    for ( v70 = v7; v70 <= v73; ++v70 )
+    //v56 = &a2->array_3D8[v7];
+    //v23 = &a2->array_18[v7];
+    for ( v70 = v7; v70 <= v8; ++v70 )
     {
-      v24 = v67;
-      if ( v22 < stru_50B700._screen_space_y[v67] || v22 == v73 )
-        goto LABEL_57;
-      v25 = v64 + v67;
-      v67 = v25;
-      if ( v25 < pNumVertices )
+      v24 = v13;
+      if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != v8 )
       {
-        if ( v25 >= 0 )
-          goto LABEL_55;
-        v25 += pNumVertices;
-      }
-      else
-      {
-        v25 -= pNumVertices;
+        v13 = v64 + v13;
+        if ( v13 < pNumVertices )
+        {
+          if ( v13 < 0 )
+            v13 += pNumVertices;
+        }
+        else
+        {
+          v13 -= pNumVertices;
+        }
+        v26 = v13;
+        //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+        if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
+        {
+          v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+          v62 = stru_50B700._screen_space_x[v24] << 16;
+        }
       }
-      v67 = v25;
-LABEL_55:
-      v26 = v25;
-      //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
-      if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
-      {
-        v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
-        v62 = stru_50B700._screen_space_x[v24] << 16;
-      }
-LABEL_57:
-      v29 = v66;
-      if ( v70 >= stru_50B700._screen_space_y[v66] && v70 != v73 )
+      v29 = v18;
+      if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != v8 )
       {
-        v30 = v63 + v66;
-        v66 += v63;
-        if ( v66 >= pNumVertices )
+        v18 += v63;
+        if ( v18 < pNumVertices )
         {
-          v30 -= pNumVertices;
-          goto LABEL_63;
+          if ( v18 < 0 )
+            v18 += pNumVertices;
         }
-        if ( v30 < 0 )
+        else
         {
-          v30 += pNumVertices;
-LABEL_63:
-          v66 = v30;
+          v18 -= pNumVertices;
         }
-        v31 = v30;
+        v31 = v18;
         //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
         if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 )
         {
@@ -2491,96 +2475,98 @@
           v61 = stru_50B700._screen_space_x[v29] << 16;
         }
       }
-      *(__int16 *)((char *)v56 + (int)(char *)a2->array_18 - (char *)a2->array_3D8) = HIWORD(v62);
-      *v56 = HIWORD(v61);
-      v34 = v23 + 480;
-      v35 = v23[480];
-      if ( *v23 > v35 )
+	  //v34 = (char *)a2->array_18 - (char *)a2->array_3D8;
+	  //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34);
+      //v35 = HIWORD(v62);
+      a2->array_18[v70] = HIWORD(v62);
+      a2->array_3D8[v70] = HIWORD(v61);
+      //v34 = &a2->array_3D8[v70];
+      //v35 = a2->array_3D8[v70];
+      if ( a2->array_18[v70] > a2->array_3D8[v70] )
       {
-        v36 = *v23 ^ v35;
-        v37 = *v34;
-        *v23 = v36;
+        v36 = a2->array_18[v70] ^ a2->array_3D8[v70];
+        v37 = a2->array_3D8[v70];
+        a2->array_18[v70] = v36;
         v38 = v37 ^ v36;
-        *v23 ^= v38;
-        *v34 = v38;
+        a2->array_18[v70] ^= v38;
+        a2->array_3D8[v70] = v38;
       }
-      ++v56;
+      //++v56;
       v62 += v54;
       v22 = v70 + 1;
       v61 += v53;
-      ++v23;
+      //++v23;
     }
   }
-  v40 = v73;
-  if ( v73 < a3->_viewport_space_y || (v41 = a3->_viewport_space_w, v7 > v41) )
+  if ( v8 < a3->_viewport_space_y )
+    return false;
+  if ( v7 > a3->_viewport_space_w )
     return false;
   if ( v7 < a3->_viewport_space_y )
     v7 = a3->_viewport_space_y;
-  if ( v73 > v41 )
-  {
-    v40 = a3->_viewport_space_w;
-    v73 = a3->_viewport_space_w;
-  }
-  if ( v7 <= v40 )
+  if ( v8 > a3->_viewport_space_w )
+    v8 = a3->_viewport_space_w;
+  if ( v7 <= v8 )
   {
-    a3a = (char *)a2 - (char *)a3;
-    v57 = &a2->array_18[v7];
-    v42 = &a3->array_3D8[v7];
-    for ( v71 = v7; v71 <= v40; ++v71 )
+    //a3a = (char *)a2 - (char *)a3;
+    //v42 = &a3->array_3D8[v7];
+    //v57 = *(__int16 *)((char *)v42 + a3a);
+    for ( v71 = v7; v71 <= v8; ++v71 )
     {
-      if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && a2->array_18[v71] <= a3->array_3D8[v71] )
+      if ( a2->array_18[v71] >= a3->array_18[v71] && a2->array_18[v71] <= a3->array_3D8[v71] )
         break;
-      ++v57;
+      //++v57;
       ++v7;
-      ++v42;
+      //++v42;
     }
   }
-  if ( v40 < v7 )
+  if ( v8 < v7 )
     return false;
-  v58 = &a2->array_18[v40];
-  v43 = &a3->array_3D8[v40];
-  for ( v72 = v40; v72 >= v7; --v72 )
+  //a3a = (char *)a2 - (char *)a3;
+  //v43 = &a3->array_3D8[v8];
+  //v58 = *(__int16 *)((char *)v43 + a3a);
+  for ( v72 = v8; v72 >= v7; --v72 )
   {
-    if ( *(__int16 *)((char *)v43 + (int)(char *)a2 - (char *)a3) >= *(v43 - 480) && *v58 <= a3->array_3D8[v72] )
+    if ( a2->array_3D8[v72] >= a3->array_18[v72] && a2->array_18[v72] <= a3->array_3D8[v72] )
       break;
-    --v58;
-    --v40;
-    --v43;
-    v73 = v40;
+    //--v58;
+    --v8;
+    //--v43;
+    //v8 = v8;
   }
-  if ( v7 >= v40 )
+  if ( v7 >= v8 )
     return false;
-  a3b = (char *)a3 - (char *)a2;
-  v59 = &a3->array_3D8[v7];
-  v45 = &a2->array_18[v7];
+  //a3b = (char *)a3 - (char *)a2;
+  v59 = v7;
+  //v45 = &a2->array_18[v7];
   
-  for ( v46 = v73 - v7 + 1; v46; --v46 )
+  for ( v46 = v8 - v7 + 1; v46; --v46 )
   {
-    v47 = *(__int16 *)((char *)v45 + a3b);
-    if ( *v45 < v47 )
-      *v45 = v47;
-    if ( v45[480] > *v59 )
-      v45[480] = *v59;
+    //v47 = *(__int16 *)((char *)v45 + a3b);
+    if ( a2->array_18[v59] < a3->array_18[v59] )
+      a2->array_18[v59] = a3->array_18[v59];
+    if ( a2->array_3D8[v59] > a3->array_3D8[v59] )
+      a2->array_3D8[v59] = a3->array_3D8[v59];
     ++v59;
-    ++v45;
+    //++v45;
   }
   a2->_viewport_space_y = v7;
-  a2->_viewport_space_w = v73;
+  a2->_viewport_space_w = v8;
   a2->field_8 = a2->array_18[v7];
-  v48 = a2->array_3D8[v7];
+  //v48 = a2->array_3D8[v7];
   a2->field_10 = v7;
   a2->field_14 = v7;
-  a2->field_C = v48;
+  a2->field_C = a2->array_3D8[v7];
   v49 = v7 + 1;
-  if ( v49 <= v73 )
+  if ( v49 <= v8 )
   {
-    v50 = &a2->array_3D8[v49];
-    for ( v49; v49 <= v73; ++v49 )
+    //v50 = &a2->array_3D8[v49];
+    for ( v49; v49 <= v8; ++v49 )
     {
-      v51 = *(v50 - 480);
-      if ( v51 < a2->field_8 )
+      //v51 = a2->array_18[v49];
+      if ( a2->array_18[v49] < a2->field_8 )
       {
-        a2->field_8 = v51;
+        a2->field_8 = a2->array_18[v49];
         a2->field_10 = v49;
       }
       if ( a2->array_3D8[v49] > a2->field_C )
@@ -2588,7 +2574,7 @@
         a2->field_C = a2->array_3D8[v49];
         a2->field_14 = v49;
       }
-      ++v50;
+      //++v50;
     }
   }
   return true;