From 70d246065b37a36984a83751b16f2b5f54905265 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 5 Jul 2022 22:51:32 +0300 Subject: [PATCH 55/55] Add svgflag.[ch] module See osdn #45024 Signed-off-by: Marko Lindqvist --- client/Makefile.am | 6 +- client/client_main.c | 2 + client/gui-qt/gui_main.cpp | 9 +++ client/mapview_common.c | 12 ++-- client/svgflag.c | 134 +++++++++++++++++++++++++++++++++++++ client/svgflag.h | 46 +++++++++++++ client/tilespec.c | 116 ++++++++++++++++++-------------- meson.build | 1 + 8 files changed, 267 insertions(+), 59 deletions(-) create mode 100644 client/svgflag.c create mode 100644 client/svgflag.h diff --git a/client/Makefile.am b/client/Makefile.am index e2aea7d50c..a72f0583d6 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -136,8 +136,10 @@ freeciv_client_src = $(AUDIO_SDL_FILES) \ repodlgs_common.h \ reqtree.c \ reqtree.h \ - servers.c \ - servers.h \ + servers.c \ + servers.h \ + svgflag.c \ + svgflag.h \ text.c \ text.h \ themes_common.c \ diff --git a/client/client_main.c b/client/client_main.c index 3a03af5271..a29443621d 100644 --- a/client/client_main.c +++ b/client/client_main.c @@ -94,6 +94,7 @@ #include "options.h" #include "overview_common.h" #include "packhand.h" +#include "svgflag.h" #include "tilespec.h" #include "themes_common.h" #include "update_queue.h" @@ -727,6 +728,7 @@ void fc__noreturn client_exit(int return_value) conn_list_destroy(game.all_connections); conn_list_destroy(game.est_connections); + free_svg_flag_API(); registry_module_close(); free_libfreeciv(); free_nls(); diff --git a/client/gui-qt/gui_main.cpp b/client/gui-qt/gui_main.cpp index f640699ab4..4aa5e01d00 100644 --- a/client/gui-qt/gui_main.cpp +++ b/client/gui-qt/gui_main.cpp @@ -45,6 +45,7 @@ #include "editgui_g.h" #include "options.h" #include "sprite.h" +#include "svgflag.h" #include "themes_common.h" #include "tilespec.h" @@ -75,6 +76,9 @@ static void apply_notify_font(struct option *poption); static void apply_sidebar(struct option *poption); static void apply_titlebar(struct option *poption); +// Uncomment to enable svg flags +//#define FC_QT_SVGFLAG + /**********************************************************************//** Return fc_client instance **************************************************************************/ @@ -95,6 +99,11 @@ void qtg_ui_init() int main(int argc, char **argv) { setup_gui_funcs(); + +#ifdef FC_QT_SVGFLAG + svg_flag_enable(); +#endif // FC_QT_SVGFLAG + return client_main(argc, argv); } diff --git a/client/mapview_common.c b/client/mapview_common.c index a795ca2af1..d4b1103788 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -43,6 +43,7 @@ #include "goto.h" #include "citydlg_common.h" #include "overview_common.h" +#include "svgflag.h" #include "tilespec.h" #include "zoom.h" @@ -1848,9 +1849,8 @@ static void show_full_citybar(struct canvas *pcanvas, * COLOR_MAPVIEW_CITYTEXT in get_city_mapview_trade_routes() */ enum color_std trade_routes_color = COLOR_MAPVIEW_CITYTEXT; struct color *owner_color; - struct { - int x, y, w, h; - } name_rect = {0, 0, 0, 0}, growth_rect = {0, 0, 0, 0}, + struct area_rect + name_rect = {0, 0, 0, 0}, growth_rect = {0, 0, 0, 0}, prod_rect = {0, 0, 0, 0}, size_rect = {0, 0, 0, 0}, flag_rect = {0, 0, 0, 0}, occupy_rect = {0, 0, 0, 0}, food_rect = {0, 0, 0, 0}, shield_rect = {0, 0, 0, 0}, @@ -1917,7 +1917,8 @@ static void show_full_citybar(struct canvas *pcanvas, } } - get_sprite_dimensions(flag, &flag_rect.w, &flag_rect.h); + /* TODO: Configurable "svg_height" (here 44) */ + get_flag_dimensions(flag, &flag_rect, 44); flag_rect.w *= map_zoom; flag_rect.h *= map_zoom; get_sprite_dimensions(occupy, &occupy_rect.w, &occupy_rect.h); occupy_rect.w *= map_zoom; occupy_rect.h *= map_zoom; @@ -2038,8 +2039,9 @@ static void show_full_citybar(struct canvas *pcanvas, owner_color = get_player_color(tileset, city_owner(pcity)); if (gui_options.draw_city_names) { - canvas_put_sprite_full(pcanvas, + canvas_put_flag_sprite(pcanvas, flag_rect.x / map_zoom, flag_rect.y / map_zoom, + flag_rect.w / map_zoom, flag_rect.h / map_zoom, flag); /* XXX: canvas_put_line() doesn't currently take map_zoom into account. * Should it? diff --git a/client/svgflag.c b/client/svgflag.c new file mode 100644 index 0000000000..4f8593e2c7 --- /dev/null +++ b/client/svgflag.c @@ -0,0 +1,134 @@ +/*********************************************************************** + Freeciv - Copyright (C) 2005 - The Freeciv Team + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* utility */ +#include "mem.h" +#include "support.h" + +/* client */ +#include "canvas_g.h" +#include "sprite_g.h" + +#include "svgflag.h" + + +bool _prefer_svg = FALSE; + +static const char **ordered_extensions = NULL; + +/**********************************************************************//** + Enable svg flag features. +**************************************************************************/ +bool svg_flag_enable(void) +{ + _prefer_svg = TRUE; + + return TRUE; +} + +/**********************************************************************//** + Return gfx file extensions, in adjusted order. +**************************************************************************/ +const char **ordered_gfx_fextensions(void) +{ + const char **incoming; + + if (ordered_extensions != NULL) { + return ordered_extensions; + } + + incoming = gfx_fileextensions(); + + if (is_svg_flag_enabled()) { + int count; + int svg = -1; + int i; + + for (count = 0; incoming[count] != NULL; count++) { + if (!fc_strcasecmp("svg", incoming[count])) { + svg = count; + } + } + + if (svg < 0) { + /* No svg, disable svg flag features */ + _prefer_svg = FALSE; + + ordered_extensions = incoming; + } + + ordered_extensions = fc_malloc((count + 1) * sizeof(char *)); + + /* Put svg first */ + ordered_extensions[0] = incoming[svg]; + + for (i = 0; i < svg; i++) { + ordered_extensions[i + 1] = incoming[i]; + } + for (; i < count; i++) { + ordered_extensions[i] = incoming[i]; + } + + } else { + ordered_extensions = incoming; + } + + return ordered_extensions; +} + +/**********************************************************************//** + Return gfx file extensions, in adjusted order. +**************************************************************************/ +void free_svg_flag_API(void) +{ + if (ordered_extensions != NULL) { + if (is_svg_flag_enabled()) { + free(ordered_extensions); + } + + ordered_extensions = NULL; + } +} + +/**********************************************************************//** + Fill flag dimensions to rect. +**************************************************************************/ +void get_flag_dimensions(struct sprite *flag, struct area_rect *rect, + int svg_height) +{ + get_sprite_dimensions(flag, &(rect->w), &(rect->h)); + + if (is_svg_flag_enabled()) { + rect->h = rect->h * svg_height / rect->w; + rect->w = svg_height; + } +} + +/**********************************************************************//** + Put flag sprite to canvas. +**************************************************************************/ +void canvas_put_flag_sprite(struct canvas *pcanvas, + int canvas_x, int canvas_y, int canvas_w, int canvas_h, + struct sprite *flag) +{ + if (is_svg_flag_enabled()) { + canvas_put_sprite_full_scaled(pcanvas, canvas_x, canvas_y, canvas_w, canvas_h, + flag); + } else { + canvas_put_sprite_full(pcanvas, canvas_x, canvas_y, flag); + } +} diff --git a/client/svgflag.h b/client/svgflag.h new file mode 100644 index 0000000000..3aedf56f06 --- /dev/null +++ b/client/svgflag.h @@ -0,0 +1,46 @@ +/*********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ +#ifndef FC__SVGFLAG_H +#define FC__SVGFLAG_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +struct canvas; + +struct area_rect +{ + int x, y, w, h; +}; + +extern bool _prefer_svg; + +bool svg_flag_enable(void); +#define is_svg_flag_enabled() _prefer_svg + +const char **ordered_gfx_fextensions(void); + +void free_svg_flag_API(void); + +void get_flag_dimensions(struct sprite *flag, struct area_rect *rect, + int svg_height); +void canvas_put_flag_sprite(struct canvas *pcanvas, + int canvas_x, int canvas_y, int canvas_w, int canvas_h, + struct sprite *flag); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* FC__SVGFLAG_H */ diff --git a/client/tilespec.c b/client/tilespec.c index 20135e3790..4477240c64 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -72,6 +72,7 @@ #include "goto.h" #include "helpdata.h" #include "options.h" /* for fill_xxx */ +#include "svgflag.h" #include "themes_common.h" #include "tilespec.h" @@ -1522,11 +1523,17 @@ void tilespec_reread_frozen_refresh(const char *tname) Loads the given graphics file (found in the data path) into a newly allocated sprite. ****************************************************************************/ -static struct sprite *load_gfx_file(const char *gfx_filename) +static struct sprite *load_gfx_file(const char *gfx_filename, bool flag) { - const char **gfx_fileexts = gfx_fileextensions(), *gfx_fileext; + const char **gfx_fileexts, *gfx_fileext; struct sprite *s; + if (flag) { + gfx_fileexts = ordered_gfx_fextensions(); + } else { + gfx_fileexts = gfx_fileextensions(); + } + /* Try out all supported file extensions to find one that works. */ while ((gfx_fileext = *gfx_fileexts++)) { const char *real_full_name; @@ -1568,13 +1575,13 @@ static void ensure_big_sprite(struct specfile *sf) } if (!check_tilespec_capabilities(file, "spec", - SPEC_CAPSTR, sf->file_name, TRUE)) { + SPEC_CAPSTR, sf->file_name, TRUE)) { tileset_error(LOG_FATAL, _("Incompatible tileset capabilities")); } gfx_filename = secfile_lookup_str(file, "file.gfx"); - sf->big_sprite = load_gfx_file(gfx_filename); + sf->big_sprite = load_gfx_file(gfx_filename, FALSE); if (!sf->big_sprite) { tileset_error(LOG_FATAL, _("Could not load gfx file for the spec file \"%s\"."), @@ -2603,7 +2610,7 @@ static char *valid_index_str(const struct tileset *t, int idx) other scaling algorithm than nearest neighbor. ****************************************************************************/ static struct sprite *load_sprite(struct tileset *t, const char *tag_name, - bool scale, bool smooth) + bool scale, bool smooth, bool flag) { struct small_sprite *ss; float sprite_scale = 1.0f; @@ -2624,13 +2631,13 @@ static struct sprite *load_sprite(struct tileset *t, const char *tag_name, struct sprite *s; if (scale) { - s = load_gfx_file(ss->file); + s = load_gfx_file(ss->file, flag); get_sprite_dimensions(s, &w, &h); ss->sprite = crop_sprite(s, 0, 0, w, h, NULL, -1, -1, t->scale, smooth); free_sprite(s); } else { - ss->sprite = load_gfx_file(ss->file); + ss->sprite = load_gfx_file(ss->file, flag); } if (!ss->sprite) { tileset_error(LOG_FATAL, _("Couldn't load gfx file \"%s\" for sprite '%s'."), @@ -2718,7 +2725,7 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) /* Not very safe, but convenient: */ #define SET_SPRITE(field, tag) \ do { \ - t->sprites.field = load_sprite(t, tag, TRUE, TRUE); \ + 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); \ } \ @@ -2727,7 +2734,7 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) #define SET_SPRITE_NOTSMOOTH(field, tag) \ do { \ - t->sprites.field = load_sprite(t, tag, TRUE, FALSE); \ + 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); \ } \ @@ -2735,7 +2742,7 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) #define SET_SPRITE_UNSCALED(field, tag) \ do { \ - t->sprites.field = load_sprite(t, tag, FALSE, FALSE); \ + t->sprites.field = load_sprite(t, tag, FALSE, FALSE, FALSE); \ if (t->sprites.field == NULL) { \ tileset_error(LOG_FATAL, _("Sprite for tag '%s' missing."), tag); \ } \ @@ -2744,9 +2751,9 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) /* Sets sprites.field to tag or (if tag isn't available) to alt */ #define SET_SPRITE_ALT(field, tag, alt) \ do { \ - t->sprites.field = load_sprite(t, tag, TRUE, TRUE); \ + t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE); \ if (!t->sprites.field) { \ - t->sprites.field = load_sprite(t, alt, TRUE, TRUE); \ + 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 " \ @@ -2756,7 +2763,7 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) /* Sets sprites.field to tag, or NULL if not available */ #define SET_SPRITE_OPT(field, tag) \ - t->sprites.field = load_sprite(t, tag, TRUE, TRUE) + t->sprites.field = load_sprite(t, tag, TRUE, TRUE, FALSE) #define SET_SPRITE_ALT_OPT(field, tag, alt) \ do { \ @@ -2798,7 +2805,8 @@ static void tileset_setup_specialist_type(struct tileset *t, } else { fc_snprintf(buffer, sizeof(buffer), "%s_%d", tag, j); } - set->specialist[id].sprite[j] = load_sprite(t, buffer, FALSE, FALSE); + set->specialist[id].sprite[j] = load_sprite(t, buffer, + FALSE, FALSE, FALSE); /* Break if no more index specific sprites are defined */ if (!set->specialist[id].sprite[j]) { @@ -2808,7 +2816,8 @@ static void tileset_setup_specialist_type(struct tileset *t, if (j == 0) { /* Try non-indexed */ - set->specialist[id].sprite[j] = load_sprite(t, tag, FALSE, FALSE); + set->specialist[id].sprite[j] = load_sprite(t, tag, + FALSE, FALSE, FALSE); if (set->specialist[id].sprite[j]) { j = 1; @@ -2824,7 +2833,8 @@ static void tileset_setup_specialist_type(struct tileset *t, } else { fc_snprintf(buffer, sizeof(buffer), "%s_%d", graphic_alt, j); } - set->specialist[id].sprite[j] = load_sprite(t, buffer, FALSE, FALSE); + set->specialist[id].sprite[j] = load_sprite(t, buffer, + FALSE, FALSE, FALSE); /* Break if no more index specific sprites are defined */ if (!set->specialist[id].sprite[j]) { @@ -2835,7 +2845,8 @@ static void tileset_setup_specialist_type(struct tileset *t, if (j == 0) { /* Try alt tag non-indexed */ - set->specialist[id].sprite[j] = load_sprite(t, graphic_alt, FALSE, FALSE); + set->specialist[id].sprite[j] = load_sprite(t, graphic_alt, + FALSE, FALSE, FALSE); if (set->specialist[id].sprite[j]) { j = 1; @@ -2882,7 +2893,7 @@ static void tileset_setup_citizen_types(struct tileset *t, } else { fc_snprintf(buffer, sizeof(buffer), "citizen.%s_%d", name, j); } - set->citizen[i].sprite[j] = load_sprite(t, buffer, FALSE, FALSE); + set->citizen[i].sprite[j] = load_sprite(t, buffer, FALSE, FALSE, FALSE); if (!set->citizen[i].sprite[j]) { break; } @@ -2952,7 +2963,7 @@ static int load_city_thresholds_sprites(struct tileset *t, const char *tag, for (size = 0; size < MAX_CITY_SIZE; size++) { fc_snprintf(buffer, sizeof(buffer), "%s_%s_%d", gfx_in_use, tag, size); - if ((sprite = load_sprite(t, buffer, TRUE, TRUE))) { + if ((sprite = load_sprite(t, buffer, TRUE, TRUE, FALSE))) { num_thresholds++; *thresholds = fc_realloc(*thresholds, num_thresholds * sizeof(**thresholds)); (*thresholds)[num_thresholds - 1].sprite = sprite; @@ -3113,7 +3124,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) struct sprite *sprite; fc_snprintf(buffer, sizeof(buffer), "explode.unit_%d", i); - sprite = load_sprite(t, buffer, TRUE, TRUE); + sprite = load_sprite(t, buffer, TRUE, TRUE, FALSE); if (!sprite) { break; } @@ -3159,7 +3170,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) /* Veteran level sprites are optional. For instance "green" units * usually have no special graphic. */ fc_snprintf(buffer, sizeof(buffer), "unit.vet_%d", i); - t->sprites.unit.vet_lev[i] = load_sprite(t, buffer, TRUE, TRUE); + t->sprites.unit.vet_lev[i] = load_sprite(t, buffer, TRUE, TRUE, FALSE); } t->sprites.unit.select[0] = NULL; @@ -3180,7 +3191,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) struct sprite *sprite; fc_snprintf(buffer, sizeof(buffer), "citybar.occupancy_%d", i); - sprite = load_sprite(t, buffer, TRUE, TRUE); + sprite = load_sprite(t, buffer, TRUE, TRUE, FALSE); if (!sprite) { break; } @@ -3302,7 +3313,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) struct sprite *sprite; fc_snprintf(buffer, sizeof(buffer), "colors.overlay_%d", i); - sprite = load_sprite(t, buffer, TRUE, TRUE); + sprite = load_sprite(t, buffer, TRUE, TRUE, FALSE); if (!sprite) { break; } @@ -3377,7 +3388,8 @@ static void tileset_lookup_sprite_tags(struct tileset *t) case DARKNESS_ISORECT: { /* Isometric: take a single tx.darkness tile and split it into 4. */ - struct sprite *darkness = load_sprite(t, "tx.darkness", TRUE, FALSE); + struct sprite *darkness = load_sprite(t, "tx.darkness", + TRUE, FALSE, FALSE); const int ntw = t->normal_tile_width, nth = t->normal_tile_height; int offsets[4][2] = {{ntw / 2, 0}, {0, nth / 2}, {ntw / 2, nth / 2}, {0, 0}}; @@ -3425,7 +3437,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) } fc_assert(k == 0); - t->sprites.tx.fullfog[i] = load_sprite(t, buf, TRUE, FALSE); + t->sprites.tx.fullfog[i] = load_sprite(t, buf, TRUE, FALSE, FALSE); } break; }; @@ -3447,7 +3459,7 @@ static bool load_river_sprites(struct tileset *t, for (i = 0; i < t->num_index_cardinal; i++) { fc_snprintf(buffer, sizeof(buffer), "%s_s_%s", tag_pfx, cardinal_index_str(t, i)); - store->spec[i] = load_sprite(t, buffer, TRUE, TRUE); + store->spec[i] = load_sprite(t, buffer, TRUE, TRUE, FALSE); if (store->spec[i] == NULL) { return FALSE; } @@ -3456,7 +3468,7 @@ static bool load_river_sprites(struct tileset *t, for (i = 0; i < t->num_cardinal_tileset_dirs; i++) { fc_snprintf(buffer, sizeof(buffer), "%s_outlet_%s", tag_pfx, dir_get_tileset_name(t->cardinal_tileset_dirs[i])); - store->outlet[i] = load_sprite(t, buffer, TRUE, TRUE); + store->outlet[i] = load_sprite(t, buffer, TRUE, TRUE, FALSE); if (store->outlet[i] == NULL) { log_error("Missing \"%s\" for \"%s\".", buffer, tag_pfx); return FALSE; @@ -3467,9 +3479,9 @@ static bool load_river_sprites(struct tileset *t, } /************************************************************************//** - Frees any internal buffers which are created by load_sprite. Should - be called after the last (for a given period of time) load_sprite - call. This saves a fair amount of memory, but it will take extra time + Frees any internal buffers which are created by load_sprite(). Should + be called after the last (for a given period of time) load_sprite() + call. This saves a fair amount of memory, but it will take extra time the next time we start loading sprites again. ****************************************************************************/ void finish_loading_sprites(struct tileset *t) @@ -3512,10 +3524,10 @@ struct sprite *tiles_lookup_sprite_tag_alt(struct tileset *t, "attempt to lookup for %s \"%s\" before " "sprite_hash setup", what, name); - sp = load_sprite(t, tag, scale, TRUE); + sp = load_sprite(t, tag, scale, TRUE, FALSE); if (sp) return sp; - sp = load_sprite(t, alt, scale, TRUE); + sp = load_sprite(t, alt, scale, TRUE, FALSE); if (sp) { log_verbose("Using alternate graphic \"%s\" " "(instead of \"%s\") for %s \"%s\".", @@ -3567,7 +3579,8 @@ static bool tileset_setup_unit_direction(struct tileset *t, /* We don't use _alt graphics here, as that could lead to loading * real icon gfx, but alternative orientation gfx. Tileset author * probably meant icon gfx to be used as fallback for all orientations */ - t->sprites.units.facing[uidx][dir] = load_sprite(t, buf, TRUE, TRUE); + t->sprites.units.facing[uidx][dir] = load_sprite(t, buf, + TRUE, TRUE, FALSE); if (t->sprites.units.facing[uidx][dir] != NULL) { return TRUE; @@ -3584,7 +3597,7 @@ static bool tileset_setup_unit_type_from_tag(struct tileset *t, { bool has_icon, facing_sprites = TRUE; - t->sprites.units.icon[uidx] = load_sprite(t, tag, TRUE, TRUE); + t->sprites.units.icon[uidx] = load_sprite(t, tag, TRUE, TRUE, FALSE); has_icon = t->sprites.units.icon[uidx] != NULL; #define LOAD_FACING_SPRITE(dir) \ @@ -3742,11 +3755,10 @@ void tileset_setup_extra(struct tileset *t, fc_snprintf(buffer, sizeof(buffer), "%s_%s", tag, cardinal_index_str(t, i)); t->sprites.extras[id].u.cardinals[i] = load_sprite(t, buffer, - TRUE, TRUE); + TRUE, TRUE, FALSE); if (!t->sprites.extras[id].u.cardinals[i]) { - t->sprites.extras[id].u.cardinals[i] = load_sprite(t, - tag, TRUE, - TRUE); + t->sprites.extras[id].u.cardinals[i] = load_sprite(t, tag, + TRUE, TRUE, FALSE); } if (!t->sprites.extras[id].u.cardinals[i]) { tileset_error(LOG_FATAL, @@ -3766,14 +3778,14 @@ void tileset_setup_extra(struct tileset *t, t->sprites.extras[id].activity = NULL; } else { t->sprites.extras[id].activity = load_sprite(t, pextra->activity_gfx, - TRUE, TRUE); + TRUE, TRUE, FALSE); if (t->sprites.extras[id].activity == NULL) { t->sprites.extras[id].activity = load_sprite(t, pextra->act_gfx_alt, - TRUE, TRUE); + TRUE, TRUE, FALSE); } if (t->sprites.extras[id].activity == NULL) { t->sprites.extras[id].activity = load_sprite(t, pextra->act_gfx_alt2, - TRUE, TRUE); + TRUE, TRUE, FALSE); } if (t->sprites.extras[id].activity == NULL) { tileset_error(LOG_FATAL, _("Missing %s building activity sprite for tags \"%s\" and alternatives \"%s\" and \"%s\"."), @@ -3785,11 +3797,11 @@ void tileset_setup_extra(struct tileset *t, if (!fc_strcasecmp(pextra->rmact_gfx, "none")) { t->sprites.extras[id].rmact = NULL; } else { - t->sprites.extras[id].rmact = load_sprite(t, pextra->rmact_gfx, TRUE, - TRUE); + t->sprites.extras[id].rmact = load_sprite(t, pextra->rmact_gfx, + TRUE, TRUE, FALSE); if (t->sprites.extras[id].rmact == NULL) { t->sprites.extras[id].rmact = load_sprite(t, pextra->rmact_gfx_alt, - TRUE, TRUE); + TRUE, TRUE, FALSE); if (t->sprites.extras[id].rmact == NULL) { tileset_error(LOG_FATAL, _("Missing %s removal activity sprite for tags \"%s\" and alternative \"%s\"."), extra_rule_name(pextra), pextra->rmact_gfx, pextra->rmact_gfx_alt); @@ -3922,17 +3934,17 @@ static void tileset_setup_base(struct tileset *t, sz_strlcpy(full_tag_name, tag); strcat(full_tag_name, "_bg"); t->sprites.extras[id].u.bmf.background = load_sprite(t, full_tag_name, - TRUE, TRUE); + TRUE, TRUE, FALSE); sz_strlcpy(full_tag_name, tag); strcat(full_tag_name, "_mg"); t->sprites.extras[id].u.bmf.middleground = load_sprite(t, full_tag_name, - TRUE, TRUE); + TRUE, TRUE, FALSE); sz_strlcpy(full_tag_name, tag); strcat(full_tag_name, "_fg"); t->sprites.extras[id].u.bmf.foreground = load_sprite(t, full_tag_name, - TRUE, TRUE); + TRUE, TRUE, FALSE); if (t->sprites.extras[id].u.bmf.background == NULL && t->sprites.extras[id].u.bmf.middleground == NULL @@ -3983,7 +3995,7 @@ void tileset_setup_tile_type(struct tileset *t, 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); + sprite = load_sprite(t, buffer, TRUE, FALSE, FALSE); if (!sprite) { break; } @@ -4121,7 +4133,7 @@ void tileset_setup_tile_type(struct tileset *t, "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); + sprite = load_sprite(t, buffer, TRUE, FALSE, FALSE); if (sprite) { /* Crop the sprite to separate this cell. */ @@ -4238,11 +4250,11 @@ void tileset_setup_nation_flag(struct tileset *t, for (i = 0; tags[i] && !flag; i++) { fc_snprintf(buf, sizeof(buf), "f.%s", tags[i]); - flag = load_sprite(t, buf, TRUE, TRUE); + flag = load_sprite(t, buf, TRUE, TRUE, TRUE); } for (i = 0; tags[i] && !shield; i++) { fc_snprintf(buf, sizeof(buf), "f.shield.%s", tags[i]); - shield = load_sprite(t, buf, TRUE, TRUE); + shield = load_sprite(t, buf, TRUE, TRUE, TRUE); } if (!flag || !shield) { /* Should never get here because of the f.unknown fallback. */ @@ -5270,7 +5282,7 @@ static int fill_terrain_sprite_layer(struct tileset *t, /* FIXME: this should avoid calling load_sprite since it's slow and * increases the refcount without limit. */ if (ptile->spec_sprite && (sprite = load_sprite(t, ptile->spec_sprite, - TRUE, FALSE))) { + TRUE, FALSE, FALSE))) { if (l == 0) { ADD_SPRITE_SIMPLE(sprite); return 1; diff --git a/meson.build b/meson.build index 35842c3756..f6905ab79a 100644 --- a/meson.build +++ b/meson.build @@ -1564,6 +1564,7 @@ client_common = static_library('fc_client_common', 'client/repodlgs_common.c', 'client/reqtree.c', 'client/servers.c', + 'client/svgflag.c', 'client/text.c', 'client/themes_common.c', 'client/tilespec.c', -- 2.35.1