From e48c16eaa3280c7627a152044651b5539ee4985f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 30 Nov 2022 03:28:09 +0200 Subject: [PATCH 15/15] savegame2.c: Fix activities order "unused entry" warnings Also adjust that same, already existing, functionality in savegame3.c to unify it with other similar cases of silencing entries of some 'order'. See osdn #46143 Signed-off-by: Marko Lindqvist --- server/savegame2.c | 13 +++++++++++++ server/savegame3.c | 17 ++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/server/savegame2.c b/server/savegame2.c index f6e2dd3e3d..f7339b5f10 100644 --- a/server/savegame2.c +++ b/server/savegame2.c @@ -1202,6 +1202,19 @@ static void sg_load_savefile(struct loaddata *loading) secfile_error()); } + /* Since freeciv-2.6 savegame format contains activities order, for the + * benefit of future versions. This version does not need them. + * Just lookup the entries to avoid warnings about unused entries. */ + { + int j; + + i = secfile_lookup_int_default(loading->file, 0, "savefile.activities_size"); + for (j = 0; j < i; j++) { + (void) secfile_entry_lookup(loading->file, + "savefile.activities_vector,%d", j); + } + } + /* Load traits. */ loading->trait.size = secfile_lookup_int_default(loading->file, 0, diff --git a/server/savegame3.c b/server/savegame3.c index 353f551f6b..0c2913129f 100644 --- a/server/savegame3.c +++ b/server/savegame3.c @@ -1288,7 +1288,6 @@ static void sg_load_savefile(struct loaddata *loading) const char *terr_name; const char *ruleset = NULL; bool current_ruleset_rejected; - size_t dummy_size; /* Check status and return if not OK (sg_success FALSE). */ sg_check_ret(); @@ -1404,15 +1403,15 @@ static void sg_load_savefile(struct loaddata *loading) } /* Freeciv-3.0 savegame format contains activities order, for the - * benefit of future versions. Freeciv-3.0 itself does not need it. + * benefit of future versions. This version does not need them. * Just lookup the entries to avoid warnings about unused entries. */ - dummy_size = secfile_lookup_int_default(loading->file, 0, - "savefile.activities_size"); - if (dummy_size > 0) { - const char **order = secfile_lookup_str_vec(loading->file, &dummy_size, - "savefile.activities_vector"); - if (order != NULL) { - free(order); + { + int j; + + i = secfile_lookup_int_default(loading->file, 0, "savefile.activities_size"); + for (j = 0; j < i; j++) { + (void) secfile_entry_lookup(loading->file, + "savefile.activities_vector,%d", j); } } -- 2.35.1