From a988966df4cd0e074b4c9a81ac01cbea3ae4c0b0 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 11 Jan 2022 23:45:35 +0200 Subject: [PATCH 43/43] conn_set_access(): Check if settings control packet has been sent Only sent updated settings, if the client knows how to handle them. If control packet has not yet been sent, we will sent the settings later anyway. Current code never calls conn_set_access() before control packet has been sent. This is to prepare to the future where it might get called earlier. See osdn #43606 Signed-off-by: Marko Lindqvist --- common/networking/connection.h | 5 ++++- server/connecthand.c | 6 +++++- server/settings.c | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common/networking/connection.h b/common/networking/connection.h index 0f29291e7b..0e452c642b 100644 --- a/common/networking/connection.h +++ b/common/networking/connection.h @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -228,6 +228,9 @@ struct connection { /* The access level initially given to the client upon connection. */ enum cmdlevel granted_access_level; + /* Server setting control packet already sent. */ + bool settings_sent; + /* The list of ignored connection patterns. */ struct conn_pattern_list *ignore_list; diff --git a/server/connecthand.c b/server/connecthand.c index 263b98cfb0..b70a8c2e72 100644 --- a/server/connecthand.c +++ b/server/connecthand.c @@ -75,7 +75,10 @@ void conn_set_access(struct connection *pconn, enum cmdlevel new_level, pconn->server.granted_access_level = new_level; } - if (old_level != new_level) { + /* Send updated settings only if settings control already sent. + * Otherwise client is not ready to receive them, AND we will send + * them later anyway. */ + if (old_level != new_level && pconn->server.settings_sent) { send_server_access_level_settings(pconn->self, old_level, new_level); } } @@ -149,6 +152,7 @@ void establish_new_connection(struct connection *pconn) pconn->server.delegation.status = FALSE; pconn->server.delegation.playing = NULL; pconn->server.delegation.observer = FALSE; + pconn->server.settings_sent = FALSE; conn_list_append(game.est_connections, pconn); if (conn_list_size(game.est_connections) == 1) { diff --git a/server/settings.c b/server/settings.c index fc1099a3ef..63215e2972 100644 --- a/server/settings.c +++ b/server/settings.c @@ -5125,6 +5125,8 @@ void send_server_setting_control(struct connection *pconn) /* Send off the control packet. */ send_packet_server_setting_control(pconn, &control); + pconn->server.settings_sent = TRUE; + /* Send the constant and common part of the settings. */ settings_iterate(SSET_ALL, pset) { setting.id = setting_number(pset); -- 2.34.1