<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39492 >
On 06/08/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > Bug is present also in S2_0. But since S2_0 has no alternating > movement mode, bug has less severe consequences there. Still, backporting was simple. - ML
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2007-03-05 19:16:15.000000000 +0200 +++ freeciv/client/packhand.c 2007-08-06 02:57:13.000000000 +0300 @@ -2894,11 +2894,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(); @@ -2906,11 +2914,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/capstr.c freeciv/common/capstr.c --- freeciv/common/capstr.c 2007-03-05 19:15:59.000000000 +0200 +++ freeciv/common/capstr.c 2007-08-06 02:58:14.000000000 +0300 @@ -80,6 +80,9 @@ * * "username_info" means that the username is sent in the player_info packet * + * "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. * @@ -87,7 +90,7 @@ * as long as possible. We want to maintain network compatibility with * the stable branch for as long as possible. */ -#define CAPABILITY "+2.0 conn_ping_info username_info new_hack" +#define CAPABILITY "+2.0 conn_ping_info username_info new_hack ReportFreezeFix" void init_our_capability(void) { diff -Nurd -X.diff_ignore freeciv/common/packets.c freeciv/common/packets.c --- freeciv/common/packets.c 2007-08-04 04:27:37.000000000 +0300 +++ freeciv/common/packets.c 2007-08-06 02:57:13.000000000 +0300 @@ -133,6 +133,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-05 19:15:59.000000000 +0200 +++ freeciv/common/packets.def 2007-08-06 02:57:13.000000000 +0300 @@ -884,6 +884,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-04 04:27:24.000000000 +0300 +++ freeciv/server/srv_main.c 2007-08-06 03:00:59.000000000 +0300 @@ -119,6 +119,8 @@ static void send_select_nation(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) */ @@ -1506,6 +1508,30 @@ } /************************************************************************** + Send PACKET_FREEZE_CLIENT to all clients capable of handling it. +**************************************************************************/ +static void freeze_clients(void) +{ + conn_list_iterate(game.game_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.game_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) @@ -1522,10 +1548,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.game_connections); + freeze_clients(); while(server_state==RUN_GAME_STATE) { /* The beginning of a turn. @@ -1542,7 +1568,7 @@ /* * This will thaw the reports and agents at the client. */ - lsend_packet_thaw_hint(&game.game_connections); + thaw_clients(); /* Before sniff (human player activites), report time to now: */ freelog(LOG_VERBOSE, "End/start-turn server/ai activities: %g seconds", @@ -1574,7 +1600,7 @@ /* * This will freeze the reports and agents at the client. */ - lsend_packet_freeze_hint(&game.game_connections); + freeze_clients(); end_phase(); end_turn(); @@ -1591,7 +1617,7 @@ /* * This will thaw the reports and agents at the client. */ - lsend_packet_thaw_hint(&game.game_connections); + thaw_clients(); free_timer(eot_timer); }
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev