From 2deb6a1061533492d3b10bb76697cf96cddf28f9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 24 Apr 2022 07:51:20 +0300 Subject: [PATCH 24/24] Client: Consider dev format scenarios incompatible with stable ones See osdn #44452 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/pages.c | 26 ++++++++++++++++++++++---- client/gui-gtk-3.0/pages.c | 26 ++++++++++++++++++++++---- client/gui-gtk-3.22/pages.c | 26 ++++++++++++++++++++++---- client/gui-qt/pages.cpp | 24 +++++++++++++++++++++--- 4 files changed, 87 insertions(+), 15 deletions(-) diff --git a/client/gui-gtk-2.0/pages.c b/client/gui-gtk-2.0/pages.c index 6dd3bc6ac4..5ac5c03992 100644 --- a/client/gui-gtk-2.0/pages.c +++ b/client/gui-gtk-2.0/pages.c @@ -2914,7 +2914,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")); @@ -2975,7 +2981,15 @@ static void update_scenario_page(void) && secfile_lookup_bool_default(sf, TRUE, "scenario.is_scenario")) { const char *sname, *sdescription; 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) { @@ -2984,14 +2998,18 @@ 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"); 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-3.0/pages.c b/client/gui-gtk-3.0/pages.c index 8dc575d2e1..9ac3bd53f9 100644 --- a/client/gui-gtk-3.0/pages.c +++ b/client/gui-gtk-3.0/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-3.22/pages.c b/client/gui-gtk-3.22/pages.c index e80e790c59..2d5912f32a 100644 --- a/client/gui-gtk-3.22/pages.c +++ b/client/gui-gtk-3.22/pages.c @@ -2991,7 +2991,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")); @@ -3055,7 +3061,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) { @@ -3064,15 +3078,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 ecd305b7de..a6cd85c32b 100644 --- a/client/gui-qt/pages.cpp +++ b/client/gui-qt/pages.cpp @@ -1423,7 +1423,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) { @@ -1432,13 +1439,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; @@ -1454,7 +1466,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