From 2c5aec6d39d55dd67a943eac2d669a4e1f35f865 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 19 Aug 2022 05:30:55 +0300 Subject: [PATCH 21/21] Be less spammy about fixing research count errors from old savegames See osdn #45344 Signed-off-by: Marko Lindqvist --- server/savecompat.h | 12 +++++++++++- server/savegame2.c | 7 +++++-- server/savegame3.c | 7 +++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/savecompat.h b/server/savecompat.h index 166fe7d224..f36d247586 100644 --- a/server/savecompat.h +++ b/server/savecompat.h @@ -46,6 +46,7 @@ struct loaddata { struct section_file *file; const char *secfile_options; int version; + int full_version; /* loaded in sg_load_savefile(); needed in sg_load_player() */ struct { @@ -121,7 +122,9 @@ struct loaddata { int *worked_tiles; }; -#define log_sg log_error +#define log_sg log_error +/* Fixing known problems from older savegame formats */ +#define log_sgfix log_normal #define sg_check_ret(...) \ if (!sg_success) { \ @@ -160,6 +163,13 @@ struct loaddata { sg_check_ret_val(_val); \ } +#define sg_regr(fixversion, message, ...) \ + if (loading->full_version >= fixversion) { \ + log_sg(message, ## __VA_ARGS__); \ + } else { \ + log_sgfix(message, ## __VA_ARGS__); \ + } + void sg_load_compat(struct loaddata *loading); int current_compat_ver(void); diff --git a/server/savegame2.c b/server/savegame2.c index 2d2f4a0a64..0f9a08d551 100644 --- a/server/savegame2.c +++ b/server/savegame2.c @@ -1522,6 +1522,8 @@ static void sg_load_game(struct loaddata *loading) sg_failure_ret(20299 <= game_version, "Saved game is too old, at least " "version 2.2.99 required."); + loading->full_version = game_version; + /* Load server state. */ string = secfile_lookup_str_default(loading->file, "S_S_INITIAL", "game.server_state"); @@ -5210,8 +5212,9 @@ static void sg_load_sanitycheck(struct loaddata *loading) techs = recalculate_techs_researched(presearch); if (presearch->techs_researched != techs) { - log_sg(_("%s had finished researches count wrong."), - research_name_translation(presearch)); + sg_regr(03000300, + _("%s had finished researches count wrong."), + research_name_translation(presearch)); presearch->techs_researched = techs; } } researches_iterate_end; diff --git a/server/savegame3.c b/server/savegame3.c index 4cd5522a42..fb1062d688 100644 --- a/server/savegame3.c +++ b/server/savegame3.c @@ -2350,6 +2350,8 @@ static void sg_load_scenario(struct loaddata *loading) sg_failure_ret(29099 <= game_version, "Saved game is too old, at least " "version 2.90.99 required."); + loading->full_version = game_version; + sg_failure_ret(secfile_lookup_bool(loading->file, &game.scenario.is_scenario, "scenario.is_scenario"), "%s", secfile_error()); if (!game.scenario.is_scenario) { @@ -7137,8 +7139,9 @@ static void sg_load_sanitycheck(struct loaddata *loading) techs = recalculate_techs_researched(presearch); if (presearch->techs_researched != techs) { - log_sg(_("%s had finished researches count wrong."), - research_name_translation(presearch)); + sg_regr(03000300, + _("%s had finished researches count wrong."), + research_name_translation(presearch)); presearch->techs_researched = techs; } } researches_iterate_end; -- 2.35.1