Author: cazfi Date: Tue Jan 5 19:17:41 2016 New Revision: 31371 URL: http://svn.gna.org/viewcvs/freeciv?rev=31371&view=rev Log: Added information about the phase of the turn event happened to the event cache.
See patch #6774 Modified: branches/S2_6/client/climisc.c branches/S2_6/client/climisc.h branches/S2_6/client/packhand.c branches/S2_6/common/fc_types.h branches/S2_6/common/packets.def branches/S2_6/fc_version branches/S2_6/server/notify.c branches/S2_6/server/notify.h branches/S2_6/server/srv_main.c Modified: branches/S2_6/client/climisc.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/climisc.c?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/client/climisc.c (original) +++ branches/S2_6/client/climisc.c Tue Jan 5 19:17:41 2016 @@ -938,7 +938,7 @@ Handles a chat or event message. **************************************************************************/ void handle_event(const char *featured_text, struct tile *ptile, - enum event_type event, int turn, int conn_id) + enum event_type event, int turn, int phase, int conn_id) { char plain_text[MAX_LEN_MSG]; struct text_tag_list *tags; @@ -1077,9 +1077,9 @@ featured_text_apply_tag(message, colored_text, sizeof(colored_text), TTT_COLOR, 0, FT_OFFSET_UNSET, color); - handle_event(colored_text, ptile, event, game.info.turn, -1); - } else { - handle_event(message, ptile, event, game.info.turn, -1); + handle_event(colored_text, ptile, event, game.info.turn, game.info.phase, -1); + } else { + handle_event(message, ptile, event, game.info.turn, game.info.phase, -1); } } Modified: branches/S2_6/client/climisc.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/climisc.h?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/client/climisc.h (original) +++ branches/S2_6/client/climisc.h Tue Jan 5 19:17:41 2016 @@ -106,7 +106,7 @@ int num_supported_units_in_city(struct city* pcity); void handle_event(const char *featured_text, struct tile *ptile, - enum event_type event, int turn, int conn_id); + enum event_type event, int turn, int phase, int conn_id); void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format, ...) fc__attribute((__format__ (__printf__, 4, 5))); Modified: branches/S2_6/client/packhand.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/packhand.c?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/client/packhand.c (original) +++ branches/S2_6/client/packhand.c Tue Jan 5 19:17:41 2016 @@ -1318,10 +1318,14 @@ Handle a message packet. This includes all messages - both in-game messages and chats from other players. **************************************************************************/ -void handle_chat_msg(const char *message, int tile, - enum event_type event, int turn, int conn_id) -{ - handle_event(message, index_to_tile(tile), event, turn, conn_id); +void handle_chat_msg(const struct packet_chat_msg *packet) +{ + handle_event(packet->message, + index_to_tile(packet->tile), + packet->event, + packet->turn, + packet->phase, + packet->conn_id); } /************************************************************************** Modified: branches/S2_6/common/fc_types.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/common/fc_types.h (original) +++ branches/S2_6/common/fc_types.h Tue Jan 5 19:17:41 2016 @@ -558,6 +558,11 @@ PMT_TEAMS_ALTERNATE }; +/* Phase mode change has changed meaning of the phase numbers */ +#define PHASE_INVALIDATED -1 +/* Phase was never known */ +#define PHASE_UNKNOWN -2 + /* Used in the network protocol. */ enum borders_mode { BORDERS_DISABLED = 0, Modified: branches/S2_6/common/packets.def URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/packets.def?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/common/packets.def (original) +++ branches/S2_6/common/packets.def Tue Jan 5 19:17:41 2016 @@ -580,6 +580,7 @@ TILE tile; EVENT event; TURN turn; + PHASE phase; CONNECTION conn_id; end Modified: branches/S2_6/fc_version URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/fc_version (original) +++ branches/S2_6/fc_version Tue Jan 5 19:17:41 2016 @@ -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-2015.Dec.25" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2016.Jan.05" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: branches/S2_6/server/notify.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/notify.c?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/server/notify.c (original) +++ branches/S2_6/server/notify.c Tue Jan 5 19:17:41 2016 @@ -68,6 +68,7 @@ packet->event = event; packet->conn_id = pconn ? pconn->id : -1; packet->turn = game.info.turn; + packet->phase = game.info.phase; fc_vsnprintf(buf, sizeof(buf), format, vargs); if (is_capitalization_enabled()) { @@ -758,7 +759,7 @@ enum event_cache_target target_type; enum server_states server_status; struct event_cache_players *players = NULL; - int i, x, y, turn, event_count; + int i, x, y, event_count; time_t timestamp, now; const char *p, *q; @@ -771,6 +772,9 @@ now = time(NULL); for (i = 0; i < event_count; i++) { + int turn; + int phase; + /* restore packet */ x = secfile_lookup_int_default(file, -1, "%s.events%d.x", section, i); y = secfile_lookup_int_default(file, -1, "%s.events%d.y", section, i); @@ -799,6 +803,11 @@ turn = secfile_lookup_int_default(file, 0, "%s.events%d.turn", section, i); packet.turn = turn; + + phase = secfile_lookup_int_default(file, PHASE_UNKNOWN, "%s.events%d.phase", + section, i); + packet.phase = phase; + timestamp = secfile_lookup_int_default(file, now, "%s.events%d.timestamp", section, i); @@ -883,6 +892,16 @@ secfile_insert_int(file, pdata->packet.turn, "%s.events%d.turn", section, event_count); + if (pdata->packet.phase != PHASE_UNKNOWN) { + /* Do not save current value of PHASE_UNKNOWN to savegame. + * It practically means that "savegame had no phase stored". + * Note that the only case where phase might be PHASE_UNKNOWN + * may be present is that the event was loaded from previous + * savegame created by a freeciv version that did not store event + * phases. */ + secfile_insert_int(file, pdata->packet.phase, "%s.events%d.phase", + section, event_count); + } secfile_insert_int(file, pdata->timestamp, "%s.events%d.timestamp", section, event_count); secfile_insert_int(file, tile_x, "%s.events%d.x", section, event_count); @@ -923,3 +942,15 @@ event_cache_status = TRUE; } + +/*************************************************************** + Mark all existing phase values in event cache invalid. +***************************************************************/ +void event_cache_phases_invalidate(void) +{ + event_cache_iterate(pdata) { + if (pdata->packet.phase >= 0) { + pdata->packet.phase = PHASE_INVALIDATED; + } + } event_cache_iterate_end; +} Modified: branches/S2_6/server/notify.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/notify.h?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/server/notify.h (original) +++ branches/S2_6/server/notify.h Tue Jan 5 19:17:41 2016 @@ -113,6 +113,8 @@ void send_pending_events(struct connection *pconn, bool include_public); +void event_cache_phases_invalidate(void); + struct section_file; void event_cache_load(struct section_file *file, const char *section); void event_cache_save(struct section_file *file, const char *section); Modified: branches/S2_6/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/srv_main.c?rev=31371&r1=31370&r2=31371&view=diff ============================================================================== --- branches/S2_6/server/srv_main.c (original) +++ branches/S2_6/server/srv_main.c Tue Jan 5 19:17:41 2016 @@ -912,7 +912,10 @@ /* Reset this each turn. */ if (is_new_turn) { - game.info.phase_mode = game.server.phase_mode_stored; + if (game.info.phase_mode != game.server.phase_mode_stored) { + event_cache_phases_invalidate(); + game.info.phase_mode = game.server.phase_mode_stored; + } } /* NB: Phase logic must match is_player_phase(). */ _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits