From 079b72680c0d8c0ed8a9b4c9ade2478a012059aa Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 13 Feb 2022 03:06:50 +0200 Subject: [PATCH 5/5] 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 c8ad1dc8b2..b9d4a0d410 100644 --- a/client/options.c +++ b/client/options.c @@ -4187,6 +4187,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 \ @@ -5608,6 +5610,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 67b9176775..1d91e295de 100644 --- a/client/options.h +++ b/client/options.h @@ -493,6 +493,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 d82ef86a63..45b16e3554 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -3270,6 +3270,8 @@ void handle_ruleset_control(const struct packet_ruleset_control *packet) } tileset_ruleset_reset(tileset); + + resend_desired_settable_options(); } /**************************************************************************** -- 2.34.1