From 1698cd4c1748ebd5844f49a4b840f2954f3037bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= Date: Sun, 14 Nov 2021 16:10:26 +0100 Subject: [PATCH] - Added intial counters savegame-related functions Added functions to save counters (savegame-related) and save counter information. Save function only saves city's counter names. diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index aca6c1ee1b..2e00f93db1 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -90,6 +90,7 @@ #include "capability.h" #include "citizens.h" #include "city.h" +#include "counters.h" #include "game.h" #include "government.h" #include "map.h" @@ -336,6 +337,8 @@ static void sg_save_scenario(struct savedata *saving); static void sg_load_settings(struct loaddata *loading); static void sg_save_settings(struct savedata *saving); +static void sg_save_counters (struct savedata * saving); + static void sg_load_map(struct loaddata *loading); static void sg_save_map(struct savedata *saving); static void sg_load_map_tiles(struct loaddata *loading); @@ -523,6 +526,8 @@ static void savegame3_save_real(struct section_file *file, sg_save_scenario(saving); /* [savefile] */ sg_save_savefile(saving); + /* [counters] */ + sg_save_counters(saving); /* [game] */ sg_save_game(saving); /* [random] */ @@ -2568,6 +2573,33 @@ static void sg_save_settings(struct savedata *saving) /* Add all compatibility settings here. */ } +/************************************************************************//** +Save [counters]. +****************************************************************************/ +static void sg_save_counters(struct savedata *saving) +{ + /* Check status and return if not OK (sg_success != TRUE). */ + sg_check_ret(); + + const char **countnames;; + int j, count; + + count = counters_get_city_counters_count(); + countnames = fc_calloc(count, sizeof(*countnames)); + + + secfile_insert_int(saving->file, count, + "savefile.city_counters_order_size"); + + for (j = 0; j < count; j++) { + countnames[j] = counter_by_index(j, CTGT_CITY)->rule_name; + } + + secfile_insert_str_vec(saving->file, countnames, count, "savefile.city_counters_order_vector"); + + free(countnames); +} + /* ======================================================================= * Load / save the main map. * ======================================================================= */ -- 2.34.1