From dc0d6105c089282d39e12638005fda07e545aa0a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 24 Apr 2022 07:53:37 +0300 Subject: [PATCH 55/55] Client: Consider dev format scenarios incompatible with stable ones See osdn #44452 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/pages.c | 26 ++++++++++++++++++++++---- client/gui-gtk-4.0/pages.c | 26 ++++++++++++++++++++++---- client/gui-qt/pages.cpp | 24 +++++++++++++++++++++--- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/client/gui-gtk-3.22/pages.c b/client/gui-gtk-3.22/pages.c index e6ce06f8ac..015ad24aac 100644 --- a/client/gui-gtk-3.22/pages.c +++ b/client/gui-gtk-3.22/pages.c @@ -2992,7 +2992,13 @@ static void scenario_list_callback(void) maj = ver / 1000000; ver %= 1000000; min = ver / 10000; - fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min); + ver %= 10000; + if (ver >= 9000) { + /* Development version, have '+' */ + fc_snprintf(vername, sizeof(vername), "%d.%d+", maj, min); + } else { + fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min); + } } else { /* TRANS: Old scenario format version */ fc_snprintf(vername, sizeof(vername), _("pre-2.6")); @@ -3056,7 +3062,15 @@ static void update_scenario_page(void) && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) { const char *sname, *sdescription, *sauthors; int fcver; + int fcdev; int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000; + int current_dev; + + current_dev = current_ver; + if (PATCH_VERSION >= 90) { + /* Patch level matters on development versions */ + current_dev += PATCH_VERSION * 100; + } fcver = secfile_lookup_int_default(sf, 0, "scenario.game_version"); if (fcver < 30000) { @@ -3065,15 +3079,19 @@ static void update_scenario_page(void) * multiply by 100. */ fcver *= 100; } - fcver -= (fcver % 10000); /* Patch level does not affect compatibility */ + if (fcver % 10000 >= 9000) { + fcdev = fcver - (fcver % 100); /* Emergency version does not count. */ + } else { + fcdev = fcver - (fcver % 10000); /* Patch version does not count. */ + } sname = secfile_lookup_str_default(sf, NULL, "scenario.name"); sdescription = secfile_lookup_str_default(sf, NULL, "scenario.description"); sauthors = secfile_lookup_str_default(sf, NULL, "scenario.authors"); log_debug("scenario file: %s from %s", sname, pfile->fullname); - /* Ignore scenarios for newer freeciv versions than we are */ - if (fcver <= current_ver) { + /* Ignore scenarios for newer freeciv versions than we are. */ + if (fcdev <= current_dev) { bool add_new = TRUE; if (sname != NULL) { diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index f1d7de2e75..694557b965 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -3027,7 +3027,13 @@ static void scenario_list_callback(void) maj = ver / 1000000; ver %= 1000000; min = ver / 10000; - fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min); + ver %= 10000; + if (ver >= 9000) { + /* Development version, have '+' */ + fc_snprintf(vername, sizeof(vername), "%d.%d+", maj, min); + } else { + fc_snprintf(vername, sizeof(vername), "%d.%d", maj, min); + } } else { /* TRANS: Old scenario format version */ fc_snprintf(vername, sizeof(vername), _("pre-2.6")); @@ -3091,7 +3097,15 @@ static void update_scenario_page(void) && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) { const char *sname, *sdescription, *sauthors; int fcver; + int fcdev; int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000; + int current_dev; + + current_dev = current_ver; + if (PATCH_VERSION >= 90) { + /* Patch level matters on development versions */ + current_dev += PATCH_VERSION * 100; + } fcver = secfile_lookup_int_default(sf, 0, "scenario.game_version"); if (fcver < 30000) { @@ -3100,15 +3114,19 @@ static void update_scenario_page(void) * multiply by 100. */ fcver *= 100; } - fcver -= (fcver % 10000); /* Patch level does not affect compatibility */ + if (fcver % 10000 >= 9000) { + fcdev = fcver - (fcver % 100); /* Emergency version does not count. */ + } else { + fcdev = fcver - (fcver % 10000); /* Patch version does not count. */ + } sname = secfile_lookup_str_default(sf, NULL, "scenario.name"); sdescription = secfile_lookup_str_default(sf, NULL, "scenario.description"); sauthors = secfile_lookup_str_default(sf, NULL, "scenario.authors"); log_debug("scenario file: %s from %s", sname, pfile->fullname); - /* Ignore scenarios for newer freeciv versions than we are */ - if (fcver <= current_ver) { + /* Ignore scenarios for newer freeciv versions than we are. */ + if (fcdev <= current_dev) { bool add_new = TRUE; if (sname != NULL) { diff --git a/client/gui-qt/pages.cpp b/client/gui-qt/pages.cpp index 44b74720c6..4fc0db8235 100644 --- a/client/gui-qt/pages.cpp +++ b/client/gui-qt/pages.cpp @@ -1444,7 +1444,14 @@ void fc_client::update_scenarios_page(void) QString format; QString st; int fcver; + int fcdev; int current_ver = MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000; + int current_dev = current_ver; + + if (PATCH_VERSION >= 90) { + // Patch level matters on development versions + current_dev += PATCH_VERSION * 100; + } fcver = secfile_lookup_int_default(sf, 0, "scenario.game_version"); if (fcver < 30000) { @@ -1453,13 +1460,18 @@ void fc_client::update_scenarios_page(void) * multiply by 100. */ fcver *= 100; } - fcver -= (fcver % 10000); /* Patch level does not affect compatibility */ + if (fcver % 10000 >= 9000) { + fcdev = fcver - (fcver % 100); // Emergency version does not count. + } else { + fcdev = fcver - (fcver % 10000); // Patch version does not count. + } sname = secfile_lookup_str_default(sf, NULL, "scenario.name"); sdescription = secfile_lookup_str_default(sf, NULL, "scenario.description"); sauthors = secfile_lookup_str_default(sf, NULL, "scenario.authors"); - if (fcver <= current_ver) { + // Ignore scenarios for newer freeciv versions than we are. + if (fcdev <= current_dev) { QString version; bool add_item = true; bool found = false; @@ -1475,7 +1487,13 @@ void fc_client::update_scenarios_page(void) maj = fcver / 1000000; fcver %= 1000000; min = fcver / 10000; - version = QString("%1.%2").arg(maj).arg(min); + fcver %= 10000; + if (fcver >= 9000) { + // Development version, have '+' + version = QString("%1.%2+").arg(maj).arg(min); + } else { + version = QString("%1.%2").arg(maj).arg(min); + } } else { /* TRANS: Unknown scenario format */ version = QString(_("pre-2.6")); -- 2.35.1