From b594a7f6b703aecb01f6d7914620dc2443c25990 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 5 May 2024 13:21:17 +0300 Subject: [PATCH 60/60] savegame: Don't save techs_researched count It's recalculated after loading the game anyway. See osdn #44610 Signed-off-by: Marko Lindqvist --- server/savegame/savecompat.c | 22 ++++++++++++++++++++++ server/savegame/savegame2.c | 15 +-------------- server/savegame/savegame3.c | 17 +---------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 689993e396..944bfdcb0d 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -2554,6 +2554,17 @@ static void compat_load_030300(struct loaddata *loading, } } player_slots_iterate_end; } + + /* Researches */ + { + int count = secfile_lookup_int_default(loading->file, 0, "research.count"); + int i; + + for (i = 0; i < count; i++) { + /* It's ok for old savegames to have these entries. */ + secfile_entry_ignore(loading->file, "research.r%d.techs", i); + } + } } /************************************************************************//** @@ -3418,6 +3429,17 @@ static void compat_load_dev(struct loaddata *loading) } } player_slots_iterate_end; + /* Researches */ + { + int count = secfile_lookup_int_default(loading->file, 0, "research.count"); + int i; + + for (i = 0; i < count; i++) { + /* It's ok for old savegames to have these entries. */ + secfile_entry_ignore(loading->file, "research.r%d.techs", i); + } + } + } /* Version < 3.2.92 */ #endif /* FREECIV_DEV_SAVE_COMPAT_3_3 */ diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index ad319a2033..b56bfc4223 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -5298,10 +5298,6 @@ static void sg_load_researches(struct loaddata *loading) presearch->tech_goal = technology_load(loading->file, "research.r%d.goal", i); - sg_failure_ret(secfile_lookup_int(loading->file, - &presearch->techs_researched, - "research.r%d.techs", i), - "%s", secfile_error()); sg_failure_ret(secfile_lookup_int(loading->file, &presearch->future_tech, "research.r%d.futuretech", i), @@ -5624,8 +5620,6 @@ static void sg_load_sanitycheck(struct loaddata *loading) /* Check researching technologies and goals. */ researches_iterate(presearch) { - int techs; - if (presearch->researching != A_UNSET && !is_future_tech(presearch->researching) && (valid_advance_by_number(presearch->researching) == NULL @@ -5646,14 +5640,7 @@ static void sg_load_sanitycheck(struct loaddata *loading) presearch->tech_goal = A_UNSET; } - techs = recalculate_techs_researched(presearch); - - if (presearch->techs_researched != techs) { - sg_regr(3000300, - _("%s had finished researches count wrong."), - research_name_translation(presearch)); - presearch->techs_researched = techs; - } + presearch->techs_researched = recalculate_techs_researched(presearch); } researches_iterate_end; players_iterate(pplayer) { diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index f3d8fbed42..2a633860f9 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -7583,10 +7583,6 @@ static void sg_load_researches(struct loaddata *loading) presearch->tech_goal = technology_load(loading->file, "research.r%d.goal", i); - sg_failure_ret(secfile_lookup_int(loading->file, - &presearch->techs_researched, - "research.r%d.techs", i), - "%s", secfile_error()); sg_failure_ret(secfile_lookup_int(loading->file, &presearch->future_tech, "research.r%d.futuretech", i), @@ -7674,8 +7670,6 @@ static void sg_save_researches(struct savedata *saving) "research.r%d.number", i); technology_save(saving->file, "research.r%d.goal", i, presearch->tech_goal); - secfile_insert_int(saving->file, presearch->techs_researched, - "research.r%d.techs", i); secfile_insert_int(saving->file, presearch->future_tech, "research.r%d.futuretech", i); secfile_insert_int(saving->file, presearch->bulbs_researching_saved, @@ -8077,8 +8071,6 @@ static void sg_load_sanitycheck(struct loaddata *loading) /* Check researching technologies and goals. */ researches_iterate(presearch) { - int techs; - if (presearch->researching != A_UNSET && !is_future_tech(presearch->researching) && (valid_advance_by_number(presearch->researching) == NULL @@ -8099,14 +8091,7 @@ static void sg_load_sanitycheck(struct loaddata *loading) presearch->tech_goal = A_UNSET; } - techs = recalculate_techs_researched(presearch); - - if (presearch->techs_researched != techs) { - sg_regr(3000300, - _("%s had finished researches count wrong."), - research_name_translation(presearch)); - presearch->techs_researched = techs; - } + presearch->techs_researched = recalculate_techs_researched(presearch); } researches_iterate_end; /* Check if some player has more than one of some UTYF_UNIQUE unit type */ -- 2.43.0