diff mm7_2.cpp @ 271:1f0af5cac2dd

_42ECB5_PlayerAttacksActor
author Nomad
date Mon, 18 Feb 2013 13:07:25 +0200
parents ac44e716d051
children 0ea5fbd16edb 640a176c030f
line wrap: on
line diff
--- a/mm7_2.cpp	Mon Feb 18 11:29:55 2013 +0200
+++ b/mm7_2.cpp	Mon Feb 18 13:07:25 2013 +0200
@@ -9124,24 +9124,26 @@
 }
 
 //----- (00452A9E) --------------------------------------------------------
-signed int __fastcall sub_452A9E(signed int a1)
+int sub_452A9E(int square_distance)
 {
   signed int result; // eax@2
   int v2; // edx@3
-  signed int v3; // edi@3
-  signed int v4; // ebx@3
+  unsigned int v3; // edi@3
+  //signed int v4; // ebx@3
   int v5; // esi@4
 
-  if ( a1 > 1 )
-  {
+  if (square_distance < 1)
+    return square_distance;
+
+
     v2 = 0;
-    v3 = a1;
+    v3 = square_distance;
     result = 0;
-    v4 = 16;
-    do
-    {
+    //v4 = 16;
+  for (uint i = 0; i < 16; ++i)
+  {
       result *= 2;
-      v2 = ((unsigned int)v3 >> 30) | 4 * v2;
+      v2 = (v3 >> 30) | 4 * v2;
       v5 = 2 * result + 1;
       v3 *= 4;
       if ( v2 >= (unsigned int)v5 )
@@ -9149,17 +9151,11 @@
         ++result;
         v2 -= v5;
       }
-      --v4;
-    }
-    while ( v4 );
-    if ( a1 - result * result >= (unsigned int)(result - 1) )
+      //--v4;
+  }
+    //while ( v4 );
+    if ( square_distance - result * result >= (unsigned int)(result - 1) )
       ++result;
-  }
-  else
-  {
-    result = a1;
-  }
-  return result;
 }
 
 //----- (00452AE2) --------------------------------------------------------