From 1407a92c394fdf8bd9247cd0f26ffbec335b67a9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 1 May 2022 21:10:14 +0300 Subject: [PATCH 62/62] Rename 'styles_count' as 'num_city_styles' See osdn #44462 Signed-off-by: Marko Lindqvist --- client/packhand.c | 6 +++--- client/tilespec.c | 18 +++++++++--------- common/city.c | 16 ++++++++-------- common/game.c | 2 +- common/networking/packets.def | 2 +- common/style.c | 4 ++-- server/rssanity.c | 2 +- server/ruleset.c | 4 ++-- tools/ruledit/validity.c | 2 +- tools/ruleutil/rulesave.c | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 045612efc9..c0bf880585 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -3351,7 +3351,7 @@ void handle_ruleset_control(const struct packet_ruleset_control *packet) VALIDATE(num_achievement_types, MAX_ACHIEVEMENT_TYPES, "achievements"); /* game.control.government_count, game.control.nation_count and - * game.control.styles_count are allocated dynamically, and does + * game.control.num_city_styles are allocated dynamically, and does * not need a size check. See the allocation bellow. */ VALIDATE(terrain_count, MAX_NUM_TERRAINS, "terrains"); @@ -3362,7 +3362,7 @@ void handle_ruleset_control(const struct packet_ruleset_control *packet) governments_alloc(game.control.government_count); nations_alloc(game.control.nation_count); styles_alloc(game.control.num_styles); - city_styles_alloc(game.control.styles_count); + city_styles_alloc(game.control.num_city_styles); music_styles_alloc(game.control.num_music_styles); if (game.control.desc_length > 0) { @@ -4618,7 +4618,7 @@ void handle_ruleset_city(const struct packet_ruleset_city *packet) struct citystyle *cs; id = packet->style_id; - fc_assert_ret_msg(0 <= id && game.control.styles_count > id, + fc_assert_ret_msg(0 <= id && game.control.num_city_styles > id, "Bad citystyle %d.", id); cs = &city_styles[id]; diff --git a/client/tilespec.c b/client/tilespec.c index 36b7912bca..34bf552a83 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -43,7 +43,7 @@ /* common */ #include "base.h" #include "effects.h" -#include "game.h" /* game.control.styles_count */ +#include "game.h" /* game.control.num_city_styles */ #include "government.h" #include "map.h" #include "movement.h" @@ -1444,10 +1444,10 @@ bool tilespec_reread(const char *new_tileset_name, } specialist_type_iterate_end; tileset->sprites.style_citizen_sets.sets - = fc_malloc(game.control.styles_count + = fc_malloc(game.control.num_city_styles * sizeof(tileset->sprites.style_citizen_sets.sets[0])); - for (id = 0; id < game.control.styles_count; id++) { + for (id = 0; id < game.control.num_city_styles; id++) { tileset_setup_city_tiles(tileset, id); } @@ -2984,9 +2984,9 @@ static struct city_sprite *load_city_sprite(struct tileset *t, int style; /* Store number of styles we have allocated memory for. - * game.control.styles_count might change if client disconnects from + * game.control.num_city_styles might change if client disconnects from * server and connects new one. */ - city_sprite->num_styles = game.control.styles_count; + city_sprite->num_styles = game.control.num_city_styles; city_sprite->styles = fc_malloc(city_sprite->num_styles * sizeof(*city_sprite->styles)); @@ -6237,7 +6237,7 @@ void tileset_setup_city_tiles(struct tileset *t, int style) { const char *style_name = city_style_rule_name(style); - if (style == game.control.styles_count - 1) { + if (style == game.control.num_city_styles - 1) { int i; /* Free old sprites */ @@ -6277,8 +6277,8 @@ void tileset_setup_city_tiles(struct tileset *t, int style) style_name, FALSE); } specialist_type_iterate_end; - if (style == game.control.styles_count - 1) { - for (style = 0; style < game.control.styles_count; style++) { + if (style == game.control.num_city_styles - 1) { + for (style = 0; style < game.control.num_city_styles; style++) { if (t->sprites.city.tile->styles[style].land_num_thresholds == 0) { tileset_error(LOG_FATAL, _("City style \"%s\": no city graphics."), city_style_rule_name(style)); @@ -7270,7 +7270,7 @@ void tileset_ruleset_reset(struct tileset *t) } t->sprites.style_citizen_sets.sets - = fc_malloc(game.control.styles_count + = fc_malloc(game.control.num_city_styles * sizeof(t->sprites.style_citizen_sets.sets[0])); } diff --git a/common/city.c b/common/city.c index 3fa32a0d2c..b43f4a9c41 100644 --- a/common/city.c +++ b/common/city.c @@ -1654,7 +1654,7 @@ int city_style_by_translated_name(const char *s) { int i; - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { if (0 == strcmp(city_style_name_translation(i), s)) { return i; } @@ -1672,7 +1672,7 @@ int city_style_by_rule_name(const char *s) const char *qs = Qn_(s); int i; - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { if (0 == fc_strcasecmp(city_style_rule_name(i), qs)) { return i; } @@ -3270,34 +3270,34 @@ bool is_city_option_set(const struct city *pcity, enum city_options option) } /**********************************************************************//** - Allocate memory for this amount of city styles. + Allocate memory for this amount of city styles. **************************************************************************/ void city_styles_alloc(int num) { int i; city_styles = fc_calloc(num, sizeof(*city_styles)); - game.control.styles_count = num; + game.control.num_city_styles = num; - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { requirement_vector_init(&city_styles[i].reqs); } } /**********************************************************************//** - De-allocate the memory used by the city styles. + De-allocate the memory used by the city styles. **************************************************************************/ void city_styles_free(void) { int i; - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { requirement_vector_free(&city_styles[i].reqs); } free(city_styles); city_styles = NULL; - game.control.styles_count = 0; + game.control.num_city_styles = 0; } /**********************************************************************//** diff --git a/common/game.c b/common/game.c index f7f144ebef..b86d662011 100644 --- a/common/game.c +++ b/common/game.c @@ -246,7 +246,7 @@ static void game_defaults(bool keep_ruleset_value) game.control.preferred_tileset[0] = '\0'; game.control.preferred_soundset[0] = '\0'; game.control.preferred_musicset[0] = '\0'; - game.control.styles_count = 0; + game.control.num_city_styles = 0; game.control.terrain_count = 0; game.ruleset_summary = NULL; diff --git a/common/networking/packets.def b/common/networking/packets.def index 2ae304b661..7e9fd256ea 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -1921,7 +1921,7 @@ PACKET_RULESET_CONTROL = 155; sc, lsend UINT16 num_music_styles; UINT16 government_count; UINT16 nation_count; - UINT16 styles_count; + UINT16 num_city_styles; UINT16 terrain_count; UINT16 num_specialist_types; diff --git a/common/style.c b/common/style.c index d2acf226ab..418e88b92f 100644 --- a/common/style.c +++ b/common/style.c @@ -211,7 +211,7 @@ int basic_city_style_for_style(struct nation_style *pstyle) { int i; - for (i = game.control.styles_count - 1; i >= 0; i--) { + for (i = game.control.num_city_styles - 1; i >= 0; i--) { enum fc_tristate style_style = TRI_MAYBE; requirement_vector_iterate(&city_styles[i].reqs, preq) { @@ -247,7 +247,7 @@ int city_style(struct city *pcity) .tile = city_tile(pcity), }; - for (i = game.control.styles_count - 1; i >= 0; i--) { + for (i = game.control.num_city_styles - 1; i >= 0; i--) { if (are_reqs_active(&context, NULL, &city_styles[i].reqs, RPT_CERTAIN)) { return i; diff --git a/server/rssanity.c b/server/rssanity.c index 8f917d7141..12ecf87821 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -1127,7 +1127,7 @@ bool sanity_check_ruleset_data(struct rscompat_info *compat) } extra_type_by_cause_iterate_end; /* City styles */ - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { if (!sanity_check_req_vec(&city_styles[i].reqs, TRUE, -1, city_style_rule_name(i))) { ruleset_error(LOG_ERROR, diff --git a/server/ruleset.c b/server/ruleset.c index 660bbc6705..4d7b46f901 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -5559,7 +5559,7 @@ static bool load_ruleset_styles(struct section_file *file, sec = secfile_sections_by_name_prefix(file, CITYSTYLE_SECTION_PREFIX); /* Get rest: */ - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { struct requirement_vector *reqs; const char *sec_name = section_name(section_list_get(sec, i)); @@ -8658,7 +8658,7 @@ static void send_ruleset_cities(struct conn_list *dest) struct packet_ruleset_city city_p; int k, j; - for (k = 0; k < game.control.styles_count; k++) { + for (k = 0; k < game.control.num_city_styles; k++) { city_p.style_id = k; j = 0; diff --git a/tools/ruledit/validity.c b/tools/ruledit/validity.c index 348859f702..4982130e6d 100644 --- a/tools/ruledit/validity.c +++ b/tools/ruledit/validity.c @@ -127,7 +127,7 @@ static bool is_universal_needed(struct universal *uni, requirers_cb cb, } action_enabler_list_re_iterate_end; } action_iterate_end; - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { if (universal_is_mentioned_by_requirements(&city_styles[i].reqs, uni)) { cb(city_style_rule_name(i), data); needed = TRUE; diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index f16399d91f..4de91d1611 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -469,7 +469,7 @@ static bool save_styles_ruleset(const char *filename, const char *name) comment_citystyles(sfile); sect_idx = 0; - for (i = 0; i < game.control.styles_count; i++) { + for (i = 0; i < game.control.num_city_styles; i++) { char path[512]; fc_snprintf(path, sizeof(path), "citystyle_%d", sect_idx++); -- 2.35.1