changeset 2560:44d9df75dc13

Слияние
author Ritor1
date Thu, 14 May 2015 19:16:21 +0600
parents 6ab1273bc507 (diff) 91c75d202d30 (current diff)
children 98057834c9a0
files Engine/Graphics/Render.cpp
diffstat 6 files changed, 235 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Thu May 14 11:03:14 2015 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Thu May 14 19:16:21 2015 +0600
@@ -93,8 +93,8 @@
     <ClCompile Include="..\..\Arcomage\Arcomage.cpp" />
     <ClCompile Include="..\..\Arcomage\ArcomageCards.cpp" />
     <ClCompile Include="..\..\Engine\Conditions.cpp" />
+    <ClCompile Include="..\..\Engine\Engine.cpp" />
     <ClCompile Include="..\..\Engine\Events.cpp" />
-    <ClCompile Include="..\..\Engine\Game.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\BSPModel.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\DecalBuilder.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\DecorationList.cpp" />
@@ -152,15 +152,27 @@
     <ClCompile Include="..\..\Engine\TurnEngine\TurnEngine.cpp" />
     <ClCompile Include="..\..\Engine\VectorTypes.cpp" />
     <ClCompile Include="..\..\Engine\ZlibWrapper.cpp" />
+    <ClCompile Include="..\..\Game\CreateParty.cpp" />
+    <ClCompile Include="..\..\Game\Game.cpp" />
+    <ClCompile Include="..\..\Game\GameMenu.cpp" />
+    <ClCompile Include="..\..\Game\GameOver.cpp" />
+    <ClCompile Include="..\..\Game\MainMenu.cpp" />
+    <ClCompile Include="..\..\Game\MainMenuLoad.cpp" />
     <ClCompile Include="..\..\GUI\GUIButton.cpp" />
     <ClCompile Include="..\..\GUI\GUIFont.cpp" />
     <ClCompile Include="..\..\GUI\GUIProgressBar.cpp" />
     <ClCompile Include="..\..\GUI\GUIWindow.cpp" />
     <ClCompile Include="..\..\GUI\NewUI\Core\UIControlModule_wrap.cxx" />
     <ClCompile Include="..\..\GUI\NewUI\MainMenu.cpp" />
-    <ClCompile Include="..\..\GUI\UI\Books\UIMapBook.cpp" />
-    <ClCompile Include="..\..\GUI\UI\Books\UINotesBooks.cpp" />
-    <ClCompile Include="..\..\GUI\UI\Books\UISpellBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\AutonotesBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\CalendarBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\JournalBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\LloydsBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\MapBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\QuestBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Books\TownPortalBook.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Chest.cpp" />
+    <ClCompile Include="..\..\GUI\UI\Spellbook.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIArena.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIBooks.cpp" />
     <ClCompile Include="..\..\GUI\UI\UICharacter.cpp" />
@@ -168,10 +180,10 @@
     <ClCompile Include="..\..\GUI\UI\UIGuilds.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIHouses.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIMainMenu.cpp" />
-    <ClCompile Include="..\..\GUI\UI\UIMsgProc.cpp" />
-    <ClCompile Include="..\..\GUI\UI\UIOptions.cpp" />
+    <ClCompile Include="..\..\GUI\UI\UIModal.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIPartyCreation.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIPopup.cpp" />
+    <ClCompile Include="..\..\GUI\UI\UIQuickReference.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIRest.cpp" />
     <ClCompile Include="..\..\GUI\UI\UISaveLoad.cpp" />
     <ClCompile Include="..\..\GUI\UI\UIShops.cpp" />
@@ -253,10 +265,10 @@
     <ClInclude Include="..\..\Engine\Autonotes.h" />
     <ClInclude Include="..\..\Engine\Awards.h" />
     <ClInclude Include="..\..\Engine\Conditions.h" />
+    <ClInclude Include="..\..\Engine\Engine.h" />
     <ClInclude Include="..\..\Engine\ErrorHandling.h" />
     <ClInclude Include="..\..\Engine\Events.h" />
     <ClInclude Include="..\..\Engine\Events2D.h" />
-    <ClInclude Include="..\..\Engine\Game.h" />
     <ClInclude Include="..\..\Engine\Graphics\BSPModel.h" />
     <ClInclude Include="..\..\Engine\Graphics\DecalBuilder.h" />
     <ClInclude Include="..\..\Engine\Graphics\DecorationList.h" />
@@ -312,7 +324,6 @@
     <ClInclude Include="..\..\Engine\stru298.h" />
     <ClInclude Include="..\..\Engine\stru314.h" />
     <ClInclude Include="..\..\Engine\stru367.h" />
-    <ClInclude Include="..\..\Engine\stuff.h" />
     <ClInclude Include="..\..\Engine\Tables\FactionTable.h" />
     <ClInclude Include="..\..\Engine\Tables\FrameTableInc.h" />
     <ClInclude Include="..\..\Engine\Tables\IconFrameTable.h" />
@@ -324,15 +335,27 @@
     <ClInclude Include="..\..\Engine\TurnEngine\TurnEngine.h" />
     <ClInclude Include="..\..\Engine\VectorTypes.h" />
     <ClInclude Include="..\..\Engine\ZlibWrapper.h" />
+    <ClInclude Include="..\..\Game\CreateParty.h" />
+    <ClInclude Include="..\..\Game\Game.h" />
+    <ClInclude Include="..\..\Game\GameMenu.h" />
+    <ClInclude Include="..\..\Game\GameOver.h" />
+    <ClInclude Include="..\..\Game\MainMenu.h" />
+    <ClInclude Include="..\..\Game\MainMenuLoad.h" />
     <ClInclude Include="..\..\GUI\GUIButton.h" />
     <ClInclude Include="..\..\GUI\GUIFont.h" />
     <ClInclude Include="..\..\GUI\GUIProgressBar.h" />
     <ClInclude Include="..\..\GUI\GUIWindow.h" />
     <ClInclude Include="..\..\GUI\NewUI\Core\UIControl.h" />
     <ClInclude Include="..\..\GUI\NewUI\MainMenu.h" />
-    <ClInclude Include="..\..\GUI\UI\Books\UIMapBook.h" />
-    <ClInclude Include="..\..\GUI\UI\Books\UINotesBooks.h" />
-    <ClInclude Include="..\..\GUI\UI\Books\UISpellBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\AutonotesBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\CalendarBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\JournalBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\LloydsBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\MapBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\QuestBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Books\TownPortalBook.h" />
+    <ClInclude Include="..\..\GUI\UI\Chest.h" />
+    <ClInclude Include="..\..\GUI\UI\Spellbook.h" />
     <ClInclude Include="..\..\GUI\UI\UIArena.h" />
     <ClInclude Include="..\..\GUI\UI\UIBooks.h" />
     <ClInclude Include="..\..\GUI\UI\UICharacter.h" />
@@ -340,10 +363,10 @@
     <ClInclude Include="..\..\GUI\UI\UIGuilds.h" />
     <ClInclude Include="..\..\GUI\UI\UIHouses.h" />
     <ClInclude Include="..\..\GUI\UI\UIMainMenu.h" />
-    <ClInclude Include="..\..\GUI\UI\UIMsgProc.h" />
-    <ClInclude Include="..\..\GUI\UI\UIOptions.h" />
+    <ClInclude Include="..\..\GUI\UI\UIModal.h" />
     <ClInclude Include="..\..\GUI\UI\UIPartyCreation.h" />
     <ClInclude Include="..\..\GUI\UI\UIPopup.h" />
+    <ClInclude Include="..\..\GUI\UI\UIQuickReference.h" />
     <ClInclude Include="..\..\GUI\UI\UIRest.h" />
     <ClInclude Include="..\..\GUI\UI\UISaveLoad.h" />
     <ClInclude Include="..\..\GUI\UI\UIShops.h" />
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Thu May 14 11:03:14 2015 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Thu May 14 19:16:21 2015 +0600
@@ -109,6 +109,9 @@
     <Filter Include="Engine\Graphics\Shaders">
       <UniqueIdentifier>{740b8731-e3ff-44cb-b6c8-85a64c7cbfc0}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Game">
+      <UniqueIdentifier>{6dd9bc0c-a6d9-40ea-9eb9-d0f38abd514b}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\lib\zlib\adler32.c">
@@ -441,9 +444,6 @@
     <ClCompile Include="..\..\Engine\Events.cpp">
       <Filter>Engine</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\Engine\Game.cpp">
-      <Filter>Engine</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\Engine\LOD.cpp">
       <Filter>Engine</Filter>
     </ClCompile>
@@ -490,15 +490,6 @@
     <ClCompile Include="..\..\GUI\NewUI\MainMenu.cpp">
       <Filter>GUI\NewUI</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\GUI\UI\Books\UISpellBook.cpp">
-      <Filter>GUI\UI\Books</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\GUI\UI\Books\UIMapBook.cpp">
-      <Filter>GUI\UI\Books</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\GUI\UI\Books\UINotesBooks.cpp">
-      <Filter>GUI\UI\Books</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\GUI\UI\UIGuilds.cpp">
       <Filter>GUI\UI</Filter>
     </ClCompile>
@@ -508,12 +499,6 @@
     <ClCompile Include="..\..\GUI\UI\UIMainMenu.cpp">
       <Filter>GUI\UI</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\GUI\UI\UIMsgProc.cpp">
-      <Filter>GUI\UI</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\GUI\UI\UIOptions.cpp">
-      <Filter>GUI\UI</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\GUI\UI\UIPartyCreation.cpp">
       <Filter>GUI\UI</Filter>
     </ClCompile>
@@ -574,6 +559,60 @@
     <ClCompile Include="..\..\Media\MediaPlayer.cpp">
       <Filter>Media</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\Engine\Engine.cpp">
+      <Filter>Engine</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\Game.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\GameOver.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\MainMenu.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\UIModal.cpp">
+      <Filter>GUI\UI</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\UIQuickReference.cpp">
+      <Filter>GUI\UI</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\AutonotesBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\CalendarBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\JournalBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\LloydsBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\MapBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\QuestBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Books\TownPortalBook.cpp">
+      <Filter>GUI\UI\Books</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Chest.cpp">
+      <Filter>GUI\UI</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\GUI\UI\Spellbook.cpp">
+      <Filter>GUI\UI</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\GameMenu.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\CreateParty.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Game\MainMenuLoad.cpp">
+      <Filter>Game</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\lib\libavcodec\avcodec.h">
@@ -1140,9 +1179,6 @@
     <ClInclude Include="..\..\Engine\stru367.h">
       <Filter>Engine</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\Engine\stuff.h">
-      <Filter>Engine</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\Engine\texts.h">
       <Filter>Engine</Filter>
     </ClInclude>
@@ -1173,9 +1209,6 @@
     <ClInclude Include="..\..\Engine\Events2D.h">
       <Filter>Engine</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\Engine\Game.h">
-      <Filter>Engine</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\Engine\LOD.h">
       <Filter>Engine</Filter>
     </ClInclude>
@@ -1234,15 +1267,6 @@
     <ClInclude Include="..\..\GUI\NewUI\MainMenu.h">
       <Filter>GUI\NewUI</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\GUI\UI\Books\UISpellBook.h">
-      <Filter>GUI\UI\Books</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\GUI\UI\Books\UIMapBook.h">
-      <Filter>GUI\UI\Books</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\GUI\UI\Books\UINotesBooks.h">
-      <Filter>GUI\UI\Books</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\GUI\UI\UIGame.h">
       <Filter>GUI\UI</Filter>
     </ClInclude>
@@ -1255,12 +1279,6 @@
     <ClInclude Include="..\..\GUI\UI\UIMainMenu.h">
       <Filter>GUI\UI</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\GUI\UI\UIMsgProc.h">
-      <Filter>GUI\UI</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\GUI\UI\UIOptions.h">
-      <Filter>GUI\UI</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\GUI\UI\UIPartyCreation.h">
       <Filter>GUI\UI</Filter>
     </ClInclude>
@@ -1321,6 +1339,60 @@
     <ClInclude Include="..\..\Media\MediaPlayer.h">
       <Filter>Media</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\Engine\Engine.h">
+      <Filter>Engine</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\Game.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\GameOver.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\MainMenu.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\UIModal.h">
+      <Filter>GUI\UI</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\UIQuickReference.h">
+      <Filter>GUI\UI</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\AutonotesBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\CalendarBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\JournalBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\LloydsBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\MapBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\QuestBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Books\TownPortalBook.h">
+      <Filter>GUI\UI\Books</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Chest.h">
+      <Filter>GUI\UI</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\GUI\UI\Spellbook.h">
+      <Filter>GUI\UI</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\GameMenu.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\CreateParty.h">
+      <Filter>Game</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Game\MainMenuLoad.h">
+      <Filter>Game</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\lib\OpenAL\lib\x86\avcodec-55.def">
--- a/Engine/Graphics/LightmapBuilder.cpp	Thu May 14 11:03:14 2015 +0200
+++ b/Engine/Graphics/LightmapBuilder.cpp	Thu May 14 19:16:21 2015 +0600
@@ -79,7 +79,7 @@
 }
 
 //----- (0045D0D5) --------------------------------------------------------
-bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot)
+bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot)
 {
   //For outdoor terrain light (II)
   bool result; // eax@1
@@ -95,37 +95,49 @@
   float tY_0;
   float tY_1; // [sp+1Ch] [bp-4h]@5
 
+  //  x0,y0		  x1,y1
+  //  .____________.
+  //  |            |
+  //  |            |
+  //  |            |
+  //  .____________.
+  // x3,y3        x2,y2
+
+
   if ( pLight->uRadius <= 0 )
-    return 0;
+    return false;
   if ( uStripType == 4 )
   {
-    tX_0 = a1->vWorldPosition.x;
-    tX_1 = a1[3].vWorldPosition.x;
-    tY_0 = a1[1].vWorldPosition.y;
-    tY_1 = a1->vWorldPosition.y;
+    tX_0 = TerrainVertices[0].vWorldPosition.x;
+    tX_1 = TerrainVertices[3].vWorldPosition.x;
+
+    tY_0 = TerrainVertices[1].vWorldPosition.y;
+    tY_1 = TerrainVertices[0].vWorldPosition.y;
   }
-  else // uStripType == 3
+  else if(uStripType == 3)
   {
-    if ( uStripType != 3 )
-      MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0);
-    else if ((unsigned char)X)
+    if ((unsigned char)X)
     {
-      tX_0 = a1->vWorldPosition.x;
-      tX_1 = a1[2].vWorldPosition.x;
-      tY_0 = a1[1].vWorldPosition.y;
-      tY_1 = a1[2].vWorldPosition.y;
+      tX_0 = TerrainVertices[0].vWorldPosition.x;
+      tX_1 = TerrainVertices[2].vWorldPosition.x;
+
+      tY_0 = TerrainVertices[1].vWorldPosition.y;
+      tY_1 = TerrainVertices[2].vWorldPosition.y;
     }
     else
     {
-      tX_0 = a1[1].vWorldPosition.x;
-      tX_1 = a1[2].vWorldPosition.x;
-      tY_0 = a1[1].vWorldPosition.y;
-      tY_1 = a1->vWorldPosition.y;
+      tX_0 = TerrainVertices[1].vWorldPosition.x;
+      tX_1 = TerrainVertices[2].vWorldPosition.x;
+
+      tY_0 = TerrainVertices[1].vWorldPosition.y;
+      tY_1 = TerrainVertices[0].vWorldPosition.y;
     }
   }
+  else
+	MessageBoxW(nullptr, L"Uknown strip type detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:981", 0);
 
-  minz = pIndoorCameraD3D->GetPolygonMinZ(a1, uStripType);
-  maxz = pIndoorCameraD3D->GetPolygonMaxZ(a1, uStripType);
+  minz = pIndoorCameraD3D->GetPolygonMinZ(TerrainVertices, uStripType);
+  maxz = pIndoorCameraD3D->GetPolygonMaxZ(TerrainVertices, uStripType);
 
   float bounding_x1 = tX_0 - (float)pLight->uRadius; //13 976 - 128 = 13848.0
   float bounding_y1 = tY_0 - (float)pLight->uRadius; // 3 800 - 128 = 3672.0
@@ -135,16 +147,17 @@
   float bounding_y2 = (float)pLight->uRadius + tY_1; //3 792 + 128 =  3920.0
   float bounding_z2 = (float)pLight->uRadius + maxz;// 260.0
 
+  //  
   if ( (float)pLight->vPosition.x <= bounding_x1 || (float)pLight->vPosition.x >= bounding_x2
     || (float)pLight->vPosition.y <= bounding_y1 || (float)pLight->vPosition.y >= bounding_y2 
     || (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 )
-    return 0;
+    return false;
 
-    Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3);
-    float p_dot = (float)pLight->vPosition.x * pNormal->x 
-                + (float)pLight->vPosition.y * pNormal->y 
-                + (float)pLight->vPosition.z * pNormal->z + *a3;
-    p_dot = p_dot + 0.5f;
+  Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3);
+  float p_dot = (float)pLight->vPosition.x * pNormal->x 
+              + (float)pLight->vPosition.y * pNormal->y 
+              + (float)pLight->vPosition.z * pNormal->z + *a3;
+  p_dot = p_dot + 0.5f;
   if  ( (//v49 = pNormal,
         //Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3),
         //X = v8->vPosition.y,
@@ -160,7 +173,7 @@
         //X = LODWORD(v61),
         //v52 = v63,
         p_dot > pLight->uRadius) )
-    return 0;
+    return false;
 /*
         v49 = pNormal;
         Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3);
@@ -192,18 +205,18 @@
     v57 = _4E94D2_light_type;
   stru_F8AD28._blv_lights_types[*pSlot] = v57;
 
-  result = 4 * *pSlot;
+  int id = 4 * *pSlot;
   if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular )
   {
     if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 )
     {
-      stru_F8AD28._blv_lights_rs[result] = stru_F8AD28._blv_lights_rs[result] * 0.3300000131130219;
-      stru_F8AD28._blv_lights_gs[result] = stru_F8AD28._blv_lights_gs[result] * 0.3300000131130219;
-      stru_F8AD28._blv_lights_bs[result] = stru_F8AD28._blv_lights_bs[result] * 0.3300000131130219;
+      stru_F8AD28._blv_lights_rs[id] = stru_F8AD28._blv_lights_rs[id] * 0.3300000131130219;
+      stru_F8AD28._blv_lights_gs[id] = stru_F8AD28._blv_lights_gs[id] * 0.3300000131130219;
+      stru_F8AD28._blv_lights_bs[id] = stru_F8AD28._blv_lights_bs[id] * 0.3300000131130219;
     }
   }
   ++*pSlot;
-  return 1;
+  return true;
 }
 
 //----- (0045CE50) --------------------------------------------------------
@@ -869,7 +882,7 @@
     }
   }
   else
-    if (for_refactoring)
+    //if (for_refactoring)
     {
     for (unsigned int i = 0; i < std__vector_000004_size; ++i)
       if ( !pRenderer->DrawLightmap(std__vector_000004 + i, &arg4, 0.0) )
--- a/Engine/Graphics/Render.cpp	Thu May 14 11:03:14 2015 +0200
+++ b/Engine/Graphics/Render.cpp	Thu May 14 19:16:21 2015 +0600
@@ -383,7 +383,7 @@
         norm = 0;
       else
         norm = &pTerrainNormals[norm_idx];
-      if (for_refactoring)
+      //if (for_refactoring)
       {
         //MessageBoxA(nullptr, "Ritor1: function StackLights_TerrainFace needed refactoring and result - slows", "", 0);
         //__debugbreak();
--- a/GUI/GUIWindow.cpp	Thu May 14 11:03:14 2015 +0200
+++ b/GUI/GUIWindow.cpp	Thu May 14 19:16:21 2015 +0600
@@ -1246,7 +1246,7 @@
     }
 
     //GUIWindow* pWindow = &pWindowList[uNextFreeWindowID];
-    pWindowList[uNextFreeWindowID] = this;
+    pWindowList[uNextFreeWindowID] = this;//sometimes uNextFreeWindowID == 20. it's result crash
     this->uFrameWidth = uWidth;
     this->uFrameHeight = uHeight;
 
--- a/Media/Audio/AudioPlayer.cpp	Thu May 14 11:03:14 2015 +0200
+++ b/Media/Audio/AudioPlayer.cpp	Thu May 14 19:16:21 2015 +0600
@@ -1425,7 +1425,6 @@
   double v11; // st7@13
   SpriteObject *v12; // eax@14
   Actor *v13; // eax@15
-//  signed int v14; // edx@15
   BLVDoor *pDoor; // eax@19
   double v16; // st7@22
   double v17; // st6@22
@@ -1439,8 +1438,6 @@
   int v25; // eax@32
   float v26; // ST10_4@34
   float v27; // ST08_4@34
-//  int v38; // eax@53
-//  __int16 v51; // ax@71
   signed int v53; // eax@88
   RenderVertexSoft a1; // [sp+24h] [bp-48h]@1
   float v55; // [sp+54h] [bp-18h]@22
@@ -1449,11 +1446,7 @@
   float v58; // [sp+60h] [bp-Ch]@23
   int v59; // [sp+64h] [bp-8h]@4
 
-  //pAudioPlayer = this;
   v2 = 0;
-  //thisa = this;
-  //v3 = this->bPlayerReady == 0;
-  //a1.flt_2C = 0.0;
   if (!bPlayerReady)
     return;
   
@@ -1515,11 +1508,11 @@
                   v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                /*else
-                {
-                  v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
-                  v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }*/
+                //else
+               // {
+                 // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
+                 // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
+                //}
                 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
                 a1.vWorldViewPosition.y = v20;
                 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1533,11 +1526,11 @@
                   a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                /*else
-                {
-                  a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
-                  v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }*/
+                //else
+                //{
+                //  a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
+                //  v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
+                //}
                 a1.vWorldViewPosition.y = v21;
                 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
               }
@@ -1586,11 +1579,11 @@
                   v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                /*else
-                {
-                  v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
-                  v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }*/
+                //else
+                //{
+                 // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
+                 // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
+                //}
                 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
                 a1.vWorldViewPosition.y = v20;
                 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1604,11 +1597,11 @@
                   a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                /*else
-                {
-                  a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
-                  v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }*/
+                //else
+                //{
+                 // a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
+                 // v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
+                //}
                 a1.vWorldViewPosition.y = v21;
                 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
               }
@@ -1660,11 +1653,11 @@
               v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
               v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            /*else
-            {
-              v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
-              v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }*/
+            //else
+           // {
+            //  v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
+           //   v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
+            //}
             a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
             a1.vWorldViewPosition.y = v20;
             a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1678,11 +1671,11 @@
               a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
               v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            /*else
-            {
-              a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
-              v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }*/
+            //else
+            //{
+              //a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
+              //v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
+            //}
             a1.vWorldViewPosition.y = v21;
             a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
           }
@@ -1758,11 +1751,11 @@
               v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
               v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            /*else
-            {
-              v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
-              v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }*/
+            //else
+            //{
+             // v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
+             // v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
+            //}
             a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
             a1.vWorldViewPosition.y = v20;
             a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1776,11 +1769,11 @@
               a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
               v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            /*else
-            {
-              a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
-              v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }*/
+            //else
+            //{
+            //  a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
+            //  v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
+            //}
             a1.vWorldViewPosition.y = v21;
             a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
           }