Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7434) bug with orders lists at client
Home

[Freeciv-Dev] (PR#7434) bug with orders lists at client

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7434) bug with orders lists at client
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Feb 2004 08:44:13 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7434 >

> [jdorje - Wed Feb 18 05:40:26 2004]:
> 
> If you do the shift-G return-to-city order, then middle-click on the 
> unit in the middle of its route, the route will be off.  It looks like 
> the server is not sending an update.

A bug in packhand caused the client structure not to be updated.

Another bug causes the data to sometimes not be sent by the server.

This patch fixes both bugs.

jason

? diff
? orders_to_client.diff
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.350
diff -u -r1.350 packhand.c
--- client/packhand.c   2004/02/07 11:16:49     1.350
+++ client/packhand.c   2004/02/18 16:43:15
@@ -954,7 +954,8 @@
         || punit->activity_target != packet_unit->activity_target
        || punit->has_orders != packet_unit->has_orders
        || punit->orders.repeat != packet_unit->orders.repeat
-       || punit->orders.vigilant != packet_unit->orders.vigilant) {
+       || punit->orders.vigilant != packet_unit->orders.vigilant
+       || punit->orders.index != packet_unit->orders.index) {
       /*** Change in activity or activity's target. ***/
 
       /* May change focus if focus unit gets a new activity.
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.278
diff -u -r1.278 unittools.c
--- server/unittools.c  2004/02/07 11:16:50     1.278
+++ server/unittools.c  2004/02/18 16:43:17
@@ -3229,20 +3229,22 @@
 
     /* Advance the orders one step forward.  This is needed because any
      * updates sent to the client as a result of the action should include
-     * the new index value. */
+     * the new index value.  Note that we have to send_unit_info somewhere
+     * after this point so that the client is properly updated. */
     punit->orders.index++;
 
     switch (order.order) {
     case ORDER_FINISH_TURN:
       punit->done_moving = TRUE;
       freelog(LOG_DEBUG, "  waiting this turn");
-      send_unit_info(unit_owner(punit), punit);
+      send_unit_info(NULL, punit);
       break;
     case ORDER_MOVE:
       /* Move unit */
       if (!MAPSTEP(dest_x, dest_y, punit->x, punit->y, order.dir)) {
        freelog(LOG_DEBUG, "  move order sent us to invalid location");
        free_unit_orders(punit);
+       send_unit_info(NULL, punit);
        notify_player_ex(pplayer, punit->x, punit->y, E_UNIT_ORDERS,
                         _("Game: Orders for %s aborted since they "
                           "give an invalid location."),
@@ -3254,6 +3256,7 @@
          && maybe_cancel_goto_due_to_enemy(punit, dest_x, dest_y)) {
        freelog(LOG_DEBUG, "  orders canceled because of enemy");
        free_unit_orders(punit);
+       send_unit_info(NULL, punit);
        notify_player_ex(pplayer, punit->x, punit->y, E_UNIT_ORDERS,
                         _("Game: Orders for %s aborted as there "
                           "are units in the way."),
@@ -3273,6 +3276,7 @@
       if (res && !same_pos(dest_x, dest_y, punit->x, punit->y)) {
        /* Movement succeeded but unit didn't move. */
        freelog(LOG_DEBUG, "  orders resulted in combat.");
+       send_unit_info(NULL, punit);
        return TRUE;
       }
 
@@ -3280,6 +3284,7 @@
        /* Movement failed (ZOC, etc.) */
        freelog(LOG_DEBUG, "  attempt to move failed.");
        free_unit_orders(punit);
+       send_unit_info(NULL, punit);
        notify_player_ex(pplayer, punit->x, punit->y, E_UNIT_ORDERS,
                         _("Game: Orders for %s aborted because of "
                           "failed move."),
@@ -3291,6 +3296,7 @@
     case ORDER_LAST:
       freelog(LOG_DEBUG, "  client sent invalid order!");
       free_unit_orders(punit);
+      send_unit_info(NULL, punit);
       notify_player_ex(pplayer, punit->x, punit->y, E_UNIT_ORDERS,
                       _("Game: Your %s has invalid orders."),
                       unit_name(punit->type));

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