changeset 64:f6e7d7110512

Слияние
author Ritor1
date Wed, 23 Jan 2013 13:14:41 +0600
parents a96ebf3123d2 (current diff) 80484cf3a683 (diff)
children 31feb3432bbd
files LightmapBuilder.cpp ParticleEngine.cpp Render.cpp Vis.cpp
diffstat 7 files changed, 143 insertions(+), 166 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/GUIWindow.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -1830,7 +1830,6 @@
       break;
   }
 
-
   auto pWindow = &pWindowList[uNextFreeWindowID];
   pWindow->uFrameWidth = uWidth;
   pWindow->uFrameZ = uX + uWidth - 1;
--- a/LightmapBuilder.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/LightmapBuilder.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -964,7 +964,7 @@
   RenderD3D *v13; // ecx@11
   char v14; // dl@11
 
-//  __debugbreak();
+  //__debugbreak();
 
   v6 = pLight->uRadius;
   if ( v6 > 0
--- a/Outdoor.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/Outdoor.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -102,7 +102,7 @@
 //LABEL_14:
     pRenderer->DrawSkyD3D();
     pRenderer->DrawBuildingsD3D();
-    //pRenderer->DrawBezierTerrain();
+    pRenderer->DrawBezierTerrain();// Ritor1: sometimes crash
     goto LABEL_16;
   }
   pRenderer->DrawBuildingsSW();
@@ -138,7 +138,7 @@
   if ( !pOutdoorCamera->bDoNotRenderDecorations )
     pRenderer->DrawDecorations();
   pRenderer->DrawLayingItems_Shooting_Magic_ODM();
-  pRenderer->TransformBillboardsAndSetPalettesODM();
+  pRenderer->TransformBillboardsAndSetPalettesODM();//Ritor1: do comment to test
   sub_485F53((Vec2_int_ *)unnamed_6BE060);
 }
 
--- a/ParticleEngine.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/ParticleEngine.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -707,121 +707,115 @@
 //----- (0048BEEF) --------------------------------------------------------
 void ParticleEngine::DrawParticles_ODM()
 {
-  ParticleEngine *v1; // esi@1
-  int v2; // eax@1
+  ParticleEngine *pParticleEngine; // esi@1
+  int pParticleNum; // eax@1
   unsigned __int8 v3; // zf@1
   char v4; // sf@1
   unsigned __int8 v5; // of@1
   char *v7; // edi@2
   int v8; // eax@6
-  signed int v9; // eax@8
+  signed int pNumLines; // eax@8
   int v10; // eax@14
   int v11; // ecx@16
   int v12; // edx@16
-  Particle *v13; // eax@24
-  RenderBillboardTransform_local0 v14; // [sp+Ch] [bp-58h]@1
+  Particle *pParticle; // eax@24
+  RenderBillboardTransform_local0 pBillboard; // [sp+Ch] [bp-58h]@1
   int v15; // [sp+5Ch] [bp-8h]@9
   int v16; // [sp+60h] [bp-4h]@1
 
-  v14.uParentBillboardID = -1;
-  v1 = this;
-  v2 = this->uStartParticle;
-  v5 = v2 > this->uEndParticle;//  v5 = __OFSUB__(v2, this->uEndParticle);
-  v3 = v2 == this->uEndParticle;
-  v4 = v2 - this->uEndParticle < 0;
-  v16 = this->uStartParticle;
-  if ( (unsigned __int8)(v4 ^ v5) | v3 )
+  pBillboard.uParentBillboardID = -1;
+  pParticleEngine = this;
+  //v2 = this->uStartParticle;
+  //v5 = v2 > this->uEndParticle;//  v5 = __OFSUB__(v2, this->uEndParticle);
+  //v3 = v2 == this->uEndParticle;
+  //v4 = v2 - this->uEndParticle < 0;
+  //v16 = this->uStartParticle;
+  for (pParticleNum = this->uStartParticle; pParticleNum <= this->uEndParticle; ++pParticleNum)
   {
-    v7 = (char *)&this->pParticles[v2].sZValue + 2;
-    do
-    {
-      if ( *(int *)(v7 - 82) && v1->_48B5B3(v2) )
+    v7 = (char *)&this->pParticles[pParticleNum].sZValue + 2;
+    //do
+    //{
+      if ( *(_DWORD *)(v7 - 82) && pParticleEngine->_48B5B3(pParticleNum) )//*(_DWORD *)(v7 - 82) = this->pParticles[pParticleNum] or this->pParticles[pParticleNum].uType
       {
         if ( pRenderer->pRenderD3D )
         {
-          v8 = *(int *)(v7 - 82);
+          v8 = *(_DWORD *)(v7 - 82);
           if ( BYTE1(v8) & 1 )
           {
-            v13 = &v1->pParticles[v16];
-            v14.field_10 = v13->field_58 >> 2;
-            v14.field_14 = v13->field_58 >> 2;
-            v14.uScreenSpaceX = v13->uScreenSpaceX;
-            v14.uScreenSpaceY = v13->uScreenSpaceY;
-            v14.sZValue = v13->sZValue;
-            pRenderer->MakeParticleBillboardAndPush_ODM(&v14, 0, v13->uLightColor, v13->_rotation);
+            pParticle = &pParticleEngine->pParticles[pParticleNum];
+            pBillboard.field_10 = pParticle->field_58 >> 2;
+            pBillboard.field_14 = pParticle->field_58 >> 2;
+            pBillboard.uScreenSpaceX = pParticle->uScreenSpaceX;
+            pBillboard.uScreenSpaceY = pParticle->uScreenSpaceY;
+            pBillboard.sZValue = pParticle->sZValue;
+            pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, 0, pParticle->uLightColor, pParticle->_rotation);
             return;
           }
           if ( BYTE1(v8) & 2 )
           {
-            v9 = v1->pLines.uNumLines;
-            if ( v9 < 100 )
+            pNumLines = pParticleEngine->pLines.uNumLines;
+            if ( pNumLines < 100 )
             {
-              v1->pLines.pLineVertices[2 * v9].pos.x = (double)*(signed int *)(v7 - 18);
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.y = (double)*(signed int *)(v7 - 14);
-              v15 = *(short *)v7;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].pos.z = 1.0 - 1.0 / ((double)v15 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist);
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].rhw = 1.0;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].diffuse = *(int *)(v7 + 18);
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].specular = 0;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines].texcoord.x = 0.0;
-              *((float *)&v1->pParticles[0].uType + 16 * (v1->pLines.uNumLines + 813)) = 0.0;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 10);
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 6);
-              v15 = *(short *)v7;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((double)v15 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist);
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].rhw = 1.0;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].diffuse = *(int *)(v7 + 18);
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].specular = 0;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines + 1].texcoord.x = 0.0;
-              v1->pLines.pLineVertices[2 * v1->pLines.uNumLines++ + 1].texcoord.y = 0.0;
+              pParticleEngine->pLines.pLineVertices[2 * pNumLines].pos.x = (double)*(signed int *)(v7 - 18);
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].pos.y = (double)*(signed int *)(v7 - 14);
+              v15 = *(_DWORD *)v7;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].pos.z = 1.0 - 1.0 / ((double)v15 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist);
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].rhw = 1.0;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].diffuse = *(_DWORD *)(v7 + 18);
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].specular = 0;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].texcoord.x = 0.0;
+              *((float *)&pParticleEngine->pParticles[0].uType + 16 * (pParticleEngine->pLines.uNumLines + 813)) = 0.0;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 10);
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 6);
+              v15 = *(_DWORD *)v7;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((double)v15 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist);
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].rhw = 1.0;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].diffuse = *(_DWORD *)(v7 + 18);
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].specular = 0;
+              pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].texcoord.x = 0.0;
+              __debugbreak();//v1->pLines.pLineVertices[2 * v1->pLines.uNumLines++ + 1].texcoord.y = 0.0;
             }
           }
           if ( *(v7 - 81) & 4 )
           {
-            v14.field_10 = *(int *)(v7 + 6);
-            v14.field_14 = *(int *)(v7 + 6);
-            v14.uScreenSpaceX = *(int *)(v7 - 18);
-            v14.uScreenSpaceY = *(int *)(v7 - 14);
-            v14.sZValue = *(int *)(v7 - 2);
-            pRenderer->MakeParticleBillboardAndPush_ODM(&v14, pBitmaps_LOD->pHardwareTextures[*(int *)(v7 - 46)], *(int *)(v7 + 18), *(int *)(v7 - 22));
+            pBillboard.field_10 = *(_DWORD *)(v7 + 6);
+            pBillboard.field_14 = *(_DWORD *)(v7 + 6);
+            pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18);
+            pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14);
+            pBillboard.sZValue = *(_DWORD *)(v7 - 2);
+            pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pBitmaps_LOD->pHardwareTextures[*(_DWORD *)(v7 - 46)], *(_DWORD *)(v7 + 18), *(_DWORD *)(v7 - 22));
           }
           if ( *(v7 - 81) & 8 )
           {
-            v14.field_10 = *(int *)(v7 + 6);
-            v14.field_14 = *(int *)(v7 + 6);
-            v14.uScreenSpaceX = *(int *)(v7 - 18);
-            v14.uScreenSpaceY = *(int *)(v7 - 14);
-            v14.sZValue = *(int *)(v7 - 2);
-            pRenderer->MakeParticleBillboardAndPush_ODM(&v14, pSprites_LOD->pHardwareSprites[*(int *)(v7 - 46)].pTexture, *(int *)(v7 + 18),
-              *(int *)(v7 - 22));
+            pBillboard.field_10 = *(_DWORD *)(v7 + 6);
+            pBillboard.field_14 = *(_DWORD *)(v7 + 6);
+            pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18);
+            pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14);
+            pBillboard.sZValue = *(_DWORD *)(v7 - 2);
+            pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pSprites_LOD->pHardwareSprites[*(_DWORD *)(v7 - 46)].pTexture, *(_DWORD *)(v7 + 18),
+              *(_DWORD *)(v7 - 22));
           }
         }
         else
         {
-          v10 = 13 * *(int *)(v7 + 6) >> 16;
+          v10 = 13 * *(_DWORD *)(v7 + 6) >> 16;
           if ( v10 > 30 )
             v10 = 30;
-          v11 = *(int *)(v7 - 18) - (v10 >> 1);
-          v12 = *(int *)(v7 - 14) - v10;
-          if ( v11 + v10 < (signed int)pViewport->uViewportX
-            || v11 >= (signed int)pViewport->uViewportZ
-            || *(int *)(v7 - 14) < (signed int)pViewport->uViewportY
+          v11 = *(_DWORD *)(v7 - 18) - (v10 >> 1);
+          v12 = *(_DWORD *)(v7 - 14) - v10;
+          if ( v11 + v10 < pViewport->uViewportX
+            || v11 >= pViewport->uViewportZ
+            || *(_DWORD *)(v7 - 14) < pViewport->uViewportY
             || v12 >= (signed int)pViewport->uViewportW )
           {
             ;
           }
           else
           {
-            pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, *(int *)(v7 - 2), *(int *)(v7 + 18), v10);
+            pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, *(_DWORD *)(v7 - 2), *(_DWORD *)(v7 + 18), v10);
           }
         }
       }
-      v7 += 104;
-      v2 = v16 + 1;
-      v5 = v16 + 1 > v1->uEndParticle;// v5 = __OFSUB__(v16 + 1, v1->uEndParticle);
-      v3 = v16 + 1 == v1->uEndParticle;
-      v4 = v16++ + 1 - v1->uEndParticle < 0;
-    }
-    while ( (unsigned __int8)(v4 ^ v5) | v3 );
+      
   }
 }
\ No newline at end of file
--- a/Render.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/Render.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -1001,7 +1001,7 @@
   char v102; // [sp+Ch] [bp-68h]@191
   __int16 v103; // [sp+10h] [bp-64h]@190
   __int16 v104; // [sp+12h] [bp-62h]@190
-  int v105; // [sp+1Ch] [bp-58h]@1
+  int pHeight; // [sp+1Ch] [bp-58h]@1
   int v106; // [sp+20h] [bp-54h]@3
   int v107; // [sp+24h] [bp-50h]@3
   int v108; // [sp+28h] [bp-4Ch]@9
@@ -1025,7 +1025,7 @@
   float v126; // [sp+70h] [bp-4h]@9
 
   memset(&v102, 0, sizeof(v102));
-  v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);
+  pHeight = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);
   v0 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);
   v1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + v0);
   LODWORD(v124) = (signed int)((pIndoorCamera->uMapGridCellX << 16)
@@ -1149,7 +1149,7 @@
   LODWORD(v126) = 0;
   v17 = v117 - 1;
   v18 = v116 - 1;
-  switch ( v105 )
+  switch ( pHeight )
   {
     case 0:
     case 7:
@@ -1561,7 +1561,7 @@
   ptr_801A08 = pVerticesSR_806210;
   ptr_801A04 = pVerticesSR_801A10;
   LODWORD(v126) = v69;
-  if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )
+  if ( pHeight && pHeight != 7 && pHeight != 3 && pHeight != 4 )
   {
     for ( i = v69; i >= 1; --i )
     {
@@ -1590,21 +1590,21 @@
         v127 = 0;
         v79 = (v73 - 66) << 9;
         v116 = v77;
-        v105 = v79;
+        pHeight = v79;
         v111 = v75 - v77;
         do
         {//    
-		  *(float *)&v106 = (double)v105;
+		  *(float *)&v106 = (double)pHeight;
           *(float *)((char *)&ptr_801A08->vWorldPosition.x + v127) = *(float *)&v106;//x
-          v105 = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
-          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)v105;//y
-          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
-          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)v105;//z
+          pHeight = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)pHeight;//y
+          pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70));
+          *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)pHeight;//z
           *(float *)((char *)&ptr_801A04->vWorldPosition.x + v127) = *(float *)&v106;//x
-          v105 = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
-          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)v105;//y
-          v105 = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
-          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)v105;//z
+          pHeight = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)pHeight;//y
+          pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)pHeight;//z
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
             a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v127, 1);
@@ -1615,16 +1615,16 @@
           v79 += 512;
           v127 += 48;
           ++v116;
-          v105 = v79;
+          pHeight = v79;
 		}
         while ( v116 < v107 );
       }
 	  v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v70]);
       v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v70]);
-	  //if ( pRenderer->pRenderD3D )
-        //Render::DrawTerrainD3D(v111, 0, (int)&v102);
-      //else
-        //Render::DrawTerrainSW(v111, 0, (int)&v102);
+	  if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
+        Render::DrawTerrainD3D(v111, 0, (int)&v102);
+      else
+        Render::DrawTerrainSW(v111, 0, (int)&v102);
     }
   }
   else
@@ -1653,23 +1653,23 @@
         v86 = 0;
         v116 = v89 - 2;
         v92 = (66 - v89) << 9;
-        v105 = (66 - v89) << 9;
+        pHeight = (66 - v89) << 9;
         v111 = v90 + 2 - (v89 - 2);
         do
         {
           v93 = v116;
           v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
           *(float *)((char *)&ptr_801A08->vWorldPosition.x + v86) = (double)v106;
-          *(float *)&v105 = (double)v105;
-          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&v105;
+          *(float *)&pHeight = (double)pHeight;
+          *(float *)((char *)&ptr_801A08->vWorldPosition.y + v86) = *(float *)&pHeight;
           v106 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86), v93);
           v97 = v116;
           *(float *)((char *)&ptr_801A08->vWorldPosition.z + v86) = (double)v106;
           v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
           *(float *)((char *)&ptr_801A04->vWorldPosition.x + v86) = (double)v106;
-          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&v105;
-          v105 = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
-          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)v105;
+          *(float *)((char *)&ptr_801A04->vWorldPosition.y + v86) = *(float *)&pHeight;
+          pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
+          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight;
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
            a1->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1);
@@ -1680,16 +1680,16 @@
           v92 -= 512;
           v86 += 48;
           ++v116;
-          v105 = v92;
+          pHeight = v92;
 		}
         while ( v116 < v107 );
       }
       v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
 	  v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
-	  //if ( pRenderer->pRenderD3D )
-        //Render::DrawTerrainD3D(v111, 1, (int)&v102);
-      //else
-        //Render::DrawTerrainSW(v111, 1, (int)&v102);
+	  if ( pRenderer->pRenderD3D )
+        Render::DrawTerrainD3D(v111, 1, (int)&v102);
+      else
+        Render::DrawTerrainSW(v111, 1, (int)&v102);
     }
   }
   result = v126;
@@ -1851,11 +1851,11 @@
                v13 = v8->vWorldPosition.y + 6.755399441055744e15,
                sY = LODWORD(v13),
                thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5,
-               v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),
+               v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X
                v15 = v9->vWorldPosition.y + v8->vWorldPosition.y,
                v89 = v14,
                thise = v15 * 0.5,
-               _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),
+               _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z
                WorldPosToGridCellX(sX),
                WorldPosToGridCellZ(sY),
                !byte_4D864C)
@@ -2110,24 +2110,10 @@
       a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0);
       static_sub_0048034E_stru_76D590._49B0C9(v99, *(float *)&a4);
       if ( pDecalBuilder->uNumDecals > 0 )
-        pDecalBuilder->ApplyDecals(
-          31 - v40->field_58,
-          4,
-          &static_sub_0048034E_stru_76D590,
-          uNumVertices,
-          array_50AC10,
-          0,
-          (char)a8,
-          -1);
+        pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)a8, -1);
     }
     if ( stru_F8AD28.uNumLightsApplied > 0 )
-      v96->ApplyLights(
-        &stru_F8AD28,
-        &static_sub_0048034E_stru_76D590,
-        uNumVertices,
-        array_50AC10,
-        0,
-        (char)a8);
+      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)a8);
     v55 = uNumVertices;
     v35 = byte_4D864C == 0;
     v40->uNumVertices = uNumVertices;
@@ -2836,7 +2822,7 @@
   int v13; // eax@14
   RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1
   int v15; // [sp+54h] [bp-10h]@13
-  int i; // [sp+58h] [bp-Ch]@1
+  int v16; // [sp+58h] [bp-Ch]@1
   int v17; // [sp+5Ch] [bp-8h]@2
   int v18; // [sp+60h] [bp-4h]@13
 
@@ -2850,41 +2836,39 @@
   billboard.uViewportW = pViewport->uViewportW;
   v0 = 0;
   pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
-  //v16 = 0;
-  for (i = 0; i < uNumBillboardsToDraw; ++i)//if ( (signed int)uNumBillboardsToDraw > 0 )
+  v16 = 0;
+  if ( (signed int)uNumBillboardsToDraw > 0 )
   {
     v17 = 0;
-    struct RenderBillboard *pBillboard;
-    pBillboard = &pBillboardRenderList[i];
     v1 = (char *)&pBillboardRenderList[0].uScreenSpaceY;
-    //do
-    //{
-      billboard.uScreenSpaceX = pBillboard->uScreenSpaceX;;
-      v2 = pBillboard->field_1E;
-      billboard.uScreenSpaceY = pBillboard->uScreenSpaceY;
-      //v3 = *((int *)v1 - 10);
-      billboard.uParentBillboardID = i;
-      //v4 = *((int *)v1 + 1);
-      billboard.field_10 = pBillboard->field_0;
-      //v5 = *((int *)v1 - 9);
-      billboard.uTintColor = pBillboard->uTintColor;
-      //v6 = *((short *)v1 - 8);
-      billboard.field_14 = pBillboard->field_4;
-      //v7 = *((int *)v1 - 6);
-      billboard.sZValue = pBillboard->sZValue;
-      billboard.uFlags = pBillboard->field_1E;
-      if ( pBillboard->uHwSpriteID != -1 )
-      {
-        v8 = pBillboard->uPaletteSubindex;;
-        //if ( pRenderer->pRenderD3D )
-        //{
-          billboard.sZValue = pBillboard->sZValue;
-          billboard.uFlags = pBillboard->field_1E;
-          pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], pBillboard->uPaletteSubindex, pBillboard);
-        //}
-        //else
-        //{
-          /*if ( *(v1 - 10) & 2 )
+    do
+    {
+      billboard.uScreenSpaceX = *((short *)v1 - 1);
+      v2 = *((short *)v1 - 5);
+      billboard.uScreenSpaceY = *(short *)v1;
+      v3 = *((int *)v1 - 10);
+      billboard.uParentBillboardID = v0;
+      v4 = *((int *)v1 + 1);
+      billboard.field_10 = v3;
+      v5 = *((int *)v1 - 9);
+      billboard.uTintColor = v4;
+      v6 = *((short *)v1 - 8);
+      billboard.field_14 = v5;
+      v7 = *((int *)v1 - 6);
+      billboard.sZValue = *((int *)v1 - 6);
+      billboard.uFlags = v2;
+      if ( v6 != -1 )
+      {
+        v8 = *((short *)v1 + 1);
+        if ( pRenderer->pRenderD3D )
+        {
+          billboard.sZValue = v7;
+          billboard.uFlags = v2;
+          pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[v6], v8, (RenderBillboard *)(v1 - 40));
+        }
+        else
+        {
+          if ( *(v1 - 10) & 2 )
             v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1);
           else
             v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), v7, *((short *)v1 + 1));
@@ -2902,15 +2886,15 @@
           }
           v13 = *((short *)v1 - 8);
           if ( v13 >= 0 )
-            pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1);*/
-        //}
+            pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1);
+        }
       }
       v17 += 5;
-      //v0 = i + 1;
+      v0 = v16 + 1;
       v1 += 52;
-      //++v16;
-    //}
-    //while ( v16 < (signed int)uNumBillboardsToDraw );
+      ++v16;
+    }
+    while ( v16 < (signed int)uNumBillboardsToDraw );
   }
 }
 
@@ -4291,7 +4275,7 @@
     {
       if ( !v54 || byte_4D864C && pGame->uFlags & 2 )
       {
-        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));
+        ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1u));//   
         ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
         if (bUsingSpecular)
         {
--- a/Vis.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/Vis.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -1605,7 +1605,7 @@
 
   stru1.uNumPointers = 0;
   CastPickRay(pMouseRay, fMouseX, fMouseY, fDepth);
-  //PickBillboards(fDepth, fMouseX, fMouseY, &stru1, a5);
+  PickBillboards(fDepth, fMouseX, fMouseY, &stru1, a5);//Ritor1: do comment to test
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     PickIndoor(fDepth, pMouseRay, &stru1, a6);
   else
--- a/mm7_4.cpp	Wed Jan 23 13:14:10 2013 +0600
+++ b/mm7_4.cpp	Wed Jan 23 13:14:41 2013 +0600
@@ -3245,7 +3245,7 @@
     if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 )
     {
       pPlayer->field_1AA2 = pFrame->uTextureID - 1;
-      pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];
+      pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID];
       pPortrait = pFace;
       v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
       if ( pParty->pPartyBuffs[11].uExpireTime )