Author: cazfi
Date: Fri Nov 13 20:58:10 2015
New Revision: 30599

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

See patch #6550

Modified:
    branches/S2_6/common/map.c

Modified: branches/S2_6/common/map.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/map.c?rev=30599&r1=30598&r2=30599&view=diff
==============================================================================
--- branches/S2_6/common/map.c  (original)
+++ branches/S2_6/common/map.c  Fri Nov 13 20:58:10 2015
@@ -1296,8 +1296,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)
@@ -1319,7 +1319,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