changeset 2245:8817c398b792

for RasterLine2D
author Ritor1
date Tue, 25 Feb 2014 20:02:06 +0600
parents 66c509997062
children 529bf95fb0d7 47bcb700b74b
files DecalBuilder.cpp DecalBuilder.h IndoorCameraD3D.cpp IndoorCameraD3D.h LightmapBuilder.cpp Render.cpp TurnEngine.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp mm7_7.cpp
diffstat 11 files changed, 267 insertions(+), 448 deletions(-) [+]
line wrap: on
line diff
--- a/DecalBuilder.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/DecalBuilder.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -236,7 +236,7 @@
       v29 = v21->radius;
       //v30 = (int)v21;
       //v31 = thisa;
-      if ( !this->_49B790_build_decal_geometry(v42, a3, (DecalBuilder_stru0 *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) )
+      if ( !this->_49B790_build_decal_geometry(v42, a3, (Bloodsplat *)v21, (int)&a5a, SLODWORD(v29), v43, v33, &static_AE4F60, a5, a6, a8) )
       {
       MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
       }
@@ -249,26 +249,26 @@
 }
 
 //----- (0049B790) --------------------------------------------------------
-char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
+char DecalBuilder::_49B790_build_decal_geometry(int a2, char a3, Bloodsplat *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, stru314 *a9, signed int a10, RenderVertexSoft *a11, char uClipFlags)
 {
-  DecalBuilder *v12; // esi@1
+  //DecalBuilder *v12; // esi@1
   Decal *v13; // edi@2
   int *v14; // eax@2
-  double v15; // st7@4
-  double v16; // st7@4
-  int v17; // eax@4
-  stru314 *v18; // ebx@4
-  double v19; // st7@4
-  double v20; // st7@4
-  double v21; // st7@4
-  double v22; // st6@4
-  double v23; // st6@4
-  double v24; // st5@4
-  char *v25; // eax@4
-  signed int v26; // ecx@4
-  double v27; // st5@4
+  //double v15; // st7@4
+  //double v16; // st7@4
+  //int v17; // eax@4
+  //stru314 *v18; // ebx@4
+  //double v19; // st7@4
+  //double v20; // st7@4
+  //double v21; // st7@4
+  //double v22; // st6@4
+  //double v23; // st6@4
+  //double v24; // st5@4
+  //char *v25; // eax@4
+  //signed int v26; // ecx@4
+  //double v27; // st5@4
   double v28; // st7@5
-  double v29; // st7@6
+  //double v29; // st7@6
   char result; // al@6
   unsigned int *v31; // edi@7
   RenderVertexSoft *v32; // ebx@8
@@ -277,163 +277,150 @@
   const char *v35; // [sp-Ch] [bp-2Ch]@15
   int v36; // [sp-8h] [bp-28h]@15
   std::string v37; // [sp-4h] [bp-24h]@15
-  float v38; // [sp+8h] [bp-18h]@6
-  RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
-  unsigned int v40; // [sp+10h] [bp-10h]@6
+  //float v38; // [sp+8h] [bp-18h]@6
+  //RenderVertexSoft *v39; // [sp+Ch] [bp-14h]@6
+  //unsigned int v40; // [sp+10h] [bp-10h]@6
 
-  int a6a;
-  RenderVertexSoft *a8a;
+  //int a6a;
+  //RenderVertexSoft *a8a;
   unsigned int a8b = 0;
 
-  v12 = this;
+  //v12 = this;
   if ( a6 == 0.0 )
     return 1;
   v13 = &this->std__vector_pDecals[this->field_308008];
   v14 = &this->std__vector_pDecals[this->field_308008].field_C1C;
-  this->std__vector_pDecals[this->field_308008].field_C18 = a4;
+  this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)a4;
   *v14 = 0;
   if ( a3 & 2 )
     *v14 = 1;
-  v15 = a6 - a8;
-  this->field_30C028 = v15;
-  v16 = sqrt((a6 + a6 - v15) * v15);
-  v12->field_30C02C = v16;
-  v17 = a5;
-  v18 = a9;
-  v12->flt_30C030 = 1.0 - (a6 - v16) / a6;
-  v13->field_C08 = (signed __int64)((double)*(signed int *)v17 - a8 * v18->field_4.x);
-  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * v18->field_4.y);
-  v19 = a6;
-  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * v18->field_4.z);
-  v20 = v19 * v12->flt_30C030;
-  a8a = v13->pVertices;
-  v12->field_30C034 = v20;
-  v12->field_30C010 = v20 * v18->field_10.x;
-  v12->field_30C014 = v20 * v18->field_10.y;
-  v12->field_30C018 = v20 * v18->field_10.z;
-  v12->field_30C01C = v20 * v18->field_1C.x;
-  v12->field_30C020 = v20 * v18->field_1C.y;
-  v12->field_30C024 = v20 * v18->field_1C.z;
-  a6a = v13->field_C08;
-  v21 = (double)a6a;
-  v22 = v21 - v12->field_30C01C;
-  a6a = v13->field_C0A;
-  v13->pVertices[0].vWorldPosition.x = v22 + v12->field_30C010;
-  v23 = (double)a6a;
-  v24 = v23 - v12->field_30C020 + v12->field_30C014;
-  v25 = (char *)&v13->pVertices[0].vWorldPosition.y;
-  a6 = v13->field_C0C;
-  v26 = 4;
-  v13->pVertices[0].vWorldPosition.y = v24;
-  v27 = (double)a6a;
-  a6 = v27;
-  v13->pVertices[0].vWorldPosition.z = v27 - v12->field_30C024 + v12->field_30C018;
+  //v15 = a6 - a8;
+  this->field_30C028 = a6 - a8;
+  //v16 = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028);
+  this->field_30C02C = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028);
+  //v17 = a5;
+  //v18 = a9;
+  this->flt_30C030 = 1.0 - (a6 - this->field_30C02C) / a6;
+  v13->field_C08 = (signed __int64)((double)*(signed int *)a5 - a8 * a9->field_4.x);
+  v13->field_C0A = (signed __int64)((double)*(signed int *)(a5 + 4) - a8 * a9->field_4.y);
+  //v19 = a6;
+  v13->field_C0C = (signed __int64)((double)*(signed int *)(a5 + 8) - a8 * a9->field_4.z);
+  //v20 = a6 * this->flt_30C030;
+  //a8a = v13->pVertices;
+  this->field_30C034 = a6 * this->flt_30C030;
+  this->field_30C010 = this->field_30C034 * a9->field_10.x;
+  this->field_30C014 = this->field_30C034 * a9->field_10.y;
+  this->field_30C018 = this->field_30C034 * a9->field_10.z;
+  this->field_30C01C = this->field_30C034 * a9->field_1C.x;
+  this->field_30C020 = this->field_30C034 * a9->field_1C.y;
+  this->field_30C024 = this->field_30C034 * a9->field_1C.z;
+  //a6a = v13->field_C08;
+  //v21 = (double)v13->field_C08;
+  //v22 = (double)v13->field_C08 - this->field_30C01C;
+  //a6a = v13->field_C0A;
+  v13->pVertices[0].vWorldPosition.x = (double)v13->field_C08 - this->field_30C01C + this->field_30C010;
+  v13->pVertices[0].vWorldPosition.y = (double)v13->field_C0A - this->field_30C020 + this->field_30C014;
+  v13->pVertices[0].vWorldPosition.z = (double)v13->field_C0A - this->field_30C024 + this->field_30C018;
   v13->pVertices[0].u = 0.0;
   v13->pVertices[0].v = 0.0;
-  v13->pVertices[1].vWorldPosition.x = v21 - v12->field_30C01C - v12->field_30C010;
-  v13->pVertices[1].vWorldPosition.y = v23 - v12->field_30C020 - v12->field_30C014;
-  v13->pVertices[1].vWorldPosition.z = v27 - v12->field_30C024 - v12->field_30C018;
+
+  v13->pVertices[1].vWorldPosition.x = (double)v13->field_C08 - this->field_30C01C - this->field_30C010;
+  v13->pVertices[1].vWorldPosition.y = (double)v13->field_C0A - this->field_30C020 - this->field_30C014;
+  v13->pVertices[1].vWorldPosition.z = (double)v13->field_C0A - this->field_30C024 - this->field_30C018;
   v13->pVertices[1].u = 0.0;
   v13->pVertices[1].v = 1.0;
-  v13->pVertices[2].vWorldPosition.x = v21 + v12->field_30C01C - v12->field_30C010;
-  v13->pVertices[2].vWorldPosition.y = v23 + v12->field_30C020 - v12->field_30C014;
-  v13->pVertices[2].vWorldPosition.z = v27 + v12->field_30C024 - v12->field_30C018;
+
+  v13->pVertices[2].vWorldPosition.x = (double)v13->field_C08 + this->field_30C01C - this->field_30C010;
+  v13->pVertices[2].vWorldPosition.y = (double)v13->field_C0A + this->field_30C020 - this->field_30C014;
+  v13->pVertices[2].vWorldPosition.z = (double)v13->field_C0A + this->field_30C024 - this->field_30C018;
   v13->pVertices[2].u = 1.0;
   v13->pVertices[2].v = 1.0;
-  v13->pVertices[3].vWorldPosition.x = v21 + v12->field_30C01C + v12->field_30C010;
-  v13->pVertices[3].vWorldPosition.y = v23 + v12->field_30C020 + v12->field_30C014;
-  v13->pVertices[3].vWorldPosition.z = a6 + v12->field_30C024 + v12->field_30C018;
+
+  v13->pVertices[3].vWorldPosition.x = (double)v13->field_C08 + this->field_30C01C + this->field_30C010;
+  v13->pVertices[3].vWorldPosition.y = (double)v13->field_C0A + this->field_30C020 + this->field_30C014;
+  v13->pVertices[3].vWorldPosition.z = (double)v13->field_C0A + this->field_30C024 + this->field_30C018;
   v13->pVertices[3].u = 1.0;
   v13->pVertices[3].v = 0.0;
-  do
+
+  for ( uint i = 0; i < 4; ++i )
   {
-    v28 = v18->field_4.y * *(float *)v25
-        + *((float *)v25 - 1) * v18->field_4.x
-        + *((float *)v25 + 1) * v18->field_4.z
-        + v18->dist;
-    *((float *)v25 - 1) = *((float *)v25 - 1) - v28 * v18->field_4.x;
-    *(float *)v25 = *(float *)v25 - v28 * v18->field_4.y;
-    v25 += 48;
-    --v26;
-    *((float *)v25 - 11) = *((float *)v25 - 11) - v28 * v18->field_4.z;
+    v28 = a9->field_4.x * v13->pVertices[i].vWorldPosition.x
+        + a9->field_4.y * v13->pVertices[i].vWorldPosition.y
+        + a9->field_4.z * v13->pVertices[i].vWorldPosition.z
+        + a9->dist;
+    v13->pVertices[i].vWorldPosition.x = v13->pVertices[i].vWorldPosition.x - v28 * a9->field_4.x;
+    v13->pVertices[i].vWorldPosition.y = v13->pVertices[i].vWorldPosition.y - v28 * a9->field_4.y;
+    v13->pVertices[i].vWorldPosition.z = v13->pVertices[i].vWorldPosition.z - v28 * a9->field_4.z;
+    //v25 += 48;
   }
-  while ( v26 );
   v13->uColorMultiplier = uColorMultiplier;
   //v40 = (unsigned int *)&v13->uNumVertices;
-  v39 = v13->pVertices;
+  //v39 = v13->pVertices;
   v13->uNumVertices = 4;
   v13->field_C14 = a2;
-  v29 = v18->field_4.z;
+  //v29 = a9->field_4.z;
   //a6a = (unsigned int *)&v13->uNumVertices;
-  v38 = v29;
-  result = pGame->pStru9Instance->_4980B9(a11, a10, v18->field_4.x, v18->field_4.y, v38, v39, (unsigned int*)&v13->uNumVertices);
+  //v38 = a9->field_4.z;
+  result = pGame->pStru9Instance->_4980B9(a11, a10, a9->field_4.x, a9->field_4.y, a9->field_4.z, v13->pVertices, (unsigned int*)&v13->uNumVertices);
   if ( result )
   {
     //v31 = a6a;
     if ( !v13->uNumVertices )
       return 1;
-    v32 = a8a;
+    //v32 = a8a;
     //v40 = *a6a;
-    v39 = a8a;
-    pGame->pIndoorCameraD3D->ViewTransform(a8a, (unsigned int)v13->uNumVertices);
-    v40 = 0;
-    pGame->pIndoorCameraD3D->Project(v32, v13->uNumVertices, 0);
+    //v39 = a8a;
+    pGame->pIndoorCameraD3D->ViewTransform(v13->pVertices, (unsigned int)v13->uNumVertices);
+    //v40 = 0;
+    pGame->pIndoorCameraD3D->Project(v13->pVertices, v13->uNumVertices, 0);
     if ( !(uClipFlags & 1) )
     {
-      ++v12->field_308008;
+      ++this->field_308008;
       v34 = 1024;
-      if ( v12->field_308008 == 1024 )
-        v12->field_308008 = 0;
-      if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
-        v34 = v12->std__vector_pDecals_size + 1;
-      v12->std__vector_pDecals_size = v34;
+      if ( this->field_308008 == 1024 )
+        this->field_308008 = 0;
+      if ( (signed int)(this->std__vector_pDecals_size + 1) <= 1024 )
+        v34 = this->std__vector_pDecals_size + 1;
+      this->std__vector_pDecals_size = v34;
       return 1;
     }
     if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
     {
       if ( uClipFlags & 2 )
       {
-        v40 = (int)&a8;
-        v39 = v12->pVertices;
-      __debugbreak(); // warning C4700: uninitialized local variable 'v31' used
-        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b);
-        v40 = (int)v31;
-        v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
+        //v40 = (int)&a8;
+        //v39 = this->pVertices;
+      //__debugbreak(); // warning C4700: uninitialized local variable 'v31' used
+        pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v13->pVertices, v13->uNumVertices, this->pVertices, &a8b);
+        //v40 = (int)v31;
+        //v39 = this->pVertices;
+        pGame->pIndoorCameraD3D->_437143(a8b, v13->pVertices, this->pVertices, (unsigned int *)v13->uNumVertices);
       }
       else if ( uClipFlags & 4 )
       {
-        v40 = (int)&a8;
-        v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v32, *v31, v12->pVertices, &a8b);
-        v40 = (int)v31;
-        v39 = v12->pVertices;
-        pGame->pIndoorCameraD3D->_437143(a8b, v32, v12->pVertices, v31);
+        //v40 = (int)&a8;
+        //v39 = this->pVertices;
+        pGame->pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(v13->pVertices, v13->uNumVertices, this->pVertices, &a8b);
+        //v40 = (int)v31;
+        //v39 = this->pVertices;
+        pGame->pIndoorCameraD3D->_437143(a8b, v13->pVertices, this->pVertices, (unsigned int *)v13->uNumVertices);
       }
-	  else
-	  {
-        v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258";
-        v35 = "Undefined clip flag specified";
-	    MessageBoxA(nullptr, v35, (const char *)v39, 0);
-	  }
+      else
+        MessageBoxA(nullptr, "Undefined clip flag specified", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:258", 0);
     }
     else
-    {
-      v39 = (RenderVertexSoft *)"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263";
-      v35 = "Lightpoly builder native indoor clipping not implemented";
-	  MessageBoxA(nullptr, v35, (const char *)v39, 0);
-    }
+      MessageBoxA(nullptr, "Lightpoly builder native indoor clipping not implemented", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263", 0);
     if ( a8b != 0 )
-	{
-      ++v12->field_308008;
+    {
+      ++this->field_308008;
       v34 = 1024;
-      if ( v12->field_308008 == 1024 )
-        v12->field_308008 = 0;
-      if ( (signed int)(v12->std__vector_pDecals_size + 1) <= 1024 )
-        v34 = v12->std__vector_pDecals_size + 1;
-      v12->std__vector_pDecals_size = v34;
+      if ( this->field_308008 == 1024 )
+        this->field_308008 = 0;
+      if ( (signed int)(this->std__vector_pDecals_size + 1) <= 1024 )
+        v34 = this->std__vector_pDecals_size + 1;
+      this->std__vector_pDecals_size = v34;
       return 1;
-	}
+    }
     result = 1;
   }
   return result;
--- a/DecalBuilder.h	Mon Feb 24 16:54:21 2014 +0600
+++ b/DecalBuilder.h	Tue Feb 25 20:02:06 2014 +0600
@@ -168,7 +168,7 @@
   void 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 light_level, 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, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
+  char _49B790_build_decal_geometry(int a2, char a3, Bloodsplat *a4, int a5, float a6, unsigned int uColorMultiplier, float 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 Polygon *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
--- a/IndoorCameraD3D.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/IndoorCameraD3D.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -23,86 +23,41 @@
 //----- (004361EF) --------------------------------------------------------
 IndoorCameraD3D::IndoorCameraD3D()
 {
-  IndoorCameraD3D *v1; // esi@1
-  //double v2; // st7@1
-  //double v3; // st6@1
-  //double v4; // st5@1
-  //double v5; // st7@1
-  //double v6; // st6@1
-  //double v7; // st5@1
-
-  v1 = this;
-  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&this->field_4);
-  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v1->field_14);
-  //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v1->field_24);
-  /*_eh_vector_constructor_iterator_(v1->std__vector_000034_prolly_frustrum,
-    24,
-    6,
-    (void ( *)(void *))IndoorCameraD3D_Vec4::IndoorCameraD3D_Vec4,
-    (void ( *)(void *))IndoorCameraD3D_Vec4::dtor);*/
-  //v2 = 0;//(double)pBLVRenderParams->vPartyPos.z;
-  //v3 = 0;//(double)pBLVRenderParams->vPartyPos.y;
-  //v4 = 0;//(double)pBLVRenderParams->vPartyPos.x;
-  v1->field_108 = 0.0;
-  //v1->blv_party_x = 0;
-  //v1->blv_party_y = 0;
-  //v1->blv_party_z = 0;
-  //v5 = 0;//(double)pBLVRenderParams->vPartyPos.z;
-  //v6 = 0;//(double)pBLVRenderParams->vPartyPos.y;
-  //v7 = 300;//(double)(pBLVRenderParams->vPartyPos.x + 300);
-  v1->field_138 = 0.0;
-  //v1->blv_party_x_2 = 300;
-  //v1->blv_party_y_2 = 0;
-  //v1->blv_party_z_2 = 0;
-  v1->field_168 = 0.0;
-  v1->field_198 = 0.0;
-  v1->field_1C8 = 0.0;
-  v1->field_1F8 = 0.0;
-  v1->field_228 = 0.0;
-  v1->field_258 = 0.0;
-  v1->field_288 = 0.0;
-  v1->field_2B8 = 0.0;
-  v1->field_2E8 = 0.0;
-  v1->field_2BC = 0.0;
-  v1->field_2C0 = 0.0;
-  v1->field_2C4 = 0.0;
-  v1->field_318 = 0.0;
-  v1->field_2EC = 0.0;
-  v1->field_2F0 = 0.0;
-  v1->field_2F4 = 0.0;
-  v1->field_348 = 0.0;
-  v1->field_31C = 0.0;
-  v1->field_320 = 0.0;
-  v1->field_324 = 0.0;
-  v1->field_378 = 0.0;
-  v1->field_34C = 0.0;
-  v1->field_350 = 0.0;
-  v1->field_354 = 0.0;
+  this->field_108 = 0.0;
+  this->field_138 = 0.0;
+  this->field_168 = 0.0;
+  this->field_198 = 0.0;
+  this->field_1C8 = 0.0;
+  this->field_1F8 = 0.0;
+  this->field_228 = 0.0;
+  this->field_258 = 0.0;
+  this->field_288 = 0.0;
+  this->field_2B8 = 0.0;
+  this->field_2E8 = 0.0;
+  this->field_2BC = 0.0;
+  this->field_2C0 = 0.0;
+  this->field_2C4 = 0.0;
+  this->field_318 = 0.0;
+  this->field_2EC = 0.0;
+  this->field_2F0 = 0.0;
+  this->field_2F4 = 0.0;
+  this->field_348 = 0.0;
+  this->field_31C = 0.0;
+  this->field_320 = 0.0;
+  this->field_324 = 0.0;
+  this->field_378 = 0.0;
+  this->field_34C = 0.0;
+  this->field_350 = 0.0;
+  this->field_354 = 0.0;
   for (uint i = 0; i < 16384; ++i)
   {
     list_0037C[i].field_0 = 0;
     list_0037C[i].flt_30 = 0.0f;
   }
-
   list_0037C_size = 0;
   for (uint i = 0; i < 256; ++i)
     list_E0380[i].mm7__vector_000004_size = 0;
-  /*v10 = v1->list_E0380;
-  v12 = 256;
-  do
-  {
-    v10->mm7__vector_000004_size = 0;
-    //mm7__vector_constructor(
-    //  v10->mm7__vector_000004,
-    //  48,
-    //  64,
-    //  (int ( *)(int))IndoorCameraD3D_stru1::IndoorCameraD3D_stru1);
-    //++v10;
-    --v12;
-  }
-  while ( v12 );*/
   list_E0380_size = 0;
-  //v1->vdestructor_ptr = &stru8_pvdtor;
 }
 
 
@@ -786,37 +741,20 @@
 void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *out)
 {
   float *v4; // ecx@1
-  float *v5; // eax@1
-  signed int v6; // ebx@1
-  float *v7; // edx@2
-  float *v8; // ecx@2
-  signed int v9; // edi@2
   double v10; // st7@3
   double v11; // st6@3
 
   v4 = (float *)out;
-  v5 = &a1->_12;
-  v6 = 3;
-  do
+  for ( uint i = 0; i < 3; i++ )
   {
-    v7 = v4;
-    v8 = &a2->_21;
-    v9 = 3;
-    do
+    for ( uint j = 0; j < 3; j++ )
     {
-      v10 = v8[3] * v5[1] + *(v8 - 3) * *(v5 - 1);
-      v11 = *v8 * *v5;
-      ++v8;
-      *v7 = v10 + v11;
-      ++v7;
-      --v9;
+      v10 = a2->v[2][j] * a1->v[i][2] + a2->v[0][j] * a1->v[i][0];
+      v11 = a2->v[1][j] * a1->v[i][1];
+      *v4 = v10 + v11;
+      ++v4;
     }
-    while ( v9 );
-    v5 += 3;
-    --v6;
-    v4 = v7;
   }
-  while ( v6 );
 }
 
 //----- (004376E7) --------------------------------------------------------
@@ -946,56 +884,57 @@
 //----- (00437376) --------------------------------------------------------
 char IndoorCameraD3D::_437376(stru154 *thisa, RenderVertexSoft *a2, unsigned int *pOutNumVertices)
 {
-  unsigned int v4; // ebx@1
-  RenderVertexSoft *v5; // edx@2
+  //unsigned int v4; // ebx@1
+  //RenderVertexSoft *v5; // edx@2
   double v6; // st7@3
-  unsigned int v7; // edi@5
+  //unsigned int v7; // edi@5
   signed int v8; // esi@6
   int v9; // ebx@8
   int v10; // eax@8
-  int v11; // ecx@14
-  int v12; // eax@14
+  //int v11; // ecx@14
+  //int v12; // eax@14
   int v13; // eax@15
   signed int v14; // ebx@17
-  RenderVertexSoft *v15; // eax@18
+  //RenderVertexSoft *v15; // eax@18
   unsigned int *v16; // eax@20
   char result; // al@24
   RenderVertexSoft v18; // [sp+Ch] [bp-34h]@2
   int v19; // [sp+3Ch] [bp-4h]@8
   signed int thisb; // [sp+48h] [bp+8h]@6
-  char a2_3; // [sp+4Fh] [bp+Fh]@5
+  bool a2_3; // [sp+4Fh] [bp+Fh]@5
 
-  v4 = *pOutNumVertices;
+  //v4 = *pOutNumVertices;
+  //v5 = a2;
+  memcpy(&v18, a2, sizeof(v18));
+  a2_3 = false;
+  memcpy(&a2[*pOutNumVertices], a2, sizeof(a2[*pOutNumVertices]));
+  memcpy(&a2[*pOutNumVertices + 1], &a2[1], sizeof(a2[*pOutNumVertices + 1]));
+  //v7 = *pOutNumVertices;
+
   if ( (signed int)*pOutNumVertices <= 3
-    || ((v5 = a2,
-         memcpy(&v18, a2, sizeof(v18)),
-         (v18.vWorldPosition.z - (double)pGame->pIndoorCameraD3D->vPartyPos.z) * thisa->face_plane.vNormal.z
+    || (((v18.vWorldPosition.z - (double)pGame->pIndoorCameraD3D->vPartyPos.z) * thisa->face_plane.vNormal.z
        + (v18.vWorldPosition.y - (double)pGame->pIndoorCameraD3D->vPartyPos.y) * thisa->face_plane.vNormal.y
        + (v18.vWorldPosition.x - (double)pGame->pIndoorCameraD3D->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])),
-        v7 = *pOutNumVertices,
         (signed int)*pOutNumVertices <= 0) )
-    goto LABEL_28;
+    return 0;
   v8 = 1;
-  for ( thisb = 1; ; v8 = thisb )
+  for ( thisb = 1; thisb - 1 < (signed int)*pOutNumVertices; v8 = thisb )
   {
     v9 = v8 - 1;
     v10 = v8 + 1;
     v19 = v8 + 1;
-    if ( v8 - 1 >= (signed int)v7 )
-      v9 -= v7;
-    if ( v8 >= (signed int)v7 )
-      v8 -= v7;
-    if ( v19 >= (signed int)v7 )
-      v10 = v19 - v7;
-    v11 = (int)&v5[v10];
-    v12 = (int)&v5[v9];
-    if ( -0.009999999776482582 > ((v5[v8].vWorldViewProjX - *(float *)(v12 + 24))
-                                * (*(float *)(v11 + 28) - *(float *)(v12 + 28))
-                                - (v5[v8].vWorldViewProjY - *(float *)(v12 + 28))
-                                * (*(float *)(v11 + 24) - *(float *)(v12 + 24)))
+    if ( v8 - 1 >= (signed int)*pOutNumVertices )
+      v9 -= *pOutNumVertices;
+    if ( v8 >= (signed int)*pOutNumVertices )
+      v8 -= *pOutNumVertices;
+    if ( v19 >= (signed int)*pOutNumVertices )
+      v10 = v19 - *pOutNumVertices;
+    //v11 = (int)&a2[v10];
+    //v12 = (int)&a2[v9];
+    if ( -0.009999999776482582 > ((a2[v8].vWorldViewProjX - a2[v9].vWorldViewProjX)
+                                * (a2[v10].vWorldViewProjY - a2[v9].vWorldViewProjY)
+                                - (a2[v8].vWorldViewProjY - a2[v9].vWorldViewProjY)
+                                * (a2[v10].vWorldViewProjX - a2[v9].vWorldViewProjX))
                                * v6 )
     {
       thisb = v19;
@@ -1004,34 +943,25 @@
     else
     {
       v13 = thisb;
-      if ( thisb >= (signed int)v7 )
-        v13 = thisb - v7;
-      v14 = v13;
-      if ( v13 < (signed int)v7 )
+      if ( thisb >= (signed int)*pOutNumVertices )
+        v13 = thisb - *pOutNumVertices;
+      if ( v13 < (signed int)*pOutNumVertices )
       {
-        v15 = &v5[v13];
-        do
-        {
-          memcpy(v15, &v15[1], 0x30u);
-          ++v14;
-          ++v15;
-        }
-        while ( v14 < (signed int)*pOutNumVertices );
+        for ( v14 = v13; v14 < (signed int)*pOutNumVertices; ++v14 )
+          memcpy(&a2[v14], &a2[v14 + 1], sizeof(a2[v14]));
       }
       v16 = pOutNumVertices;
-      a2_3 = 1;
+      a2_3 = true;
       --*v16;
     }
-    v7 = *v16;
-    if ( thisb - 1 >= (signed int)*v16 )
-      break;
+    *pOutNumVertices = *v16;
+    //if ( thisb - 1 >= (signed int)*v16 )
+      //break;
   }
   if ( a2_3 )
-    result = 1;
+    return true;
   else
-LABEL_28:
-    result = 0;
-  return result;
+    return false;
 }
 
 //----- (00437285) --------------------------------------------------------
@@ -1162,42 +1092,22 @@
 // 50F1E0: using guessed type char static_sub_4371C3_byte_50F1E0_init_flags;
 
 //----- (00437143) --------------------------------------------------------
-int IndoorCameraD3D::_437143(unsigned int uNumInVertices, RenderVertexSoft *pOutVertices, RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices)
+void IndoorCameraD3D::_437143(unsigned int uNumInVertices, RenderVertexSoft *pOutVertices, RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices)
 {
-  unsigned int v5; // edi@1
-  char *pOutVertices_; // edx@2
-  char *v7; // eax@2
-  unsigned int v8; // ebx@2
   double v9; // st7@3
-  double v10; // st6@3
-  int result; // eax@5
-  unsigned int a2a; // [sp+10h] [bp+Ch]@2
 
-  v5 = uNumInVertices;
-  if ( (signed int)uNumInVertices > 0 )
+  uint i = 0;
+
+  for ( i; i < uNumInVertices; ++i )
   {
-    pOutVertices_ = (char *)&pOutVertices->vWorldViewProjY;
-    v7 = (char *)&pInVertices->_rhw;
-    v8 = (char *)pOutVertices - (char *)pInVertices;
-    a2a = uNumInVertices;
-    do
-    {
-      *(float *)v7 = 1.0 / (*((float *)v7 - 5) + 0.0000001);
-      memcpy(pOutVertices_ - 28, v7 - 32, 0x30u);
-      v9 = (double)pODMRenderParams->int_fov_rad * *(float *)&v7[v8];
-      v10 = (double)pViewport->uScreenCenterX - v9 * *((float *)v7 - 4);
-      v7 += 48;
-      *((float *)pOutVertices_ - 1) = v10;
-      *(float *)pOutVertices_ = (double)pViewport->uScreenCenterY - v9 * *((float *)v7 - 15);
-      pOutVertices_ += 48;
-      --a2a;
-    }
-    while ( a2a );
-    v5 = uNumInVertices;
+    pInVertices[i]._rhw = 1.0 / (pInVertices[i].vWorldViewPosition.x + 0.0000001);
+    memcpy(&pOutVertices[i], &pInVertices[i], sizeof(pOutVertices[i]));
+    v9 = (double)pODMRenderParams->int_fov_rad * pInVertices[i]._rhw;
+    pOutVertices[i].vWorldViewProjX = (double)pViewport->uScreenCenterX - v9 * pInVertices[i].vWorldViewPosition.y;
+    pOutVertices[i].vWorldViewProjY = (double)pViewport->uScreenCenterY - v9 * pInVertices[i].vWorldViewPosition.z;
   }
-  result = (int)pOutNumVertices;
-  *pOutNumVertices = v5;
-  return result;
+  *pOutNumVertices = i;
+  return;
 }
 
 //----- (00436F09) --------------------------------------------------------
--- a/IndoorCameraD3D.h	Mon Feb 24 16:54:21 2014 +0600
+++ b/IndoorCameraD3D.h	Tue Feb 25 20:02:06 2014 +0600
@@ -140,7 +140,7 @@
   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);
+  void _437143(unsigned int uNumInVertices, struct RenderVertexSoft *pOutVertices, struct RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices);
   bool _4371C3(struct RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused);
   bool CalcPortalShape(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);
--- a/LightmapBuilder.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/LightmapBuilder.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -65,10 +65,7 @@
       memcpy(static_69B140 + i, a5 + i, sizeof(RenderVertexSoft));
 
     //__debugbreak();
-    if (pGame->pIndoorCameraD3D->_437376(
-           a3,
-           static_69B140,
-           &uNumVertices) == 1)
+    if (pGame->pIndoorCameraD3D->_437376(a3, static_69B140, &uNumVertices) == 1)
     {
       if ( !uNumVertices )
         return false;
@@ -81,11 +78,8 @@
   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))
+  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);
@@ -104,16 +98,8 @@
     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) )
+    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) )
     {
       MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0);
     }
@@ -466,76 +452,62 @@
 //----- (0045C6D6) --------------------------------------------------------
 int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap)
 {
-  Lightmap *v4; // edi@1
-  signed int v5; // ebx@1
   signed int v6; // esi@1
-  RenderVertexSoft *v7; // ecx@2
-  char *v8; // edx@4
   double v9; // st7@6
   double v10; // st6@10
   double v11; // st5@14
   double v12; // st7@17
-  RenderVertexSoft *v13; // eax@21
   int v15; // [sp+Ch] [bp-8h]@1
   float v16; // [sp+10h] [bp-4h]@1
-  int pLightmapa; // [sp+24h] [bp+10h]@3
 
-  v4 = pLightmap;
-  v5 = 0;
   v6 = -1;
   v16 = 3.4028235e38;
   v15 = 0;
   if ( (signed int)pLightmap->uNumVertices > 0 )
   {
-    v7 = pLightmap->pVertices;
-    do
+    for ( uint i = 0; i < (signed int)pLightmap->uNumVertices; ++i )
     {
-      pLightmapa = 0;
       if ( a2 > 0 )
       {
-        v8 = (char *)&a3->vWorldPosition.z;
-        do
+        for ( uint j = 0; j < a2; ++j )
         {
-          if ( v7->vWorldPosition.x <= (double)*((float *)v8 - 2) )
-            v9 = *((float *)v8 - 2) - v7->vWorldPosition.x;
+          if ( pLightmap->pVertices[i].vWorldPosition.x <= (double)a3[j].vWorldPosition.x )
+            v9 = a3[j].vWorldPosition.x - pLightmap->pVertices[i].vWorldPosition.x;
           else
-            v9 = v7->vWorldPosition.x - *((float *)v8 - 2);
+            v9 = pLightmap->pVertices[i].vWorldPosition.x - a3[j].vWorldPosition.x;
           if ( v9 < 2.0 )
           {
-            v10 = v7->vWorldPosition.y <= (double)*((float *)v8 - 1) ? *((float *)v8 - 1) - v7->vWorldPosition.y : v7->vWorldPosition.y - *((float *)v8 - 1);
+            v10 = pLightmap->pVertices[i].vWorldPosition.y <= (double)a3[j].vWorldPosition.y
+                ? a3[j].vWorldPosition.y - pLightmap->pVertices[i].vWorldPosition.y
+                : pLightmap->pVertices[i].vWorldPosition.y - a3[j].vWorldPosition.y;
             if ( v10 < 2.0 )
             {
-              v11 = v7->vWorldPosition.z <= (double)*(float *)v8 ? *(float *)v8 - v7->vWorldPosition.z : v7->vWorldPosition.z - *(float *)v8;
+              v11 = pLightmap->pVertices[i].vWorldPosition.z <= (double)a3[j].vWorldPosition.z
+                  ? a3[j].vWorldPosition.z - pLightmap->pVertices[i].vWorldPosition.z
+                  : pLightmap->pVertices[i].vWorldPosition.z - a3[j].vWorldPosition.z;
               if ( v11 < 2.0 )
               {
                 v12 = v9 + v11 + v10;
                 if ( v12 < v16 )
                 {
                   v16 = v12;
-                  v6 = pLightmapa;
+                  v6 = j;
                 }
               }
             }
           }
-          ++pLightmapa;
-          v8 += 48;
         }
-        while ( pLightmapa < a2 );
         if ( v6 != -1 )
         {
-          v13 = &a3[v6];
           ++v15;
-          v7->vWorldPosition.x = v13->vWorldPosition.x;
-          v7->vWorldPosition.y = v13->vWorldPosition.y;
-          v7->vWorldPosition.z = v13->vWorldPosition.z;
+          pLightmap->pVertices[i].vWorldPosition.x = a3[v6].vWorldPosition.x;
+          pLightmap->pVertices[i].vWorldPosition.y = a3[v6].vWorldPosition.y;
+          pLightmap->pVertices[i].vWorldPosition.z = a3[v6].vWorldPosition.z;
         }
       }
       v6 = -1;
-      ++v5;
-      ++v7;
       v16 = 3.4028235e38;
     }
-    while ( v5 < (signed int)v4->uNumVertices );
   }
   return v15;
 }
--- a/Render.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/Render.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -3567,64 +3567,73 @@
   int v30; // ebx@60
   int v31; // edx@61
   int v32; // edi@61
-  __int64 v36; // [sp+14h] [bp-8h]@1
   signed int upper_bound; // [sp+18h] [bp-4h]@28
   unsigned int uXa; // [sp+24h] [bp+8h]@49
   int uYb; // [sp+28h] [bp+Ch]@47
-
-  v36 = 0i64;
+  bool left_border_x = false;
+  bool right_border_x = false;
+  bool left_border_z = false;
+  bool right_border_z = false;
+  bool upper_border_y = false;
+  bool bottom_border_y = false;
+  bool upper_border_w = false;
+  bool bottom_border_w = false;
+
   if ( uX < this->raster_clip_x )// x выходит за рамки левой границы
-    HIDWORD(v36) = 8; //left_border = true;
+    left_border_x = true;
   if ( uX > this->raster_clip_z )// x выходит за рамки правой границы
-    HIDWORD(v36) |= 4;//right_border = true;
+    right_border_x = true;
 
   if ( uZ < this->raster_clip_x )// z выходит за рамки левой границы
-    LODWORD(v36) = 8;//
+    left_border_z = true;
   if ( uZ > this->raster_clip_z )// z выходит за рамки правой границы
-    LODWORD(v36) |= 4;
+    right_border_z = true;
 
   if ( uY < this->raster_clip_y )// y выходит за рамки верхней границы
-    HIDWORD(v36) |= 2;//upper_border = true;
+    upper_border_y = true;
   if ( uY > this->raster_clip_w )// y выходит за рамки нижней границы
-    HIDWORD(v36) |= 1;//bottom_border = true;
+    bottom_border_y = true;
 
   if ( uW < this->raster_clip_y )// w выходит за рамки верхней границы
-    LODWORD(v36) |= 2;
+    upper_border_w = true;
   if ( uW > this->raster_clip_w )// w выходит за рамки нижней границы
-    LODWORD(v36) |= 1;
-
-  //LOBYTE(v12) = v36;
-  if ( (unsigned int)v36 & HIDWORD(v36) )
+    bottom_border_w = true;
+
+  if ( (left_border_x && left_border_z) || (right_border_x && right_border_z )
+    || (upper_border_y && upper_border_w) || (bottom_border_y && bottom_border_w))
     return;
 
-  if ( v36 ) //не полностью в рамках
-  {
-    if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left and right(левая и правая)
-    {
-      if ( BYTE4(v36) & 8 )//left_border = true;
-      {
-        uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
+  if ( left_border_x || left_border_z || right_border_x || right_border_z
+    || upper_border_y || upper_border_w || bottom_border_y || bottom_border_w)
+  {
+    if ( left_border_x || left_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left (левая граница)
+    {
+      if ( left_border_x )//left_border = true; х меньше левой границы
+      {
+        uY += (uW - uY) * ((this->raster_clip_x - uX) / (uZ - uX));//t = near_clip - v0.x / v1.x - v0.x  (формула получения точки пересечения отрезка с плоскостью)
         uX = this->raster_clip_x;
       }
-      else
+      else if ( left_border_z )//z меньше левой границы
       {
         uZ = this->raster_clip_x;
-        uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ);
-      }
-    }
-    if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
-    {
-      if ( BYTE4(v36) & 4 ) //right_border = true
-      {
-        uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX);
+        uW += (uY - uW) * ((this->raster_clip_x - uZ) / (uX - uZ));
+      }
+    }
+
+    if ( right_border_x || right_border_z )//if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )//for right (правая граница)
+    {
+      if ( right_border_x ) //right_border = true; х больше правой границы
+      {
+        uY += (uY - uW) * ((this->raster_clip_z - uX) / (uZ - uX));
         uX = this->raster_clip_z;
       }
-      else
-      {
-        uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ);
+      else if ( right_border_z )//z больше правой границы
+      {
+        uW += (uW - uY) * ((this->raster_clip_z - uZ) / (uX - uZ));
         uZ = this->raster_clip_z;
       }
     }
+
     upper_bound = 0;
     if ( uY < this->raster_clip_y )
       upper_bound = 2;
@@ -3644,12 +3653,12 @@
       {
         if ( upper_bound & 2 )
         {
-          uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY);
+          uX += (uZ - uX) * ((this->raster_clip_y - uY) / (uW - uY));
           uY = this->raster_clip_y;
         }
         else
         {
-          uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW);
+          uZ += (uX - uZ) * ((this->raster_clip_y - uW) / (uY - uW));
           uW = this->raster_clip_y;
         }
       }
@@ -3657,12 +3666,12 @@
       {
         if ( upper_bound & 1 )
         {
-          uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY);
+          uX += (uZ - uX) * ((this->raster_clip_w - uY) / (uW - uY));
           uY = this->raster_clip_w;
         }
         else
         {
-          uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW);
+          uZ += (uX - uZ) * ((this->raster_clip_w - uW) / (uY - uW));
           uW = this->raster_clip_w;
         }
       }
@@ -3766,7 +3775,7 @@
 //----- (004A0E80) --------------------------------------------------------
 void Render::ClearZBuffer(int a2, int a3)
 {
-  memset32(this->pActiveZBuffer, -65536, 0x4B000u);
+  memset32(this->pActiveZBuffer, -65536, 0x4B000);
 }
 
 //----- (004A0E97) --------------------------------------------------------
--- a/TurnEngine.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/TurnEngine.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -918,48 +918,29 @@
 //----- (00406D10) --------------------------------------------------------
 bool stru262_TurnBased::ActorMove(signed int queue_position)
 {
-  //int v2; // ecx@1
-  //int v3; // ecx@2
-  //Actor *actor; // ebx@2
   AIDirection v9; // esi@10
-  //int v10; // eax@10
   int v11; // ecx@10
   unsigned __int8 pHostileType; // al@12
   AIDirection a3; // [sp+Ch] [bp-48h]@10
   AIDirection pDir; // [sp+28h] [bp-2Ch]@10
-  //int v28; // [sp+48h] [bp-Ch]@10
-  //TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7
   unsigned int uActorID; // [sp+50h] [bp-4h]@2
-  //unsigned int a2a; // [sp+5Ch] [bp+8h]@7
 
-  // __debugbreak();//срабатывает при пошаговом режиме после пяти шагов
-  //v2 = pQueue[queue_position].uPackedID;
   if (PID_TYPE(pQueue[queue_position].uPackedID) == OBJECT_Player)
     return 0;
   uActorID = PID_ID(pQueue[queue_position].uPackedID);
-  //uActorID = v3;
-  //actor = &pActors[uActorID];
-  //v5 = v4->uAIState;
   if ( pActors[uActorID].uAIState == AIState::Dead || pActors[uActorID].uAIState ==  AIState::Dying || 
        pActors[uActorID].uAIState == AIState::Removed|| pActors[uActorID].uAIState == AIState::Disabled || 
        pActors[uActorID].uAIState == AIState::Summoned  )
     return 1;
-  //v29 = &pTurnEngine->pQueue[queue_position];
-  //a2a = ai_near_actors_targets_pid[uActorID];
   Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true);
   if ( pActors[uActorID].pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[uActorID] )
     pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly;
   Actor::GetDirectionInfo(pQueue[queue_position].uPackedID, ai_near_actors_targets_pid[uActorID], &v9, 0);
-  //v10 = pActors[uActorID].uActorRadius;
   memcpy(&a3, &v9, sizeof(AIDirection));
   memcpy(&pDir, &a3, sizeof(AIDirection));
   v11 = a3.uDistance - pActors[uActorID].uActorRadius;
-  //v28 = a3.uDistance - pActors[uActorID].uActorRadius;
   if ( v11 < 0 )
-  {
     v11 = 0;
-    //v28 = 0;
-  }
   pHostileType = pActors[uActorID].pMonsterInfo.uHostilityType;
   switch (pHostileType)
   {
--- a/mm7_4.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/mm7_4.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -2143,7 +2143,7 @@
 {
   const char *v2; // edi@1
 
-  __debugbreak();
+  //__debugbreak();
   uDialogueType = DIALOGUE_SKILL_TRAINER;
   current_npc_text = (char *)pNPCTopics[a4 + 168].pText;
   _4B254D_SkillMasteryTeacher(a4);  //might be needed because of contract_approved ?
@@ -2155,7 +2155,7 @@
   v2 = "";
   if ( contract_approved )
     v2 = pGlobalTXT_LocalizationStrings[535];
-  pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0);
+  pDialogueWindow->CreateButton(480, 160, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0);
   pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
--- a/mm7_5.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/mm7_5.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -556,9 +556,7 @@
       v6 = 0;
   }
   else
-  {
     v6 = 31;
-  }
   return v6;
 }
 
--- a/mm7_6.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/mm7_6.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -211,9 +211,7 @@
     result = a3;
   }
   else
-  {
     result = 0;
-  }
   return result;
 }
 
@@ -279,7 +277,6 @@
   }
 }
 
-
 //----- (0042EBDB) --------------------------------------------------------
 int stru193_math::Sin(int angle)
 {
@@ -289,46 +286,12 @@
 //----- (0042ECB5) --------------------------------------------------------
 void _42ECB5_PlayerAttacksActor()
 {
-  //unsigned int v0; // ebx@1
-  //Player *v1; // esi@1
-  //bool result; // eax@1
-  //int v3; // edi@2
-  //unsigned int v4; // eax@7
   char *v5; // eax@8
-  //int v6; // ecx@9
-  //signed int v7; // eax@16
-  //Actor *v8; // edi@20
   unsigned int v9; // ecx@21
-  //char *v10; // eax@26
   char *v11; // eax@26
   unsigned int v12; // eax@47
-  //char *v13; // eax@47
-  //char *v14; // eax@47
-  //unsigned int v15; // ebx@54
-  //int v16; // [sp-10h] [bp-4Ch]@24
-  //int v17; // [sp-10h] [bp-4Ch]@44
-  //unsigned int v18; // [sp-Ch] [bp-48h]@24
-  //unsigned int v19; // [sp-Ch] [bp-48h]@44
-  //__int16 v20; // [sp-8h] [bp-44h]@24
-  //__int16 v21; // [sp-8h] [bp-44h]@44
-  //int v22; // [sp-4h] [bp-40h]@24
-  //int v23; // [sp-4h] [bp-40h]@44
   SoundID v24; // [sp-4h] [bp-40h]@58
-  //Vec3_int_ a3; // [sp+Ch] [bp-30h]@19
-  //unsigned int a2; // [sp+18h] [bp-24h]@20
-  //unsigned int v27; // [sp+1Ch] [bp-20h]@1
-  //int v28; // [sp+20h] [bp-1Ch]@9
-  //unsigned int *v28b;
-  //int v29; // [sp+24h] [bp-18h]@16
-  //int v30; // [sp+28h] [bp-14h]@16
-  //int v31; // [sp+2Ch] [bp-10h]@4
-  //int v32; // [sp+30h] [bp-Ch]@7
-  //int v33; // [sp+34h] [bp-8h]@7
-  //int v34; // [sp+38h] [bp-4h]@17
 
-  //v0 = uActiveCharacter;
-  //v27 = 6972 * uActiveCharacter;
-  //v1 = &pParty->pPlayers[uActiveCharacter-1];
   //result = pParty->pPlayers[uActiveCharacter-1].CanAct();
   Player* player = &pParty->pPlayers[uActiveCharacter - 1];
   if (!player->CanAct())
--- a/mm7_7.cpp	Mon Feb 24 16:54:21 2014 +0600
+++ b/mm7_7.cpp	Tue Feb 25 20:02:06 2014 +0600
@@ -37,7 +37,6 @@
 //----- (00423B4A) --------------------------------------------------------
 void  sub_423B4A()
 {
-	//__debugbreak();//Ritor1
   for ( uint i = 0; i < 50; i++ )
     array_507D30[i].flt_2C = 0.0;
 }