Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#12984) update the citybar when units move
Home

[Freeciv-Dev] (PR#12984) update the citybar when units move

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12984) update the citybar when units move
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 4 May 2005 13:42:08 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12984 >

With the occupied data shown in the citybar (which is very nice btw) we
have to redraw the citybar when units move into or out of cities.  This
patch fixes it.

-jason

Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.171
diff -u -r1.171 control.c
--- client/control.c    29 Apr 2005 18:39:25 -0000      1.171
+++ client/control.c    4 May 2005 20:39:28 -0000
@@ -1405,14 +1405,12 @@
 **************************************************************************/
 void do_move_unit(struct unit *punit, struct unit *target_unit)
 {
-  struct tile *ptile;
+  struct tile *src_tile = punit->tile, *dst_tile = target_unit->tile;
   bool was_teleported, do_animation;
 
-  was_teleported = !is_tiles_adjacent(punit->tile, target_unit->tile);
+  was_teleported = !is_tiles_adjacent(src_tile, dst_tile);
   do_animation = (!was_teleported && smooth_move_unit_msec > 0);
 
-  ptile = punit->tile;
-
   if (!was_teleported
       && punit->activity != ACTIVITY_SENTRY
       && punit->transported_by == -1) {
@@ -1420,37 +1418,49 @@
                     unit_type(punit)->sound_move_alt);
   }
 
-  unit_list_unlink(ptile->units, punit);
+  unit_list_unlink(src_tile->units, punit);
 
   if (game.player_idx == punit->owner
       && auto_center_on_unit
       && !unit_has_orders(punit)
       && punit->activity != ACTIVITY_GOTO
       && punit->activity != ACTIVITY_SENTRY
-      && !tile_visible_and_not_on_border_mapcanvas(target_unit->tile)) {
-    center_tile_mapcanvas(target_unit->tile);
+      && !tile_visible_and_not_on_border_mapcanvas(dst_tile)) {
+    center_tile_mapcanvas(dst_tile);
   }
 
   /* Set the tile before the movement animation is done, so that everything
    * drawn there will be up-to-date. */
-  punit->tile = target_unit->tile;
+  punit->tile = dst_tile;
 
   if (punit->transported_by == -1) {
     /* We have to refresh the tile before moving.  This will draw
      * the tile without the unit (because it was unlinked above). */
-    refresh_unit_mapcanvas(punit, ptile, TRUE, FALSE);
+    refresh_unit_mapcanvas(punit, src_tile, TRUE, FALSE);
 
     if (do_animation) {
       int dx, dy;
 
       /* For the duration of the animation the unit exists at neither
        * tile. */
-      map_distance_vector(&dx, &dy, ptile, target_unit->tile);
-      move_unit_map_canvas(punit, ptile, dx, dy);
+      map_distance_vector(&dx, &dy, src_tile, dst_tile);
+      move_unit_map_canvas(punit, src_tile, dx, dy);
     }
   }
 
-  unit_list_prepend(punit->tile->units, punit);
+  unit_list_prepend(dst_tile->units, punit);
+
+  /* With the "full" citybar we have to update the citybar when units move
+   * into or out of a city.  For foreign cities this is handled separately,
+   * via the occupied field of the short-city packet. */
+  if (src_tile->city
+      && can_player_see_units_in_city(game.player_ptr, src_tile->city)) {
+    update_city_description(src_tile->city);
+  }
+  if (dst_tile->city
+      && can_player_see_units_in_city(game.player_ptr, dst_tile->city)) {
+    update_city_description(dst_tile->city);
+  }
 
   if (punit_focus == punit) update_menus();
 }
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.501
diff -u -r1.501 packhand.c
--- client/packhand.c   2 May 2005 15:42:52 -0000       1.501
+++ client/packhand.c   4 May 2005 20:39:29 -0000
@@ -1122,6 +1122,7 @@
          if (pcity->client.occupied != new_occupied) {
            pcity->client.occupied = new_occupied;
            refresh_city_mapcanvas(pcity, pcity->tile, FALSE, FALSE);
+           update_city_description(pcity);
          }
        }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12984) update the citybar when units move, Jason Short <=