Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] Re: (PR#2625) Display of units on the left side
Home

[Freeciv-Dev] Re: (PR#2625) Display of units on the left side

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ue80@xxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2625) Display of units on the left side
From: "Raimar Falke via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 7 Jan 2003 12:51:09 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Sat, Dec 21, 2002 at 05:56:49AM -0800, Thomas Strub via RT wrote:
> 
> Hi,
> 
> the display of units in the field left below the turn done button is a
> little bit buggy.
> The AI can move units without an update of the field. So you see 3-4
> units on the field on the left side but only 1 is there.
> 
> Easy way to check that:
> start a server, create an AI, join as the AI (with option manual turn
> done in AI mode on), set expl 2, start
> 
> You will see that the 2 explorers moved away but the field on the left
> side is:
> 
> 2 explorers + 2 settlers for beta 2
> 1 explorer  + 2 settlers for cvs
> 
> Think the same will happen if units move with goto or other
> automechanism.
> 
> I'm using the gtk-client.

And the fix.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "Windows is the one true OS. MS invented the GUI. MS invented 
   the 32 bit OS. MS is open and standard. MS loves you. We have 
   always been at war with Oceana."

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.270
diff -u -u -r1.270 packhand.c
--- client/packhand.c   2003/01/05 23:24:51     1.270
+++ client/packhand.c   2003/01/07 20:37:01
@@ -814,6 +814,9 @@
   struct unit *punit;
   bool repaint_unit;
   bool repaint_city;           /* regards unit's homecity */
+  bool moved = FALSE;
+  int old_x = -1, old_y = -1;  /* make compiler happy; guarded by moved */
+
   /* Special case for a diplomat/spy investigating a city:
      The investigator needs to know the supported and present
      units of a city, whether or not they are fogged. So, we
@@ -925,8 +928,11 @@
 
     if (!same_pos(punit->x, punit->y, packet->x, packet->y)) { 
       /* change position */
-      struct city *pcity;
-      pcity=map_get_city(punit->x, punit->y);
+      struct city *pcity = map_get_city(punit->x, punit->y);
+
+      old_x = punit->x;
+      old_y = punit->y;
+      moved = TRUE;
       
       if(tile_get_known(packet->x, packet->y) == TILE_KNOWN
          && player_can_see_unit_at_location(game.player_ptr, punit, 
@@ -1035,8 +1041,11 @@
   if (punit && punit == get_unit_in_focus()) {
     update_unit_info_label(punit);
   } else if (get_unit_in_focus()
-            && same_pos(get_unit_in_focus()->x, get_unit_in_focus()->y,
-                        punit->x, punit->y)) {
+            && (same_pos(get_unit_in_focus()->x, get_unit_in_focus()->y,
+                         punit->x, punit->y)
+                || (moved
+                    && same_pos(get_unit_in_focus()->x,
+                                get_unit_in_focus()->y, old_x, old_y)))) {
     update_unit_info_label(get_unit_in_focus());
   }
 

[Prev in Thread] Current Thread [Next in Thread]