From dd9b9443d9d2af47c696080df136268edbbc4d63 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 6 Oct 2022 03:20:15 +0300 Subject: [PATCH 33/33] Send "unknown research" notifications to client Even when the client does not know research details, it needs to be informed about that fact to initialize values, or to clear old ones. Reported by ihnatus See osdn #45076 Signed-off-by: Marko Lindqvist --- client/packhand.c | 30 ++++++++++++++++++++++++++++++ common/networking/packets.def | 4 ++++ fc_version | 2 +- server/techtools.c | 12 +++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 8172a570f2..cc5389f1c0 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -2697,6 +2697,36 @@ void handle_research_info(const struct packet_research_info *packet) } } +/************************************************************************//** + Received a packet indicating we don't know the research details any more. +****************************************************************************/ +void handle_unknown_research(int id) +{ + struct research *presearch = research_by_number(id); + + if (presearch == NULL) { + log_error("Received unknown research for clearing: %d.", id); + return; + } + + /* Do we need to set other fields? */ + presearch->researching = A_UNKNOWN; + presearch->future_tech = 0; + presearch->tech_goal = A_UNKNOWN; + + advance_index_iterate(A_NONE, advi) { + research_invention_set(presearch, advi, TECH_UNKNOWN); + } advance_index_iterate_end; + + if (editor_is_active()) { + editgui_refresh(); + research_players_iterate(presearch, pplayer) { + editgui_notify_object_changed(OBJTYPE_PLAYER, player_number(pplayer), + FALSE); + } research_players_iterate_end; + } +} + /************************************************************************//** Packet player_diplstate handler. ****************************************************************************/ diff --git a/common/networking/packets.def b/common/networking/packets.def index 240fe4fb7b..531389568f 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -1002,6 +1002,10 @@ PACKET_RESEARCH_INFO = 60; sc, lsend, is-game-info STRING inventions[A_LAST + 1]; end +PACKET_UNKNOWN_RESEARCH = 66; sc, is-game-info, cancel(PACKET_RESEARCH_INFO) + RESEARCH id; +end + PACKET_PLAYER_RESEARCH = 55; cs, dsend TECH tech; end diff --git a/fc_version b/fc_version index 59ac7473bb..be0b866c1a 100755 --- a/fc_version +++ b/fc_version @@ -61,7 +61,7 @@ DEFAULT_FOLLOW_TAG=S3_1 # - No new mandatory capabilities can be added to the release branch; doing # so would break network capability of supposedly "compatible" releases. # -NETWORK_CAPSTRING="+Freeciv.Devel-${MAIN_VERSION}-2022.Sep.10" +NETWORK_CAPSTRING="+Freeciv.Devel-${MAIN_VERSION}-2022.Oct.06" FREECIV_DISTRIBUTOR="" diff --git a/server/techtools.c b/server/techtools.c index da75cf8d97..fdd6eb6196 100644 --- a/server/techtools.c +++ b/server/techtools.c @@ -274,6 +274,7 @@ void send_research_info(const struct research *presearch, const struct conn_list *dest) { struct packet_research_info full_info, restricted_info; + struct packet_unknown_research unknown_info; const struct player *pplayer; fc_assert_ret(NULL != presearch); @@ -286,6 +287,7 @@ void send_research_info(const struct research *presearch, restricted_info = full_info; restricted_info.tech_goal = A_UNSET; restricted_info.total_bulbs_prod = 0; + unknown_info.id = research_number(presearch); conn_list_iterate(dest, pconn) { pplayer = conn_get_player(pconn); @@ -295,12 +297,20 @@ void send_research_info(const struct research *presearch, send_packet_research_info(pconn, &full_info); } else { /* 'pplayer' may have an embassy for looking to 'presearch'. */ + bool embassy = FALSE; + research_players_iterate(presearch, powner) { if (team_has_embassy(pplayer->team, powner)) { - send_packet_research_info(pconn, &restricted_info); + embassy = TRUE; break; } } research_players_iterate_end; + + if (embassy) { + send_packet_research_info(pconn, &restricted_info); + } else { + send_packet_unknown_research(pconn, &unknown_info); + } } } else if (pconn->observer) { /* Case global observer. */ -- 2.35.1