Author: cazfi
Date: Fri Nov 13 20:58:00 2015
New Revision: 30598

URL: http://svn.gna.org/viewcvs/freeciv?rev=30598&view=rev
Log:
Optimized is_move_cardinal()

See patch #6550

Modified:
    trunk/common/map.c

Modified: trunk/common/map.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/map.c?rev=30598&r1=30597&r2=30598&view=diff
==============================================================================
--- trunk/common/map.c  (original)
+++ trunk/common/map.c  Fri Nov 13 20:58:00 2015
@@ -1297,8 +1297,8 @@
 }
 
 /**************************************************************************
-Return the direction which is needed for a step on the map from
-(start_x, start_y) to (end_x, end_y).
+  Return the direction which is needed for a step on the map from
+ (start_x, start_y) to (end_x, end_y).
 **************************************************************************/
 int get_direction_for_step(const struct tile *start_tile,
                           const struct tile *end_tile)
@@ -1320,7 +1320,13 @@
 bool is_move_cardinal(const struct tile *start_tile,
                      const struct tile *end_tile)
 {
-  return is_cardinal_dir(get_direction_for_step(start_tile, end_tile));
+  cardinal_adjc_dir_iterate(start_tile, test_tile, test_dir) {
+    if (same_pos(end_tile, test_tile)) {
+      return TRUE;
+    }
+  } cardinal_adjc_dir_iterate_end;
+
+  return FALSE;
 }
 
 /****************************************************************************


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

Reply via email to