Skip to content

Commit

Permalink
Add followtag_override client option
Browse files Browse the repository at this point in the history
See osdn #48638

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
  • Loading branch information
cazfi committed Sep 20, 2023
1 parent c4588c8 commit cdefcfa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
10 changes: 10 additions & 0 deletions client/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 "
Expand Down
2 changes: 2 additions & 0 deletions client/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
#include "mapimg.h"

#define DEFAULT_METASERVER_OPTION "default"
#define DEFAULT_FOLLOWTAG_OPTION "builtin"

#define FONT_NAME_SIZE 512

Expand Down Expand Up @@ -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];
Expand Down
27 changes: 19 additions & 8 deletions client/servers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand All @@ -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];
Expand All @@ -139,37 +150,37 @@ 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 {
if (latest_ver != NULL) {
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),
/* TRANS: Type is version tag name like "stable", "S3_2",
* "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);
}
}
Expand Down

0 comments on commit cdefcfa

Please sign in to comment.