Author: sveinung
Date: Mon Nov 14 07:55:59 2016
New Revision: 34507

URL: http://svn.gna.org/viewcvs/freeciv?rev=34507&view=rev
Log:
handle_unit_get_actions(): actor target distance.

Replace the cached calculation if the actor and the target are at the same
tile with caching the distance between actor and target. The distance is
more reusable.

See patch #7975

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=34507&r1=34506&r2=34507&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Mon Nov 14 07:55:59 2016
@@ -1433,7 +1433,7 @@
   struct unit *target_unit;
   struct city *target_city;
 
-  bool is_same_tile;
+  int actor_target_distance;
 
   /* No potentially legal action is known yet. If none is found the player
    * should get an explanation. */
@@ -1481,8 +1481,9 @@
     target_city = game_city_by_number(target_city_id_client);
   }
 
-  /* Is the actor asking about actions against his own tile? */
-  is_same_tile = unit_tile(actor_unit) == target_tile;
+  /* Distance between actor and target tile. */
+  actor_target_distance = real_map_distance(unit_tile(actor_unit),
+                                            target_tile);
 
   /* Find out what can be done to the targets. */
 
@@ -1507,7 +1508,7 @@
     } else if (target_tile && action_id_get_target_kind(act) == ATK_TILE) {
       probabilities[act] = action_prob_vs_tile(actor_unit, act,
                                                target_tile);
-    } else if (is_same_tile
+    } else if (actor_target_distance == 0
                && action_id_get_target_kind(act) == ATK_SELF) {
       /* Don't bother with self targeted actions unless the actor is asking
        * about what can be done to its own tile. */


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to