changeset 1472:2395e99b89d0

sub_4077F1 cleaned, and fixed previous mistake in cleaning
author zipi
date Mon, 26 Aug 2013 21:40:29 +0100
parents 736973e11d11
children 5a29caf9b79d
files mm7_5.cpp
diffstat 1 files changed, 42 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_5.cpp	Mon Aug 26 20:59:51 2013 +0100
+++ b/mm7_5.cpp	Mon Aug 26 21:40:29 2013 +0100
@@ -4624,15 +4624,15 @@
   __debugbreak();
 
   v5 = a4->uAttributes;
+  v9 = pIndoor->pVertices;
   if ( v5 & FACE_XY_PLANE )
   {
     a4a = a1;
     v8 = a2;
-	v9 = pIndoor->pVertices;
     for(int i = 0; i < a4->uNumVertices; i++)
 	{
         dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].x;
-        dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i+1]].y;
+        dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i]].y;
 	}
   }
   else
@@ -4641,21 +4641,19 @@
     if ( v5 & FACE_XY_PLANE )
     {
       a4a = a1;
-      v9 = pIndoor->pVertices;
       for(int i = 0; i < a4->uNumVertices; i++)
 	  {
 		dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].x;
-		dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i+1]].z;
+		dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i]].z;
 	  }
     }
     else
     {
       a4a = a2;
-      v9 = pIndoor->pVertices;
       for(int i = 0; i < a4->uNumVertices; i++)
 	  {
 		dword_4F5D98_xs[i] = v9[a4->pVertexIDs[i]].y;
-		dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i+1]].z;
+		dword_4F5CC4_ys[i+1] = v9[a4->pVertexIDs[i]].z;
 	  }
     }
   }
@@ -4692,11 +4690,12 @@
 //----- (004077F1) --------------------------------------------------------
 bool __fastcall sub_4077F1(int a1, int a2, int a3, ODMFace *a4, BSPVertexBuffer *a5)
 {
-  ODMFace *v5; // eax@1
-  unsigned int v6; // esi@1
+  //ODMFace *v5; // eax@1
+  Vec3_short_ *v9;
+  unsigned int v5; // esi@1
   signed int v7; // edi@1
-  char v8; // zf@2
-  unsigned __int16 *v9; // edx@3
+  //char v8; // zf@2
+  //unsigned __int16 *v9; // edx@3
   int v10; // ecx@4
   unsigned __int16 *v11; // edx@8
   int v12; // ecx@9
@@ -4718,111 +4717,68 @@
 
   __debugbreak();
 
-  v5 = a4;
-  v6 = a4->uAttributes;
-  v7 = 0;
-  if ( v6 & 0x100 )
+  v5 = a4->uAttributes;
+  v9 = a5->pVertices;
+  if ( v5 & FACE_XY_PLANE )
   {
-    v8 = a4->uNumVertices == 0;
     a4a = a1;
     a3 = a2;
-    if ( !v8 )
-    {
-      v9 = v5->pVertexIDs;
-      do
-      {
-        ++v7;
-        dword_4F5BF4_xs[v7] = a5->pVertices[*v9].x;
-        v10 = *v9;
-        ++v9;
-        dword_4F5B24_ys[v7] = a5->pVertices[v10].y;
-      }
-      while ( v7 < v5->uNumVertices );
-    }
+    for(int i = 0; i < a4->uNumVertices; i++)
+	{
+        dword_4F5BF4_xs[i+1] = v9[a4->pVertexIDs[i]].x;
+        dword_4F5B24_ys[i+1] = v9[a4->pVertexIDs[i]].y;
+	}
   }
   else
   {
-    if ( v6 & 0x200 )
+    if ( v5 & FACE_XY_PLANE )
     {
-      v8 = a4->uNumVertices == 0;
       a4a = a1;
-      if ( !v8 )
-      {
-        v11 = v5->pVertexIDs;
-        do
-        {
-          ++v7;
-          dword_4F5BF4_xs[v7] = a5->pVertices[*v11].x;
-          v12 = *v11;
-          ++v11;
-          dword_4F5B24_ys[v7] = a5->pVertices[v12].z;
-        }
-        while ( v7 < v5->uNumVertices );
-      }
+      for(int i = 0; i < a4->uNumVertices; i++)
+	  {
+		dword_4F5BF4_xs[i+1] = v9[a4->pVertexIDs[i]].x;
+		dword_4F5B24_ys[i+1] = v9[a4->pVertexIDs[i]].z;
+	  }
     }
     else
     {
-      v8 = a4->uNumVertices == 0;
       a4a = a2;
-      if ( !v8 )
-      {
-        v13 = (int)v5->pVertexIDs;
-        do
-        {
-          ++v7;
-          dword_4F5BF4_xs[v7] = a5->pVertices[*(short *)v13].y;
-          v14 = *(short *)v13;
-          v13 += 2;
-          dword_4F5B24_ys[v7] = a5->pVertices[v14].z;
-        }
-        while ( v7 < v5->uNumVertices );
-      }
+      for(int i = 0; i < a4->uNumVertices; i++)
+	  {
+		dword_4F5BF4_xs[i+1] = v9[a4->pVertexIDs[i]].y;
+		dword_4F5B24_ys[i+1] = v9[a4->pVertexIDs[i]].z;
+	  }
     }
   }
-  v15 = v5->uNumVertices;
   a5a = 0;
-  dword_4F5BF4_xs[v15 + 1] = dword_4F5BF4_xs[1];
-  dword_4F5B24_ys[v15 + 1] = dword_4F5B24_ys[1];
-  v25 = 0;
-  v16 = dword_4F5B24_ys[1] >= a3;
-  if ( v15 <= 0 )
-    return 0;
-  do
+  dword_4F5BF4_xs[a4->uNumVertices + 1] = dword_4F5BF4_xs[1];
+  dword_4F5B24_ys[a4->uNumVertices + 1] = dword_4F5B24_ys[1];
+  for(int i = 0; i < a4->uNumVertices; i++)
   {
     if ( a5a >= 2 )
       break;
-    v17 = v25;
-    v18 = dword_4F5B24_ys[v25 + 2];
-    if ( v16 ^ (v18 >= a3) )
+    if ( dword_4F5B24_ys[i + 1] >= a3 ^ (dword_4F5B24_ys[i + 2] >= a3) )
     {
-      v19 = dword_4F5BF4_xs[v17 + 2];
-      if ( v19 >= a4a )
-        v20 = 0;
-      else
-        v20 = 2;
-      v21 = v20 | (dword_4F5BF4_xs[v17 + 1] < a4a);
-      if ( v21 != 3 )
+	  if( dword_4F5BF4_xs[i + 2] >= a4a || dword_4F5BF4_xs[i] >= a4a)
       {
-        if ( !v21
-          || (v22 = v19 - dword_4F5BF4_xs[v17 + 1],
-              LODWORD(v23) = v22 << 16,
-              HIDWORD(v23) = v22 >> 16,
-              dword_4F5BF4_xs[v17 + 1]
+		  if ( (dword_4F5BF4_xs[i + 2] >= a4a && dword_4F5BF4_xs[i + 1] >= a4a)
+          || (v25 = dword_4F5BF4_xs[i + 2] - dword_4F5BF4_xs[i + 1],
+              LODWORD(v23) = v25 << 16,
+              HIDWORD(v23) = v25 >> 16,
+              dword_4F5BF4_xs[i + 1]
             + ((signed int)(((unsigned __int64)(v23
-                                              / (v18 - dword_4F5B24_ys[v17 + 1])
-                                              * ((a3 - dword_4F5B24_ys[v17 + 1]) << 16)) >> 16)
+                                              / (dword_4F5B24_ys[i + 2] - dword_4F5B24_ys[i + 1])
+                                              * ((a3 - dword_4F5B24_ys[i + 1]) << 16)) >> 16)
                           + 32768) >> 16) >= a4a) )
           ++a5a;
-      }
+	  }
     }
-    ++v25;
-    v16 = v18 >= a3;
   }
-  while ( v25 < v15 );
   result = 1;
   if ( a5a != 1 )
     result = 0;
   return result;
+
 }
 
 //----- (004088E9) --------------------------------------------------------