Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] (PR#4586) vector wrapping in do_move_unit
Home

[Freeciv-Dev] (PR#4586) vector wrapping in do_move_unit

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4586) vector wrapping in do_move_unit
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Jul 2003 21:24:43 -0700
Reply-to: rt@xxxxxxxxxxxxxx

The code in do_move_unit to determine the vector of movement of a unit 
is not topology-safe.  Using map_distance_vector can make it so.

jason

Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.103
diff -u -r1.103 control.c
--- client/control.c    2003/07/10 03:50:55     1.103
+++ client/control.c    2003/07/17 04:22:12
@@ -1248,12 +1248,11 @@
     center_tile_mapcanvas(pinfo->x, pinfo->y);
 
   if(!pinfo->carried && !was_teleported) {
-    int dx=pinfo->x - x;
-    if(dx>1) dx=-1;
-    else if(dx<-1)
-      dx=1;
+    int dx, dy;
+
+    map_distance_vector(&dx, &dy, punit->x, punit->y, pinfo->x, pinfo->y);
     if(smooth_move_units)
-      move_unit_map_canvas(punit, x, y, dx, pinfo->y - punit->y);
+      move_unit_map_canvas(punit, x, y, dx, dy);
     refresh_tile_mapcanvas(x, y, FALSE);
   }
     

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#4586) vector wrapping in do_move_unit, Jason Short <=