changeset 1072:48168499f52e

pointer cleaning
author zipi
date Sat, 25 May 2013 11:24:10 +0100
parents a7e63532b9a8
children d4a1a46192ba
files Player.cpp Render.cpp mm7_3.cpp
diffstat 3 files changed, 49 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Fri May 24 20:57:11 2013 +0100
+++ b/Player.cpp	Sat May 25 11:24:10 2013 +0100
@@ -7853,7 +7853,7 @@
     v4 = pValue;
     return v4 >= pValue;
   }
-  return *((int *)this + 2 * VarNum - 210);
+  return &LODWORD(this->pConditions[VarNum]);// *((int *)this + 2 * VarNum - 210);
 }
 
 
--- a/Render.cpp	Fri May 24 20:57:11 2013 +0100
+++ b/Render.cpp	Sat May 25 11:24:10 2013 +0100
@@ -7659,11 +7659,11 @@
   signed int v4; // edi@2
   int v5; // eax@3
   int v6; // edx@5
-  char *v7; // eax@6
-  char *v8; // ecx@6
-  double v9; // st6@7
-  int v10; // ebx@7
-  int v11; // ebx@7
+  RenderVertexD3D3 *v7; // eax@6
+  RenderVertexSoft *v8; // ecx@6
+  //double v9; // st6@7
+  //int v10; // ebx@7
+  //int v11; // ebx@7
 
   if ( this->uNumD3DSceneBegins )
   {
@@ -7675,29 +7675,18 @@
       if ( v5 < pOutdoor->max_terrain_dimming_level )
         v5 = pOutdoor->max_terrain_dimming_level;
       v6 = 8 * v5 | ((8 * v5 | (v5 << 11)) << 8);
-      if ( a2 > 0 )
-      {
-        v7 = (char *)&d3d_vertex_buffer[0].pos.y;
-        v8 = (char *)&array_507D30[0].vWorldViewProjY;
-        do
-        {
-          v9 = *((float *)v8 - 4) * 0.061758894;
-          v10 = *((int *)v8 - 1);
-          *((int *)v7 + 4) = 0;
-          *((int *)v7 - 1) = v10;
-          *(int *)v7 = *(int *)v8;
-          *((int *)v7 + 2) = *((int *)v8 + 1);
-          *((int *)v7 + 5) = *((int *)v8 + 2);
-          v11 = *((int *)v8 + 3);
-          *((int *)v7 + 3) = v6;
-          *((int *)v7 + 6) = v11;
-          v8 += 48;
-          v7 += 32;
-          --v4;
-          *((float *)v7 - 7) = 1.0 - 1.0 / v9;
-        }
-        while ( v4 );
-      }
+	  for (uint i = 0; i < a2; ++i)
+	  {
+		d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
+		d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
+		d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / array_507D30[i].vWorldViewPosition.y;
+		d3d_vertex_buffer[i].rhw = array_507D30[i]._rhw;
+		d3d_vertex_buffer[i].diffuse = v6;
+		d3d_vertex_buffer[i].specular = 0;
+		d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u;
+		d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v;
+	  }
+
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
         D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
@@ -7713,8 +7702,8 @@
 {
   //Render *v8; // edi@1
   //unsigned int v9; // esi@3
-  char *v12; // ecx@9
-  char *v13; // eax@9
+  RenderVertexSoft *v12; // ecx@9
+  RenderVertexD3D3 *v13; // eax@9
   double v14; // st6@10
   int v15; // edx@10
   Texture *v16; // edx@10
@@ -7772,35 +7761,18 @@
       __debugbreak();
       ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
       ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
-      if ( (signed int)uNumVertices > 0 )
-      {
-        v12 = (char *)&array_507D30[0].vWorldViewPosition;
-        v13 = (char *)&d3d_vertex_buffer[0].pos.y;
-        auto a7 = uNumVertices;
-        uint v18;
-        do
-        {
-          v14 = *(float *)v12 * 0.061758894;
-          v15 = *((int *)v12 + 3);
-          *((int *)v13 + 4) = 0;
-          *((int *)v13 - 1) = v15;
-          *(int *)v13 = *((int *)v12 + 4);
-          *((int *)v13 + 3) = uCorrectedColor;
-          v16 = pTex;
-          v13 += 32;
-          *((float *)v13 - 7) = 1.0 - 1.0 / v14;
-          v17 = 1.0 / *(float *)v12;
-          v12 += 48;
-          v18 = a7-- == 1;
-          *((float *)v13 - 6) = v17;
-          pHwTex = (IDirect3DTexture2 *)v16->uTextureWidth;
-          v19 = pTex;
-          *((float *)v13 - 3) = *((float *)v12 - 6) / (double)(signed int)pHwTex;
-          pHwTex = (IDirect3DTexture2 *)v19->uTextureHeight;
-          *((float *)v13 - 2) = *((float *)v12 - 5) / (double)(signed int)pHwTex;
-        }
-        while ( !v18 );
-      }
+	  for (uint i = 0; i < uNumVertices; ++i)
+	  {
+		d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX;
+		d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY;
+		d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894);
+		d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x;
+		d3d_vertex_buffer[i].diffuse = uCorrectedColor;
+		d3d_vertex_buffer[i].specular = 0;
+		d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth;
+		d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight;
+	  }
+
       ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
       ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
       ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
--- a/mm7_3.cpp	Fri May 24 20:57:11 2013 +0100
+++ b/mm7_3.cpp	Sat May 25 11:24:10 2013 +0100
@@ -5014,7 +5014,7 @@
       {
 		v1->field_40 |= 1u;
         v2 = v1->uNumFaces;
-        v3 = (ODMFace *)v1->pFaces;
+        v3 = v1->pFaces;
         v74 = 0;
         v76 = v3;
         v68 = v2;
@@ -5084,16 +5084,16 @@
         *(int *)&v12->flags = 0;
         if ( v82 == v7 )
           *(int *)&v12->flags = 65536;
-        v12->pODMFace = (ODMFace *)v3;
+        v12->pODMFace = v3;
         v12->uNumVertices = v7;
         v12->field_59 = 5;
-        v84 = *(int *)v3;
+        v84 = v3->pFacePlane.vNormal.x;
         v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16;
         v82 = -pOutdoor->vSunlight.y;
-        v84 = *(int *)(v3 + 4);
+        v84 = v3->pFacePlane.vNormal.y;
         v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16;
         v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z;
-        v84 = *(int *)(v3 + 8);
+        v84 = v3->pFacePlane.vNormal.z;
         v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
         v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
         v13 = (double)v84 * 0.000015258789;
@@ -5108,8 +5108,8 @@
           *(char *)v15 = 0;
         if ( *(char *)v15 > 31 )
           *(char *)v15 = 31;
-        v16 = *(short *)(v3 + 272);
-        if ( *(char *)(v3 + 29) & 0x40 )
+        v16 = v3->uTextureID;
+        if ( BYTE1(v3->uAttributes) & 0x40 )
           v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed);
         v17 = v16;
         result = (BSPModel *)&pBitmaps_LOD->pTextures[v16];
@@ -5120,7 +5120,7 @@
           return result;
         ++pOutdoorCamera->numStru148s;
         ++pOutdoorCamera->field_44;
-        if ( !ODMFace::IsBackfaceCulled((ODMFace *)v3, array_73D150, v12) )
+        if ( !ODMFace::IsBackfaceCulled(v3, array_73D150, v12) )
         {
 LABEL_71:
           --pOutdoorCamera->numStru148s;
@@ -5129,18 +5129,18 @@
         }
         LOBYTE(v20) = v79;
         v21 = a1;
-        *(char *)(v3 + 305) = 1;
+        v3->bVisible = 1;
         v12->uBModelFaceID = v20;
         LOWORD(v20) = (unsigned __int8)v20;
         v12->uBModelID = v21;
         v22 = 8 * (v20 | (v21 << 6));
         LOBYTE(v22) = v22 | 6;
         v12->field_50 = v22;
-        if ( *(char *)(v3 + 28) & 0x10 )
+        if ( v3->uAttributes & 0x10 )
           *(int *)&v12->flags |= 2u;
-        if ( *(char *)(v3 + 30) & 0x40 )
+        if ( BYTE2(v3->uAttributes) & 0x40 )
           HIBYTE(v12->flags) |= 4u;
-        v23 = *(int *)(v3 + 28);
+        v23 = v3->uAttributes;
         if ( v23 & 4 )
         {
           HIBYTE(v12->flags) |= 4u;
@@ -5150,7 +5150,7 @@
           if ( v23 & 0x20 )
             HIBYTE(v12->flags) |= 8u;
         }
-        v24 = *(int *)(v3 + 28);
+        v24 = v3->uAttributes;
         if ( BYTE1(v24) & 8 )
         {
           HIBYTE(v12->flags) |= 0x20u;
@@ -5277,9 +5277,9 @@
             if ( !v50 )
               goto LABEL_71;
             sr_sub_4829B9(
-              &array_73D150[*(char *)(v3 + 298)],
-              &array_73D150[*(char *)(v3 + 299)],
-              &array_73D150[*(char *)(v3 + 300)],
+              &array_73D150[v3->uGradientVertex1],
+              &array_73D150[v3->uGradientVertex2],
+              &array_73D150[v3->uGradientVertex3],
               v12,
               0);
             v51 = 0;
@@ -5307,7 +5307,7 @@
 LABEL_72:
       ++v79;
       v1 = v78;
-      v3 += 308;
+      ++v3;
       v76 = v3;
       if ( v79 >= v68 )
         goto LABEL_73;