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

On 06/08/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  This patch adds new packets PACKET_FREEZE_CLIENT and
> PACKET_THAW_CLIENT. These are used instead of PACKET_FREEZE_HINT and
> PACKET_THAW_HINT when we want client reports and agents to freeze
> instead of buffering network traffic.

 Untested S2_1 version.

 Bug is present also in S2_0. But since S2_0 has no alternating
movement mode, bug has less severe consequences there.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-08-01 19:21:39.000000000 +0300
+++ freeciv/client/packhand.c	2007-08-06 02:29:40.000000000 +0300
@@ -2806,11 +2806,19 @@
 }
 
 /**************************************************************************
-...
+  We have received PACKET_FREEZE_HINT. It is packet internal to network code
 **************************************************************************/
 void handle_freeze_hint(void)
 {
   freelog(LOG_DEBUG, "handle_freeze_hint");
+}
+
+/**************************************************************************
+  We have received PACKET_FREEZE_CLIENT.
+**************************************************************************/
+void handle_freeze_client(void)
+{
+  freelog(LOG_DEBUG, "handle_freeze_client");
 
   reports_freeze();
 
@@ -2818,11 +2826,19 @@
 }
 
 /**************************************************************************
-...
+  We have received PACKET_THAW_HINT. It is packet internal to network code
 **************************************************************************/
 void handle_thaw_hint(void)
 {
   freelog(LOG_DEBUG, "handle_thaw_hint");
+}
+
+/**************************************************************************
+  We have received PACKET_THAW_CLIENT
+**************************************************************************/
+void handle_thaw_client(void)
+{
+  freelog(LOG_DEBUG, "handle_thaw_client");
 
   reports_thaw();
 
diff -Nurd -X.diff_ignore freeciv/common/packets.c freeciv/common/packets.c
--- freeciv/common/packets.c	2007-08-01 19:21:30.000000000 +0300
+++ freeciv/common/packets.c	2007-08-06 02:29:40.000000000 +0300
@@ -119,6 +119,12 @@
       compression_level_initialized = TRUE;
     }
 
+    /* TODO: PACKET_FREEZE_HINT and PACKET_THAW_HINT are meaningful
+     * only internally. They should not be sent to connection at all.
+     * Freezing could also be handled via separate functions, and
+     * not by special packets.
+     * Only problem is backward compatibility, so this cannot be
+     * changed in stable branch. */
     if (packet_type == PACKET_PROCESSING_STARTED
 	|| packet_type == PACKET_FREEZE_HINT) {
       if (pc->compression.frozen_level == 0) {
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def	2007-03-19 09:57:33.000000000 +0200
+++ freeciv/common/packets.def	2007-08-06 02:29:40.000000000 +0300
@@ -998,6 +998,14 @@
   TURN turn;
 end
 
+# Freeze reports and agents
+PACKET_FREEZE_CLIENT=135;sc,lsend
+end
+
+# Thaw reports and agents
+PACKET_THAW_CLIENT=136;sc,lsend
+end
+
 /************** Spaceship packets **********************/
 
 PACKET_SPACESHIP_LAUNCH=93;cs
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c	2007-08-01 19:18:41.000000000 +0300
+++ freeciv/server/srv_main.c	2007-08-06 02:42:12.000000000 +0300
@@ -114,6 +114,8 @@
 static void announce_player(struct player *pplayer);
 static void srv_loop(void);
 
+static void freeze_clients(void);
+static void thaw_clients(void);
 
 /* this is used in strange places, and is 'extern'd where
    needed (hence, it is not 'extern'd in srv_main.h) */
@@ -1625,6 +1627,30 @@
 }
 
 /**************************************************************************
+  Send PACKET_FREEZE_CLIENT to all clients capable of handling it.
+**************************************************************************/
+static void freeze_clients(void)
+{
+  conn_list_iterate(game.est_connections, pconn) {
+    if (has_capability("ReportFreezeFix", pconn->capability)) {
+      send_packet_freeze_client(pconn);
+    }
+  } conn_list_iterate_end;
+}
+
+/**************************************************************************
+  Send PACKET_THAW_CLIENT to all clients capable of handling it.
+**************************************************************************/
+static void thaw_clients(void)
+{
+  conn_list_iterate(game.est_connections, pconn) {
+    if (has_capability("ReportFreezeFix", pconn->capability)) {
+      send_packet_thaw_client(pconn);
+    }
+  } conn_list_iterate_end;
+}
+
+/**************************************************************************
 Play the game! Returns when server_state == GAME_OVER_STATE.
 **************************************************************************/
 static void main_loop(void)
@@ -1641,10 +1667,10 @@
   /* 
    * This will freeze the reports and agents at the client.
    * 
-   * Do this before the body so that the PACKET_THAW_HINT packet is
-   * balanced. 
+   * Do this before the body so that the PACKET_THAW_CLIENT packet is
+   * balanced.
    */
-  lsend_packet_freeze_hint(game.est_connections);
+  freeze_clients();
 
   assert(server_state == RUN_GAME_STATE);
   while (server_state == RUN_GAME_STATE) {
@@ -1666,7 +1692,7 @@
       /* 
        * This will thaw the reports and agents at the client.
        */
-      lsend_packet_thaw_hint(game.est_connections);
+      thaw_clients();
 
       /* Before sniff (human player activites), report time to now: */
       freelog(LOG_VERBOSE, "End/start-turn server/ai activities: %g seconds",
@@ -1701,7 +1727,7 @@
       /* 
        * This will freeze the reports and agents at the client.
        */
-      lsend_packet_freeze_hint(game.est_connections);
+      freeze_clients();
 
       end_phase();
 
@@ -1723,7 +1749,7 @@
   }
 
   /* This will thaw the reports and agents at the client.  */
-  lsend_packet_thaw_hint(game.est_connections);
+  thaw_clients();
 
   free_timer(eot_timer);
 }
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in	2007-06-28 20:19:41.000000000 +0300
+++ freeciv/version.in	2007-08-06 02:46:51.000000000 +0300
@@ -16,10 +16,13 @@
 
 # Freeciv network capstring: see documentation in common/capstr.c
 #
-# For reasons I don't understand, any spaces in this string causes it to
-# be seen completely empty.
+# "+2.1c" is the base capability string.
 #
-# +2.1c is the base capability string.
+# "CitywallFix"     fixes problem that cities were sometimes drawn with walls
+#                   even when there was no wall
+#
+# "ReportFreezeFix" allows clients to correctly freeze reports and agents
+#                   over turn change.
 #
 #   - No new manditory capabilities can be added to the release branch; doing
 #     so would break network capability of supposedly "compatible" releases.
@@ -27,4 +30,4 @@
 #   - Avoid adding a new manditory capbility to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-FREECIV_NETWORK_CAPSTRING(["+2.1c, CitywallFix"])
+FREECIV_NETWORK_CAPSTRING(["+2.1c, CitywallFix, ReportFreezeFix"])
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to