changeset 1471:736973e11d11

sub_4075DB cleaned
author zipi
date Mon, 26 Aug 2013 20:59:51 +0100
parents c987b5ed09af
children 2395e99b89d0
files mm7_5.cpp
diffstat 1 files changed, 30 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/mm7_5.cpp	Mon Aug 26 19:11:55 2013 +0100
+++ b/mm7_5.cpp	Mon Aug 26 20:59:51 2013 +0100
@@ -4598,20 +4598,15 @@
 //----- (004075DB) --------------------------------------------------------
 bool __fastcall sub_4075DB(int a1, int a2, int a3, BLVFace *a4)
 {
-  BLVFace *v4; // eax@1
   unsigned int v5; // esi@1
-  signed int v6; // esi@2
   char v7; // zf@2
   int v8; // edi@2
   Vec3_short_ *v9; // ecx@3
   int v10; // edx@4
-  signed int v11; // esi@7
   Vec3_short_ *v12; // ecx@8
   int v13; // edx@9
-  signed int v14; // esi@11
   Vec3_short_ *v15; // ecx@12
   int v16; // edx@13
-  int v17; // eax@14
   bool v18; // esi@14
   int v19; // ecx@14
   int v20; // ecx@16
@@ -4622,113 +4617,72 @@
   signed int v25; // eax@22
   signed __int64 v26; // qtt@22
   bool result; // eax@25
-  int v28; // [sp+8h] [bp-14h]@14
   int v29; // [sp+10h] [bp-Ch]@14
   signed int a3a; // [sp+24h] [bp+8h]@14
   int a4a; // [sp+28h] [bp+Ch]@2
 
   __debugbreak();
 
-  v4 = a4;
   v5 = a4->uAttributes;
-  if ( v5 & 0x100 )
+  if ( v5 & FACE_XY_PLANE )
   {
-    v6 = 0;
-    v7 = a4->uNumVertices == 0;
     a4a = a1;
     v8 = a2;
-    if ( !v7 )
-    {
-      v9 = pIndoor->pVertices;
-      do
-      {
-        dword_4F5D98_xs[v6] = v9[v4->pVertexIDs[v6]].x;
-        v10 = v4->pVertexIDs[v6++];
-        dword_4F5CC4_ys[v6] = v9[v10].y;
-      }
-      while ( v6 < v4->uNumVertices );
-    }
+	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;
+	}
   }
   else
   {
     v8 = a3;
-    if ( v5 & 0x200 )
+    if ( v5 & FACE_XY_PLANE )
     {
-      v11 = 0;
-      v7 = a4->uNumVertices == 0;
       a4a = a1;
-      if ( !v7 )
-      {
-        v12 = pIndoor->pVertices;
-        do
-        {
-          dword_4F5D98_xs[v11] = v12[v4->pVertexIDs[v11]].x;
-          v13 = v4->pVertexIDs[v11++];
-          dword_4F5CC4_ys[v11] = v12[v13].z;
-        }
-        while ( v11 < v4->uNumVertices );
-      }
+      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;
+	  }
     }
     else
     {
-      v14 = 0;
-      v7 = a4->uNumVertices == 0;
       a4a = a2;
-      if ( !v7 )
-      {
-        v15 = pIndoor->pVertices;
-        do
-        {
-          dword_4F5D98_xs[v14] = v15[v4->pVertexIDs[v14]].y;
-          v16 = v4->pVertexIDs[v14++];
-          dword_4F5CC4_ys[v14] = v15[v16].z;
-        }
-        while ( v14 < v4->uNumVertices );
-      }
+      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;
+	  }
     }
   }
-  v17 = v4->uNumVertices;
   a3a = 0;
-  dword_4F5D98_xs[v17] = dword_4F5D98_xs[0];
-  dword_4F5CC4_ys[v17 + 1] = dword_4F5CC4_ys[1];
-  v28 = v17;
-  v18 = dword_4F5CC4_ys[1] >= v8;
-  v19 = 0;
-  v29 = 0;
-  if ( v17 <= 0 )
-    return 0;
-  do
+  dword_4F5D98_xs[a4->uNumVertices] = dword_4F5D98_xs[0];
+  dword_4F5CC4_ys[a4->uNumVertices + 1] = dword_4F5CC4_ys[1];
+  for(int i = 0; i < a4->uNumVertices; i++)
   {
     if ( a3a >= 2 )
       break;
-    v20 = v19;
-    v21 = dword_4F5CC4_ys[v20 + 2];
-    if ( v18 ^ (v21 >= v8) )
+    if ( dword_4F5CC4_ys[i + 1] >= v8 ^ (dword_4F5CC4_ys[i + 2] >= v8) )
     {
-      v22 = dword_4F5D98_xs[v20 + 1];
-      if ( v22 >= a4a )
-        v23 = 0;
-      else
-        v23 = 2;
-      v24 = v23 | (dword_4F5D98_xs[v20] < a4a);
-      if ( v24 != 3 )
+	  if( dword_4F5D98_xs[i + 1] >= a4a || dword_4F5D98_xs[i] >= a4a)
       {
-        if ( !v24
-          || (v25 = v22 - dword_4F5D98_xs[v20],
+		  if ( (dword_4F5D98_xs[i + 1] >= a4a && dword_4F5D98_xs[i] >= a4a)
+          || (v25 = dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i],
               LODWORD(v26) = v25 << 16,
               HIDWORD(v26) = v25 >> 16,
-              dword_4F5D98_xs[v20]
+              dword_4F5D98_xs[i]
             + ((signed int)(((unsigned __int64)(v26
-                                              / (v21 - dword_4F5CC4_ys[v20 + 1])
-                                              * ((v8 - dword_4F5CC4_ys[v20 + 1]) << 16)) >> 16)
+                                              / (dword_4F5CC4_ys[i + 2] - dword_4F5CC4_ys[i + 1])
+                                              * ((v8 - dword_4F5CC4_ys[i + 1]) << 16)) >> 16)
                           + 32768) >> 16) >= a4a) )
           ++a3a;
       }
     }
-    v18 = v21 >= v8;
-    v19 = v29++ + 1;
   }
-  while ( v29 < v28 );
   result = 1;
   if ( a3a != 1 )
     result = 0;