Author: cazfi Date: Thu Nov 13 21:20:24 2014 New Revision: 27042 URL: http://svn.gna.org/viewcvs/freeciv?rev=27042&view=rev Log: Moved seconds_to_phasedone to its own packet so that game_info can benefit from is-info flag.
See patch #5414 Modified: trunk/client/packhand.c trunk/common/game.h trunk/common/packets.def trunk/fc_version trunk/server/gamehand.c trunk/server/sernet.c trunk/server/settings.c trunk/server/srv_main.c Modified: trunk/client/packhand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/client/packhand.c (original) +++ trunk/client/packhand.c Thu Nov 13 21:20:24 2014 @@ -1883,13 +1883,6 @@ boot_help = (can_client_change_view() && game.info.victory_conditions != pinfo->victory_conditions); - if (game.info.timeout != 0 && pinfo->seconds_to_phasedone >= 0) { - /* If this packet is received in the middle of a turn, this value - * represents the number of seconds from now to the end of the turn - * (not from the start of the turn). So we need to restart our - * timer. */ - set_seconds_to_turndone(pinfo->seconds_to_phasedone); - } if (boot_help) { boot_help_texts(client.conn.playing); /* reboot, after setting game.spacerace */ } @@ -1905,6 +1898,20 @@ } editgui_notify_object_changed(OBJTYPE_GAME, 1, FALSE); +} + +/************************************************************************** + Sets the remaining turn time. +**************************************************************************/ +void handle_timeout_info(float seconds_to_phasedone) +{ + if (game.info.timeout != 0 && seconds_to_phasedone >= 0) { + /* If this packet is received in the middle of a turn, this value + * represents the number of seconds from now to the end of the turn + * (not from the start of the turn). So we need to restart our + * timer. */ + set_seconds_to_turndone(seconds_to_phasedone); + } } /************************************************************************** Modified: trunk/common/game.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/common/game.h (original) +++ trunk/common/game.h Thu Nov 13 21:20:24 2014 @@ -76,6 +76,7 @@ struct packet_ruleset_control control; struct packet_scenario_info scenario; struct packet_game_info info; + struct packet_timeout_info tinfo; struct government *government_during_revolution; Modified: trunk/common/packets.def URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/common/packets.def (original) +++ trunk/common/packets.def Thu Nov 13 21:20:24 2014 @@ -3,7 +3,7 @@ Max used id: ============ -Max id: 243 +Max id: 244 Packets are not ordered by their id, but by their category. New packet with higher id may get added to existing category, and not to the end of file. @@ -421,12 +421,8 @@ STRING label[MAX_LEN_NAME]; end -# This packet used to have is_info set but that doesn't work with the -# seconds_to_phasedone field: sending the same value a second time after a -# while has passed means a completely reset timeout. -# # The variables in the packet are listed in alphabetical order. -PACKET_GAME_INFO = 16; sc +PACKET_GAME_INFO = 16; sc, is-info UINT8 add_to_size_limit; UINT8 aifill; AIRLIFTING_STYLE airlifting_style; @@ -505,7 +501,6 @@ BOOL restrictinfra; BOOL unreachable_protects; UINT32 sciencebox; - SFLOAT10x3 seconds_to_phasedone; UINT32 shieldbox; UINT32 skill_level; BOOL slow_invasions; @@ -535,6 +530,12 @@ BOOL paradrop_to_transport; end +# This cannot have is-info set. Sending the same value a second time after a +# while has passed means a completely reset timeout. +PACKET_TIMEOUT_INFO = 244; sc + SFLOAT10x3 seconds_to_phasedone; +end + PACKET_MAP_INFO = 17; sc, lsend XYSIZE xsize; XYSIZE ysize; Modified: trunk/fc_version URL: http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/fc_version (original) +++ trunk/fc_version Thu Nov 13 21:20:24 2014 @@ -54,7 +54,7 @@ # - Avoid adding a new mandatory capability to the development branch for # as long as possible. We want to maintain network compatibility with # the stable branch for as long as possible. -NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Nov.06" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Nov.13" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: trunk/server/gamehand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/gamehand.c?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/server/gamehand.c (original) +++ trunk/server/gamehand.c Thu Nov 13 21:20:24 2014 @@ -854,12 +854,14 @@ void send_game_info(struct conn_list *dest) { struct packet_game_info ginfo; + struct packet_timeout_info tinfo; if (!dest) { dest = game.est_connections; } ginfo = game.info; + tinfo = game.tinfo; /* the following values are computed every time a packet_game_info packet is created */ @@ -869,17 +871,20 @@ if (game.info.timeout > 0 && game.server.phase_timer) { /* Whenever the client sees this packet, it starts a new timer at 0; * but the server's timer is only ever reset at the start of a phase - * (and game.info.seconds_to_phasedone is relative to this). + * (and game.tinfo.seconds_to_phasedone is relative to this). * Account for the difference. */ - ginfo.seconds_to_phasedone = game.info.seconds_to_phasedone + tinfo.seconds_to_phasedone = game.tinfo.seconds_to_phasedone - timer_read_seconds(game.server.phase_timer); } else { /* unused but at least initialized */ - ginfo.seconds_to_phasedone = -1.0; + tinfo.seconds_to_phasedone = -1.0; } conn_list_iterate(dest, pconn) { + /* These are separate packets as first one may not get sent at all + * if there's no changes in it */ send_packet_game_info(pconn, &ginfo); + send_packet_timeout_info(pconn, &tinfo); } conn_list_iterate_end; } @@ -969,8 +974,8 @@ double maxsec = (timer_read_seconds(game.server.phase_timer) + (double) game.server.timeoutaddenemymove); - if (maxsec > game.info.seconds_to_phasedone) { - game.info.seconds_to_phasedone = maxsec; + if (maxsec > game.tinfo.seconds_to_phasedone) { + game.tinfo.seconds_to_phasedone = maxsec; send_game_info(NULL); } } Modified: trunk/server/sernet.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/sernet.c?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/server/sernet.c (original) +++ trunk/server/sernet.c Thu Nov 13 21:20:24 2014 @@ -686,7 +686,7 @@ && S_S_RUNNING == server_state() && game.server.phase_timer && (timer_read_seconds(game.server.phase_timer) - > game.info.seconds_to_phasedone)) { + > game.tinfo.seconds_to_phasedone)) { con_prompt_off(); return S_E_END_OF_TURN_TIMEOUT; } @@ -874,7 +874,7 @@ && S_S_RUNNING == server_state() && game.server.phase_timer && (timer_read_seconds(game.server.phase_timer) - > game.info.seconds_to_phasedone)) { + > game.tinfo.seconds_to_phasedone)) { return S_E_END_OF_TURN_TIMEOUT; } if ((game.server.autosaves & (1 << AS_TIMER)) Modified: trunk/server/settings.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/settings.c?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/server/settings.c (original) +++ trunk/server/settings.c Thu Nov 13 21:20:24 2014 @@ -596,7 +596,7 @@ if (S_S_RUNNING == server_state()) { int timeout = *pset->integer.pvalue; /* This may cause the current turn to end immediately. */ - game.info.seconds_to_phasedone = timeout; + game.tinfo.seconds_to_phasedone = timeout; send_game_info(NULL); } } Modified: trunk/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=27042&r1=27041&r2=27042&view=diff ============================================================================== --- trunk/server/srv_main.c (original) +++ trunk/server/srv_main.c Thu Nov 13 21:20:24 2014 @@ -1046,9 +1046,9 @@ sanity_check(); if (game.info.turn == 0 && game.server.first_timeout != -1) { - game.info.seconds_to_phasedone = (double)game.server.first_timeout; + game.tinfo.seconds_to_phasedone = (double)game.server.first_timeout; } else { - game.info.seconds_to_phasedone = (double)game.info.timeout; + game.tinfo.seconds_to_phasedone = (double)game.info.timeout; } game.server.phase_timer = timer_renew(game.server.phase_timer, TIMER_USER, TIMER_ACTIVE); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits