From 9541cdcb7e1ea5f0ca60f727a633b2dae4302af5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 7 Sep 2023 14:08:39 +0300 Subject: [PATCH 7/7] Combine bv_special, bv_roads, bv_bases to bv_max_extras See osdn #48587 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/editprop.c | 6 +++--- client/gui-gtk-3.22/editprop.c | 6 +++--- client/gui-gtk-4.0/editprop.c | 6 +++--- client/packhand.c | 16 ++++++++-------- client/tilespec.c | 6 +++--- 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, 31 insertions(+), 38 deletions(-) diff --git a/client/gui-gtk-3.0/editprop.c b/client/gui-gtk-3.0/editprop.c index 0ad842137d..1338264fba 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 f9e7cd7b26..d2bb9dd0ce 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/gui-gtk-4.0/editprop.c b/client/gui-gtk-4.0/editprop.c index 1ae34cbe10..d485affcb6 100644 --- a/client/gui-gtk-4.0/editprop.c +++ b/client/gui-gtk-4.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/packhand.c b/client/packhand.c index 1862ebbc27..aac31f6b01 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -3452,14 +3452,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 40c3b91552..c3230d153a 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -4268,7 +4268,7 @@ 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, @@ -6874,7 +6874,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; /* :( */ @@ -6885,7 +6885,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 387e964eff..a973e659e7 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -48,8 +48,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 @@ -764,9 +762,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 ebf9844bb7..3ed5158344 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -275,8 +275,7 @@ type BV_ACTION_SUB_RES = bitvector(bv_action_sub_results) type BV_EXTRA_FLAGS = bitvector(bv_extra_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_CAUSES = bitvector(bv_causes) type BV_RMCAUSES = bitvector(bv_rmcauses) @@ -284,7 +283,6 @@ 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) @@ -1794,7 +1792,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 b6e7841066..bf4d28a38a 100644 --- a/common/road.h +++ b/common/road.h @@ -81,7 +81,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 35fd2f07c8..8fb1df362a 100644 --- a/common/tile.h +++ b/common/tile.h @@ -121,7 +121,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); bool tile_has_not_aggressive_extra_for_unit(const struct tile *ptile, const struct unit_type *punittype); diff --git a/server/generator/mapgen.c b/server/generator/mapgen.c index 242d15b1d5..1989ce8ac9 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 6da394d230..97e7475905 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -2973,15 +2973,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; } @@ -3026,15 +3026,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