From c885b756b93915a0d32273f6c23d3d3012c75853 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 15 Sep 2023 14:23:35 +0300 Subject: [PATCH 13/13] Make it possible for all extras to be resources Drop separate MAX_RESOURCE_TYPES, and allow MAX_EXTRAS_TYPES resources. See osdn #48607 Signed-off-by: Marko Lindqvist --- client/packhand.c | 2 +- common/networking/packets.def | 4 ++-- common/terrain.h | 3 --- server/ruleset.c | 7 +++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 4ca99dd750..e1be57905c 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -3413,7 +3413,7 @@ void handle_ruleset_control(const struct packet_ruleset_control *packet) VALIDATE(num_tech_types, A_LAST, "advances"); VALIDATE(num_base_types, MAX_EXTRA_TYPES, "bases"); VALIDATE(num_road_types, MAX_EXTRA_TYPES, "roads"); - VALIDATE(num_resource_types, MAX_RESOURCE_TYPES, "resources"); + VALIDATE(num_resource_types, MAX_EXTRA_TYPES, "resources"); VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters"); VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements"); VALIDATE(num_counters, MAX_COUNTERS, "counters"); diff --git a/common/networking/packets.def b/common/networking/packets.def index 35f6933f5c..b58822a924 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -1700,8 +1700,8 @@ PACKET_RULESET_TERRAIN = 151; sc, lsend UINT8 output[O_LAST]; UINT8 num_resources; - RESOURCE resources[MAX_RESOURCE_TYPES:num_resources]; - UINT8 resource_freq[MAX_RESOURCE_TYPES:num_resources]; + RESOURCE resources[MAX_EXTRA_TYPES:num_resources]; + UINT8 resource_freq[MAX_EXTRA_TYPES:num_resources]; UINT16 road_output_incr_pct[O_LAST]; UINT8 base_time; diff --git a/common/terrain.h b/common/terrain.h index 259252aaaa..c505ab21d4 100644 --- a/common/terrain.h +++ b/common/terrain.h @@ -62,9 +62,6 @@ struct resource_type { /* A hard limit on the number of terrains; useful for static arrays. * Used in the network protocol. */ #define MAX_NUM_TERRAINS (96) -/* Reflect reality; but theoretically could be larger than terrains! - * Used in the network protocol. */ -#define MAX_RESOURCE_TYPES (MAX_NUM_TERRAINS / 2) /* Used in the network protocol. */ #define SPECENUM_NAME terrain_class diff --git a/server/ruleset.c b/server/ruleset.c index 4b3cff51d1..ff91834534 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -3021,15 +3021,14 @@ static bool load_terrain_names(struct section_file *file, section_list_destroy(sec); sec = NULL; - /* resource names */ - + /* Resource names */ if (ok) { sec = secfile_sections_by_name_prefix(file, RESOURCE_SECTION_PREFIX); nval = (NULL != sec ? section_list_size(sec) : 0); - if (nval > MAX_RESOURCE_TYPES) { + if (nval > MAX_EXTRA_TYPES) { ruleset_error(NULL, LOG_ERROR, "\"%s\": Too many resource types (%d, max %d)", - filename, nval, MAX_RESOURCE_TYPES); + filename, nval, MAX_EXTRA_TYPES); ok = FALSE; } -- 2.40.1