From 96be43c838a0da9156097d470563fd177051a104 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 19 Aug 2022 05:25:03 +0300 Subject: [PATCH 38/38] Be less spammy about fixing research count errors from old savegames See osdn #45344 Signed-off-by: Marko Lindqvist --- server/savegame/savecompat.h | 12 +++++++++++- server/savegame/savegame2.c | 7 +++++-- server/savegame/savegame3.c | 7 +++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/savegame/savecompat.h b/server/savegame/savecompat.h index 0fd4aefa71..d7f33880fc 100644 --- a/server/savegame/savecompat.h +++ b/server/savegame/savecompat.h @@ -48,6 +48,7 @@ struct loaddata { struct section_file *file; const char *secfile_options; int version; + int full_version; struct { const char **order; @@ -137,7 +138,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) { \ @@ -176,6 +179,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, enum sgf_version format_class); void sg_load_post_load_compat(struct loaddata *loading, enum sgf_version format_class); diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index 75ade60409..be690ba8cd 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -1532,6 +1532,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"); @@ -5233,8 +5235,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/savegame/savegame3.c b/server/savegame/savegame3.c index 345188d52c..e76a77a529 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -2391,6 +2391,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; + game.scenario.datafile[0] = '\0'; sg_failure_ret(secfile_lookup_bool(loading->file, &game.scenario.is_scenario, @@ -7700,8 +7702,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