From 33b10256ef08f80736e13d35c90ed66e442ebd2e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 7 Sep 2023 14:12:04 +0300 Subject: [PATCH 4/4] Combine bv_special, bv_roads, bv_bases to bv_max_extras See osdn #48587 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/editprop.c | 6 +++--- client/gui-gtk-3.0/editprop.c | 6 +++--- client/gui-gtk-3.22/editprop.c | 6 +++--- client/packhand.c | 16 ++++++++-------- client/tilespec.c | 12 ++++++------ common/fc_types.h | 6 +----- common/networking/packets.def | 6 ++---- common/road.h | 2 +- common/tile.h | 1 - server/generator/mapgen.c | 2 +- server/ruleset.c | 12 ++++++------ 11 files changed, 34 insertions(+), 41 deletions(-) diff --git a/client/gui-gtk-2.0/editprop.c b/client/gui-gtk-2.0/editprop.c index 8398997edc..131409369d 100644 --- a/client/gui-gtk-2.0/editprop.c +++ b/client/gui-gtk-2.0/editprop.c @@ -228,9 +228,9 @@ union propval_data { const char *v_const_string; GdkPixbuf *v_pixbuf; struct built_status *v_built; - bv_special v_bv_special; - bv_roads v_bv_roads; - bv_bases v_bv_bases; + bv_max_extras v_bv_special; + bv_max_extras v_bv_roads; + bv_max_extras v_bv_bases; struct nation_type *v_nation; struct nation_hash *v_nation_hash; struct government *v_gov; diff --git a/client/gui-gtk-3.0/editprop.c b/client/gui-gtk-3.0/editprop.c index f858161e74..2b2796abb5 100644 --- a/client/gui-gtk-3.0/editprop.c +++ b/client/gui-gtk-3.0/editprop.c @@ -229,9 +229,9 @@ union propval_data { const char *v_const_string; GdkPixbuf *v_pixbuf; struct built_status *v_built; - bv_special v_bv_special; - bv_roads v_bv_roads; - bv_bases v_bv_bases; + bv_max_extras v_bv_special; + bv_max_extras v_bv_roads; + bv_max_extras v_bv_bases; struct nation_type *v_nation; struct nation_hash *v_nation_hash; struct government *v_gov; diff --git a/client/gui-gtk-3.22/editprop.c b/client/gui-gtk-3.22/editprop.c index 1b261a9f32..dd7462f8f1 100644 --- a/client/gui-gtk-3.22/editprop.c +++ b/client/gui-gtk-3.22/editprop.c @@ -229,9 +229,9 @@ union propval_data { const char *v_const_string; GdkPixbuf *v_pixbuf; struct built_status *v_built; - bv_special v_bv_special; - bv_roads v_bv_roads; - bv_bases v_bv_bases; + bv_max_extras v_bv_special; + bv_max_extras v_bv_roads; + bv_max_extras v_bv_bases; struct nation_type *v_nation; struct nation_hash *v_nation_hash; struct government *v_gov; diff --git a/client/packhand.c b/client/packhand.c index 403f64369f..3e7d075183 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -3316,14 +3316,14 @@ void handle_ruleset_control(const struct packet_ruleset_control *packet) game.control._count = _maximum; \ } - VALIDATE(num_unit_classes, UCL_LAST, "unit classes"); - VALIDATE(num_unit_types, U_LAST, "unit types"); - VALIDATE(num_impr_types, B_LAST, "improvements"); - VALIDATE(num_tech_types, A_LAST, "advances"); - VALIDATE(num_base_types, MAX_BASE_TYPES, "bases"); - VALIDATE(num_road_types, MAX_ROAD_TYPES, "roads"); - VALIDATE(num_resource_types, MAX_RESOURCE_TYPES, "resources"); - VALIDATE(num_disaster_types, MAX_DISASTER_TYPES, "disasters"); + VALIDATE(num_unit_classes, UCL_LAST, "unit classes"); + VALIDATE(num_unit_types, U_LAST, "unit types"); + VALIDATE(num_impr_types, B_LAST, "improvements"); + 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_disaster_types, MAX_DISASTER_TYPES, "disasters"); VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements"); /* game.control.government_count, game.control.nation_count and diff --git a/client/tilespec.c b/client/tilespec.c index d168daf0cb..54f325644b 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -4251,12 +4251,12 @@ static struct sprite *get_unit_nation_flag_sprite(const struct tileset *t, (map_x, map_y) : the (normalized) map position The values we fill in: tterrain_near : terrain types of all adjacent terrain - tspecial_near : specials of all adjacent terrain + textra_near : extras of all adjacent terrain **************************************************************************/ static void build_tile_data(const struct tile *ptile, - struct terrain *pterrain, - struct terrain **tterrain_near, - bv_extras *textras_near) + struct terrain *pterrain, + struct terrain **tterrain_near, + bv_extras *textras_near) { enum direction8 dir; @@ -6753,7 +6753,7 @@ int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawing_data *draw = t->sprites.drawing[terrain_index(pterrain)]; struct terrain *tterrain_near[8]; - bv_special tspecial_near[8]; + bv_extras textra_near[8]; struct tile dummy_tile; /* :( */ @@ -6764,7 +6764,7 @@ int fill_basic_terrain_layer_sprite_array(struct tileset *t, for (i = 0; i < 8; i++) { tterrain_near[i] = pterrain; - BV_CLR_ALL(tspecial_near[i]); + BV_CLR_ALL(textra_near[i]); } i = draw->is_reversed ? draw->num_layers - layer - 1 : layer; diff --git a/common/fc_types.h b/common/fc_types.h index 91dc81d50f..b16dad1710 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -45,8 +45,6 @@ extern "C" { /* Used in the network protocol. See diplomat_success_vs_defender() */ #define MAX_VET_LEVELS 20 #define MAX_EXTRA_TYPES 128 /* Used in the network protocol. */ -#define MAX_BASE_TYPES MAX_EXTRA_TYPES /* Used in the network protocol. */ -#define MAX_ROAD_TYPES MAX_EXTRA_TYPES /* Used in the network protocol. */ #define MAX_GOODS_TYPES 25 #define MAX_DISASTER_TYPES 10 #define MAX_ACHIEVEMENT_TYPES 40 @@ -546,9 +544,7 @@ struct universal { /* Used in the network protocol. */ BV_DEFINE(bv_extras, MAX_EXTRA_TYPES); -BV_DEFINE(bv_special, MAX_EXTRA_TYPES); -BV_DEFINE(bv_bases, MAX_BASE_TYPES); -BV_DEFINE(bv_roads, MAX_ROAD_TYPES); +BV_DEFINE(bv_max_extras, MAX_EXTRA_TYPES); BV_DEFINE(bv_startpos_nations, MAX_NUM_STARTPOS_NATIONS); /* Used in the network protocol. */ diff --git a/common/networking/packets.def b/common/networking/packets.def index 018f4d4c65..3038bac02a 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -267,14 +267,12 @@ type BV_EXTRA_FLAGS = bitvector(bv_extra_flags) type BV_BASE_FLAGS = bitvector(bv_base_flags) type BV_GOODS_FLAGS = bitvector(bv_goods_flags) type BV_EXTRAS = bitvector(bv_extras) -type BV_BASES = bitvector(bv_bases) -type BV_ROADS = bitvector(bv_roads) +type BV_MAX_EXTRAS = bitvector(bv_max_extras) type BV_ROAD_FLAGS = bitvector(bv_road_flags) type BV_CITY_OPTIONS = bitvector(bv_city_options) type BV_IMPR_FLAGS = bitvector(bv_impr_flags) type BV_IMPRS = bitvector(bv_imprs) type BV_PLAYER = bitvector(bv_player) -type BV_SPECIAL = bitvector(bv_special) type BV_STARTPOS_NATIONS= bitvector(bv_startpos_nations) type BV_TECH_FLAGS = bitvector(bv_tech_flags) type BV_TERRAIN_FLAGS = bitvector(bv_terrain_flags) @@ -1756,7 +1754,7 @@ PACKET_RULESET_ROAD = 220; sc, lsend UINT16 tile_incr[O_LAST]; UINT16 tile_bonus[O_LAST]; ROAD_COMPAT compat; - BV_ROADS integrates; + BV_MAX_EXTRAS integrates; BV_ROAD_FLAGS flags; end diff --git a/common/road.h b/common/road.h index 7b113d8090..0145d2df25 100644 --- a/common/road.h +++ b/common/road.h @@ -72,7 +72,7 @@ struct road_type { struct requirement_vector first_reqs; - bv_roads integrates; + bv_max_extras integrates; bv_road_flags flags; /* Same information as in integrates, but iterating through this list is much diff --git a/common/tile.h b/common/tile.h index 34156d0b7c..2f6dfb6335 100644 --- a/common/tile.h +++ b/common/tile.h @@ -119,7 +119,6 @@ static inline const bv_extras *tile_extras(const struct tile *ptile) return &(ptile->extras); } -void tile_set_bases(struct tile *ptile, bv_bases bases); bool tile_has_base(const struct tile *ptile, const struct base_type *pbase); void tile_add_base(struct tile *ptile, const struct base_type *pbase); void tile_remove_base(struct tile *ptile, const struct base_type *pbase); diff --git a/server/generator/mapgen.c b/server/generator/mapgen.c index d40cd7ffe2..fb8112a8ba 100644 --- a/server/generator/mapgen.c +++ b/server/generator/mapgen.c @@ -69,7 +69,7 @@ struct terrain_select { }; -static struct extra_type *river_types[MAX_ROAD_TYPES]; +static struct extra_type *river_types[MAX_EXTRA_TYPES]; static int river_type_count = 0; #define SPECLIST_TAG terrain_select diff --git a/server/ruleset.c b/server/ruleset.c index a1928b575b..2437f88485 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -2574,15 +2574,15 @@ static bool load_terrain_names(struct section_file *file, section_list_destroy(sec); sec = NULL; - /* base names */ + /* Base names */ if (ok) { sec = secfile_sections_by_name_prefix(file, BASE_SECTION_PREFIX); nval = (NULL != sec ? section_list_size(sec) : 0); - if (nval > MAX_BASE_TYPES) { + if (nval > MAX_EXTRA_TYPES) { ruleset_error(NULL, LOG_ERROR, "\"%s\": Too many base types (%d, max %d)", - filename, nval, MAX_BASE_TYPES); + filename, nval, MAX_EXTRA_TYPES); ok = FALSE; } @@ -2627,15 +2627,15 @@ static bool load_terrain_names(struct section_file *file, section_list_destroy(sec); sec = NULL; - /* road names */ + /* Road names */ if (ok) { sec = secfile_sections_by_name_prefix(file, ROAD_SECTION_PREFIX); nval = (NULL != sec ? section_list_size(sec) : 0); - if (nval > MAX_ROAD_TYPES) { + if (nval > MAX_EXTRA_TYPES) { ruleset_error(NULL, LOG_ERROR, "\"%s\": Too many road types (%d, max %d)", - filename, nval, MAX_ROAD_TYPES); + filename, nval, MAX_EXTRA_TYPES); ok = FALSE; } -- 2.40.1