changeset 1816:9442b7c19a64

Merge
author Nomad
date Tue, 08 Oct 2013 11:06:24 +0200
parents bd899dfd976c (current diff) 6de366add757 (diff)
children 24b70fa98474 0b44f4d67c18
files
diffstat 5 files changed, 130 insertions(+), 385 deletions(-) [+]
line wrap: on
line diff
--- a/Indoor.cpp	Tue Oct 08 11:04:08 2013 +0200
+++ b/Indoor.cpp	Tue Oct 08 11:06:24 2013 +0200
@@ -5179,14 +5179,14 @@
   {
     v19 = fixpoint_mul(a2, v8) + fixpoint_mul(a3, v29);
 
-    this->field_C = fixpoint_mul(v19, v28) + fixpoint_mul(a4, v9);
-    this->field_10 = fixpoint_mul(a3, v8) - fixpoint_mul(a2, v29);
+    this->angle_from_north = fixpoint_mul(v19, v28) + fixpoint_mul(a4, v9);
+    this->angle_from_west = fixpoint_mul(a3, v8) - fixpoint_mul(a2, v29);
     this->field_14 = fixpoint_mul(a4, v28) - fixpoint_mul(v19, v9);
   }
   else
   {
-    this->field_C = fixpoint_mul(a2, v8) + fixpoint_mul(a3, v29);
-    this->field_10 = fixpoint_mul(a3, v8) - fixpoint_mul(a2, v29);
+    this->angle_from_north = fixpoint_mul(a2, v8) + fixpoint_mul(a3, v29);
+    this->angle_from_west = fixpoint_mul(a3, v8) - fixpoint_mul(a2, v29);
     this->field_14 = a4;
   }
 
@@ -5194,26 +5194,26 @@
   {
     v21 = fixpoint_mul(a5, v8) + fixpoint_mul(a6, v29);
 
-    this->field_18 = fixpoint_mul(v21, v28) + fixpoint_mul(a7, v9);
-    this->field_1C = fixpoint_mul(a6, v8) - fixpoint_mul(a5, v29);
+    this->angle_from_east = fixpoint_mul(v21, v28) + fixpoint_mul(a7, v9);
+    this->angle_from_south = fixpoint_mul(a6, v8) - fixpoint_mul(a5, v29);
     this->field_20 = fixpoint_mul(a7, v28) - fixpoint_mul(v21, v9);
   }
   else
   {
-    this->field_18 = fixpoint_mul(a5, v8) + fixpoint_mul(a6, v29);
-    this->field_1C = fixpoint_mul(a6, v8) - fixpoint_mul(a5, v29);
+    this->angle_from_east = fixpoint_mul(a5, v8) + fixpoint_mul(a6, v29);
+    this->angle_from_south = fixpoint_mul(a6, v8) - fixpoint_mul(a5, v29);
     this->field_20 = a7;
   }
 
-  this->field_18 = -this->field_18;
-  this->field_1C = -this->field_1C;
+  this->angle_from_east = -this->angle_from_east;
+  this->angle_from_south = -this->angle_from_south;
   this->field_20 = -this->field_20;
 
-  this->field_24 = fixpoint_dot(this->field_C,  this->field_0_party_dir_x,
-                                this->field_10, this->field_4_party_dir_y,
+  this->field_24 = fixpoint_dot(this->angle_from_north,  this->field_0_party_dir_x,
+                                this->angle_from_west, this->field_4_party_dir_y,
                                 this->field_14, this->field_8_party_dir_z);
-  this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x,
-                                this->field_1C, this->field_4_party_dir_y,
+  this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
+                                this->angle_from_south, this->field_4_party_dir_y,
                                 this->field_20, this->field_8_party_dir_z);
 }
 //----- (00407A1C) --------------------------------------------------------
--- a/Outdoor_stuff.h	Tue Oct 08 11:04:08 2013 +0200
+++ b/Outdoor_stuff.h	Tue Oct 08 11:06:24 2013 +0200
@@ -75,11 +75,11 @@
   int field_0_party_dir_x;
   int field_4_party_dir_y;
   int field_8_party_dir_z;
-  int field_C;
-  int field_10;
+  int angle_from_north;//field_C
+  int angle_from_west;//field_10
   int field_14;
-  int field_18;
-  int field_1C;
+  int angle_from_east;//field_18
+  int angle_from_south;//field_1C
   int field_20;
   int field_24;
   int field_28;
--- a/Render.cpp	Tue Oct 08 11:04:08 2013 +0200
+++ b/Render.cpp	Tue Oct 08 11:06:24 2013 +0200
@@ -5161,11 +5161,11 @@
   {
     v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY));
     v77 = (unsigned __int64)(v62.ptr_38->field_14 * (signed __int64)(signed int)v15) >> 16;
-    v74 = v77 + v62.ptr_38->field_C;
+    v74 = v77 + v62.ptr_38->angle_from_north;
     v77 = (int)v15;
     v77 = (unsigned __int64)(v62.ptr_38->field_20 * (signed __int64)(signed int)v15) >> 16;
     v79 = v15;
-    v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
+    v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->angle_from_east);
     v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
     v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX);
     v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0;
@@ -5201,8 +5201,8 @@
       v79 = (void *)(v23 / X);
       v77 = v17;
       v77 = v17;
-      LODWORD(v76) = v74 + ((unsigned __int64)(v62.ptr_38->field_10 * (signed __int64)v17) >> 16);
-      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v62.ptr_38->field_1C * (signed __int64)v17) >> 16));
+      LODWORD(v76) = v74 + ((unsigned __int64)(v62.ptr_38->angle_from_west * (signed __int64)v17) >> 16);
+      v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v62.ptr_38->angle_from_south * (signed __int64)v17) >> 16));
       v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
       LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
       //v14 += 48;
@@ -5277,13 +5277,13 @@
     v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34));
     v78 = v62.ptr_38->field_14;
     v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
-    v36 = (int)((char *)v81 + v62.ptr_38->field_C);
+    v36 = (int)((char *)v81 + v62.ptr_38->angle_from_north);
     v81 = v35;
     v74 = v36;
     v78 = v62.ptr_38->field_20;
     v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
     v78 = (int)v35;
-    v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18);
+    v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->angle_from_east);
     v81 = (const void *)v62.v_18.z;
     v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16;
     v37 = (const void *)(v72
@@ -5326,12 +5326,12 @@
     HIDWORD(v42) = v77 >> 16;
     v79 = (void *)(v42 / X);
     v81 = v37;
-    v78 = v62.ptr_38->field_10;
+    v78 = v62.ptr_38->angle_from_west;
     v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
     v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
     v74 = (unsigned int)v37;
     LODWORD(v76) = v43;
-    v78 = v62.ptr_38->field_1C;
+    v78 = v62.ptr_38->angle_from_south;
     v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16));
     v74 = (unsigned __int64)(v43 * v42 / X) >> 16;
     v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16);
--- a/mm7_3.cpp	Tue Oct 08 11:04:08 2013 +0200
+++ b/mm7_3.cpp	Tue Oct 08 11:06:24 2013 +0200
@@ -4879,69 +4879,51 @@
 //----- (00479543) --------------------------------------------------------
 void Render::DrawSkyD3D()
 {
-  int v0; // esi@2
-  int v1; // eax@2
-  int v8; // eax@4
   int v9; // eax@4
   int v10; // ebx@4
-  signed __int64 v11; // qax@6
   int v13; // edi@6
   int v14; // ecx@6
+  int v15; // eax@8
   int v16; // eax@12
-  //signed __int64 v17; // qtt@13
-  signed int pShading; // ecx@13
+  signed __int64 v17; // qtt@13
+  signed int v18; // ecx@13
   struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
-  float v28; // [sp+12Ch] [bp-38h]@2
-  int v29; // [sp+130h] [bp-34h]@4
+  double v26; // [sp+120h] [bp-44h]@4
   int v30; // [sp+134h] [bp-30h]@1
   int v32; // [sp+13Ch] [bp-28h]@6
   int v33; // [sp+140h] [bp-24h]@2
-  int v34; // [sp+144h] [bp-20h]@1
+  signed __int64 v34; // [sp+144h] [bp-20h]@1
   int v35; // [sp+148h] [bp-1Ch]@4
-  int screen_center_x; // [sp+14Ch] [bp-18h]@2
+  int v36; // [sp+14Ch] [bp-18h]@2
   int v37; // [sp+154h] [bp-10h]@8
-  int pViewportBR_Y; // [sp+158h] [bp-Ch]@1
+  int v38; // [sp+158h] [bp-Ch]@1
   int v39; // [sp+15Ch] [bp-8h]@4
-  //int v40; // [sp+160h] [bp-4h]@7
-
-//Хотя сами двухмерные изображения основаны на системе координат XY, накладываются  текстуры  на объект, основанный на
-//осях координат U (горизонталь) и V (вертикаль), обхватывающих поверхность объекта.
-
-  extern bool new_sky;
-  if (new_sky)
-  {
-    if (DrawSkyD3D_Skybox())
-    return;
-  }
-
-  v30 = ((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z)
-        / ((double)pODMRenderParams->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);//184 изменяется при подъёме на высоту
-  pViewportBR_Y = pViewport->uScreenCenterY - pODMRenderParams->int_fov_rad /
-       (pODMRenderParams->shading_dist_mist *  cos(pGame->pIndoorCameraD3D->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) *
-       (pODMRenderParams->shading_dist_mist * -sin(pGame->pIndoorCameraD3D->sRotationX * 0.003066406352445483) - pGame->pIndoorCameraD3D->vPartyPos.z);//61 / 184 / 310 изменяется при наклоне камеры
-
-  pSkyPolygon.Create_48607B(&stru_8019C8);
-  pSkyPolygon.ptr_38->_48694B_frustum_sky();//maybe creating skydome(возможно создание купола неба)
-  pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;//номер текстуры
-  pSkyPolygon.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//текстура неба
-  if (pOutdoor->uSky_TextureID == -1)
-    return;
-
-  pSkyPolygon.dimming_level = 0;//затемнение
-  pSkyPolygon.uNumVertices = 4;//количество вершин
-
-  //centering(центруем)--наклон камеры ----------------------------------------//
-  pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);//-3216, вверх: -28020, вниз: 22078
-  pSkyPolygon.v_18.y = 0;
-  pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);//-65457, вверх: -59244, вниз: -61705
-  //---------------------------------------------------------------------------//
-
-  pSkyPolygon.field_24 = 0x2000000;
-
-  pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//60928
-  pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
+  int v40; // [sp+160h] [bp-4h]@7
+
+  v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z)
+                       / ((double)pODMRenderParams->int_fov_rad + 8192.0)
+                       + (double)(pViewport->uScreenCenterY + 7));//include "+ 7"
+  v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;//(double)pODMRenderParams->shading_dist_mist
+  v38 = (signed __int64)((double)(pViewport->uScreenCenterY + 7)
+                       - (double)pODMRenderParams->int_fov_rad
+                       / (v34 + 0.0000001)
+                       * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064)
+                        * (double)-0x2000//(double)pODMRenderParams->shading_dist_mist
+                        - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
+  pSkyPolygon.Create_48607B(&stru_8019C8);//заполняется ptr_38
+  pSkyPolygon.ptr_38->_48694B_frustum_sky();
+  pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;//179(original 166)
+  pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
+  if ( pSkyPolygon.pTexture )
+  {
+    pSkyPolygon.dimming_level = 0;
+    pSkyPolygon.uNumVertices = 4;
+  //centering(центруем)--наклон камеры ----------------------------------------
+    pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
+    pSkyPolygon.v_18.y = 0;
+    pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX + 16);
   
-  //sky wiew position(положение неба)------------------------------------------
+  //sky wiew position(положение неба на экране)------------------------------------------
   //                X
   // 0._____________________________.3
   //  |8,8                    468,8 |
@@ -4952,248 +4934,37 @@
   //  |8,351                468,351 |
   // 1._____________________________.2
   // 
-
-  array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;//8
-  array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;//8
-
-  array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;//8
-  array_50AC10[1].vWorldViewProjY = pViewportBR_Y;//61 / 184 / 310
-
-  array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;//468
-  array_50AC10[2].vWorldViewProjY = pViewportBR_Y;//61 / 184 / 310
-
-  array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;//468
-  array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;//8
-  //--------------------------------------------------------------------------
-
-  //pParty->sRotationY / 2048.0f
-  // move sky(движение неба)--------------include(вставка)---------------------
-    float t = (GetTickCount() % 96000) / 96000.0f;
-    array_50AC10[0].u = t - pParty->sRotationY / 1024.0f;
-    array_50AC10[0].v = t - pParty->sRotationX / 512.0f;
-    
-    array_50AC10[1].u = t - pParty->sRotationY / 1024.0f;
-    array_50AC10[1].v = 1 + t - pParty->sRotationX / 512.0f;
-
-    array_50AC10[2].u = 1 + t - pParty->sRotationY / 1024.0f;
-    array_50AC10[2].v = 1 + t - pParty->sRotationX / 512.0f;
-
-    array_50AC10[3].u = 1 + t - pParty->sRotationY / 1024.0f;
-    array_50AC10[3].v = t - pParty->sRotationX / 512.0f;
-  //--------------------------------------------------------------------------//
-
-  //rotate skydome(вращение купола неба)--------------------------------------
-  // В игре принята своя система измерения углов. Полный угол в 2П радиан соответствует 65536 еденицам. Значению угла 0 соответствует 
-  // направление на восток, значению 16384(0х4000) - на север и т.д..
-
-  //нахождение вектора взгляда------------------------------------------------
-  //положение камеры----------------------------------------------------------
-  screen_center_x = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;//центр экрана по X = 230
-  v33 = 65536 / (signed int)(screen_center_x / tan(0.6457717418670654) + 0.5);//360 : (расстояние от экрана до камеры в пикселях) = 214
-  //--------------------------------------------------------------------------
-
-  for ( uint vertex_id = 0; vertex_id < pSkyPolygon.uNumVertices; ++vertex_id )
-  {
-    v29 = floorf(array_50AC10[vertex_id].vWorldViewProjY + 0.5f);//8
-    v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0
-    v8 = v39 + pSkyPolygon.ptr_38->field_C;//0
-
-    v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0
-    screen_center_x = v39 + pSkyPolygon.ptr_38->field_18;//65536
-
-    v9 = (unsigned __int64)(pSkyPolygon.v_18.z * v33 * (v30 - v29)) / 65536;//27917
-    v10 = pSkyPolygon.v_18.x + v9;//24701
-    v39 = pSkyPolygon.v_18.x + v9;//24701
-    if ( pSkyPolygon.v_18.x + v9 > 0 )
-    {
-      v10 = 0;
-      v39 = 0;
-    }
-    //v11 = (signed __int64)array_50AC10[i].vWorldViewProjX;
-    pViewportBR_Y = v10;
-    //v12 = array_50AC10[i].vWorldViewProjY - 1.0;
-    v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[vertex_id].vWorldViewProjX);
-    v34 = -pSkyPolygon.field_24;
-    v32 = (signed __int64)array_50AC10[vertex_id].vWorldViewProjY - 1.0;
-    v14 = v33 * (v30 - v32);
-
-    while ( 1 )
-    {
-      //v40 = v14;
-      if ( !v10 )
-      {
-        v37 = pSkyPolygon.v_18.z;
-        v16 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v14) >> 16;
-        --v32;
-        v14 += v33;
-        v10 = pSkyPolygon.v_18.x + v16;
-        v39 = pSkyPolygon.v_18.x + v16;
-        pViewportBR_Y = pSkyPolygon.v_18.x + v16;
-        break;
-      }
-      v37 = abs(v34 >> 14);//2048
-      if ( abs(v34 >> 14) <= abs(v10) || v32 <= pViewport->uViewportTL_Y )
-      {
-        if ( v39 <= 0 )
-          break;
-      }
-      //v14 = v40;
-      v37 = pSkyPolygon.v_18.z;
-      v16 = (unsigned __int64)(pSkyPolygon.v_18.z * v14) >> 16;
-      --v32;
-      v14 += v33;
-      v10 = pSkyPolygon.v_18.x + v16;
-      v39 = pSkyPolygon.v_18.x + v16;
-      pViewportBR_Y = pSkyPolygon.v_18.x + v16;
-      break;
-    }
-
-    pShading = fixpoint_div(v34, pViewportBR_Y);//53570690 = -33554432 / -41049
-    if ( pShading < 0 )
-      pShading = pODMRenderParams->shading_dist_mist;
-	int a = ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16);//16316
-    v37 += ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16);
-	int b = ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16);
-    screen_center_x += ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16);
-    v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, pShading) / 8;// Медленно вращаем небесный купол
-    screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(screen_center_x, pShading) / 8;
-
-    array_50AC10[vertex_id].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist;
-    //array_50AC10[vertex_id].vWorldPosition.x = v36 / (pSkyPolygon.pTexture->uTextureHeight * 65536.0);
-    //array_50AC10[vertex_id].vWorldPosition.y = 1.0 / (pODMRenderParams->shading_dist_mist >> 16);
-    //array_50AC10[vertex_id].vWorldPosition.z = v35 / (pSkyPolygon.pTexture->uTextureWidth * 65536.0);
-    //array_50AC10[vertex_id]._rhw = 1.0f / (pShading >> 16);//1.0 / (array_50AC10[vertex_id].vWorldViewPosition.x + 0.0000001);
-    //array_50AC10[vertex_id].u = (double)v35 / (65536.0 * pSkyPolygon.pTexture->uTextureWidth);//t - pParty->sRotationY / 1024.0f
-    //array_50AC10[vertex_id].v = (double)screen_center_x / (65536.0 * pSkyPolygon.pTexture->uTextureHeight);
-  //-----------------------------------------------------------------------------------------
-
-    array_50AC10[vertex_id]._rhw = 1.0f;
-  }
-  //if ( i  == _this.uNumVertices - 1 )
-  //{
-    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]);
-
-    array_50AC10[0].vWorldViewProjY = pViewportBR_Y;
-    array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
-    array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
-    array_50AC10[3].vWorldViewProjY = pViewportBR_Y;
-
-    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]);
-  //}
-}
-/*void Render::DrawSkyD3D()
-{
-  int v0; // esi@2
-  int v1; // eax@2
-  double v2; // st7@2
-  double v3; // st6@2
-  double v4; // st5@2
-  double v5; // st4@2
-  double v6; // st7@2
-  char *v7; // esi@3
-  int v8; // eax@4
-  int v9; // eax@4
-  int v10; // ebx@4
-  signed __int64 v11; // qax@6
-  double v12; // st7@6
-  int v13; // edi@6
-  int v14; // ecx@6
-  int v15; // eax@8
-  int v16; // eax@12
-  signed __int64 v17; // qtt@13
-  signed int v18; // ecx@13
-  Texture *v19; // eax@15
-  double v20; // st6@15
-  double v21; // st7@15
-  double v22; // st6@15
-  unsigned __int8 v23; // sf@15
-  unsigned __int8 v24; // of@15
-  struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
-  double v26; // [sp+120h] [bp-44h]@4
-  float v27; // [sp+128h] [bp-3Ch]@4
-  float v28; // [sp+12Ch] [bp-38h]@2
-  int v29; // [sp+130h] [bp-34h]@4
-  int v30; // [sp+134h] [bp-30h]@1
-  int v31; // [sp+138h] [bp-2Ch]@2
-  int v32; // [sp+13Ch] [bp-28h]@6
-  int v33; // [sp+140h] [bp-24h]@2
-  signed __int64 v34; // [sp+144h] [bp-20h]@1
-  int v35; // [sp+148h] [bp-1Ch]@4
-  double v36; // [sp+14Ch] [bp-18h]@2
-  int v37; // [sp+154h] [bp-10h]@8
-  int v38; // [sp+158h] [bp-Ch]@1
-  int v39; // [sp+15Ch] [bp-8h]@4
-  int v40; // [sp+160h] [bp-4h]@7
-
-  v30 = (signed __int64)((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z)
-                       / ((double)pODMRenderParams->int_fov_rad + 8192.0)
-                       + (double)(pViewport->uScreenCenterY + 7));//include "+ 7"
-  //v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * (double)pODMRenderParams->shading_dist_mist;
-  /*v38 = (signed __int64)((double)(pViewport->uScreenCenterY + 7)
-                       - (double)pODMRenderParams->int_fov_rad
-                       / (v34 + 0.0000001)
-                       * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064)
-                        * (double)-pODMRenderParams->shading_dist_mist
-                        - (double)pGame->pIndoorCameraD3D->vPartyPos.z));*/
-  /*v34 = cos((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064) * 0x2000;
-  v38 = (signed __int64)((double)(pViewport->uScreenCenterY + 7)
-                       - (double)pODMRenderParams->int_fov_rad
-                       / (v34 + 0.0000001)
-                       * (sin((double)pGame->pIndoorCameraD3D->sRotationX * 0.0030664064)
-                        * (double)-0x2000
-                        - (double)pGame->pIndoorCameraD3D->vPartyPos.z));
-  pSkyPolygon.Create_48607B(&stru_8019C8);//заполняется ptr_38
-  pSkyPolygon.ptr_38->_48694B_frustum_sky();
-  pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;//179(original 166)
-  pSkyPolygon.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0);
-  if ( pSkyPolygon.pTexture )
-  {
-    v0 = pGame->pIndoorCameraD3D->sRotationX;
-    pSkyPolygon.dimming_level = 0;
-    pSkyPolygon.uNumVertices = 4;
-    pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX + 16);
-    pSkyPolygon.v_18.y = 0;
-    v1 = stru_5C6E00->Cos(v0 + 16);
-    v2 = (double)(signed int)pViewport->uViewportTL_X;
-    pSkyPolygon.v_18.z = -v1;
-    array_50AC10[0].vWorldViewProjX = v2;
-    v3 = (double)(signed int)pViewport->uViewportTL_Y;
-    array_50AC10[0].vWorldViewProjY = v3;
-    array_50AC10[1].vWorldViewProjX = v2;
-    v4 = (double)v38;
+    array_50AC10[0].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;
+    array_50AC10[0].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;
+
+    array_50AC10[1].vWorldViewProjX = (double)(signed int)pViewport->uViewportTL_X;
+    array_50AC10[1].vWorldViewProjY = (double)v38;
+
+    array_50AC10[2].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;
+    array_50AC10[2].vWorldViewProjY = (double)v38;
+
+    array_50AC10[3].vWorldViewProjX = (double)(signed int)pViewport->uViewportBR_X;
+    array_50AC10[3].vWorldViewProjY = (double)(signed int)pViewport->uViewportTL_Y;
+
     pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
     pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
-    v28 = v4;
-    array_50AC10[1].vWorldViewProjY = v4;
-    v5 = (double)(signed int)pViewport->uViewportBR_X;
-    array_50AC10[2].vWorldViewProjX = v5;
-    v38 = pViewport->uViewportBR_X - pViewport->uViewportTL_X;
+
     pSkyPolygon.field_24 = 0x2000000u;
-    array_50AC10[2].vWorldViewProjY = v4;
-    array_50AC10[3].vWorldViewProjX = v5;
-    array_50AC10[3].vWorldViewProjY = v3;
-    v36 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;
-    v6 = tan(0.6457717418670654);
-    v31 = 0;
-    v33 = 65536 / (signed int)(signed __int64)(v36 / v6 + 0.5);
-    if ( (signed int)pSkyPolygon.uNumVertices <= 0 )
-      goto LABEL_16;
-    v7 = (char *)&array_50AC10[0].vWorldViewProjY;
-    while ( 1 )
+    v33 = 65536 / (signed int)(signed __int64)(((double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5) / tan(0.6457717418670654) + 0.5);
+    for ( uint i = 0; i < pSkyPolygon.uNumVertices; ++i )
     {
-      LODWORD(v27) = *(_DWORD *)v7;
-      v26 = v27 + 6.7553994e15;
-      v29 = v27;
-      v38 = pSkyPolygon.ptr_38->field_14;
-      v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - v27))) >> 16;
-      v8 = v39 + pSkyPolygon.ptr_38->field_C;
-      v39 = v33 * (v30 - v27);
-      v35 = v8;
-      v38 = pSkyPolygon.ptr_38->field_20;
-      v39 = (unsigned __int64)(v38 * (signed __int64)(v33 * (v30 - v27))) >> 16;
-      v36 = v39 + pSkyPolygon.ptr_38->field_18;
+      v26 = array_50AC10[i].vWorldViewProjY + 6.7553994e15;
+      //rotate skydome(вращение купола неба)--------------------------------------
+      // В игре принята своя система измерения углов. Полный угол (180). Значению угла 0 соответствует 
+      // направление на север и/или юг (либо на восток и/или запад), значению 65536 еденицам(0х10000) соответствует угол 90.
+      v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_14 * (signed __int64)(v33 * (v30 - array_50AC10[i].vWorldViewProjY))) >> 16;
+      v35 = v39 + pSkyPolygon.ptr_38->angle_from_north;
+
+      v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_20 * (signed __int64)(v33 * (v30 - array_50AC10[i].vWorldViewProjY))) >> 16;
+      v36 = v39 + pSkyPolygon.ptr_38->angle_from_east;
+
       v38 = pSkyPolygon.v_18.z;
-      v9 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(v33 * (v30 - v27))) >> 16;
+      v9 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(v33 * (v30 - array_50AC10[i].vWorldViewProjY))) >> 16;
       v10 = pSkyPolygon.v_18.x + v9;
       v39 = pSkyPolygon.v_18.x + v9;
       if ( pSkyPolygon.v_18.x + v9 > 0 )
@@ -5201,13 +4972,11 @@
         v10 = 0;
         v39 = 0;
       }
-      v11 = (signed __int64)*((float *)v7 - 1);
       v38 = v10;
-      v12 = *(float *)v7 - 1.0;
-      v13 = v33 * (pViewport->uScreenCenterX - v11);
+      v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX);
       v34 = -pSkyPolygon.field_24;
-      v32 = (signed __int64)v12;
-      v14 = v33 * (v30 - v32);
+      v32 = (signed __int64)array_50AC10[i].vWorldViewProjX;
+      v14 = v33 * (v30 - (signed __int64)array_50AC10[i].vWorldViewProjX);
       while ( 1 )
       {
         v40 = v14;
@@ -5231,56 +5000,33 @@
         v38 = pSkyPolygon.v_18.x + v16;
       }
       LODWORD(v17) = LODWORD(v34) << 16;
-      //HIDWORD(v17) = LODWORD(v34) >> 16;
       HIDWORD(v17) = v34 >> 16;
-	  //v17 = (int)v34 >> 16;
-	  //v17 = v17 << 16;
-      v40 = v17 / v38;//v38 = -42331
+      v40 = v17 / v38;
       v18 = v17 / v38;
       if ( v18 < 0 )
         v18 = pODMRenderParams->shading_dist_mist;
-      v40 = v13;
-      v37 = pSkyPolygon.ptr_38->field_10;
-      v40 = v13;
-      v37 = v35 + ((unsigned __int64)(v37 * (signed __int64)v13) >> 16);
-      v35 = pSkyPolygon.ptr_38->field_1C;
-      v36 += (unsigned __int64)(v35 * (signed __int64)v13) >> 16;
+      v37 = v35 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v13) >> 16);
       v35 = 224 * pMiscTimer->uTotalGameTimeElapsed
           + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3);
-      v40 = (unsigned __int64)(v36 * (signed __int64)v18) >> 16;
-      v19 = pSkyPolygon.pTexture;
-      v36 = pSkyPolygon.pTexture->uTextureWidth;
-      v7 += 48;
-      v20 = (double)v36 * 65536.0;
-      HIDWORD(v36) = 224 * pMiscTimer->uTotalGameTimeElapsed + (v40 >> 3);
-      ++v31;
-      array_50AC10[v31 - 1].u = (double)v35 / v20;
-      v21 = (double)SHIDWORD(v36);
-      HIDWORD(v36) = v19->uTextureHeight;
-      v22 = (double)SHIDWORD(v36);
-      HIDWORD(v36) = v18 >> 16;
-      //v24 = __OFSUB__(v31, pSkyPolygon.uNumVertices);
-      //v23 = ((v31 - pSkyPolygon.uNumVertices) & 0x80000000u) != 0;
-      array_50AC10[v31 - 1].v = v21 / (v22 * 65536.0);
-      //array_50AC10[v31 - 1].vWorldViewPosition.x = (double)pODMRenderParams->shading_dist_mist;
-	  array_50AC10[v31 - 1].vWorldViewPosition.x = (double)0x2000;
-      array_50AC10[v31 - 1]._rhw = 1.0 / (double)SHIDWORD(v36);
-      //if ( !(v23 ^ v24) )
-      if ( v31 == pSkyPolygon.uNumVertices )
-      {
-LABEL_16:
-        pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices,
-          &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
-        array_50AC10[0].vWorldViewProjY = v28;
-        array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
-        array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
-        array_50AC10[3].vWorldViewProjY = v28;
-        pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
-        return;
-      }
+      array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0);
+
+      v36 = v36 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v13) >> 16);
+      v35 = 224 * pMiscTimer->uTotalGameTimeElapsed
+         + ((signed int)((unsigned __int64)(v36 * (signed __int64)v18) >> 16) >> 3);
+      array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0);
+
+      array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist
+      array_50AC10[i]._rhw = 1.0 / (double)(v18 >> 16);
     }
-  }
-}*/
+    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
+    array_50AC10[0].vWorldViewProjY = (double)v38;
+    array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
+    array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
+    array_50AC10[3].vWorldViewProjY = (double)v38;
+    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]);
+    return;
+  }
+}
 
 //----- (0047A384) --------------------------------------------------------
 void ODM_LoadAndInitialize(const char *pLevelFilename, ODMRenderParams *thisa)
@@ -5976,14 +5722,14 @@
   {
     v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
 
-    this->field_C = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27);
-    this->field_10 = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
+    this->angle_from_north = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27);
+    this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
     this->field_14 = fixpoint_mul(a4, v25) - fixpoint_mul(v17, v27);
   }
   else
   {
-    this->field_C = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
-    this->field_10 = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
+    this->angle_from_north = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7);
+    this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7);
     this->field_14 = a4;
   }
 
@@ -5991,41 +5737,41 @@
   {
     v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
 
-    this->field_18 = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27);
-    this->field_1C = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
+    this->angle_from_east = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27);
+    this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
     this->field_20 = fixpoint_mul(a7, v25) - fixpoint_mul(v19, v27);
   }
   else
   {
-    this->field_18 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
-    this->field_1C = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
+    this->angle_from_east = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7);
+    this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7);
     this->field_20 = a7;
   }
 
-  this->field_18 = -this->field_18;
-  this->field_1C = -this->field_1C;
+  this->angle_from_east = -this->angle_from_east;
+  this->angle_from_south = -this->angle_from_south;
   this->field_20 = -this->field_20;
 
-  this->field_24 = fixpoint_dot(this->field_C,  this->field_0_party_dir_x,
-                                this->field_10, this->field_4_party_dir_y,
+  this->field_24 = fixpoint_dot(this->angle_from_north,  this->field_0_party_dir_x,
+                                this->angle_from_west, this->field_4_party_dir_y,
                                 this->field_14, this->field_8_party_dir_z);
-  this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x,
-                                this->field_1C, this->field_4_party_dir_y,
+  this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
+                                this->angle_from_south, this->field_4_party_dir_y,
                                 this->field_20, this->field_8_party_dir_z);
 }
 
 //----- (0048694B) --------------------------------------------------------
 void stru149::_48694B_frustum_sky()
 {
-  this->field_18 = -this->field_18;
-  this->field_1C = -this->field_1C;
+  this->angle_from_east = -this->angle_from_east;
+  this->angle_from_south = -this->angle_from_south;
   this->field_20 = -this->field_20;
 
-  this->field_24 = fixpoint_dot(this->field_C,  this->field_0_party_dir_x,
-                                this->field_10, this->field_4_party_dir_y,
+  this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x,
+                                this->angle_from_west, this->field_4_party_dir_y,
                                 this->field_14, this->field_8_party_dir_z);
-  this->field_28 = fixpoint_dot(this->field_18, this->field_0_party_dir_x,
-                                this->field_1C, this->field_4_party_dir_y,
+  this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x,
+                                this->angle_from_south, this->field_4_party_dir_y,
                                 this->field_20, this->field_8_party_dir_z);
 }
 
--- a/mm7_4.cpp	Tue Oct 08 11:04:08 2013 +0200
+++ b/mm7_4.cpp	Tue Oct 08 11:06:24 2013 +0200
@@ -123,11 +123,10 @@
   v31 = v4;
   v39 = 1;
   dword_720F20[0] = 10000;
-  v32 = 0;
   if ( (signed int)pOutdoor->uNumBModels > 0 )
   {
     v29 = 0;
-    do
+    for ( v32 = 0; v32 < (signed int)pOutdoor->uNumBModels; ++v32 )
     {
       v6 = &pOutdoor->pBModels[v29];
       if ( v4 <= pOutdoor->pBModels[v29].sMaxX )
@@ -239,11 +238,11 @@
           }
         }
       }
-      ++v32;
+      //++v32;
       ++v29;
       v5 = 0;
     }
-    while ( v32 < (signed int)pOutdoor->uNumBModels );
+    //while ( v32 < (signed int)pOutdoor->uNumBModels );
     if ( !v39 )
     {
       *(int *)a4 = 0;