From 5e0c8a8807e9972627aa1a3d85a5884e02b6bbe2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 20 Jan 2023 02:27:17 +0200 Subject: [PATCH 26/26] Increase hard limit of trade routes to 20 See osdn #45857 Signed-off-by: Marko Lindqvist --- common/fc_types.h | 2 +- server/savegame/savecompat.c | 3 --- server/savegame/savecompat.h | 3 +++ server/savegame/savegame2.c | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/fc_types.h b/common/fc_types.h index 291cdd3f02..8f8a6043f5 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -1206,7 +1206,7 @@ enum road_compat { ROCO_ROAD, ROCO_RAILROAD, ROCO_RIVER, ROCO_NONE }; * Maximum number of trade routes a city can have in any situation. * Changing this changes network protocol. */ -#define MAX_TRADE_ROUTES 5 +#define MAX_TRADE_ROUTES 20 /* Used in the network protocol. */ #define SPECENUM_NAME goods_selection_method diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 04772a4634..f5b4ca5910 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -39,9 +39,6 @@ static char *special_names[] = "Fallout", NULL }; -/* Old savegames might have padding up to this amount of trade routes */ -#define MAX_TRADE_ROUTES_OLD 5 - /* For each savefile format after 2.3.0, compatibility functions are defined which translate secfile structures from previous version to that version; diff --git a/server/savegame/savecompat.h b/server/savegame/savecompat.h index c0449a75b4..9f25545c60 100644 --- a/server/savegame/savecompat.h +++ b/server/savegame/savecompat.h @@ -215,4 +215,7 @@ enum barbarian_type barb_type_convert(int old_type); void set_unit_activity_base(struct unit *punit, Base_type_id base); void set_unit_activity_road(struct unit *punit, Road_type_id road); +/* Old savegames might have padding up to this amount of trade routes */ +#define MAX_TRADE_ROUTES_OLD 5 + #endif /* FC__SAVECOMPAT_H */ diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c index e9e02122e9..89baa3c9f1 100644 --- a/server/savegame/savegame2.c +++ b/server/savegame/savegame2.c @@ -3497,7 +3497,8 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr, sp_count += value; } - for (i = 0; i < MAX_TRADE_ROUTES; i++) { + /* savegame2.c saves were ever saved with MAX_TRADE_ROUTES_OLD routes max */ + for (i = 0; i < MAX_TRADE_ROUTES_OLD; i++) { int partner = secfile_lookup_int_default(loading->file, 0, "%s.traderoute%d", citystr, i); -- 2.39.0