changeset 985:062788391c88

BezierTerrain little clean
author Ritor1
date Sun, 12 May 2013 09:38:20 +0600
parents a079c489118d
children b584c743cb47
files Outdoor.cpp Render.cpp Render.h
diffstat 3 files changed, 154 insertions(+), 150 deletions(-) [+]
line wrap: on
line diff
--- a/Outdoor.cpp	Thu May 09 21:19:59 2013 +0600
+++ b/Outdoor.cpp	Sun May 12 09:38:20 2013 +0600
@@ -127,19 +127,22 @@
 	{
 		pRenderer->DrawSkyD3D();
 		pRenderer->DrawBuildingsD3D();
-		pRenderer->RenderTerrainD3D();//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag
+		pRenderer->RenderTerrainD3D();
+		//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag
 	}
   }
   else if (pRenderer->pRenderD3D)
   {
     pRenderer->DrawSkyD3D();
     pRenderer->DrawBuildingsD3D();
-    pRenderer->RenderTerrainD3D();//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag
+    pRenderer->RenderTerrainD3D();
+    //pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag
   }
   else
   {
 	pRenderer->DrawBuildingsSW();
-	pRenderer->RenderTerrainD3D();//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag
+	pRenderer->RenderTerrainD3D();
+	//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag
 	sr_sub_486F92_MessWithEdgesAndSpans();
 	pOutdoorCamera->_487355();
   }
--- a/Render.cpp	Thu May 09 21:19:59 2013 +0600
+++ b/Render.cpp	Sun May 12 09:38:20 2013 +0600
@@ -874,8 +874,8 @@
   int v8; // eax@4
   unsigned int v9; // eax@6
   int v10; // eax@7
-  int v11; // ebx@9
-  int v12; // edi@9
+  //int v11; // ebx@9
+  //int v12; // edi@9
   int v13; // eax@21
   int v14; // eax@31
   int v15; // edi@33
@@ -885,7 +885,7 @@
   int v19; // eax@36
   int v20; // eax@39
   int v21; // ecx@43
-  char v22; // zf@44
+  //char v22; // zf@44
   int v23; // ecx@47
   int v24; // edi@52
   int v25; // eax@54
@@ -934,32 +934,32 @@
   int v68; // ecx@167
   int v69; // eax@173
   int v70; // edi@178
-  int v71; // eax@178
-  int v72; // ecx@178
-  int x; // ebx@180
-  int v74; // eax@182
+  //int v71; // eax@178
+  //int v72; // ecx@178
+  //int x; // ebx@180
+  //int v74; // eax@182
   int v75; // eax@184
   IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184
   int uStartZ; // ecx@184
   int v79; // ebx@185
   int v127; // esi@185
   int v86; // edi@196
-  int v87; // eax@196
-  int v88; // ecx@196
-  int v89; // eax@198
-  int v90; // ecx@200
+  //int v87; // eax@196
+  //int v88; // ecx@196
+  //int v89; // eax@198
+  //int v90; // ecx@200
   int v92; // ebx@203
-  int v93; // ST08_4@204
+  //int v93; // ST08_4@204
   int v97; // ST08_4@204
   float result; // eax@212
-  struct 
-  {
-  char v102[4]; // [sp+Ch] [bp-68h]@191
-  __int16 v103; // [sp+10h] [bp-64h]@190
-  __int16 v104; // [sp+12h] [bp-62h]@190
-  } v102;
+  //struct 
+  //{
+  int v106; // [sp+Ch] [bp-68h]@191
+  int v103; // [sp+10h] [bp-64h]@190
+  int v104; // [sp+12h] [bp-62h]@190
+  //} v102;
   int v105; // [sp+1Ch] [bp-58h]@1
-  int v106; // [sp+20h] [bp-54h]@3
+  int v107; // [sp+20h] [bp-54h]@3
   int uEndZ; // [sp+24h] [bp-50h]@3
   int v108; // [sp+28h] [bp-4Ch]@9
   int v109; // [sp+2Ch] [bp-48h]@9
@@ -970,7 +970,7 @@
   int v114; // [sp+40h] [bp-34h]@9
   int v115; // [sp+44h] [bp-30h]@9
   int v116; // [sp+48h] [bp-2Ch]@9
-  int v117; // [sp+4Ch] [bp-28h]@9
+  //int v117; // [sp+4Ch] [bp-28h]@9
   int v118; // [sp+50h] [bp-24h]@9
   int v119; // [sp+54h] [bp-20h]@1
   int v120; // [sp+58h] [bp-1Ch]@1
@@ -1014,8 +1014,8 @@
   else
     v10 = stru_5C6E00->pTanTable[v9];
   v108 = abs(v10);
-  v11 = v124;
-  v12 = v123;
+  //v11 = v124;
+  //v12 = v123;
   v114 = 0;
   v115 = 0;
   pIndoorCameraD3D_4 = 0;
@@ -1026,13 +1026,13 @@
   v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1;
   uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1;
   terrain_76E1C8[0] = 65535;
-  //v116 = 1;
+  uint _i = 1;
   v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1;
-  //v117 = 1;
+  uint j = 1;
   terrain_76E3C8[0] = 65535;
   terrain_76DDC8[0] = 65535;
   terrain_76DFC8[0] = 65535;
-  for( v116=1; v116 < 128; v116++)
+  for( _i = 1; _i < 128; _i++)
   {
     if ( v112 >= 0x10000 )
     {
@@ -1048,22 +1048,22 @@
     }
     else
     {
-      v11 += v110;
+      v124 += v110;
       v115 += v112;
       if ( v112 + v115 >= 65536 )
       {
-        v12 += v109;
+        v123 += v109;
         v115 = (unsigned __int16)v115;
       }
     }
-    if ( v11 < i || v11 > v120 || v12 < v122 || v12 > v119 )
+    if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 )
       break;
     //v13 = v116++;
-    terrain_76E3C8[v116] = v11;
-    terrain_76E1C8[v116] = v12;
-  }
-
-  for( v117=1; v117 < 128; v117++ )
+    terrain_76E3C8[_i] = v124;
+    terrain_76E1C8[_i] = v123;
+  }
+
+  for( j = 1; j < 128; j++ )
   {
     if ( v108 >= 65536 )
     {
@@ -1088,7 +1088,7 @@
     }
     //if ( v117 >= 128 )
       //break;
-    if ( v126 < i )
+    if ( v126 < _i )
       break;
     if ( v126 > v120 )
       break;
@@ -1097,27 +1097,27 @@
       break;
     if ( v118 > v119 )
       break;
-    terrain_76DFC8[v117] = v126;
-    terrain_76DDC8[v117] = v14;
+    terrain_76DFC8[j] = v126;
+    terrain_76DDC8[j] = v14;
   }
   v16 = 0;
   v126 = 0;
-  v17 = v117 - 1;
-  v18 = v116 - 1;
+  v17 = j - 1;
+  v18 = _i - 1;
   switch ( v105 )
   {
     case 0:
     case 7:
     {
-      v116 = terrain_76DFC8[v17];
-      if ( v120 > v116 )
+      //v116 = terrain_76DFC8[v17];
+      if ( v120 > terrain_76DFC8[v17] )
       {
         v125 = v120;
-        memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - v116 + 1));
+        memset32(terrain_76D9C8, v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1));
         v19 = v120;
         do
           terrain_76DBC8[v126++] = v19--;
-        while ( v19 >= v116 );
+        while ( v19 >= terrain_76DFC8[v17] );
         if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] )
         {
           do
@@ -1136,9 +1136,9 @@
         if ( v21 < v124 )
           break;
         terrain_76DBC8[v16] = v21;
-        v22 = terrain_76DDC8[v17] == 65535;
+        //v22 = terrain_76DDC8[v17] == 65535;
         terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1;
-        if ( v22 )
+        if ( terrain_76DDC8[v17] == 65535 )
         {
           terrain_76D9C8[v16] = v123 + 1;
           break;
@@ -1210,18 +1210,18 @@
     case 1:
     case 2:
     {
-      v116 = terrain_76DDC8[v17];
-      if ( v122 < v116 )
+      //v116 = terrain_76DDC8[v17];
+      if ( v122 < terrain_76DDC8[v17] )
       {
         v106 = v122;
-        memset32(terrain_76DBC8, v120 + 1, 4 * (v116 - v122 + 1));
+        memset32(terrain_76DBC8, v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1));
         v32 = v122;
         do
         {
           v33 = v126++;
           terrain_76D9C8[v33] = v32++;
         }
-        while ( v32 <= v116 );
+        while ( v32 <= terrain_76DDC8[v17] );
         if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
         {
           do
@@ -1237,10 +1237,10 @@
       v125 = terrain_76DDC8[v17];
       while ( v35 <= v123 )
       {
-        v22 = terrain_76DFC8[v17] == 65535;
+        //v22 = terrain_76DFC8[v17] == 65535;
         terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1;
         terrain_76D9C8[v16] = v125;
-        if ( v22 )
+        if ( terrain_76DFC8[v17] == 65535 )
         {
           terrain_76DBC8[v16] = v124 + 1;
           break;
@@ -1313,15 +1313,15 @@
     case 5:
     case 6:
     {
-      v116 = terrain_76DDC8[v17];
-      if ( v119 > v116 )
+      //v116 = terrain_76DDC8[v17];
+      if ( v119 > terrain_76DDC8[v17] )
       {
         v106 = v119;
-        memset32(terrain_76DBC8, i, 4 * (v119 - v116 + 1));
+        memset32(terrain_76DBC8, i, 4 * (v119 - terrain_76DDC8[v17] + 1));
         v45 = v119;
         do
           terrain_76D9C8[v126++] = v45--;
-        while ( v45 >= v116 );
+        while ( v45 >= terrain_76DDC8[v17] );
         if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
         {
           do
@@ -1337,10 +1337,10 @@
       v125 = terrain_76DDC8[v17];
       while ( v47 >= v123 )
       {
-        v22 = terrain_76DFC8[v17] == 65535;
+        //v22 = terrain_76DFC8[v17] == 65535;
         terrain_76DBC8[v16] = terrain_76DFC8[v17];
         terrain_76D9C8[v16] = v125;
-        if ( v22 )
+        if ( terrain_76DFC8[v17] == 65535 )
         {
           terrain_76DBC8[v16] = v124;
           break;
@@ -1412,18 +1412,18 @@
     case 3:
     case 4:
     {
-      v116 = terrain_76DFC8[v17];
-      if ( i < v116 )
+      //v116 = terrain_76DFC8[v17];
+      if ( i < terrain_76DFC8[v17] )
       {
         v106 = i;
-        memset32(terrain_76D9C8, v122, 4 * (v116 - i + 1));
+        memset32(terrain_76D9C8, v122, 4 * (terrain_76DFC8[v17] - i + 1));
         v56 = i;
         do
         {
           v57 = v126++;
           terrain_76DBC8[v57] = v56++;
         }
-        while ( v56 <= v116 );
+        while ( v56 <= terrain_76DFC8[v17] );
         if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] )
         {
           do
@@ -1494,7 +1494,7 @@
         v67 = terrain_76E1C8[v18];
         terrain_76D7C8[v16] = v66;
         terrain_76D5C8[v16] = v67 + 1;
-        if ( v67 == 65535 )
+        if ( terrain_76E1C8[v18] == 65535 )
         {
           v31 = v123 + 1;
           terrain_76D5C8[v16] = v31;
@@ -1526,26 +1526,26 @@
     for ( i = v69; i >= 1; --i )
     {
       //v70 = i;
-      v71 = terrain_76D7C8[i];//88
-      v72 = terrain_76DBC8[i];//0
-      if ( v71 < v72 )//swap
-      {
-        terrain_76DBC8[i] = v71;
-        terrain_76D7C8[i] = v72;
-      }
-      x = terrain_76DBC8[i];//0
+      //v71 = terrain_76D7C8[i];//88
+      //v72 = terrain_76DBC8[i];//0
+      if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap
+      {
+        terrain_76DBC8[i] = terrain_76D7C8[i];
+        terrain_76D7C8[i] = terrain_76DBC8[i];
+      }
+      //x = terrain_76DBC8[i];//0
       v111 = 0;
-      if ( x <= 0 )
-        x = -x;
-      v74 = terrain_76D7C8[i];
-      if ( v74 <= 0 )
-        v74 = -v74;
-      v75 = v74 + 2;
+      if ( terrain_76DBC8[i] <= 0 )
+        terrain_76DBC8[i] = -terrain_76DBC8[i];
+      //v74 = terrain_76D7C8[i];
+      if ( terrain_76D7C8[i] <= 0 )
+        terrain_76D7C8[i] = -terrain_76D7C8[i];
+      v75 = terrain_76D7C8[i] + 2;
       //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D;
       uEndZ = v75;
       //pIndoorCameraD3D_4 = pIndoorCameraD3D_3;
-      uStartZ = x - 2;
-      if ( x - 2 < v75 )
+      uStartZ = terrain_76DBC8[i] - 2;
+      if ( terrain_76DBC8[i] - 2 < v75 )
       {
         v127 = 0;
         //v79 = (v73 - 66) << 9;
@@ -1554,10 +1554,10 @@
         v111 = v75 - uStartZ;
         for (int z = uStartZ; z < uEndZ; ++z)
         {
-          ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
+          ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
           ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512;
           ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]);
-          ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512;
+          ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;
           ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512;
           ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1);
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
@@ -1574,57 +1574,58 @@
        }
         //while ( v116 < v107 );
       }
-      v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
-      v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]);
+      v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
+      v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]);
       if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
-        Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102);
+        Render::DrawTerrainD3D(v111, 0, v103, v104);//Render::RenderTerrainD3D();
       else
-        Render::DrawTerrainSW(v111, 0, (int)&v102);
-    }
-  }
-/*  else
+        Render::DrawTerrainSW(v111, 0, v103, v104);
+    }
+  }
+  else
   {
     for ( i = v69; i >= 1; --i )
     {
-      v86 = i;
-      v87 = terrain_76D5C8[i];
-      v88 = terrain_76D9C8[i];
-      if ( v87 < v88 )
-      {
-        terrain_76D9C8[v86] = v87;
-        terrain_76D5C8[v86] = v88;
-      }
-      v89 = terrain_76D9C8[v86];
+      //v86 = i;
+      //v87 = terrain_76D5C8[i];
+      //v88 = terrain_76D9C8[i];
+      if ( terrain_76D5C8[i] < terrain_76D9C8[i] )
+      {
+        terrain_76D9C8[i] = terrain_76D5C8[i];
+        terrain_76D5C8[i] = terrain_76D9C8[i];
+      }
+      //v89 = terrain_76D9C8[i];
       v111 = 0;
-      if ( v89 <= 0 )
-        v89 = -v89;
-      v90 = terrain_76D5C8[v86];
-      if ( v90 <= 0 )
-        v90 = -v90;
+      if ( terrain_76D9C8[i] <= 0 )
+        terrain_76D9C8[i] = -terrain_76D9C8[i];
+      //v90 = terrain_76D5C8[i];
+      if ( terrain_76D5C8[i] <= 0 )
+        terrain_76D5C8[i] = -terrain_76D5C8[i];
       pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D;
-      v107 = v90 + 2;
-      if ( v89 - 2 < v90 + 2 )
+      v107 = terrain_76D5C8[i] + 2;
+      if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 )
       {
         v86 = 0;
-        v116 = v89 - 2;
-        v92 = (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 *)&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 *)&pHeight;
-          pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
-          *(float *)((char *)&ptr_801A04->vWorldPosition.z + v86) = (double)pHeight;
+        //v116 = terrain_76D9C8[i] - 2;
+        v92 = (66 - terrain_76D9C8[i]) << 9;
+        //pHeight = (66 - terrain_76D9C8[i]) << 9;
+        v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2);
+        //do
+        for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 )
+        {
+          //v93 = v116;
+          //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9;
+          ptr_801A08[v86].vWorldPosition.x = terrain_76DBC8[v86] - 64 << 9;
+          //*(float *)&pHeight = (double)pHeight;
+          ptr_801A08[v86].vWorldPosition.y = v92;
+          //v106 = ;
+          //v97 = v116;
+          ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116);
+          //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9;
+          ptr_801A04[v86].vWorldPosition.x = terrain_76DBC8[v86] - 63 << 9;
+          ptr_801A04[v86].vWorldPosition.y = v92;
+          //pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97);
+          ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116);
           if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
           {
            pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1);
@@ -1634,19 +1635,19 @@
           }
           v92 -= 512;
           v86 += 48;
-          ++v116;
-          pHeight = v92;
-		}
-        while ( v116 < v107 );
+          //++v116;
+          //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);
+        Render::DrawTerrainD3D(v111, 1, v103, v104);
       else
-        Render::DrawTerrainSW(v111, 1, (int)&v102);
-    }
-  }*/
+        Render::DrawTerrainSW(v111, 1, v103, v104);
+    }
+  }
   result = v126;
   pOutdoorCamera->field_40 = v126;
   return result;
@@ -1838,9 +1839,9 @@
 }
 
 //----- (0048034E) --------------------------------------------------------
-void Render::DrawTerrainD3D(int a1, int a2, int a3)
-{
-  int v3; // esi@1
+void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4)
+{
+  //int v3; // esi@1
   int v4; // edi@1
   int v5; // ebx@2
   int v6; // eax@2
@@ -1914,10 +1915,10 @@
   unsigned int v73; // eax@150
   int v74; // eax@154
   unsigned int v75; // eax@158
-  unsigned int v76; // [sp-10h] [bp-E0h]@61
+  //unsigned int v76; // [sp-10h] [bp-E0h]@61
   int v77; // [sp-Ch] [bp-DCh]@61
   IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61
-  int v79; // [sp-4h] [bp-D4h]@61
+  //int v79; // [sp-4h] [bp-D4h]@61
   int v80; // [sp+0h] [bp-D0h]@59
   int v81; // [sp+0h] [bp-D0h]@109
   int v82; // [sp+54h] [bp-7Ch]@1
@@ -1961,24 +1962,24 @@
 
   static stru154 static_sub_0048034E_stru_154;
   static stru154 stru_76D5A8;
-  v3 = a1;
+  //v3 = a1;
   v82 = a2;
-  v83 = *(/*short **/_WORD *)(a3 + 4);
-  X = abs(*(/*short **/_WORD *)(a3 + 6));
+  v83 = a3;
+  X = abs(unk4);
   v4 = 0;
   v88 = 0;
-  v84 = v3 - 1;
+  v84 = a1 - 1;
   v90 = (float)pOutdoor->vSunlight.x / 65536.0;
   v91 = (float)pOutdoor->vSunlight.y / 65536.0;
   v92 = (float)pOutdoor->vSunlight.z / 65536.0;
-  if ( v3 - 1 > 0 )
+  if ( a1 - 1 > 0 )
   {
     while ( 1 )
     {
       v5 = abs(X);//v5 = 13108
       v6 = abs(v83);//v6 = 13108
       --X;
-      __debugbreak(); // uncoment & refactor following large if
+      //__debugbreak(); // uncoment & refactor following large if
       v93 = (int)&stru_76E5C8[(v5 << 7) + v6];
       /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7),
                                                                        v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)),
@@ -2411,12 +2412,12 @@
               v80 = true;
             }
             //v79 = 0;
-            //v78 = pBitmaps_LOD->pHardwareTextures[v75];
+            v78 = pBitmaps_LOD->pHardwareTextures[v75];
             v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary
             //v77 = (int)v71;
             //v76 = v71->uNumVertices;
             //goto LABEL_161;
-            pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80);
+            pRenderer->DrawTerrainPolygon(v71->uNumVertices, (stru148 *)v71, v78, 0, v80);
             goto LABEL_162;
           }
           v38 = (stru148 *)v71;
@@ -2435,7 +2436,7 @@
 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag;
 
 //----- (00481212) --------------------------------------------------------
-void Render::DrawTerrainSW(int a1, int a2, int a3)
+void Render::DrawTerrainSW(int a1, int a2, int a3, int a4)
 {
   int v3; // esi@1
   int v4; // ecx@1
@@ -2549,8 +2550,8 @@
   //v4 = *(short *)(a3 + 4);
   //v5 = *(short *)(a3 + 6);
   v85 = a2;
-  v86 = *(_WORD *)(a3 + 4); //v4;
-  X = abs(*(_WORD *)(a3 + 6)); //v5
+  v86 = a3; //v4;
+  X = abs(a4); //v5
   v6 = 0;
   v90 = 0;
   v81 = v3 - 1;
--- a/Render.h	Thu May 09 21:19:59 2013 +0600
+++ b/Render.h	Sun May 12 09:38:20 2013 +0600
@@ -365,8 +365,8 @@
   void TransformBillboardsAndSetPalettesODM();
   float DrawBezierTerrain();
   void RenderTerrainD3D();
-  void DrawTerrainD3D(int a1, int edx0, int a3);
-  void DrawTerrainSW(int a1, int a2, int a3);
+  void DrawTerrainD3D(int a1, int edx0, int a3, int unk4);
+  void DrawTerrainSW(int a1, int a2, int a3, int a4);
   void ExecOutdoorDrawSW();
   void ChangeBetweenWinFullscreenModes();
   void DrawBillboardList_BLV();