From cdefcfae468bd9638d07ef10bcaa794628e122e4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 17 Sep 2023 07:58:48 +0300 Subject: [PATCH] Add followtag_override client option See osdn #48638 Signed-off-by: Marko Lindqvist --- client/options.c | 10 ++++++++++ client/options.h | 2 ++ client/servers.c | 27 +++++++++++++++++++-------- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/client/options.c b/client/options.c index d72a94be3e..696cee6b77 100644 --- a/client/options.c +++ b/client/options.c @@ -83,6 +83,8 @@ struct client_options gui_options = { .default_sound_plugin_name = "\0", .default_chat_logfile = GUI_DEFAULT_CHAT_LOGFILE, + .followtag_override = DEFAULT_FOLLOWTAG_OPTION, + .save_options_on_exit = TRUE, .use_prev_server = FALSE, @@ -1939,6 +1941,14 @@ static struct client_option client_options[] = { "cut the connection due to a connectivity outage, if " "the client would otherwise sit idle for a long period."), COC_NETWORK, GUI_STUB, TRUE, NULL), + GEN_STR_OPTION(followtag_override, + N_("Followtag override"), + /* TRANS: Leave 'builtin' untranslated */ + N_("Followtag determines which kind of new freeciv versions' " + "availability gets checked from the metaserver. Special " + "value 'builtin' means that value builtin to the client " + "gets used."), + COC_NETWORK, GUI_STUB, DEFAULT_FOLLOWTAG_OPTION, NULL, 0), GEN_BOOL_OPTION(send_desired_settings, N_("Send desired settings to the server"), N_("In single-player mode client usually sends user's " diff --git a/client/options.h b/client/options.h index 20e6d6c752..6fc9bd509a 100644 --- a/client/options.h +++ b/client/options.h @@ -27,6 +27,7 @@ extern "C" { #include "mapimg.h" #define DEFAULT_METASERVER_OPTION "default" +#define DEFAULT_FOLLOWTAG_OPTION "builtin" #define FONT_NAME_SIZE 512 @@ -111,6 +112,7 @@ struct client_options bool heartbeat_enabled; bool send_desired_settings; char default_metaserver[512]; + char followtag_override[5112]; char default_tileset_square_name[512]; char default_tileset_hex_name[512]; char default_tileset_isohex_name[512]; diff --git a/client/servers.c b/client/servers.c index 852370f7e8..2ae8b847f7 100644 --- a/client/servers.c +++ b/client/servers.c @@ -76,6 +76,7 @@ #include "chatline_common.h" #include "chatline_g.h" #include "client_main.h" +#include "options.h" #include "servers.h" #include "gui_main_g.h" @@ -119,6 +120,8 @@ static struct server_list *parse_metaserver_data(fz_FILE *f) int nservers, i, j; const char *latest_ver; const char *comment; + char *followtag; + char *q_followtag; /* Have the string outside Q_() so it won't get collected for translation here. * Actual collected string lives in translations/Strings.txt */ @@ -129,8 +132,16 @@ static struct server_list *parse_metaserver_data(fz_FILE *f) return NULL; } - latest_ver = secfile_lookup_str_default(file, NULL, "versions." FOLLOWTAG); - comment = secfile_lookup_str_default(file, NULL, "version_comments." FOLLOWTAG); + if (fc_strcasecmp(DEFAULT_FOLLOWTAG_OPTION, gui_options.followtag_override)) { + followtag = gui_options.followtag_override; + q_followtag = gui_options.followtag_override; + } else { + followtag = FOLLOWTAG; + q_followtag = QUALIFIED_FOLLOWTAG; + } + + latest_ver = secfile_lookup_str_default(file, NULL, "versions.%s", followtag); + comment = secfile_lookup_str_default(file, NULL, "version_comments.%s", followtag); if (latest_ver == NULL && comment == NULL) { char vertext[2048]; @@ -139,7 +150,7 @@ static struct server_list *parse_metaserver_data(fz_FILE *f) /* TRANS: Type is version tag name like "stable", "S3_2", * "windows" (which can also be localised -- msgids start * '?vertag:') */ - _("There's no %s release yet."), Q_(QUALIFIED_FOLLOWTAG)); + _("There's no %s release yet."), Q_(q_followtag)); log_verbose("%s", vertext); version_message(vertext); } else { @@ -147,8 +158,8 @@ static struct server_list *parse_metaserver_data(fz_FILE *f) const char *my_comparable = fc_comparable_version(); char vertext[2048]; - log_verbose("Metaserver says latest '" FOLLOWTAG "' version is '%s'; we have '%s'", - latest_ver, my_comparable); + log_verbose("Metaserver says latest '%s' version is '%s'; we have '%s'", + followtag, latest_ver, my_comparable); if (cvercmp_greater(latest_ver, my_comparable)) { fc_snprintf(vertext, sizeof(vertext), @@ -156,20 +167,20 @@ static struct server_list *parse_metaserver_data(fz_FILE *f) * "windows" (which can also be localised -- msgids start * '?vertag:') */ _("Latest %s release of Freeciv is %s, this is %s."), - Q_(QUALIFIED_FOLLOWTAG), latest_ver, my_comparable); + Q_(q_followtag), latest_ver, my_comparable); version_message(vertext); } else if (comment == NULL) { fc_snprintf(vertext, sizeof(vertext), _("There is no newer %s release of Freeciv available."), - FOLLOWTAG); + followtag); version_message(vertext); } } if (comment != NULL) { - log_verbose("Mesaserver comment about '" FOLLOWTAG "': %s", comment); + log_verbose("Mesaserver comment about '%s': %s", followtag, comment); version_message(comment); } }