From eced345755e8df5a547686538c146e34681cc514 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 22 Oct 2022 01:42:14 +0300 Subject: [PATCH 37/37] savegame: Have as little trade routes padding as needed See osdn #45855 Signed-off-by: Marko Lindqvist --- server/savegame/savegame3.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index f9694964c9..2934169b1a 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -5390,7 +5390,7 @@ static void sg_load_player_city_citizens(struct loaddata *loading, static void sg_save_player_cities(struct savedata *saving, struct player *plr) { - int wlist_max_length = 0, rally_point_max_length = 0; + int wlist_max_length = 0, rally_point_max_length = 0, routes_max = 0; int i = 0; int plrno = player_number(plr); bool nations[MAX_NUM_PLAYER_SLOTS]; @@ -5411,6 +5411,8 @@ static void sg_save_player_cities(struct savedata *saving, /* First determine length of longest worklist, rally point order, and the * nationalities we have. */ city_list_iterate(plr->cities, pcity) { + int routes; + /* Check the sanity of the city. */ city_refresh(pcity); sanity_check_city(pcity); @@ -5423,6 +5425,11 @@ static void sg_save_player_cities(struct savedata *saving, rally_point_max_length = pcity->rally_point.length; } + routes = city_num_trade_routes(pcity); + if (routes > routes_max) { + routes_max = routes; + } + if (game.info.citizen_nationality) { /* Find all nations of the citizens,*/ players_iterate(pplayer) { @@ -5474,7 +5481,7 @@ static void sg_save_player_cities(struct savedata *saving, } trade_routes_iterate_end; /* Save dummy values to keep tabular format happy */ - for (; j < MAX_TRADE_ROUTES; j++) { + for (; j < routes_max; j++) { secfile_insert_int(saving->file, 0, "%s.traderoute%d", buf, j); secfile_insert_str(saving->file, route_direction_name(RDIR_BIDIRECTIONAL), "%s.route_direction%d", buf, j); -- 2.35.1