Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13185) send turn # in phase-end packet
Home

[Freeciv-Dev] (PR#13185) send turn # in phase-end packet

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13185) send turn # in phase-end packet
From: "Jason Dorje Short" <jdorje@xxxxxxxxx>
Date: Sat, 28 May 2005 13:38:55 -0700
Reply-to: bugs@xxxxxxxxxxx

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

If the player clicks the turn-done button a phase-end packet is sent to
the server.  If you do this near the end of a timed game it's possible
the packet won't be processed until the start of the next turn.  If that
happens you won't have ended this turn as you meant to, you will have
ended the next turn.

This is a problem to lesser degree with all packets.  However in some
cases you might want to issue orders in between turns while the server
is processing.  But with this packet it is always a bug, and quite an
annoying one in multiplayer games.

This patch has the client send the turn # along with the packet.  If the
turn doesn't match the packet is discarded.

-jason

Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.225
diff -u -r1.225 civclient.c
--- client/civclient.c  11 May 2005 19:31:37 -0000      1.225
+++ client/civclient.c  28 May 2005 20:00:08 -0000
@@ -427,7 +427,7 @@
 
   attribute_flush();
 
-  send_packet_player_phase_done(&aconnection);
+  dsend_packet_player_phase_done(&aconnection, game.info.turn);
 
   update_turn_done_button_state();
 }
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.128
diff -u -r1.128 packets.def
--- common/packets.def  22 May 2005 18:05:06 -0000      1.128
+++ common/packets.def  28 May 2005 20:00:09 -0000
@@ -649,7 +649,8 @@
   UINT16 small_wonders[B_LAST]; diff
 end
 
-PACKET_PLAYER_PHASE_DONE=40;cs
+PACKET_PLAYER_PHASE_DONE=40;cs,dsend
+  TURN turn;
 end
 
 PACKET_PLAYER_RATES=41;cs,dsend
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.382
diff -u -r1.382 plrhand.c
--- server/plrhand.c    27 May 2005 08:21:11 -0000      1.382
+++ server/plrhand.c    28 May 2005 20:00:10 -0000
@@ -2305,8 +2305,15 @@
 ...
 (Hmm, how should "turn done" work for multi-connected non-observer players?)
 **************************************************************************/
-void handle_player_phase_done(struct player *pplayer)
+void handle_player_phase_done(struct player *pplayer,
+                             int turn)
 {
+  if (turn != game.info.turn) {
+    /* If this happens then the player actually pressed turn-done on a
+     * previous turn but we didn't receive it until now.  The player
+     * probably didn't actually mean to end their turn! */
+    return;
+  }
   pplayer->phase_done = TRUE;
 
   check_for_full_turn_done();

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13185) send turn # in phase-end packet, Jason Dorje Short <=