diff Actor.cpp @ 2235:6ab7d7c112bb

adding int_get_vector_length calls where the calls were inlined
author Grumpy7
date Sun, 23 Feb 2014 03:07:46 +0100
parents b65e71eadd1b
children 47bcb700b74b aff7a7b072b7
line wrap: on
line diff
--- a/Actor.cpp	Sun Feb 23 00:34:38 2014 +0100
+++ b/Actor.cpp	Sun Feb 23 03:07:46 2014 +0100
@@ -3603,12 +3603,10 @@
     v61 = projectileSprite->field_60_distance_related_prolly_lod;
     if ( projectileSprite->spell_id != SPELL_DARK_SOULDRINKER )
     {
-      std::array<int, 3> distances;
-      distances[0] = abs(pParty->vPosition.x - projectileSprite->vPosition.x);
-      distances[1] = abs(pParty->vPosition.y - projectileSprite->vPosition.y);
-      distances[2] = abs(pParty->vPosition.z - projectileSprite->vPosition.z);
-      std::sort(distances.begin(), distances.end());
-      v61 = ((unsigned int)(11 * distances[1]) >> 5) + (distances[0] >> 2) + distances[2];
+      int d1 = abs(pParty->vPosition.x - projectileSprite->vPosition.x);
+      int d2 = abs(pParty->vPosition.y - projectileSprite->vPosition.y);
+      int d3 = abs(pParty->vPosition.z - projectileSprite->vPosition.z);
+      v61 = int_get_vector_length(d1, d2, d3);
 
       if ( v61 >= 5120 && !(pMonster->uAttributes & 0x400) )
         return;
@@ -4007,28 +4005,7 @@
     for_x = abs(pActors[i].vInitialPosition.x - pParty->vPosition.x);
     for_y = abs(pActors[i].vInitialPosition.y - pParty->vPosition.y);
     for_z = abs(pActors[i].vInitialPosition.z - pParty->vPosition.z);
-    v3 = for_x;
-    v4 = for_y;
-    v5 = for_z;
-    if ( v3 < for_y )
-    {
-      v6 = v3;
-      v3 = for_y;
-      v4 = v6;
-    }
-    if ( v3 < for_z )
-    {
-      v7 = v3;
-      v3 = for_z;
-      v5 = v7;
-    }
-    if ( v4 < (signed int)v5 )
-    {
-      v8 = v5;
-      v5 = v4;
-      v4 = v8;
-    }
-    if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < distance )
+    if ( int_get_vector_length(for_x, for_y, for_z) < distance )
     {
       if ( pActors[i].uAIState != Dead )
       {