Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#12679) L)oaded state update bug - cannot load unit
Home

[Freeciv-Dev] (PR#12679) L)oaded state update bug - cannot load unit

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#12679) L)oaded state update bug - cannot load unit
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Jun 2005 12:04:57 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [chrisk - Mon Mar 28 18:11:10 2005]:

> In the attached game, there is a transport with 8 Cavalries loaded in
Birch
> Coulee.
> 
> A 9th unit (apline troops) cannot be loaded, because the ship is full.
> 
> When I go into the city dialog, and unload 2 of the cavalries with the
> context menue, and close the dialog, I cannot load the alpine unit
with the
> 'L' key or with the orders menue.
> 
> This is an update problem. When I do something else and come back
later, it
> works.

Yes, it's an update problem.  When the alpine troops are activated the
unload menu choice is desensitized because you can't load them.  Later
this changes but the menu isn't updated.  The attached patch fixes this.

-jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.408.2.23
diff -u -r1.408.2.23 packhand.c
--- client/packhand.c   3 Jun 2005 18:09:30 -0000       1.408.2.23
+++ client/packhand.c   3 Jun 2005 19:04:33 -0000
@@ -981,12 +981,14 @@
 {
   struct city *pcity;
   struct unit *punit;
+  bool need_update_menus = FALSE;
   bool repaint_unit = FALSE;
   bool repaint_city = FALSE;   /* regards unit's homecity */
   struct tile *old_tile = NULL;
   bool check_focus = FALSE;     /* conservative focus change */
   bool moved = FALSE;
   bool ret = FALSE;
+  struct unit *focus_unit = get_unit_in_focus();
   
   punit = player_find_unit_by_id(get_player(packet_unit->owner),
                                 packet_unit->id);
@@ -1049,6 +1051,13 @@
       punit->activity_target = packet_unit->activity_target;
 
       punit->occupy = packet_unit->occupy;
+      if (punit->occupy != packet_unit->occupy
+         && focus_unit && focus_unit->tile == packet_unit->tile) {
+       /* Special case: (un)loading a unit in a transporter on the
+        * same tile as the focus unit may (dis)allow the focus unit to be
+        * loaded.  Thus the orders->(un)load menu item needs updating. */
+       need_update_menus = TRUE;
+      }
       punit->transported_by = packet_unit->transported_by;
 
       punit->has_orders = packet_unit->has_orders;
@@ -1072,7 +1081,7 @@
     /* These two lines force the menus to be updated as appropriate when
      * the focus unit changes. */
     if (punit == get_unit_in_focus()) {
-      update_menus();
+      need_update_menus = TRUE;
     }
 
     if (punit->homecity != packet_unit->homecity) {
@@ -1108,7 +1117,7 @@
       }
       if(punit == get_unit_in_focus()) {
         /* Update the orders menu -- the unit might have new abilities */
-        update_menus();
+       need_update_menus = TRUE;
       }
     }
 
@@ -1276,6 +1285,10 @@
     update_unit_focus();
   }
 
+  if (need_update_menus) {
+    update_menus();
+  }
+
   return ret;
 }
 
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.520
diff -u -r1.520 packhand.c
--- client/packhand.c   3 Jun 2005 18:09:28 -0000       1.520
+++ client/packhand.c   3 Jun 2005 19:01:56 -0000
@@ -940,12 +940,14 @@
 {
   struct city *pcity;
   struct unit *punit;
+  bool need_update_menus = FALSE;
   bool repaint_unit = FALSE;
   bool repaint_city = FALSE;   /* regards unit's homecity */
   struct tile *old_tile = NULL;
   bool check_focus = FALSE;     /* conservative focus change */
   bool moved = FALSE;
   bool ret = FALSE;
+  struct unit *focus_unit = get_unit_in_focus();
   
   punit = player_find_unit_by_id(get_player(packet_unit->owner),
                                  packet_unit->id);
@@ -1014,6 +1016,13 @@
       punit->activity_target = packet_unit->activity_target;
 
       punit->transported_by = packet_unit->transported_by;
+      if (punit->occupy != packet_unit->occupy
+         && focus_unit && focus_unit->tile == packet_unit->tile) {
+       /* Special case: (un)loading a unit in a transporter on the
+        * same tile as the focus unit may (dis)allow the focus unit to be
+        * loaded.  Thus the orders->(un)load menu item needs updating. */
+       need_update_menus = TRUE;
+      }
       punit->occupy = packet_unit->occupy;
     
       punit->has_orders = packet_unit->has_orders;
@@ -1037,7 +1046,7 @@
     /* These two lines force the menus to be updated as appropriate when
      * the focus unit changes. */
     if (punit == get_unit_in_focus()) {
-      update_menus();
+      need_update_menus = TRUE;
     }
 
     if (punit->homecity != packet_unit->homecity) {
@@ -1073,7 +1082,7 @@
       }
       if(punit == get_unit_in_focus()) {
         /* Update the orders menu -- the unit might have new abilities */
-        update_menus();
+       need_update_menus = TRUE;
       }
     }
 
@@ -1226,6 +1235,10 @@
     update_unit_focus();
   }
 
+  if (need_update_menus) {
+    update_menus();
+  }
+
   return ret;
 }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12679) L)oaded state update bug - cannot load unit, Jason Short <=