From 6afa5d04a9c0e3e0df1568c43a8e8bf8fb8bb5fd Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 13 Feb 2022 03:06:50 +0200 Subject: [PATCH 26/26] Resend desired server settings after a new ruleset has been loaded Reported by Dino the Dinosore See osdn #43747 Signed-off-by: Marko Lindqvist --- client/options.c | 36 ++++++++++++++++++++++++++++++++++++ client/options.h | 1 + client/packhand.c | 2 ++ 3 files changed, 39 insertions(+) diff --git a/client/options.c b/client/options.c index af316f1414..ad8dc834b6 100644 --- a/client/options.c +++ b/client/options.c @@ -4186,6 +4186,8 @@ void handle_server_setting_const psoption->is_visible = packet->is_visible; \ } \ \ + /* Keep this list of conditions in sync with one in \ + resend_desired_settable_options() */ \ if (!psoption->desired_sent \ && psoption->is_visible \ && psoption->is_changeable \ @@ -5604,6 +5606,40 @@ static void desired_settable_option_send(struct option *poption) option_name(poption)); } +/************************************************************************//** + Send the desired server options to the server, even if they have already + been sent in the past. +****************************************************************************/ +void resend_desired_settable_options(void) +{ + if (is_server_running()) { + settable_options_hash_iterate(settable_options_hash, name, value) { + (void) value; /* Silence compiler warning about unused variable */ + struct option *poption = optset_option_by_name(server_optset, name); + + if (poption != NULL) { + struct server_option *psoption = SERVER_OPTION(poption); + + /* We only sent the option if it has been sent already in the past. + * Otherwise we leave it for that "initial" sending functionality + * to send it. That has the benefit that the initial send (can) check + * that server is not currently using value from the savegame that + * we should not override */ + if (psoption->desired_sent) { + /* Keep this list of conditions in sync with one in + * handle_server_setting_common() + * For lacking initial_setting check here, see comment above about + * checking psoption->desired_sent. */ + if (psoption->is_visible + && psoption->is_changeable) { + desired_settable_option_send(OPTION(poption)); + } + } + } + } settable_options_hash_iterate_end; + } +} + /**************************************************************************** City and player report dialog options. diff --git a/client/options.h b/client/options.h index a1b807f4f5..001833d07d 100644 --- a/client/options.h +++ b/client/options.h @@ -537,6 +537,7 @@ void desired_settable_options_update(void); void desired_settable_option_update(const char *op_name, const char *op_value, bool allow_replace); +void resend_desired_settable_options(void); /** Dialog report options. **/ diff --git a/client/packhand.c b/client/packhand.c index 37b2df54a4..4082be38e5 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -3403,6 +3403,8 @@ void handle_ruleset_control(const struct packet_ruleset_control *packet) } tileset_ruleset_reset(tileset); + + resend_desired_settable_options(); } /************************************************************************//** -- 2.34.1