From 39020d1abbed5047fbdc1f86d5373bc870a4d55b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 15 Jan 2023 06:25:05 +0200 Subject: [PATCH 27/27] tilespec.[ch]: Improve coding style See osdn #46521 Signed-off-by: Marko Lindqvist --- client/tilespec.c | 940 +++++++++++++++++++++++----------------------- client/tilespec.h | 103 ++--- 2 files changed, 524 insertions(+), 519 deletions(-) diff --git a/client/tilespec.c b/client/tilespec.c index daba362197..1afe5c752e 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -22,7 +22,7 @@ #endif #include -#include /* exit */ +#include /* exit */ #include #include @@ -43,7 +43,7 @@ /* common */ #include "base.h" #include "effects.h" -#include "game.h" /* game.control.num_city_styles */ +#include "game.h" /* game.control.num_city_styles */ #include "government.h" #include "map.h" #include "movement.h" @@ -58,20 +58,20 @@ #include "dialogs_g.h" #include "graphics_g.h" #include "gui_main_g.h" -#include "mapview_g.h" /* for update_map_canvas_visible */ +#include "mapview_g.h" /* For update_map_canvas_visible */ #include "menu_g.h" #include "themes_g.h" /* client */ -#include "citydlg_common.h" /* for generate_citydlg_dimensions() */ +#include "citydlg_common.h" /* For generate_citydlg_dimensions() */ #include "client_main.h" -#include "climap.h" /* for client_tile_get_known() */ +#include "climap.h" /* For client_tile_get_known() */ #include "colors_common.h" -#include "control.h" /* for fill_xxx */ +#include "control.h" /* For fill_xxx */ #include "editor.h" #include "goto.h" #include "helpdata.h" -#include "options.h" /* for fill_xxx */ +#include "options.h" /* For fill_xxx */ #include "svgflag.h" #include "themes_common.h" @@ -97,17 +97,17 @@ /* * Individual spec file capabilities acceptable to this program: * - * +Freeciv-3.1-spec - * - basic format for Freeciv versions 3.1.x; required + * +Freeciv-3.2-spec + * - basic format for Freeciv versions 3.2.x; required */ #define TILESPEC_SUFFIX ".tilespec" #define TILE_SECTION_PREFIX "tile_" /* This the way directional indices are now encoded: */ -#define MAX_INDEX_CARDINAL 64 +#define MAX_INDEX_CARDINAL 64 #define MAX_INDEX_HALF 16 -#define MAX_INDEX_VALID 256 +#define MAX_INDEX_VALID 256 #define NUM_TILES_HP_BAR 11 #define NUM_TILES_DIGITS 10 @@ -147,14 +147,14 @@ static const int DIR4_TO_DIR8[4] = enum match_style { MATCH_NONE, - MATCH_SAME, /* "boolean" match */ + MATCH_SAME, /* "boolean" match */ MATCH_PAIR, MATCH_FULL }; enum sprite_type { - CELL_WHOLE, /* entire tile */ - CELL_CORNER /* corner of tile */ + CELL_WHOLE, /* Entire tile */ + CELL_CORNER /* Corner of tile */ }; struct drawing_data { @@ -239,7 +239,7 @@ struct named_sprites { /* The panel sprites for showing tax % allocations. */ *tax_luxury, *tax_science, *tax_gold, - *dither_tile; /* only used for isometric view */ + *dither_tile; /* Only used for isometric view */ struct { struct sprite @@ -284,7 +284,7 @@ struct named_sprites { *auto_explore, *fortified, *fortifying, - *go_to, /* goto is a C keyword :-) */ + *go_to, /* goto is a C keyword :-) */ *cultivate, *plant, *pillage, @@ -341,8 +341,8 @@ struct named_sprites { struct sprite *fog, **fullfog, - *darkness[MAX_INDEX_CARDINAL]; /* first unused */ - } tx; /* terrain extra */ + *darkness[MAX_INDEX_CARDINAL]; /* First unused */ + } tx; /* Terrain extra */ struct { struct sprite *activity, @@ -359,17 +359,17 @@ struct named_sprites { } bmf; struct { struct sprite - /* for extrastyles ESTYLE_ROAD_ALL_SEPARATE and ESTYLE_ROAD_PARITY_COMBINED */ + /* For extrastyles ESTYLE_ROAD_ALL_SEPARATE and ESTYLE_ROAD_PARITY_COMBINED */ *isolated, *corner[8]; /* Indexed by direction; only non-cardinal dirs used. */ union { - /* for ESTYLE_ROAD_ALL_SEPARATE */ - struct sprite *dir[8]; /* all entries used */ + /* For ESTYLE_ROAD_ALL_SEPARATE */ + struct sprite *dir[8]; /* All entries used */ /* ESTYLE_ROAD_PARITY_COMBINED */ struct { struct sprite - *even[MAX_INDEX_HALF], /* first unused */ - *odd[MAX_INDEX_HALF]; /* first unused */ + *even[MAX_INDEX_HALF], /* First unused */ + *odd[MAX_INDEX_HALF]; /* First unused */ } combo; /* ESTYLE_ALL_SEPARATE */ struct sprite *total[MAX_INDEX_VALID]; @@ -418,7 +418,7 @@ struct specfile { TYPED_LIST_ITERATE(struct specfile, list, pitem) #define specfile_list_iterate_end LIST_ITERATE_END -/* +/* * Information about an individual sprite. All fields except 'sprite' are * filled at the time of the scan of the specfile. 'Sprite' is * set/cleared on demand in load_sprite/unload_sprite. @@ -724,8 +724,8 @@ int tileset_hex_height(const struct tileset *t) } /************************************************************************//** - Return the tile width of the current tileset. This is the tesselation - width of the tiled plane. This means it's the width of the bounding box + Return the tile width of the current tileset. This is the tesselation + width of the tiled plane. This means it's the width of the bounding box of the basic map tile. For best results: @@ -736,7 +736,7 @@ int tileset_hex_height(const struct tileset *t) perspective). - In hex or iso-hex view, remember this is the tesselation vector. hex_width and hex_height then give the size of the side of the - hexagon. Calculating the dimensions of a "regular" hexagon or + hexagon. Calculating the dimensions of a "regular" hexagon or iso-hexagon may be tricky. However these requirements are not absolute and callers should not depend on them (although some do). @@ -747,11 +747,11 @@ int tileset_tile_width(const struct tileset *t) } /************************************************************************//** - Return the tile height of the current tileset. This is the tesselation - height of the tiled plane. This means it's the height of the bounding box + Return the tile height of the current tileset. This is the tesselation + height of the tiled plane. This means it's the height of the bounding box of the basic map tile. - See also tileset_tile_width. + See also tileset_tile_width(). ****************************************************************************/ int tileset_tile_height(const struct tileset *t) { @@ -759,7 +759,7 @@ int tileset_tile_height(const struct tileset *t) } /************************************************************************//** - Return the full tile width of the current tileset. This is the maximum + Return the full tile width of the current tileset. This is the maximum width that any mapview sprite will have. Note: currently this is always equal to the tile width. @@ -770,8 +770,8 @@ int tileset_full_tile_width(const struct tileset *t) } /************************************************************************//** - Return the full tile height of the current tileset. This is the maximum - height that any mapview sprite will have. This may be greater than the + Return the full tile height of the current tileset. This is the maximum + height that any mapview sprite will have. This may be greater than the tile width in which case the extra area is above the "normal" tile. Some callers assume the full height is 50% larger than the height in @@ -885,7 +885,7 @@ int tileset_unit_layout_small_offset_y(const struct tileset *t) } /************************************************************************//** - Return the small sprite width of the current tileset. The small sprites + Return the small sprite width of the current tileset. The small sprites are used for various theme graphics (e.g., citymap citizens/specialists as well as panel indicator icons). ****************************************************************************/ @@ -921,7 +921,7 @@ float tileset_scale(const struct tileset *t) } /************************************************************************//** - Return the small sprite height of the current tileset. The small sprites + Return the small sprite height of the current tileset. The small sprites are used for various theme graphics (e.g., citymap citizens/specialists as well as panel indicator icons). ****************************************************************************/ @@ -932,7 +932,7 @@ int tileset_small_sprite_height(const struct tileset *t) /************************************************************************//** Return the path within the data directories where the main intro graphics - file can be found. (It is left up to the GUI code to load and unload this + file can be found. (It is left up to the GUI code to load and unload this file.) ****************************************************************************/ const char *tileset_main_intro_filename(const struct tileset *t) @@ -965,12 +965,13 @@ static struct tileset *tileset_new(void) t->specfiles = specfile_list_new(); t->small_sprites = small_sprite_list_new(); + return t; } /************************************************************************//** - Return the tileset name of the direction. This is similar to - dir_get_name but you shouldn't change this or all tilesets will break. + Return the tileset name of the direction. This is similar to + dir_get_name() but you shouldn't change this or all tilesets will break. ****************************************************************************/ static const char *dir_get_tileset_name(enum direction8 dir) { @@ -1018,7 +1019,7 @@ static enum direction8 dir_by_tileset_name(const char *str) Return TRUE iff the dir is valid in this tileset. ****************************************************************************/ static bool is_valid_tileset_dir(const struct tileset *t, - enum direction8 dir) + enum direction8 dir) { if (t->hex_width > 0) { return dir != DIR8_NORTHEAST && dir != DIR8_SOUTHWEST; @@ -1036,7 +1037,7 @@ static bool is_valid_tileset_dir(const struct tileset *t, another tile in the direction rather than sharing just a single vertex. ****************************************************************************/ static bool is_cardinal_tileset_dir(const struct tileset *t, - enum direction8 dir) + enum direction8 dir) { if (t->hex_width > 0 || t->hex_height > 0) { return is_valid_tileset_dir(t, dir); @@ -1179,7 +1180,7 @@ static void tileset_free_toplevel(struct tileset *t) free(t->main_intro_filename); t->main_intro_filename = NULL; } - + if (t->preferred_themes) { for (i = 0; i < t->num_preferred_themes; i++) { free(t->preferred_themes[i]); @@ -1208,13 +1209,13 @@ static void tileset_free_toplevel(struct tileset *t) extra_type_list_destroy(t->flagged_bases_list); t->flagged_bases_list = NULL; } - + for (i = 0; i < MAX_NUM_LAYERS; i++) { struct tileset_layer *tslp = &t->layers[i]; if (tslp->match_types) { for (j = 0; j < tslp->match_count; j++) { - free(tslp->match_types[j]); + free(tslp->match_types[j]); } free(tslp->match_types); tslp->match_types = NULL; @@ -1315,9 +1316,9 @@ bool tilespec_try_read(const char *tileset_name, bool verbose, int topo_id, Read a new tilespec in from scratch. Unlike the initial reading code, which reads pieces one at a time, - this gets rid of the old data and reads in the new all at once. If the + this gets rid of the old data and reads in the new all at once. If the new tileset fails to load the old tileset may be reloaded; otherwise the - client will exit. If a NULL name is given the current tileset will be + client will exit. If a NULL name is given the current tileset will be reread. It will also call the necessary functions to redraw the graphics. @@ -1395,16 +1396,16 @@ bool tilespec_reread(const char *new_tileset_name, /* Step 3: Setup * - * This is a seriously sticky problem. On startup, we build a hash + * This is a seriously sticky problem. On startup, we build a hash * from all the sprite data. Then, when we connect to a server, the * server sends us ruleset data a piece at a time and we use this data - * to assemble the sprite structures. But if we change while connected - * we have to reassemble all of these. This should just involve - * calling tilespec_setup_*** on everything. But how do we tell what + * to assemble the sprite structures. But if we change while connected + * we have to reassemble all of these. This should just involve + * calling tilespec_setup_*** on everything. But how do we tell what * "everything" is? * * The below code just does things straightforwardly, by setting up - * each possible sprite again. Hopefully it catches everything, and + * each possible sprite again. Hopefully it catches everything, and * doesn't mess up too badly if we change tilesets while not connected * to a server. */ @@ -1465,8 +1466,8 @@ bool tilespec_reread(const char *new_tileset_name, tileset_changed(); can_slide = FALSE; center_tile_mapcanvas(center_tile); - /* update_map_canvas_visible forces a full redraw. Otherwise with fast - * drawing we might not get one. Of course this is slower. */ + /* update_map_canvas_visible forces a full redraw. Otherwise with fast + * drawing we might not get one. Of course this is slower. */ update_map_canvas_visible(); can_slide = TRUE; @@ -1546,12 +1547,13 @@ static struct sprite *load_gfx_file(const char *gfx_filename, bool flag) log_debug("trying to load gfx file \"%s\".", real_full_name); s = load_gfxfile(real_full_name); if (s) { - return s; + return s; } } } log_error("Could not load gfx file \"%s\".", gfx_filename); + return NULL; } @@ -1568,7 +1570,7 @@ static void ensure_big_sprite(struct specfile *sf) return; } - /* Otherwise load it. The big sprite will sometimes be freed and will have + /* Otherwise load it. The big sprite will sometimes be freed and will have * to be reloaded, but most of the time it's just loaded once, the small * sprites are extracted, and then it's freed. */ if (!(file = secfile_load(sf->file_name, TRUE))) { @@ -1592,7 +1594,7 @@ static void ensure_big_sprite(struct specfile *sf) } /************************************************************************//** - Scan all sprites declared in the given specfile. This means that the + Scan all sprites declared in the given specfile. This means that the positions of the sprites in the big_sprite are saved in the small_sprite structs. ****************************************************************************/ @@ -1607,7 +1609,7 @@ static void scan_specfile(struct tileset *t, struct specfile *sf, tileset_error(LOG_FATAL, _("Could not open '%s':\n%s"), sf->file_name, secfile_error()); } if (!check_tilespec_capabilities(file, "spec", - SPEC_CAPSTR, sf->file_name, TRUE)) { + SPEC_CAPSTR, sf->file_name, TRUE)) { tileset_error(LOG_FATAL, _("Specfile %s has incompatible capabilities"), sf->file_name); } @@ -1666,7 +1668,7 @@ static void scan_specfile(struct tileset *t, struct specfile *sf, hot_y = secfile_lookup_int_default(file, 0, "%s.tiles%d.hot_y", sec_name, j); - /* there must be at least 1 because of the while(): */ + /* There must be at least 1 because of the while(): */ fc_assert_action(num_tags > 0, continue); xr = x_top_left + (dx + pixel_border_x) * column; @@ -1706,7 +1708,7 @@ static void scan_specfile(struct tileset *t, struct specfile *sf, section_list_destroy(sections); } - /* Load "extra" sprites. Each sprite is one file. */ + /* Load "extra" sprites. Each sprite is one file. */ i = -1; while (NULL != secfile_entry_lookup(file, "extra.sprites%d.tag", ++i)) { struct small_sprite *ss; @@ -1868,7 +1870,7 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, fname = tilespec_fullname(tileset_name); if (!fname) { if (verbose) { - log_error("Can't find tileset \"%s\".", tileset_name); + log_error("Can't find tileset \"%s\".", tileset_name); } return NULL; } @@ -2014,8 +2016,8 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, tileset_type_set(t->type); - /* Create arrays of valid and cardinal tileset dirs. These depend - * entirely on the tileset, not the topology. They are also in clockwise + /* Create arrays of valid and cardinal tileset dirs. These depend + * entirely on the tileset, not the topology. They are also in clockwise * rotational ordering. */ t->num_valid_tileset_dirs = t->num_cardinal_tileset_dirs = 0; dir = DIR8_NORTH; @@ -2031,6 +2033,7 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, dir = dir_cw(dir); } while (dir != DIR8_NORTH); + fc_assert(t->num_valid_tileset_dirs % 2 == 0); /* Assumed elsewhere. */ t->num_index_valid = 1 << t->num_valid_tileset_dirs; t->num_index_cardinal = 1 << t->num_cardinal_tileset_dirs; @@ -2043,7 +2046,7 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, goto ON_ERROR; } t->normal_tile_width = ceil(t->scale * t->normal_tile_width); - // Adjust width to be multiple of 8 + /* Adjust width to be multiple of 8 */ if (scale != 1.0f) { i = t->normal_tile_width; while (i % 8 != 0) { @@ -2446,25 +2449,25 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, }; sprite_type - = secfile_lookup_str_default(file, "whole", "%s.layer%d_sprite_type", + = secfile_lookup_str_default(file, "whole", "%s.layer%d_sprite_type", sec_name, l); dlp->sprite_type = check_sprite_type(sprite_type, sec_name); switch (dlp->sprite_type) { case CELL_WHOLE: - /* OK, no problem */ - break; + /* OK, no problem */ + break; case CELL_CORNER: - if (dlp->is_tall - || dlp->offset_x > 0 - || dlp->offset_y > 0) { + if (dlp->is_tall + || dlp->offset_x > 0 + || dlp->offset_y > 0) { log_error("[%s] layer %d: you cannot have tall terrain or\n" "a sprite offset with a cell-based drawing method in %s.", sec_name, l, tileset_name_get(t)); - dlp->is_tall = FALSE; - dlp->offset_x = dlp->offset_y = 0; - } - break; + dlp->is_tall = FALSE; + dlp->offset_x = dlp->offset_y = 0; + } + break; }; } @@ -2586,8 +2589,8 @@ static const char *citizen_rule_name(enum citizen_category citizen) } /************************************************************************//** - Return a directional string for the cardinal directions. Normally the - binary value 1000 will be converted into "n1e0s0w0". This is in a + Return a directional string for the cardinal directions. Normally the + binary value 1000 will be converted into "n1e0s0w0". This is in a clockwise ordering. ****************************************************************************/ static const char *cardinal_index_str(const struct tileset *t, int idx) @@ -2620,7 +2623,7 @@ static char *valid_index_str(const struct tileset *t, int idx) int value = (idx >> i) & 1; cat_snprintf(c, sizeof(c), "%s%d", - dir_get_tileset_name(t->valid_tileset_dirs[i]), value); + dir_get_tileset_name(t->valid_tileset_dirs[i]), value); } return c; @@ -2673,10 +2676,10 @@ static struct sprite *load_sprite(struct tileset *t, const char *tag_name, ensure_big_sprite(ss->sf); get_sprite_dimensions(ss->sf->big_sprite, &sf_w, &sf_h); if (ss->x < 0 || ss->x + ss->width > sf_w - || ss->y < 0 || ss->y + ss->height > sf_h) { + || ss->y < 0 || ss->y + ss->height > sf_h) { tileset_error(LOG_ERROR, _("Sprite '%s' in file \"%s\" isn't within the image!"), tag_name, ss->sf->file_name); - return NULL; + return NULL; } if (scale) { sprite_scale = t->scale; @@ -2728,7 +2731,7 @@ static void unload_sprite(struct tileset *t, const char *tag_name) ss->ref_count--; if (ss->ref_count == 0) { - /* Nobody's using the sprite anymore, so we should free it. We know + /* Nobody's using the sprite anymore, so we should free it. We know * where to find it if we need it again. */ log_debug("freeing sprite '%s'.", tag_name); free_sprite(ss->sprite); @@ -2747,8 +2750,8 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) } /* Not very safe, but convenient: */ -#define SET_SPRITE(field, tag) \ - do { \ +#define SET_SPRITE(field, tag) \ + do { \ t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE); \ if (t->sprites.field == NULL) { \ tileset_error(LOG_FATAL, _("Sprite for tag '%s' missing."), tag); \ @@ -2756,8 +2759,8 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) } while (FALSE) -#define SET_SPRITE_NOTSMOOTH(field, tag) \ - do { \ +#define SET_SPRITE_NOTSMOOTH(field, tag) \ + do { \ t->sprites.field = load_sprite(t, tag, TRUE, FALSE, FALSE); \ if (t->sprites.field == NULL) { \ tileset_error(LOG_FATAL, _("Sprite for tag '%s' missing."), tag); \ @@ -2773,12 +2776,12 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) } while (FALSE) /* Sets sprites.field to tag or (if tag isn't available) to alt */ -#define SET_SPRITE_ALT(field, tag, alt) \ - do { \ +#define SET_SPRITE_ALT(field, tag, alt) \ + do { \ t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE); \ - if (!t->sprites.field) { \ + if (!t->sprites.field) { \ t->sprites.field = load_sprite(t, alt, TRUE, TRUE, FALSE); \ - } \ + } \ if (t->sprites.field == NULL) { \ tileset_error(LOG_FATAL, _("Sprite for tags '%s' and alternate '%s' are " \ "both missing."), tag, alt); \ @@ -2789,10 +2792,10 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) #define SET_SPRITE_OPT(field, tag) \ t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE) -#define SET_SPRITE_ALT_OPT(field, tag, alt) \ - do { \ +#define SET_SPRITE_ALT_OPT(field, tag, alt) \ + do { \ t->sprites.field = tiles_lookup_sprite_tag_alt(t, LOG_VERBOSE, tag, alt,\ - "sprite", #field, TRUE); \ + "sprite", #field, TRUE); \ } while (FALSE) /************************************************************************//** @@ -2938,12 +2941,12 @@ static void tileset_setup_citizen_types(struct tileset *t, Return the sprite in the city_sprite listing that corresponds to this city - based on city style and size. - See also load_city_sprite, free_city_sprite. + See also load_city_sprite(), free_city_sprite(). ****************************************************************************/ static struct sprite *get_city_sprite(const struct city_sprite *city_sprite, const struct city *pcity) { - /* get style and match the best tile based on city size */ + /* Get style and match the best tile based on city size */ int style = style_of_city(pcity); int num_thresholds; struct city_style_threshold *thresholds; @@ -3015,7 +3018,7 @@ static int load_city_thresholds_sprites(struct tileset *t, const char *tag, tag may be NULL. - See also get_city_sprite, free_city_sprite. + See also get_city_sprite(), free_city_sprite(). ****************************************************************************/ static struct city_sprite *load_city_sprite(struct tileset *t, const char *tag) @@ -3028,7 +3031,7 @@ static struct city_sprite *load_city_sprite(struct tileset *t, * server and connects new one. */ city_sprite->num_styles = game.control.num_city_styles; city_sprite->styles = fc_malloc(city_sprite->num_styles - * sizeof(*city_sprite->styles)); + * sizeof(*city_sprite->styles)); for (style = 0; style < city_sprite->num_styles; style++) { city_sprite->styles[style].land_num_thresholds = @@ -3063,7 +3066,7 @@ static void free_city_sprite(struct city_sprite *city_sprite) /************************************************************************//** Initialize 'sprites' structure based on hardwired tags which - freeciv always requires. + freeciv always requires. ****************************************************************************/ static void tileset_lookup_sprite_tags(struct tileset *t) { @@ -3109,7 +3112,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) for (i = 0; i < SPACESHIP_COUNT; i++) { const char *names[SPACESHIP_COUNT] = {"solar_panels", "life_support", "habitation", - "structural", "fuel", "propulsion", "exhaust"}; + "structural", "fuel", "propulsion", "exhaust"}; fc_snprintf(buffer, sizeof(buffer), "spaceship.%s", names[i]); SET_SPRITE(spaceship[i], buffer); @@ -3118,8 +3121,8 @@ static void tileset_lookup_sprite_tags(struct tileset *t) for (i = 0; i < CURSOR_LAST; i++) { for (f = 0; f < NUM_CURSOR_FRAMES; f++) { const char *names[CURSOR_LAST] = - {"goto", "patrol", "paradrop", "nuke", "select", - "invalid", "attack", "edit_paint", "edit_add", "wait"}; + {"goto", "patrol", "paradrop", "nuke", "select", + "invalid", "attack", "edit_paint", "edit_add", "wait"}; struct small_sprite *ss; fc_assert(ARRAY_SIZE(names) == CURSOR_LAST); @@ -3162,13 +3165,13 @@ static void tileset_lookup_sprite_tags(struct tileset *t) SET_SPRITE(unit.auto_attack, "unit.auto_attack"); SET_SPRITE(unit.auto_settler, "unit.auto_settler"); SET_SPRITE(unit.auto_explore, "unit.auto_explore"); - SET_SPRITE(unit.fortified, "unit.fortified"); - SET_SPRITE(unit.fortifying, "unit.fortifying"); - SET_SPRITE(unit.go_to, "unit.goto"); + SET_SPRITE(unit.fortified, "unit.fortified"); + SET_SPRITE(unit.fortifying, "unit.fortifying"); + SET_SPRITE(unit.go_to, "unit.goto"); SET_SPRITE(unit.cultivate, "unit.cultivate"); SET_SPRITE(unit.plant, "unit.plant"); - SET_SPRITE(unit.pillage, "unit.pillage"); - SET_SPRITE(unit.sentry, "unit.sentry"); + SET_SPRITE(unit.pillage, "unit.pillage"); + SET_SPRITE(unit.sentry, "unit.sentry"); SET_SPRITE(unit.convert, "unit.convert"); t->sprites.unit.stack = fc_malloc(sizeof(struct sprite *)); t->sprites.unit.num_stack_sprites = 1; @@ -3353,9 +3356,9 @@ static void tileset_lookup_sprite_tags(struct tileset *t) /* Chop up and build the overlay graphics. */ sprite_vector_reserve(&t->sprites.city.worked_tile_overlay, - sprite_vector_size(&t->sprites.colors.overlays)); + sprite_vector_size(&t->sprites.colors.overlays)); sprite_vector_reserve(&t->sprites.city.unworked_tile_overlay, - sprite_vector_size(&t->sprites.colors.overlays)); + sprite_vector_size(&t->sprites.colors.overlays)); for (i = 0; i < sprite_vector_size(&t->sprites.colors.overlays); i++) { struct sprite *color, *color_mask; struct sprite *worked, *unworked; @@ -3364,9 +3367,9 @@ static void tileset_lookup_sprite_tags(struct tileset *t) color_mask = crop_sprite(color, 0, 0, W, H, t->sprites.mask.tile, 0, 0, 1.0f, FALSE); worked = crop_sprite(color_mask, 0, 0, W, H, - t->sprites.mask.worked_tile, 0, 0, 1.0f, FALSE); + t->sprites.mask.worked_tile, 0, 0, 1.0f, FALSE); unworked = crop_sprite(color_mask, 0, 0, W, H, - t->sprites.mask.unworked_tile, 0, 0, 1.0f, FALSE); + t->sprites.mask.unworked_tile, 0, 0, 1.0f, FALSE); free_sprite(color_mask); t->sprites.city.worked_tile_overlay.p[i] = worked; t->sprites.city.unworked_tile_overlay.p[i] = unworked; @@ -3381,9 +3384,9 @@ static void tileset_lookup_sprite_tags(struct tileset *t) int be; if (i == EDGE_UD && t->hex_width == 0) { - continue; + continue; } else if (i == EDGE_LR && t->hex_height == 0) { - continue; + continue; } fc_snprintf(buffer, sizeof(buffer), "grid.main.%s", edge_name[i]); @@ -3437,20 +3440,20 @@ static void tileset_lookup_sprite_tags(struct tileset *t) enum direction8 dir = t->cardinal_tileset_dirs[i]; fc_snprintf(buffer, sizeof(buffer), "tx.darkness_%s", - dir_get_tileset_name(dir)); + dir_get_tileset_name(dir)); SET_SPRITE_NOTSMOOTH(tx.darkness[i], buffer); } break; case DARKNESS_CARD_FULL: for (i = 1; i < t->num_index_cardinal; i++) { fc_snprintf(buffer, sizeof(buffer), "tx.darkness_%s", - cardinal_index_str(t, i)); + cardinal_index_str(t, i)); SET_SPRITE_NOTSMOOTH(tx.darkness[i], buffer); } break; case DARKNESS_CORNER: t->sprites.tx.fullfog = fc_realloc(t->sprites.tx.fullfog, - 81 * sizeof(*t->sprites.tx.fullfog)); + 81 * sizeof(*t->sprites.tx.fullfog)); for (i = 0; i < 81; i++) { /* Unknown, fog, known. */ char ids[] = {'u', 'f', 'k'}; @@ -3458,10 +3461,10 @@ static void tileset_lookup_sprite_tags(struct tileset *t) int values[4], vi, k = i; for (vi = 0; vi < 4; vi++) { - values[vi] = k % 3; - k /= 3; + values[vi] = k % 3; + k /= 3; - cat_snprintf(buf, sizeof(buf), "_%c", ids[values[vi]]); + cat_snprintf(buf, sizeof(buf), "_%c", ids[values[vi]]); } fc_assert(k == 0); @@ -3728,10 +3731,10 @@ void tileset_setup_impr_type(struct tileset *t, { t->sprites.building[improvement_index(pimprove)] = tiles_lookup_sprite_tag_alt(t, LOG_VERBOSE, pimprove->graphic_str, - pimprove->graphic_alt, "improvement", - improvement_rule_name(pimprove), FALSE); + pimprove->graphic_alt, "improvement", + improvement_rule_name(pimprove), FALSE); - /* should maybe do something if NULL, eg generic default? */ + /* Should maybe do something if NULL, eg generic default? */ } /************************************************************************//** @@ -3744,10 +3747,10 @@ void tileset_setup_tech_type(struct tileset *t, if (valid_advance(padvance)) { t->sprites.tech[advance_index(padvance)] = tiles_lookup_sprite_tag_alt(t, LOG_VERBOSE, padvance->graphic_str, - padvance->graphic_alt, "technology", - advance_rule_name(padvance), FALSE); + padvance->graphic_alt, "technology", + advance_rule_name(padvance), FALSE); - /* should maybe do something if NULL, eg generic default? */ + /* Should maybe do something if NULL, eg generic default? */ } else { t->sprites.tech[advance_index(padvance)] = NULL; } @@ -3815,7 +3818,7 @@ void tileset_setup_extra(struct tileset *t, char buffer[512]; /* We use direction-specific irrigation and farmland graphics, if they - * are available. If not, we just fall back to the basic irrigation + * are available. If not, we just fall back to the basic irrigation * graphics. */ for (i = 0; i < t->num_index_cardinal; i++) { fc_snprintf(buffer, sizeof(buffer), "%s_%s", @@ -3915,23 +3918,23 @@ static void tileset_setup_road(struct tileset *t, int num_index = 1 << (t->num_valid_tileset_dirs / 2), j; /* ESTYLE_ROAD_PARITY_COMBINED has 32 additional sprites for each road - * type: 16 each for cardinal and diagonal directions. Each set + * type: 16 each for cardinal and diagonal directions. Each set * of 16 provides a NSEW-indexed sprite to provide connectors for - * all rails in the cardinal/diagonal directions. The 0 entry is + * all rails in the cardinal/diagonal directions. The 0 entry is * unused (the "isolated" sprite is used instead). */ for (i = 1; i < num_index; i++) { char c[64] = "", d[64] = ""; for (j = 0; j < t->num_valid_tileset_dirs / 2; j++) { - int value = (i >> j) & 1; - - cat_snprintf(c, sizeof(c), "%s%d", - dir_get_tileset_name(t->valid_tileset_dirs[2 * j]), - value); - cat_snprintf(d, sizeof(d), "%s%d", - dir_get_tileset_name(t->valid_tileset_dirs[2 * j + 1]), - value); + int value = (i >> j) & 1; + + cat_snprintf(c, sizeof(c), "%s%d", + dir_get_tileset_name(t->valid_tileset_dirs[2 * j]), + value); + cat_snprintf(d, sizeof(d), "%s%d", + dir_get_tileset_name(t->valid_tileset_dirs[2 * j + 1]), + value); } fc_snprintf(full_tag_name, sizeof(full_tag_name), @@ -4057,160 +4060,160 @@ void tileset_setup_tile_type(struct tileset *t, case CELL_WHOLE: switch (dlp->match_style) { case MATCH_NONE: - /* Load whole sprites for this tile. */ - for (i = 0; ; i++) { + /* Load whole sprites for this tile. */ + for (i = 0; ; i++) { fc_snprintf(buffer, sizeof(buffer), "t.l%d.%s%d", l, draw->name, i + 1); - sprite = load_sprite(t, buffer, TRUE, FALSE, FALSE); - if (!sprite) { - break; - } - sprite_vector_reserve(&dlp->base, i + 1); - dlp->base.p[i] = sprite; - } - /* check for base sprite, allowing missing sprites above base */ - if (0 == i && 0 == l) { - /* TRANS: 'base' means 'base of terrain gfx', not 'military base' */ + sprite = load_sprite(t, buffer, TRUE, FALSE, FALSE); + if (!sprite) { + break; + } + sprite_vector_reserve(&dlp->base, i + 1); + dlp->base.p[i] = sprite; + } + /* Check for base sprite, allowing missing sprites above base */ + if (0 == i && 0 == l) { + /* TRANS: 'base' means 'base of terrain gfx', not 'military base' */ tileset_error(LOG_FATAL, _("Missing base sprite for tag \"%s\"."), buffer); - } - break; + } + break; case MATCH_SAME: - /* Load 16 cardinally-matched sprites. */ - for (i = 0; i < t->num_index_cardinal; i++) { + /* Load 16 cardinally-matched sprites. */ + for (i = 0; i < t->num_index_cardinal; i++) { fc_snprintf(buffer, sizeof(buffer), "t.l%d.%s_%s", l, draw->name, cardinal_index_str(t, i)); - dlp->match[i] = - tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", - "matched terrain", - terrain_rule_name(pterrain), TRUE); - } - break; + dlp->match[i] = + tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", + "matched terrain", + terrain_rule_name(pterrain), TRUE); + } + break; case MATCH_PAIR: case MATCH_FULL: - fc_assert(FALSE); /* not yet defined */ + fc_assert(FALSE); /* Not yet defined */ break; }; break; case CELL_CORNER: { - const int count = dlp->match_indices; - int number = NUM_CORNER_DIRS; - - switch (dlp->match_style) { - case MATCH_NONE: - /* do nothing */ - break; - case MATCH_PAIR: - case MATCH_SAME: - /* N directions (NSEW) * 3 dimensions of matching */ + const int count = dlp->match_indices; + int number = NUM_CORNER_DIRS; + + switch (dlp->match_style) { + case MATCH_NONE: + /* Do nothing */ + break; + case MATCH_PAIR: + case MATCH_SAME: + /* N directions (NSEW) * 3 dimensions of matching */ fc_assert(count == 2); - number = NUM_CORNER_DIRS * 2 * 2 * 2; - break; - case MATCH_FULL: - default: - /* N directions (NSEW) * 3 dimensions of matching */ - /* could use exp() or expi() here? */ - number = NUM_CORNER_DIRS * count * count * count; - break; - }; - - dlp->cells - = fc_calloc(number, sizeof(*dlp->cells)); - - for (i = 0; i < number; i++) { - enum direction4 dir = i % NUM_CORNER_DIRS; - int value = i / NUM_CORNER_DIRS; - - switch (dlp->match_style) { - case MATCH_NONE: + number = NUM_CORNER_DIRS * 2 * 2 * 2; + break; + case MATCH_FULL: + default: + /* N directions (NSEW) * 3 dimensions of matching */ + /* could use exp() or expi() here? */ + number = NUM_CORNER_DIRS * count * count * count; + break; + }; + + dlp->cells + = fc_calloc(number, sizeof(*dlp->cells)); + + for (i = 0; i < number; i++) { + enum direction4 dir = i % NUM_CORNER_DIRS; + int value = i / NUM_CORNER_DIRS; + + switch (dlp->match_style) { + case MATCH_NONE: fc_snprintf(buffer, sizeof(buffer), "t.l%d.%s_cell_%c", l, draw->name, direction4letters[dir]); - dlp->cells[i] = - tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", - "cell terrain", - terrain_rule_name(pterrain), TRUE); - break; - case MATCH_SAME: + dlp->cells[i] = + tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", + "cell terrain", + terrain_rule_name(pterrain), TRUE); + break; + case MATCH_SAME: fc_snprintf(buffer, sizeof(buffer), "t.l%d.%s_cell_%c%d%d%d", l, draw->name, direction4letters[dir], (value) & 1, (value >> 1) & 1, (value >> 2) & 1); - dlp->cells[i] = - tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", - "same cell terrain", - terrain_rule_name(pterrain), TRUE); - break; - case MATCH_PAIR: + dlp->cells[i] = + tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", + "same cell terrain", + terrain_rule_name(pterrain), TRUE); + break; + case MATCH_PAIR: fc_snprintf(buffer, sizeof(buffer), "t.l%d.%s_cell_%c_%c_%c_%c", l, draw->name, direction4letters[dir], tslp->match_types[dlp->match_index[(value) & 1]][0], tslp->match_types[dlp->match_index[(value >> 1) & 1]][0], tslp->match_types[dlp->match_index[(value >> 2) & 1]][0]); - dlp->cells[i] = - tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", - "cell pair terrain", - terrain_rule_name(pterrain), TRUE); - break; - case MATCH_FULL: - { - int this = dlp->match_index[0]; - int n, s, e, w; - int v1, v2, v3; - - v1 = dlp->match_index[value % count]; - value /= count; - v2 = dlp->match_index[value % count]; - value /= count; - v3 = dlp->match_index[value % count]; + dlp->cells[i] = + tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", + "cell pair terrain", + terrain_rule_name(pterrain), TRUE); + break; + case MATCH_FULL: + { + int this = dlp->match_index[0]; + int n, s, e, w; + int v1, v2, v3; + + v1 = dlp->match_index[value % count]; + value /= count; + v2 = dlp->match_index[value % count]; + value /= count; + v3 = dlp->match_index[value % count]; fc_assert(v1 < count && v2 < count && v3 < count); - /* Assume merged cells. This should be a separate option. */ - switch (dir) { - case DIR4_NORTH: - s = this; - w = v1; - n = v2; - e = v3; - break; - case DIR4_EAST: - w = this; - n = v1; - e = v2; - s = v3; - break; - case DIR4_SOUTH: - n = this; - e = v1; - s = v2; - w = v3; - break; - case DIR4_WEST: - default: /* avoid warnings */ - e = this; - s = v1; - w = v2; - n = v3; - break; - }; - - /* Use first character of match_types, - * already checked for uniqueness. */ + /* Assume merged cells. This should be a separate option. */ + switch (dir) { + case DIR4_NORTH: + s = this; + w = v1; + n = v2; + e = v3; + break; + case DIR4_EAST: + w = this; + n = v1; + e = v2; + s = v3; + break; + case DIR4_SOUTH: + n = this; + e = v1; + s = v2; + w = v3; + break; + case DIR4_WEST: + default: /* Avoid warnings */ + e = this; + s = v1; + w = v2; + n = v3; + break; + }; + + /* Use first character of match_types, + * already checked for uniqueness. */ fc_snprintf(buffer, sizeof(buffer), "t.l%d.cellgroup_%c_%c_%c_%c", l, tslp->match_types[n][0], tslp->match_types[e][0], tslp->match_types[s][0], tslp->match_types[w][0]); - sprite = load_sprite(t, buffer, TRUE, FALSE, FALSE); + sprite = load_sprite(t, buffer, TRUE, FALSE, FALSE); - if (sprite) { - /* Crop the sprite to separate this cell. */ + if (sprite) { + /* Crop the sprite to separate this cell. */ int vec_size = sprite_vector_size(&dlp->allocated); - const int W = t->normal_tile_width; - const int H = t->normal_tile_height; - int x[4] = {W / 4, W / 4, 0, W / 2}; - int y[4] = {H / 2, 0, H / 4, H / 4}; - int xo[4] = {0, 0, -W / 2, W / 2}; - int yo[4] = {H / 2, -H / 2, 0, 0}; + const int W = t->normal_tile_width; + const int H = t->normal_tile_height; + int x[4] = {W / 4, W / 4, 0, W / 2}; + int y[4] = {H / 2, 0, H / 4, H / 4}; + int xo[4] = {0, 0, -W / 2, W / 2}; + int yo[4] = {H / 2, -H / 2, 0, 0}; sprite = crop_sprite(sprite, x[dir], y[dir], W / 2, H / 2, t->sprites.mask.tile, xo[dir], yo[dir], 1.0f, @@ -4219,26 +4222,26 @@ void tileset_setup_tile_type(struct tileset *t, * address so we can free it. */ sprite_vector_reserve(&dlp->allocated, vec_size + 1); dlp->allocated.p[vec_size] = sprite; - } else { + } else { log_error("Terrain graphics sprite for tag \"%s\" missing.", buffer); - } + } - dlp->cells[i] = sprite; - } - break; - }; - } + dlp->cells[i] = sprite; + } + break; + }; + } } break; }; } - /* try an optional special name */ + /* Try an optional special name */ fc_snprintf(buffer, sizeof(buffer), "t.blend.%s", draw->name); draw->blender = tiles_lookup_sprite_tag_alt(t, LOG_VERBOSE, buffer, "", - "blend terrain", - terrain_rule_name(pterrain), TRUE); + "blend terrain", + terrain_rule_name(pterrain), TRUE); if (draw->blending > 0) { const int bl = draw->blending - 1; @@ -4246,7 +4249,7 @@ void tileset_setup_tile_type(struct tileset *t, if (NULL == draw->blender) { int li = 0; - /* try an already loaded base */ + /* Try an already loaded base */ while (NULL == draw->blender && li < draw->blending && 0 < draw->layer[li].base.size) { @@ -4255,12 +4258,12 @@ void tileset_setup_tile_type(struct tileset *t, } if (NULL == draw->blender) { - /* try an unloaded base name */ + /* Try an unloaded base name */ fc_snprintf(buffer, sizeof(buffer), "t.l%d.%s1", bl, draw->name); draw->blender = - tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", - "base (blend) terrain", - terrain_rule_name(pterrain), TRUE); + tiles_lookup_sprite_tag_alt(t, LOG_FATAL, buffer, "", + "base (blend) terrain", + terrain_rule_name(pterrain), TRUE); } } @@ -4294,22 +4297,22 @@ void tileset_setup_government(struct tileset *t, { t->sprites.government[government_index(gov)] = tiles_lookup_sprite_tag_alt(t, LOG_FATAL, gov->graphic_str, - gov->graphic_alt, "government", - government_rule_name(gov), FALSE); - - /* should probably do something if NULL, eg generic default? */ + gov->graphic_alt, "government", + government_rule_name(gov), FALSE); + + /* Should probably do something if NULL, eg generic default? */ } /************************************************************************//** Set nation flag sprite value; should only happen after tilespec_load_tiles(). ****************************************************************************/ -void tileset_setup_nation_flag(struct tileset *t, +void tileset_setup_nation_flag(struct tileset *t, struct nation_type *nation) { char *tags[] = {nation->flag_graphic_str, - nation->flag_graphic_alt, - "unknown", NULL}; + nation->flag_graphic_alt, + "unknown", NULL}; int i; struct sprite *flag = NULL, *shield = NULL; char buf[1024]; @@ -4361,15 +4364,15 @@ static struct sprite *get_unit_nation_flag_sprite(const struct tileset *t, #define FULL_TILE_X_OFFSET ((t->normal_tile_width - t->full_tile_width) / 2) #define FULL_TILE_Y_OFFSET (t->normal_tile_height - t->full_tile_height) -#define ADD_SPRITE(s, draw_fog, x_offset, y_offset) \ - (fc_assert(s != NULL), \ - sprs->sprite = s, \ - sprs->foggable = (draw_fog && t->fogstyle == FOG_AUTO), \ - sprs->offset_x = x_offset, \ - sprs->offset_y = y_offset, \ +#define ADD_SPRITE(s, draw_fog, x_offset, y_offset) \ + (fc_assert(s != NULL), \ + sprs->sprite = s, \ + sprs->foggable = (draw_fog && t->fogstyle == FOG_AUTO), \ + sprs->offset_x = x_offset, \ + sprs->offset_y = y_offset, \ sprs++) #define ADD_SPRITE_SIMPLE(s) ADD_SPRITE(s, TRUE, 0, 0) -#define ADD_SPRITE_FULL(s) \ +#define ADD_SPRITE_FULL(s) \ ADD_SPRITE(s, TRUE, FULL_TILE_X_OFFSET, FULL_TILE_Y_OFFSET) /************************************************************************//** @@ -4386,7 +4389,7 @@ static void build_tile_data(const struct tile *ptile, { enum direction8 dir; - /* Loop over all adjacent tiles. We should have an iterator for this. */ + /* Loop over all adjacent tiles. We should have an iterator for this. */ for (dir = 0; dir < 8; dir++) { struct tile *tile1 = mapstep(&(wld.map), ptile, dir); @@ -4638,7 +4641,7 @@ static int fill_road_corner_sprites(const struct tileset *t, * - There is a diagonal road (not rail!) between two adjacent tiles. * - There is no diagonal road (not rail!) that intersects this road. * The logic is simple: roads are drawn underneath railrods, but are - * not always covered by them (even in the corners!). But if a railroad + * not always covered by them (even in the corners!). But if a railroad * connects two tiles, only the railroad (no road) is drawn between * those tiles. */ @@ -4649,7 +4652,7 @@ static int fill_road_corner_sprites(const struct tileset *t, /* Draw corner sprites for this non-cardinal direction. */ int cw = (i + 1) % t->num_valid_tileset_dirs; int ccw - = (i + t->num_valid_tileset_dirs - 1) % t->num_valid_tileset_dirs; + = (i + t->num_valid_tileset_dirs - 1) % t->num_valid_tileset_dirs; enum direction8 cwdir = t->valid_tileset_dirs[cw]; enum direction8 ccwdir = t->valid_tileset_dirs[ccw]; @@ -4701,8 +4704,8 @@ static int fill_road_sprite_array(const struct tileset *t, } /* Fill some data arrays. rail_near and road_near store whether road/rail - * is present in the given direction. draw_rail and draw_road store - * whether road/rail is to be drawn in that direction. draw_single_road + * is present in the given direction. draw_rail and draw_road store + * whether road/rail is to be drawn in that direction. draw_single_road * and draw_single_rail store whether we need an isolated road/rail to be * drawn. */ road = BV_ISSET(textras, extra_idx); @@ -4744,7 +4747,7 @@ static int fill_road_sprite_array(const struct tileset *t, } /* Draw rail/road if there is a connection from this tile to the - * adjacent tile. But don't draw road if there is also a rail + * adjacent tile. But don't draw road if there is also a rail * connection. */ roads_exist = road && (road_near[dir] || land_near[dir]); draw_road[dir] = roads_exist; @@ -4798,16 +4801,16 @@ static int fill_road_sprite_array(const struct tileset *t, /* First draw roads under rails. */ if (road) { for (i = 0; i < t->num_valid_tileset_dirs; i++) { - if (draw_road[t->valid_tileset_dirs[i]]) { - ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.ru.dir[i]); - } + if (draw_road[t->valid_tileset_dirs[i]]) { + ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.ru.dir[i]); + } } } } else if (extrastyle == ESTYLE_ROAD_PARITY_COMBINED) { /* With ESTYLE_ROAD_PARITY_COMBINED, we draw one sprite for cardinal * road connections, one sprite for diagonal road connections. * This means we need about 4x more sprites than in style 0, but up to - * 4x less drawing is needed. The drawing quality may also be + * 4x less drawing is needed. The drawing quality may also be * improved. */ /* First draw roads under rails. */ @@ -4815,27 +4818,27 @@ static int fill_road_sprite_array(const struct tileset *t, int road_even_tileno = 0, road_odd_tileno = 0, i; for (i = 0; i < t->num_valid_tileset_dirs / 2; i++) { - enum direction8 even = t->valid_tileset_dirs[2 * i]; - enum direction8 odd = t->valid_tileset_dirs[2 * i + 1]; - - if (draw_road[even]) { - road_even_tileno |= 1 << i; - } - if (draw_road[odd]) { - road_odd_tileno |= 1 << i; - } + enum direction8 even = t->valid_tileset_dirs[2 * i]; + enum direction8 odd = t->valid_tileset_dirs[2 * i + 1]; + + if (draw_road[even]) { + road_even_tileno |= 1 << i; + } + if (draw_road[odd]) { + road_odd_tileno |= 1 << i; + } } /* Draw the cardinal/even roads first. */ if (road_even_tileno != 0) { - ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.ru.combo.even[road_even_tileno]); + ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.ru.combo.even[road_even_tileno]); } if (road_odd_tileno != 0) { - ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.ru.combo.odd[road_odd_tileno]); + ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.ru.combo.odd[road_odd_tileno]); } } } else if (extrastyle == ESTYLE_ROAD_ALL_COMBINED) { - /* RSTYLE_ALL_COMBINED is a very simple method that lets us simply retrieve + /* RSTYLE_ALL_COMBINED is a very simple method that lets us simply retrieve * entire finished tiles, with a bitwise index of the presence of * roads in each direction. */ @@ -4862,7 +4865,7 @@ static int fill_road_sprite_array(const struct tileset *t, /* Draw isolated rail/road separately (ESTYLE_ROAD_ALL_SEPARATE and ESTYLE_ROAD_PARITY_COMBINED only). */ if (extrastyle == ESTYLE_ROAD_ALL_SEPARATE - || extrastyle == ESTYLE_ROAD_PARITY_COMBINED) { + || extrastyle == ESTYLE_ROAD_PARITY_COMBINED) { if (draw_single_road) { ADD_SPRITE_SIMPLE(t->sprites.extras[extra_idx].u.road.isolated); } @@ -4875,7 +4878,7 @@ static int fill_road_sprite_array(const struct tileset *t, Return the index of the sprite to be used for irrigation or farmland in this tile. - We assume that the current tile has farmland or irrigation. We then + We assume that the current tile has farmland or irrigation. We then choose a sprite (index) based upon which cardinally adjacent tiles have either farmland or irrigation (the two are considered interchangable for this). @@ -4939,7 +4942,7 @@ static int fill_irrigation_sprite_array(const struct tileset *t, } /************************************************************************//** - Fill in the city overlays for the tile. This includes the citymap + Fill in the city overlays for the tile. This includes the citymap overlays on the mapview as well as the tile output sprites. ****************************************************************************/ static int fill_city_overlays_sprite_array(const struct tileset *t, @@ -5086,19 +5089,19 @@ static int fill_fog_sprite_array(const struct tileset *t, int value = -1; if (!pcorner->tile[i]) { - value = fogged; + value = fogged; } else { - switch (client_tile_get_known(pcorner->tile[i])) { - case TILE_KNOWN_SEEN: - value = known; - break; - case TILE_KNOWN_UNSEEN: - value = fogged; - break; - case TILE_UNKNOWN: - value = unknown; - break; - } + switch (client_tile_get_known(pcorner->tile[i])) { + case TILE_KNOWN_SEEN: + value = known; + break; + case TILE_KNOWN_UNSEEN: + value = fogged; + break; + case TILE_UNKNOWN: + value = unknown; + break; + } } fc_assert(value >= 0 && value < 3); @@ -5132,8 +5135,8 @@ static int fill_terrain_sprite_array(struct tileset *t, int oy = dlp->offset_y; int i; -#define MATCH(dir) \ - (t->sprites.drawing[terrain_index(tterrain_near[(dir)])]->num_layers > l \ +#define MATCH(dir) \ + (t->sprites.drawing[terrain_index(tterrain_near[(dir)])]->num_layers > l \ ? t->sprites.drawing[terrain_index(tterrain_near[(dir)])]->layer[l].match_index[0] \ : -1) @@ -5142,118 +5145,119 @@ static int fill_terrain_sprite_array(struct tileset *t, { switch (dlp->match_style) { case MATCH_NONE: - { - int count = sprite_vector_size(&dlp->base); + { + int count = sprite_vector_size(&dlp->base); - if (count > 0) { + if (count > 0) { /* Pseudo-random reproducable algorithm to pick a sprite. Use modulo * to limit the number to a handleable size [0..32000). */ count = fc_randomly(tile_index(ptile) % 32000, count); - if (dlp->is_tall) { - ox += FULL_TILE_X_OFFSET; - oy += FULL_TILE_Y_OFFSET; - } - ADD_SPRITE(dlp->base.p[count], TRUE, ox, oy); - } - break; - } + if (dlp->is_tall) { + ox += FULL_TILE_X_OFFSET; + oy += FULL_TILE_Y_OFFSET; + } + ADD_SPRITE(dlp->base.p[count], TRUE, ox, oy); + } + break; + } case MATCH_SAME: - { - int tileno = 0; - - for (i = 0; i < t->num_cardinal_tileset_dirs; i++) { - enum direction8 dir = t->cardinal_tileset_dirs[i]; - - if (MATCH(dir) == this) { - tileno |= 1 << i; - } - } - - if (dlp->is_tall) { - ox += FULL_TILE_X_OFFSET; - oy += FULL_TILE_Y_OFFSET; - } - ADD_SPRITE(dlp->match[tileno], TRUE, ox, oy); - break; - } + { + int tileno = 0; + + for (i = 0; i < t->num_cardinal_tileset_dirs; i++) { + enum direction8 dir = t->cardinal_tileset_dirs[i]; + + if (MATCH(dir) == this) { + tileno |= 1 << i; + } + } + + if (dlp->is_tall) { + ox += FULL_TILE_X_OFFSET; + oy += FULL_TILE_Y_OFFSET; + } + ADD_SPRITE(dlp->match[tileno], TRUE, ox, oy); + break; + } case MATCH_PAIR: case MATCH_FULL: - fc_assert(FALSE); /* not yet defined */ + fc_assert(FALSE); /* Not yet defined */ break; }; break; } case CELL_CORNER: { - /* Divide the tile up into four rectangular cells. Each of these + /* Divide the tile up into four rectangular cells. Each of these * cells covers one corner, and each is adjacent to 3 different - * tiles. For each cell we pick a sprite based upon the adjacent - * terrains at each of those tiles. Thus, we have 8 different sprites + * tiles. For each cell we pick a sprite based upon the adjacent + * terrains at each of those tiles. Thus, we have 8 different sprites * for each of the 4 cells (32 sprites total). * * These arrays correspond to the direction4 ordering. */ const int W = t->normal_tile_width; const int H = t->normal_tile_height; const int iso_offsets[4][2] = { - {W / 4, 0}, {W / 4, H / 2}, {W / 2, H / 4}, {0, H / 4} + {W / 4, 0}, {W / 4, H / 2}, {W / 2, H / 4}, {0, H / 4} }; const int noniso_offsets[4][2] = { - {0, 0}, {W / 2, H / 2}, {W / 2, 0}, {0, H / 2} + {0, 0}, {W / 2, H / 2}, {W / 2, 0}, {0, H / 2} }; - /* put corner cells */ + /* Put corner cells */ for (i = 0; i < NUM_CORNER_DIRS; i++) { - const int count = dlp->match_indices; - int array_index = 0; - enum direction8 dir = dir_ccw(DIR4_TO_DIR8[i]); - int x = (t->type == TS_ISOMETRIC ? iso_offsets[i][0] : noniso_offsets[i][0]); - int y = (t->type == TS_ISOMETRIC ? iso_offsets[i][1] : noniso_offsets[i][1]); - int m[3] = {MATCH(dir_ccw(dir)), MATCH(dir), MATCH(dir_cw(dir))}; - struct sprite *s; - - /* synthesize 4 dimensional array? */ - switch (dlp->match_style) { - case MATCH_NONE: - /* We have no need for matching, just plug the piece in place. */ - break; - case MATCH_SAME: - array_index = array_index * 2 + (m[2] != this); - array_index = array_index * 2 + (m[1] != this); - array_index = array_index * 2 + (m[0] != this); - break; - case MATCH_PAIR: - array_index = array_index * 2 + (m[2] == that); - array_index = array_index * 2 + (m[1] == that); - array_index = array_index * 2 + (m[0] == that); - break; - case MATCH_FULL: - default: - { - int n[3]; - int j = 0; - for (; j < 3; j++) { - int k = 0; - for (; k < count; k++) { - n[j] = k; /* default to last entry */ - if (m[j] == dlp->match_index[k]) - { - break; - } - } - } - array_index = array_index * count + n[2]; - array_index = array_index * count + n[1]; - array_index = array_index * count + n[0]; - } - break; - }; - array_index = array_index * NUM_CORNER_DIRS + i; - - s = dlp->cells[array_index]; - if (s) { - ADD_SPRITE(s, TRUE, x, y); - } + const int count = dlp->match_indices; + int array_index = 0; + enum direction8 dir = dir_ccw(DIR4_TO_DIR8[i]); + int x = (t->type == TS_ISOMETRIC ? iso_offsets[i][0] : noniso_offsets[i][0]); + int y = (t->type == TS_ISOMETRIC ? iso_offsets[i][1] : noniso_offsets[i][1]); + int m[3] = {MATCH(dir_ccw(dir)), MATCH(dir), MATCH(dir_cw(dir))}; + struct sprite *s; + + /* Synthesize 4 dimensional array? */ + switch (dlp->match_style) { + case MATCH_NONE: + /* We have no need for matching, just plug the piece in place. */ + break; + case MATCH_SAME: + array_index = array_index * 2 + (m[2] != this); + array_index = array_index * 2 + (m[1] != this); + array_index = array_index * 2 + (m[0] != this); + break; + case MATCH_PAIR: + array_index = array_index * 2 + (m[2] == that); + array_index = array_index * 2 + (m[1] == that); + array_index = array_index * 2 + (m[0] == that); + break; + case MATCH_FULL: + default: + { + int n[3]; + int j = 0; + + for (; j < 3; j++) { + int k = 0; + + for (; k < count; k++) { + n[j] = k; /* Default to last entry */ + if (m[j] == dlp->match_index[k]) { + break; + } + } + } + array_index = array_index * count + n[2]; + array_index = array_index * count + n[1]; + array_index = array_index * count + n[0]; + } + break; + }; + array_index = array_index * NUM_CORNER_DIRS + i; + + s = dlp->cells[array_index]; + if (s) { + ADD_SPRITE(s, TRUE, x, y); + } } break; } @@ -5289,7 +5293,7 @@ static int fill_terrain_sprite_darkness(struct tileset *t, int offsets[4][2] = {{W / 2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}}; if (UNKNOWN(DIR4_TO_DIR8[i])) { - ADD_SPRITE(t->sprites.tx.darkness[i], TRUE, + ADD_SPRITE(t->sprites.tx.darkness[i], TRUE, offsets[i][0], offsets[i][1]); } } @@ -5303,14 +5307,14 @@ static int fill_terrain_sprite_darkness(struct tileset *t, break; case DARKNESS_CARD_FULL: /* We're looking to find the INDEX_NSEW for the directions that - * are unknown. We want to mark unknown tiles so that an unreal + * are unknown. We want to mark unknown tiles so that an unreal * tile will be given the same marking as our current tile - that * way we won't get the "unknown" dither along the edge of the * map. */ tileno = 0; for (i = 0; i < t->num_cardinal_tileset_dirs; i++) { if (UNKNOWN(t->cardinal_tileset_dirs[i])) { - tileno |= 1 << i; + tileno |= 1 << i; } } @@ -5328,7 +5332,7 @@ static int fill_terrain_sprite_darkness(struct tileset *t, } /************************************************************************//** - Add sprites for the base tile to the sprite list. This doesn't + Add sprites for the base tile to the sprite list. This doesn't include specials or rivers. ****************************************************************************/ static int fill_terrain_sprite_layer(struct tileset *t, @@ -5447,13 +5451,13 @@ static int fill_grid_sprite_array(const struct tileset *t, || powner == client.conn.playing) && player_in_city_map(client.conn.playing, tile)); if (city[i]) { - if (citymode) { - /* In citymode, we only draw worked tiles for this city - other - * tiles may be marked as unavailable. */ - worked[i] = (tile_worked(tile) == citymode); - } else { - worked[i] = (NULL != tile_worked(tile)); - } + if (citymode) { + /* In citymode, we only draw worked tiles for this city - other + * tiles may be marked as unavailable. */ + worked[i] = (tile_worked(tile) == citymode); + } else { + worked[i] = (NULL != tile_worked(tile)); + } } } @@ -5461,10 +5465,10 @@ static int fill_grid_sprite_array(const struct tileset *t, || mapdeco_is_highlight_set(pedge->tile[1])) { ADD_SPRITE_SIMPLE(t->sprites.grid.selected[pedge->type]); } else if (!gui_options.draw_terrain && gui_options.draw_coastline - && pedge->tile[0] && pedge->tile[1] - && known[0] && known[1] - && (is_ocean_tile(pedge->tile[0]) - ^ is_ocean_tile(pedge->tile[1]))) { + && pedge->tile[0] && pedge->tile[1] + && known[0] && known[1] + && (is_ocean_tile(pedge->tile[0]) + ^ is_ocean_tile(pedge->tile[1]))) { ADD_SPRITE_SIMPLE(t->sprites.grid.coastline[pedge->type]); } else { if (gui_options.draw_map_grid) { @@ -5510,7 +5514,7 @@ static int fill_grid_sprite_array(const struct tileset *t, int cx, cy; if (citymode - /* test to ensure valid coordinates? */ + /* Test to ensure valid coordinates? */ && city_base_to_city_map(&cx, &cy, citymode, ptile) && !client_city_can_work_tile(citymode, ptile)) { ADD_SPRITE_SIMPLE(t->sprites.grid.unavailable); @@ -5608,7 +5612,7 @@ static int fill_goto_sprite_array(const struct tileset *t, } /************************************************************************//** - Should the given extra be drawn + Should the given extra be drawn? FIXME: Some extras can not be switched ****************************************************************************/ static bool is_extra_drawing_enabled(struct extra_type *pextra) @@ -5665,17 +5669,17 @@ static bool is_extra_drawing_enabled(struct extra_type *pextra) /************************************************************************//** Fill in the sprite array for the given tile, city, and unit. - ptile, if specified, gives the tile. If specified the terrain and specials - will be drawn for this tile. In this case (map_x,map_y) should give the + ptile, if specified, gives the tile. If specified the terrain and specials + will be drawn for this tile. In this case (map_x,map_y) should give the location of the tile. - punit, if specified, gives the unit. For tile drawing this should + punit, if specified, gives the unit. For tile drawing this should generally be get_drawable_unit(); otherwise it can be any unit. - pcity, if specified, gives the city. For tile drawing this should + pcity, if specified, gives the city. For tile drawing this should generally be tile_city(ptile); otherwise it can be any city. - citymode specifies whether this is part of a citydlg. If so some drawing + citymode specifies whether this is part of a citydlg. If so some drawing is done differently. ****************************************************************************/ int fill_sprite_array(struct tileset *t, @@ -5697,12 +5701,12 @@ int fill_sprite_array(struct tileset *t, /* Unit drawing is disabled when the view options are turned off, * but only where we're drawing on the mapview. */ bool do_draw_unit = (punit && (gui_options.draw_units || !ptile - || (gui_options.draw_focus_unit - && unit_is_in_focus(punit)))); + || (gui_options.draw_focus_unit + && unit_is_in_focus(punit)))); bool solid_bg = (gui_options.solid_color_behind_units - && (do_draw_unit - || (pcity && gui_options.draw_cities) - || (ptile && !gui_options.draw_terrain))); + && (do_draw_unit + || (pcity && gui_options.draw_cities) + || (ptile && !gui_options.draw_terrain))); if (citymode) { int count = 0, i, cx, cy; @@ -5722,8 +5726,8 @@ int fill_sprite_array(struct tileset *t, for (i = 0; i < count; i++) { if (tiles[i] && city_base_to_city_map(&cx, &cy, citymode, tiles[i])) { - valid = TRUE; - break; + valid = TRUE; + break; } } if (!valid) { @@ -5756,9 +5760,9 @@ int fill_sprite_array(struct tileset *t, /* Set up background color. */ if (gui_options.solid_color_behind_units) { if (do_draw_unit) { - owner = unit_owner(punit); + owner = unit_owner(punit); } else if (pcity && gui_options.draw_cities) { - owner = city_owner(pcity); + owner = city_owner(pcity); } } if (owner) { @@ -5797,7 +5801,7 @@ int fill_sprite_array(struct tileset *t, if (NULL != pterrain) { if (gui_options.draw_terrain && !solid_bg && terrain_type_terrain_class(pterrain) == TC_OCEAN) { - for (dir = 0; dir < t->num_cardinal_tileset_dirs; dir++) { + for (dir = 0; dir < t->num_cardinal_tileset_dirs; dir++) { int didx = t->cardinal_tileset_dirs[dir]; extra_type_list_iterate(t->style_lists[ESTYLE_RIVER], priver) { @@ -5807,11 +5811,11 @@ int fill_sprite_array(struct tileset *t, ADD_SPRITE_SIMPLE(t->sprites.extras[idx].u.road.ru.rivers.outlet[dir]); } } extra_type_list_iterate_end; - } + } } sprs += fill_irrigation_sprite_array(t, sprs, textras, textras_near, - pcity); + pcity); if (gui_options.draw_terrain && !solid_bg) { extra_type_list_iterate(t->style_lists[ESTYLE_RIVER], priver) { @@ -5919,23 +5923,23 @@ int fill_sprite_array(struct tileset *t, case LAYER_GRID1: if (t->type == TS_ISOMETRIC) { sprs += fill_grid_sprite_array(t, sprs, ptile, pedge, pcorner, - punit, pcity, citymode); + punit, pcity, citymode); } break; case LAYER_CITY1: - /* City. Some city sprites are drawn later. */ + /* City. Some city sprites are drawn later. */ if (pcity && gui_options.draw_cities) { if (!gui_options.draw_full_citybar && !gui_options.solid_color_behind_units) { - ADD_SPRITE(get_city_flag_sprite(t, pcity), TRUE, - FULL_TILE_X_OFFSET + t->city_flag_offset_x, - FULL_TILE_Y_OFFSET + t->city_flag_offset_y); + ADD_SPRITE(get_city_flag_sprite(t, pcity), TRUE, + FULL_TILE_X_OFFSET + t->city_flag_offset_x, + FULL_TILE_Y_OFFSET + t->city_flag_offset_y); } /* For iso-view the city.wall graphics include the full city, whereas * for non-iso view they are an overlay on top of the base city * graphic. */ if (t->type == TS_OVERHEAD || pcity->client.walls <= 0) { - ADD_SPRITE(get_city_sprite(t->sprites.city.tile, pcity), TRUE, + ADD_SPRITE(get_city_sprite(t->sprites.city.tile, pcity), TRUE, FULL_TILE_X_OFFSET + t->city_offset_x, FULL_TILE_Y_OFFSET + t->city_offset_y); } @@ -5960,7 +5964,7 @@ int fill_sprite_array(struct tileset *t, } } if (!gui_options.draw_full_citybar && pcity->client.occupied) { - ADD_SPRITE(get_city_sprite(t->sprites.city.occupied, pcity), TRUE, + ADD_SPRITE(get_city_sprite(t->sprites.city.occupied, pcity), TRUE, FULL_TILE_X_OFFSET + t->occupied_offset_x, FULL_TILE_Y_OFFSET + t->occupied_offset_y); } @@ -5983,7 +5987,7 @@ int fill_sprite_array(struct tileset *t, } } if (pcity->client.unhappy) { - ADD_SPRITE_FULL(t->sprites.city.disorder); + ADD_SPRITE_FULL(t->sprites.city.disorder); } } break; @@ -6038,10 +6042,10 @@ int fill_sprite_array(struct tileset *t, bool backdrop = !pcity; if (ptile && unit_is_in_focus(punit) - && t->sprites.unit.select[0]) { - /* Special case for drawing the selection rectangle. The blinking - * unit is handled separately, inside get_drawable_unit(). */ - ADD_SPRITE(t->sprites.unit.select[focus_unit_state], TRUE, + && t->sprites.unit.select[0]) { + /* Special case for drawing the selection rectangle. The blinking + * unit is handled separately, inside get_drawable_unit(). */ + ADD_SPRITE(t->sprites.unit.select[focus_unit_state], TRUE, t->select_offset_x, t->select_offset_y); } @@ -6139,7 +6143,7 @@ int fill_sprite_array(struct tileset *t, break; case LAYER_CITY2: - /* City size. Drawing this under fog makes it hard to read. */ + /* City size. Drawing this under fog makes it hard to read. */ if (pcity && gui_options.draw_cities && !gui_options.draw_full_citybar) { bool warn = FALSE; unsigned int size = city_size_get(pcity); @@ -6186,7 +6190,7 @@ int fill_sprite_array(struct tileset *t, case LAYER_GRID2: if (t->type == TS_OVERHEAD) { sprs += fill_grid_sprite_array(t, sprs, ptile, pedge, pcorner, - punit, pcity, citymode); + punit, pcity, citymode); } break; @@ -6199,7 +6203,7 @@ int fill_sprite_array(struct tileset *t, case LAYER_CITYBAR: case LAYER_TILELABEL: - /* Nothing. This is just a placeholder. */ + /* Nothing. This is just a placeholder. */ break; case LAYER_GOTO: @@ -6389,7 +6393,7 @@ double get_focus_unit_toggle_timeout(const struct tileset *t) } /************************************************************************//** - Reset the focus unit state. This should be called when changing + Reset the focus unit state. This should be called when changing focus units. ****************************************************************************/ void reset_focus_unit_state(struct tileset *t) @@ -6408,7 +6412,7 @@ void focus_unit_in_combat(struct tileset *t) } /************************************************************************//** - Toggle/increment the focus unit state. This should be called once + Toggle/increment the focus unit state. This should be called once every get_focus_unit_toggle_timeout() seconds. ****************************************************************************/ void toggle_focus_unit_state(struct tileset *t) @@ -6576,8 +6580,8 @@ get_citizen_graphic(const struct citizen_set *set, } /************************************************************************//** - Return a sprite for the given citizen. The citizen's type is given, - as well as their index (in the range [0..city_size_get(pcity))). The + Return a sprite for the given citizen. The citizen's type is given, + as well as their index (in the range [0..city_size_get(pcity))). The citizen's city can be used to determine which sprite to use (a NULL value indicates there is no city; i.e., the sprite is just being used as a picture). @@ -6602,7 +6606,7 @@ struct sprite *get_citizen_sprite(const struct tileset *t, } if (graphic == NULL || graphic->count == 0) { - /* fall back to default sprites */ + /* Fall back to default sprites */ graphic = get_citizen_graphic(&t->sprites.default_citizens, type); } @@ -6815,9 +6819,9 @@ const struct editor_sprites *get_editor_sprites(const struct tileset *t) } /************************************************************************//** - Returns a sprite for the given cursor. The "hot" coordinates (the + Returns a sprite for the given cursor. The "hot" coordinates (the active coordinates of the mouse relative to the sprite) are placed int - (*hot_x, *hot_y). + (*hot_x, *hot_y). A cursor can consist of several frames to be used for animation. ****************************************************************************/ struct sprite *get_cursor_sprite(const struct tileset *t, @@ -6830,12 +6834,12 @@ struct sprite *get_cursor_sprite(const struct tileset *t, } /************************************************************************//** - Return a sprite for the given icon. Icons are used by the operating - system/window manager. Usually freeciv has to tell the OS what icon to + Return a sprite for the given icon. Icons are used by the operating + system/window manager. Usually freeciv has to tell the OS what icon to use. Note that this function will return NULL before the sprites are loaded. - The GUI code must be sure to call tileset_load_tiles before setting the + The GUI code must be sure to call tileset_load_tiles() before setting the top-level icon. ****************************************************************************/ struct sprite *get_icon_sprite(const struct tileset *t, enum icon_type icon) @@ -6855,7 +6859,7 @@ struct sprite *get_attention_crosshair_sprite(const struct tileset *t) } /************************************************************************//** - Returns a sprite for the given indicator with the given index. The + Returns a sprite for the given indicator with the given index. The index should be in [0, NUM_TILES_PROGRESS). ****************************************************************************/ struct sprite *get_indicator_sprite(const struct tileset *t, @@ -6909,7 +6913,7 @@ struct sprite *get_unit_upkeep_sprite(const struct tileset *t, } /************************************************************************//** - Return a rectangular sprite containing a fog "color". This can be used + Return a rectangular sprite containing a fog "color". This can be used for drawing fog onto arbitrary areas (like the overview). ****************************************************************************/ struct sprite *get_basic_fog_sprite(const struct tileset *t) @@ -7039,7 +7043,7 @@ int fill_basic_terrain_layer_sprite_array(struct tileset *t, memset(&dummy_tile, 0, sizeof(struct tile)); - + for (i = 0; i < 8; i++) { tterrain_near[i] = pterrain; BV_CLR_ALL(tspecial_near[i]); @@ -7311,7 +7315,7 @@ void tileset_background_init(struct tileset *t) /* Free all data before recreating it. */ tileset_background_free(t); - /* generate background color */ + /* Generate background color */ t->sprites.background.color = create_plr_sprite(ensure_color(game.plr_bg_color)); diff --git a/client/tilespec.h b/client/tilespec.h index 1bb98916b5..d88f145f85 100644 --- a/client/tilespec.h +++ b/client/tilespec.h @@ -29,6 +29,7 @@ extern "C" { #include "city.h" /* enum citizen_category */ #include "fc_types.h" +/* client */ #include "options.h" struct sprite; /* opaque; gui-dep */ @@ -69,25 +70,25 @@ struct resource_type; /* No darkness sprites are drawn. */ #define SPECENUM_VALUE0 DARKNESS_NONE #define SPECENUM_VALUE0NAME "None" -/* 1 sprite that is split into 4 parts and treated as a darkness4. Only +/* 1 sprite that is split into 4 parts and treated as a darkness4. Only * works in iso-view. */ #define SPECENUM_VALUE1 DARKNESS_ISORECT #define SPECENUM_VALUE1NAME "IsoRect" -/* 4 sprites, one per direction. More than one sprite per tile may be +/* 4 sprites, one per direction. More than one sprite per tile may be * drawn. */ #define SPECENUM_VALUE2 DARKNESS_CARD_SINGLE #define SPECENUM_VALUE2NAME "CardinalSingle" -/* 15=2^4-1 sprites. A single sprite is drawn, chosen based on whether +/* 15=2^4-1 sprites. A single sprite is drawn, chosen based on whether * there's darkness in _each_ of the cardinal directions. */ #define SPECENUM_VALUE3 DARKNESS_CARD_FULL #define SPECENUM_VALUE3NAME "CardinalFull" -/* Corner darkness & fog. 3^4 = 81 sprites. */ +/* Corner darkness & fog. 3^4 = 81 sprites. */ #define SPECENUM_VALUE4 DARKNESS_CORNER #define SPECENUM_VALUE4NAME "Corner" #include "specenum_gen.h" -/* An edge is the border between two tiles. This structure represents one - * edge. The tiles are given in the same order as the enumeration name. */ +/* An edge is the border between two tiles. This structure represents one + * edge. The tiles are given in the same order as the enumeration name. */ enum edge_type { EDGE_NS, /* North and south */ EDGE_WE, /* West and east */ @@ -101,22 +102,22 @@ struct tile_edge { const struct tile *tile[NUM_EDGE_TILES]; }; -/* A corner is the endpoint of several edges. At each corner 4 tiles will - * meet (3 in hex view). Tiles are in clockwise order NESW. */ +/* A corner is the endpoint of several edges. At each corner 4 tiles will + * meet (3 in hex view). Tiles are in clockwise order NESW. */ struct tile_corner { #define NUM_CORNER_TILES 4 const struct tile *tile[NUM_CORNER_TILES]; }; struct drawn_sprite { - bool foggable; /* Set to FALSE for sprites that are never fogged. */ + bool foggable; /* Set to FALSE for sprites that are never fogged. */ struct sprite *sprite; - int offset_x, offset_y; /* offset from tile origin */ + int offset_x, offset_y; /* Offset from tile origin */ }; -/* Items on the mapview are drawn in layers. Each entry below represents - * one layer. The names are basically arbitrary and just correspond to - * groups of elements in fill_sprite_array(). Callers of fill_sprite_array +/* Items on the mapview are drawn in layers. Each entry below represents + * one layer. The names are basically arbitrary and just correspond to + * groups of elements in fill_sprite_array(). Callers of fill_sprite_array * must call it once for each layer. */ #define SPECENUM_NAME mapview_layer #define SPECENUM_VALUE0 LAYER_BACKGROUND @@ -173,16 +174,16 @@ struct drawn_sprite { #define TERRAIN_LAYER_COUNT 3 -#define mapview_layer_iterate(layer) \ -{ \ - enum mapview_layer layer; \ +#define mapview_layer_iterate(layer) \ +{ \ + enum mapview_layer layer; \ int layer_index; \ - \ + \ for (layer_index = 0; layer_index < LAYER_COUNT; layer_index++) { \ layer = tileset_get_layer(tileset, layer_index); \ -#define mapview_layer_iterate_end \ - } \ +#define mapview_layer_iterate_end \ + } \ } /* Layer categories can be used to only render part of a tile. */ @@ -234,19 +235,19 @@ void tileset_setup_specialist_type_default_set(struct tileset *t, Specialist_type_id id); void tileset_setup_unit_type(struct tileset *t, struct unit_type *punittype); void tileset_setup_impr_type(struct tileset *t, - struct impr_type *pimprove); + struct impr_type *pimprove); void tileset_setup_tech_type(struct tileset *t, - struct advance *padvance); + struct advance *padvance); void tileset_setup_tile_type(struct tileset *t, - const struct terrain *pterrain); + const struct terrain *pterrain); void tileset_setup_resource(struct tileset *t, - const struct resource_type *presource); + const struct resource_type *presource); void tileset_setup_extra(struct tileset *t, struct extra_type *pextra); void tileset_setup_government(struct tileset *t, - struct government *gov); -void tileset_setup_nation_flag(struct tileset *t, - struct nation_type *nation); + struct government *gov); +void tileset_setup_nation_flag(struct tileset *t, + struct nation_type *nation); void tileset_setup_city_tiles(struct tileset *t, int style); void tileset_player_init(struct tileset *t, struct player *pplayer); @@ -262,11 +263,11 @@ bool tileset_layer_in_category(enum mapview_layer layer, /* Gfx support */ int fill_sprite_array(struct tileset *t, - struct drawn_sprite *sprs, enum mapview_layer layer, - const struct tile *ptile, - const struct tile_edge *pedge, - const struct tile_corner *pcorner, - const struct unit *punit, const struct city *pcity, + struct drawn_sprite *sprs, enum mapview_layer layer, + const struct tile *ptile, + const struct tile_edge *pedge, + const struct tile_corner *pcorner, + const struct unit *punit, const struct city *pcity, const struct city *citymode, const struct unit_type *putype); int fill_basic_terrain_layer_sprite_array(struct tileset *t, @@ -279,8 +280,8 @@ void reset_focus_unit_state(struct tileset *t); void focus_unit_in_combat(struct tileset *t); void toggle_focus_unit_state(struct tileset *t); struct unit *get_drawable_unit(const struct tileset *t, - struct tile *ptile, - const struct city *citymode); + struct tile *ptile, + const struct city *citymode); bool unit_drawn_with_city_outline(const struct unit *punit, bool check_focus); @@ -358,15 +359,15 @@ struct editor_sprites { #define NUM_WALL_TYPES 7 struct sprite *get_spaceship_sprite(const struct tileset *t, - enum spaceship_part part); + enum spaceship_part part); struct sprite *get_citizen_sprite(const struct tileset *t, - enum citizen_category type, - int citizen_index, - const struct city *pcity); + enum citizen_category type, + int citizen_index, + const struct city *pcity); struct sprite *get_city_flag_sprite(const struct tileset *t, - const struct city *pcity); + const struct city *pcity); struct sprite *get_nation_flag_sprite(const struct tileset *t, - const struct nation_type *nation); + const struct nation_type *nation); struct sprite *get_nation_shield_sprite(const struct tileset *t, const struct nation_type *nation); struct sprite *get_tech_sprite(const struct tileset *t, Tech_type_id tech); @@ -381,29 +382,29 @@ struct sprite *get_unittype_sprite(const struct tileset *t, struct sprite *get_sample_city_sprite(const struct tileset *t, int style_idx); struct sprite *get_arrow_sprite(const struct tileset *t, - enum arrow_type arrow); + enum arrow_type arrow); struct sprite *get_tax_sprite(const struct tileset *t, Output_type_id otype); struct sprite *get_treaty_thumb_sprite(const struct tileset *t, bool on_off); const struct sprite_vector *get_unit_explode_animation(const struct - tileset *t); + tileset *t); struct sprite *get_nuke_explode_sprite(const struct tileset *t); struct sprite *get_cursor_sprite(const struct tileset *t, - enum cursor_type cursor, - int *hot_x, int *hot_y, int frame); + enum cursor_type cursor, + int *hot_x, int *hot_y, int frame); const struct citybar_sprites *get_citybar_sprites(const struct tileset *t); const struct editor_sprites *get_editor_sprites(const struct tileset *t); struct sprite *get_icon_sprite(const struct tileset *t, enum icon_type icon); struct sprite *get_attention_crosshair_sprite(const struct tileset *t); struct sprite *get_indicator_sprite(const struct tileset *t, - enum indicator_type indicator, - int index); + enum indicator_type indicator, + int index); struct sprite *get_unit_unhappy_sprite(const struct tileset *t, - const struct unit *punit, - int happy_cost); + const struct unit *punit, + int happy_cost); struct sprite *get_unit_upkeep_sprite(const struct tileset *t, - Output_type_id otype, - const struct unit *punit, - const int *upkeep_cost); + Output_type_id otype, + const struct unit *punit, + const int *upkeep_cost); struct sprite *get_basic_fog_sprite(const struct tileset *t); int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, @@ -463,4 +464,4 @@ int tileset_topo_index(struct tileset *t); } #endif /* __cplusplus */ -#endif /* FC__TILESPEC_H */ +#endif /* FC__TILESPEC_H */ -- 2.39.0