From 0d1177a541942f980a762488beaacf4ce7a09e22 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 4 Feb 2023 07:37:48 +0200 Subject: [PATCH 15/15] Add tileset name to Tileset Error dialog Reported by VulcanScout See osdn #46558 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/dialogs.c | 18 +++- client/gui-gtk-2.0/tileset_dlg.c | 4 +- client/gui-gtk-3.0/dialogs.c | 20 +++-- client/gui-gtk-3.0/tileset_dlg.c | 4 +- client/gui-gtk-3.22/dialogs.c | 20 +++-- client/gui-gtk-3.22/tileset_dlg.c | 4 +- client/gui-qt/dialogs.cpp | 18 ++-- client/gui-sdl2/dialogs.c | 2 +- client/gui-stub/dialogs.c | 2 +- client/include/dialogs_g.h | 6 +- client/packhand.c | 3 +- client/tilespec.c | 135 +++++++++++++++++++----------- client/tilespec.h | 3 +- 13 files changed, 156 insertions(+), 83 deletions(-) diff --git a/client/gui-gtk-2.0/dialogs.c b/client/gui-gtk-2.0/dialogs.c index b9af8688d1..5172ba6c8d 100644 --- a/client/gui-gtk-2.0/dialogs.c +++ b/client/gui-gtk-2.0/dialogs.c @@ -1516,15 +1516,25 @@ void show_tech_gained_dialog(Tech_type_id tech) Show tileset error dialog. It's blocking as client will shutdown as soon as this function returns. *****************************************************************/ -void show_tileset_error(const char *msg) +void show_tileset_error(const char *tset_name, const char *msg) { if (is_gui_up()) { GtkWidget *dialog; - dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Tileset problem, it's probably incompatible with the ruleset:\n%s"), + if (tset_name != NULL) { + dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Tileset \"%s\" problem, " + "it's probably incompatible with the ruleset:\n%s"), + tset_name, msg); + } else { + dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Tileset problem, " + "it's probably incompatible with the ruleset:\n%s"), msg); + } + setup_dialog(dialog, toplevel); gtk_dialog_run(GTK_DIALOG(dialog)); diff --git a/client/gui-gtk-2.0/tileset_dlg.c b/client/gui-gtk-2.0/tileset_dlg.c index dcd3ae1e3a..b8c3b8dd90 100644 --- a/client/gui-gtk-2.0/tileset_dlg.c +++ b/client/gui-gtk-2.0/tileset_dlg.c @@ -40,8 +40,8 @@ static void tileset_suggestion_callback(GtkWidget *dlg, gint arg) /* User accepted tileset loading */ sz_strlcpy(forced_tileset_name, game.control.preferred_tileset); if (!tilespec_reread(game.control.preferred_tileset, TRUE, 1.0f)) { - tileset_error(LOG_ERROR, _("Can't load requested tileset %s."), - game.control.preferred_tileset); + tileset_error(LOG_ERROR, game.control.preferred_tileset, + _("Can't load requested tileset.")); } } } diff --git a/client/gui-gtk-3.0/dialogs.c b/client/gui-gtk-3.0/dialogs.c index ef58a7672f..628a0e661d 100644 --- a/client/gui-gtk-3.0/dialogs.c +++ b/client/gui-gtk-3.0/dialogs.c @@ -1527,15 +1527,25 @@ void show_tech_gained_dialog(Tech_type_id tech) Show tileset error dialog. It's blocking as client will shutdown as soon as this function returns. *****************************************************************/ -void show_tileset_error(const char *msg) +void show_tileset_error(const char *tset_name, const char *msg) { if (is_gui_up()) { GtkWidget *dialog; - dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Tileset problem, it's probably incompatible with the ruleset:\n%s"), - msg); + if (tset_name != NULL) { + dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Tileset \"%s\" problem, " + "it's probably incompatible with the ruleset:\n%s"), + tset_name, msg); + } else { + dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Tileset problem, " + "it's probably incompatible with the ruleset:\n%s"), + msg); + } + setup_dialog(dialog, toplevel); gtk_dialog_run(GTK_DIALOG(dialog)); diff --git a/client/gui-gtk-3.0/tileset_dlg.c b/client/gui-gtk-3.0/tileset_dlg.c index 60bdfcf49d..3ef79c8c45 100644 --- a/client/gui-gtk-3.0/tileset_dlg.c +++ b/client/gui-gtk-3.0/tileset_dlg.c @@ -44,8 +44,8 @@ static void tileset_suggestion_callback(GtkWidget *dlg, gint arg) /* User accepted tileset loading */ sz_strlcpy(forced_tileset_name, game.control.preferred_tileset); if (!tilespec_reread(game.control.preferred_tileset, TRUE, 1.0)) { - tileset_error(LOG_ERROR, _("Can't load requested tileset %s."), - game.control.preferred_tileset); + tileset_error(LOG_ERROR, game.control.preferred_tileset, + _("Can't load requested tileset.")); } } } diff --git a/client/gui-gtk-3.22/dialogs.c b/client/gui-gtk-3.22/dialogs.c index 2e8800798d..f270bacf8f 100644 --- a/client/gui-gtk-3.22/dialogs.c +++ b/client/gui-gtk-3.22/dialogs.c @@ -1521,15 +1521,25 @@ void show_tech_gained_dialog(Tech_type_id tech) Show tileset error dialog. It's blocking as client will shutdown as soon as this function returns. *****************************************************************/ -void show_tileset_error(const char *msg) +void show_tileset_error(const char *tset_name, const char *msg) { if (is_gui_up()) { GtkWidget *dialog; - dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Tileset problem, it's probably incompatible with the ruleset:\n%s"), - msg); + if (tset_name != NULL) { + dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Tileset \"%s\" problem, " + "it's probably incompatible with the ruleset:\n%s"), + tset_name, msg); + } else { + dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Tileset problem, " + "it's probably incompatible with the ruleset:\n%s"), + msg); + } + setup_dialog(dialog, toplevel); gtk_dialog_run(GTK_DIALOG(dialog)); diff --git a/client/gui-gtk-3.22/tileset_dlg.c b/client/gui-gtk-3.22/tileset_dlg.c index 9c40bbb76f..3700aa7233 100644 --- a/client/gui-gtk-3.22/tileset_dlg.c +++ b/client/gui-gtk-3.22/tileset_dlg.c @@ -45,8 +45,8 @@ static void tileset_suggestion_callback(GtkWidget *dlg, gint arg) /* User accepted tileset loading */ sz_strlcpy(forced_tileset_name, game.control.preferred_tileset); if (!tilespec_reread(game.control.preferred_tileset, TRUE, 1.0)) { - tileset_error(LOG_ERROR, _("Can't load requested tileset %s."), - game.control.preferred_tileset); + tileset_error(LOG_ERROR, game.control.preferred_tileset, + _("Can't load requested tileset.")); } } } diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp index a6f357d2d1..dd257d1360 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -3149,8 +3149,8 @@ void popup_tileset_suggestion_dialog(void) sz_strlcpy(forced_tileset_name, game.control.preferred_tileset); if (!tilespec_reread(game.control.preferred_tileset, true, gui()->map_scale)) { - tileset_error(LOG_ERROR, _("Can't load requested tileset %s."), - game.control.preferred_tileset); + tileset_error(LOG_ERROR, game.control.preferred_tileset, + _("Can't load requested tileset.")); } } } @@ -3489,13 +3489,19 @@ void show_tech_gained_dialog(Tech_type_id tech) /**************************************************************** Show tileset error dialog. *****************************************************************/ -void show_tileset_error(const char *msg) +void show_tileset_error(const char *tset_name, const char *msg) { char buf[1024]; - fc_snprintf(buf, sizeof(buf), - _("Tileset problem, it's probably incompatible with the" - " ruleset:\n%s"), msg); + if (tset_name != NULL) { + fc_snprintf(buf, sizeof(buf), + _("Tileset \"%s\" problem, it's probably incompatible with the" + " ruleset:\n%s"), tset_name, msg); + } else { + fc_snprintf(buf, sizeof(buf), + _("Tileset problem, it's probably incompatible with the" + " ruleset:\n%s"), msg); + } if (QCoreApplication::instance() != nullptr) { QMessageBox ask(gui()->central_wdg); diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index b189f61552..07a767260b 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -3591,7 +3591,7 @@ void show_tech_gained_dialog(Tech_type_id tech) /**************************************************************** Show tileset error dialog. *****************************************************************/ -void show_tileset_error(const char *msg) +void show_tileset_error(const char *tset_name, const char *msg) { /* PORTME */ } diff --git a/client/gui-stub/dialogs.c b/client/gui-stub/dialogs.c index 48a84550b6..f9ceb10f22 100644 --- a/client/gui-stub/dialogs.c +++ b/client/gui-stub/dialogs.c @@ -314,7 +314,7 @@ void show_tech_gained_dialog(Tech_type_id tech) /**************************************************************** Show tileset error dialog. *****************************************************************/ -void show_tileset_error(const char *msg) +void show_tileset_error(const char *tset_name, const char *msg) { /* PORTME */ } diff --git a/client/include/dialogs_g.h b/client/include/dialogs_g.h index 610860c777..d5145acf7a 100644 --- a/client/include/dialogs_g.h +++ b/client/include/dialogs_g.h @@ -20,8 +20,8 @@ #include "actions.h" #include "fc_types.h" #include "featured_text.h" /* struct text_tag_list */ -#include "nation.h" /* Nation_type_id */ -#include "terrain.h" /* enum tile_special_type */ +#include "nation.h" /* Nation_type_id */ +#include "terrain.h" /* enum tile_special_type */ #include "unitlist.h" /* client */ @@ -79,7 +79,7 @@ GUI_FUNC_PROTO(void, popup_soundset_suggestion_dialog, void) GUI_FUNC_PROTO(void, popup_musicset_suggestion_dialog, void) GUI_FUNC_PROTO(bool, popup_theme_suggestion_dialog, const char *theme_name) GUI_FUNC_PROTO(void, show_tech_gained_dialog, Tech_type_id tech) -GUI_FUNC_PROTO(void, show_tileset_error, const char *msg) +GUI_FUNC_PROTO(void, show_tileset_error, const char *tset_name, const char *msg) GUI_FUNC_PROTO(bool, handmade_scenario_warning, void) GUI_FUNC_PROTO(void, popdown_all_game_dialogs, void) diff --git a/client/packhand.c b/client/packhand.c index eadf4ac0cf..ad2ab80b35 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -2082,7 +2082,8 @@ void handle_map_info(int xsize, int ysize, int topology_id) wld.map.ysize = ysize; if (tileset_map_topo_compatible(topology_id, tileset, &ts_topo) == TOPO_INCOMP_HARD) { - tileset_error(LOG_NORMAL, _("Map topology (%s) and tileset (%s) incompatible."), + tileset_error(LOG_NORMAL, tileset_name_get(tileset), + _("Map topology (%s) and tileset (%s) incompatible."), describe_topology(topology_id), describe_topology(ts_topo)); } diff --git a/client/tilespec.c b/client/tilespec.c index 58f1371ea2..24b1cb96f0 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -579,7 +579,8 @@ static void tileset_player_free(struct tileset *t, int plrid); /**************************************************************************** Called when ever there's problem in ruleset/tileset compatibility ****************************************************************************/ -void tileset_error(enum log_level level, const char *format, ...) +void tileset_error(enum log_level level, const char *tset_name, + const char *format, ...) { char buf[2048]; va_list args; @@ -591,7 +592,7 @@ void tileset_error(enum log_level level, const char *format, ...) log_base(level, "%s", buf); if (level <= LOG_NORMAL) { - show_tileset_error(buf); + show_tileset_error(tset_name, buf); } if (level == LOG_FATAL) { @@ -1260,8 +1261,8 @@ bool tilespec_try_read(const char *tileset_name, bool verbose, int topo_id, } strvec_iterate_end; strvec_destroy(list); - if (!tileset) { - tileset_error(LOG_FATAL, _("No usable default tileset found, aborting!")); + if (tileset == NULL) { + tileset_error(LOG_FATAL, NULL, _("No usable default tileset found, aborting!")); } log_verbose("Trying tileset \"%s\".", tileset->name); @@ -1381,7 +1382,8 @@ bool tilespec_reread(const char *new_tileset_name, if (tileset_map_topo_compatible(wld.map.topology_id, tileset, &ts_topo) == TOPO_INCOMP_HARD) { - tileset_error(LOG_NORMAL,_("Map topology (%s) and tileset (%s) incompatible."), + tileset_error(LOG_NORMAL, tileset_name, + _("Map topology (%s) and tileset (%s) incompatible."), describe_topology(wld.map.topology_id), describe_topology(ts_topo)); } @@ -1514,7 +1516,7 @@ static struct sprite *load_gfx_file(const char *gfx_filename) /************************************************************************** Ensure that the big sprite of the given spec file is loaded. **************************************************************************/ -static void ensure_big_sprite(struct specfile *sf) +static void ensure_big_sprite(struct specfile *sf, const char *tset_name) { struct section_file *file; const char *gfx_filename; @@ -1528,12 +1530,16 @@ static void ensure_big_sprite(struct specfile *sf) * 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))) { - tileset_error(LOG_FATAL, _("Could not open '%s':\n%s"), sf->file_name, secfile_error()); + tileset_error(LOG_FATAL, tset_name, + _("Could not open '%s':\n%s"), sf->file_name, + secfile_error()); } if (!check_tilespec_capabilities(file, "spec", - SPEC_CAPSTR, sf->file_name, TRUE)) { - tileset_error(LOG_FATAL, _("Incompatible tileset capabilities")); + SPEC_CAPSTR, sf->file_name, TRUE)) { + tileset_error(LOG_FATAL, tset_name, + _("Specfile %s has incompatible capabilities"), + sf->file_name); } gfx_filename = secfile_lookup_str(file, "file.gfx"); @@ -1541,7 +1547,8 @@ static void ensure_big_sprite(struct specfile *sf) sf->big_sprite = load_gfx_file(gfx_filename); if (!sf->big_sprite) { - tileset_error(LOG_FATAL, _("Could not load gfx file for the spec file \"%s\"."), + tileset_error(LOG_FATAL, tset_name, + _("Could not load gfx file for the spec file \"%s\"."), sf->file_name); } secfile_destroy(file); @@ -1560,11 +1567,14 @@ static void scan_specfile(struct tileset *t, struct specfile *sf, int i; if (!(file = secfile_load(sf->file_name, TRUE))) { - tileset_error(LOG_FATAL, _("Could not open '%s':\n%s"), sf->file_name, secfile_error()); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Could not open '%s':\n%s"), + sf->file_name, secfile_error()); } if (!check_tilespec_capabilities(file, "spec", - SPEC_CAPSTR, sf->file_name, TRUE)) { - tileset_error(LOG_FATAL, _("Specfile %s has incompatible capabilities"), sf->file_name); + SPEC_CAPSTR, sf->file_name, TRUE)) { + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Specfile %s has incompatible capabilities"), sf->file_name); } /* Currently unused */ @@ -1715,7 +1725,8 @@ static void scan_specfile(struct tileset *t, struct specfile *sf, Returns the correct name of the gfx file (with path and extension) Must be free'd when no longer used ***********************************************************************/ -static char *tilespec_gfx_filename(const char *gfx_filename) +static char *tilespec_gfx_filename(const char *gfx_filename, + const char *tset_name) { const char *gfx_current_fileext; const char **gfx_fileexts = gfx_fileextensions(); @@ -1735,7 +1746,8 @@ static char *tilespec_gfx_filename(const char *gfx_filename) } } - tileset_error(LOG_FATAL, _("Couldn't find a supported gfx file extension for \"%s\"."), + tileset_error(LOG_FATAL, tset_name, + _("Couldn't find a supported gfx file extension for \"%s\"."), gfx_filename); return NULL; @@ -2118,8 +2130,8 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, dir = dir_by_tileset_name(c); if (!direction8_is_valid(dir)) { - tileset_error(LOG_ERROR, "Tileset \"%s\": unknown " - "unit_default_orientation \"%s\"", t->name, c); + tileset_error(LOG_ERROR, tileset_name, + _("Unknown unit_default_orientation \"%s\""), c); goto ON_ERROR; } else { /* Default orientation is allowed to not be a valid one for the @@ -2129,7 +2141,7 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, } c = secfile_lookup_str(file, "tilespec.main_intro_file"); - t->main_intro_filename = tilespec_gfx_filename(c); + t->main_intro_filename = tilespec_gfx_filename(c, tileset_name_get(t)); log_debug("intro file %s", t->main_intro_filename); /* Layer order */ @@ -2199,8 +2211,9 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, for (k = 0; k < j; k++) { if (tslp->match_types[k][0] == tslp->match_types[j][0]) { - tileset_error(LOG_FATAL, _("[layer%d] match_types: \"%s\" initial " - "('%c') is not unique."), + tileset_error(LOG_FATAL, tileset_name, + _("[layer%d] match_types: \"%s\" initial " + "('%c') is not unique."), i, tslp->match_types[j], tslp->match_types[j][0]); /* FIXME: Returns NULL. */ } @@ -2211,8 +2224,9 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, /* Tile drawing info. */ sections = secfile_sections_by_name_prefix(file, TILE_SECTION_PREFIX); if (NULL == sections || 0 == section_list_size(sections)) { - tileset_error(LOG_ERROR, _("No [%s] sections supported by tileset \"%s\"."), - TILE_SECTION_PREFIX, fname); + tileset_error(LOG_ERROR, tileset_name, + _("No [%s] sections supported."), + TILE_SECTION_PREFIX); goto ON_ERROR; } @@ -2589,17 +2603,19 @@ static struct sprite *load_sprite(struct tileset *t, const char *tag_name, ss->sprite = load_gfx_file(ss->file); } if (!ss->sprite) { - tileset_error(LOG_FATAL, _("Couldn't load gfx file \"%s\" for sprite '%s'."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Couldn't load gfx file \"%s\" for sprite '%s'."), ss->file, tag_name); } } else { int sf_w, sf_h; - ensure_big_sprite(ss->sf); + ensure_big_sprite(ss->sf, tileset_name_get(t)); 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) { - tileset_error(LOG_ERROR, _("Sprite '%s' in file \"%s\" isn't within the image!"), + tileset_error(LOG_ERROR, tileset_name_get(t), + _("Sprite '%s' in file \"%s\" isn't within the image!"), tag_name, ss->sf->file_name); return NULL; } @@ -2676,7 +2692,8 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) do { \ t->sprites.field = load_sprite(t, tag, TRUE, TRUE); \ if (t->sprites.field == NULL) { \ - tileset_error(LOG_FATAL, _("Sprite for tag '%s' missing."), tag); \ + tileset_error(LOG_FATAL, tileset_name_get(t), \ + _("Sprite for tag '%s' missing."), tag); \ } \ } while (FALSE) @@ -2685,7 +2702,8 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) do { \ t->sprites.field = load_sprite(t, tag, TRUE, FALSE); \ if (t->sprites.field == NULL) { \ - tileset_error(LOG_FATAL, _("Sprite for tag '%s' missing."), tag); \ + tileset_error(LOG_FATAL, tileset_name_get(t), \ + _("Sprite for tag '%s' missing."), tag); \ } \ } while (FALSE) @@ -2693,7 +2711,8 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) do { \ t->sprites.field = load_sprite(t, tag, FALSE, FALSE); \ if (t->sprites.field == NULL) { \ - tileset_error(LOG_FATAL, _("Sprite for tag '%s' missing."), tag); \ + tileset_error(LOG_FATAL, tileset_name_get(t), \ + _("Sprite for tag '%s' missing."), tag); \ } \ } while (FALSE) @@ -2705,8 +2724,9 @@ static bool sprite_exists(const struct tileset *t, const char *tag_name) t->sprites.field = load_sprite(t, alt, TRUE, TRUE); \ } \ if (t->sprites.field == NULL) { \ - tileset_error(LOG_FATAL, _("Sprite for tags '%s' and alternate '%s' are " \ - "both missing."), tag, alt); \ + tileset_error(LOG_FATAL, tileset_name_get(t), \ + _("Sprite for tags '%s' and alternate '%s' are " \ + "both missing."), tag, alt); \ } \ } while (FALSE) @@ -2783,7 +2803,8 @@ void tileset_setup_specialist_type(struct tileset *t, Specialist_type_id id) /* Still nothing? Give up. */ if (j == 0) { - tileset_error(LOG_FATAL, _("No graphics for specialist \"%s\"."), tag); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("No graphics for specialist \"%s\"."), tag); } } @@ -2808,7 +2829,8 @@ static void tileset_setup_citizen_types(struct tileset *t) } t->sprites.citizen[i].count = j; if (j == 0) { - tileset_error(LOG_FATAL, _("No graphics for citizen \"%s\"."), name); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("No graphics for citizen \"%s\"."), name); } } } @@ -3102,7 +3124,8 @@ static void tileset_lookup_sprite_tags(struct tileset *t) sprite_vector_append(&t->sprites.citybar.occupancy, sprite); } if (t->sprites.citybar.occupancy.size < 2) { - tileset_error(LOG_FATAL, _("Missing necessary citybar.occupancy_N sprites.")); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Missing necessary citybar.occupancy_N sprites.")); } #define SET_EDITOR_SPRITE(x) SET_SPRITE(editor.x, "editor." #x) @@ -3223,7 +3246,8 @@ static void tileset_lookup_sprite_tags(struct tileset *t) sprite_vector_append(&t->sprites.colors.overlays, sprite); } if (i == 0) { - tileset_error(LOG_FATAL, _("Missing overlay-color sprite colors.overlay_0.")); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Missing overlay-color sprite colors.overlay_0.")); } /* Chop up and build the overlay graphics. */ @@ -3296,7 +3320,8 @@ static void tileset_lookup_sprite_tags(struct tileset *t) int offsets[4][2] = {{ntw / 2, 0}, {0, nth / 2}, {ntw / 2, nth / 2}, {0, 0}}; if (!darkness) { - tileset_error(LOG_FATAL, _("Sprite tx.darkness missing.")); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Sprite tx.darkness missing.")); } for (i = 0; i < 4; i++) { t->sprites.tx.darkness[i] = crop_sprite(darkness, offsets[i][0], @@ -3437,8 +3462,9 @@ struct sprite *tiles_lookup_sprite_tag_alt(struct tileset *t, return sp; } - tileset_error(level, _("Don't have graphics tags \"%s\" or \"%s\" for %s \"%s\"."), - tag, alt, what, name); + tileset_error(level, tileset_name_get(t), + _("Don't have graphics tags \"%s\" or \"%s\" for %s \"%s\"."), + tag, alt, what, name); return NULL; } @@ -3541,8 +3567,9 @@ void tileset_setup_unit_type(struct tileset *t, struct unit_type *ut) if (!t->sprites.units.icon[uidx]) { if (!direction8_is_valid(t->unit_default_orientation)) { - tileset_error(LOG_FATAL, "Unit type %s has no unoriented sprite and " - "tileset has no unit_default_orientation.", + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Unit type %s has no unoriented sprite and " + "tileset has no unit_default_orientation."), utype_rule_name(ut)); } else { /* We're guaranteed to have an oriented sprite corresponding to @@ -3608,7 +3635,8 @@ void tileset_setup_extra(struct tileset *t, if (!estyle_hash_lookup(t->estyle_hash, tag, &extrastyle)) { tag = pextra->graphic_alt; if (!estyle_hash_lookup(t->estyle_hash, tag, &extrastyle)) { - tileset_error(LOG_FATAL, _("No extra style for \"%s\" or \"%s\"."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("No extra style for \"%s\" or \"%s\"."), pextra->graphic_str, pextra->graphic_alt); } else { @@ -3663,7 +3691,7 @@ void tileset_setup_extra(struct tileset *t, TRUE); } if (!t->sprites.extras[id].u.cardinals[i]) { - tileset_error(LOG_FATAL, + tileset_error(LOG_FATAL, tileset_name_get(t), _("No cardinal-style graphics \"%s*\" for " "extra \"%s\""), tag, extra_rule_name(pextra)); @@ -3690,7 +3718,8 @@ void tileset_setup_extra(struct tileset *t, TRUE, TRUE); } if (t->sprites.extras[id].activity == NULL) { - tileset_error(LOG_FATAL, _("Missing %s building activity sprite for tags \"%s\" and alternatives \"%s\" and \"%s\"."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Missing %s building activity sprite for tags \"%s\" and alternatives \"%s\" and \"%s\"."), extra_rule_name(pextra), pextra->activity_gfx, pextra->act_gfx_alt, pextra->act_gfx_alt2); } @@ -3705,7 +3734,8 @@ void tileset_setup_extra(struct tileset *t, t->sprites.extras[id].rmact = load_sprite(t, pextra->rmact_gfx_alt, TRUE, TRUE); if (t->sprites.extras[id].rmact == NULL) { - tileset_error(LOG_FATAL, _("Missing %s removal activity sprite for tags \"%s\" and alternative \"%s\"."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Missing %s removal activity sprite for tags \"%s\" and alternative \"%s\"."), extra_rule_name(pextra), pextra->rmact_gfx, pextra->rmact_gfx_alt); } } @@ -3793,7 +3823,7 @@ static void tileset_setup_road(struct tileset *t, } } else if (extrastyle == ESTYLE_RIVER) { if (!load_river_sprites(t, &t->sprites.extras[id].u.road.ru.rivers, tag)) { - tileset_error(LOG_FATAL, + tileset_error(LOG_FATAL, tileset_name_get(t), _("No river-style graphics \"%s*\" for extra \"%s\""), tag, extra_rule_name(pextra)); } @@ -3852,7 +3882,7 @@ static void tileset_setup_base(struct tileset *t, && t->sprites.extras[id].u.bmf.middleground == NULL && t->sprites.extras[id].u.bmf.foreground == NULL) { /* There was an extra style definition but no matching graphics */ - tileset_error(LOG_FATAL, + tileset_error(LOG_FATAL, tileset_name_get(t), _("No graphics with tag \"%s_bg/mg/fg\" for extra \"%s\""), tag, extra_rule_name(pextra)); } @@ -3872,7 +3902,8 @@ void tileset_setup_tile_type(struct tileset *t, if (!drawing_hash_lookup(t->tile_hash, pterrain->graphic_str, &draw) && !drawing_hash_lookup(t->tile_hash, pterrain->graphic_alt, &draw)) { - tileset_error(LOG_FATAL, _("Terrain \"%s\": no graphic tile \"%s\" or \"%s\"."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Terrain \"%s\": no graphic tile \"%s\" or \"%s\"."), terrain_rule_name(pterrain), pterrain->graphic_str, pterrain->graphic_alt); } @@ -3907,7 +3938,8 @@ void tileset_setup_tile_type(struct tileset *t, /* 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); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Missing base sprite for tag \"%s\"."), buffer); } break; case MATCH_SAME: @@ -4160,7 +4192,8 @@ void tileset_setup_nation_flag(struct tileset *t, } if (!flag || !shield) { /* Should never get here because of the f.unknown fallback. */ - tileset_error(LOG_FATAL, _("Nation %s: no national flag."), nation_rule_name(nation)); + tileset_error(LOG_FATAL, tileset_name_get(t), + _("Nation %s: no national flag."), nation_rule_name(nation)); } sprite_vector_reserve(&t->sprites.nation_flag, nation_count()); @@ -6089,11 +6122,13 @@ void tileset_setup_city_tiles(struct tileset *t, int style) for (style = 0; style < game.control.styles_count; style++) { if (t->sprites.city.tile->styles[style].land_num_thresholds == 0) { - tileset_error(LOG_FATAL, _("City style \"%s\": no city graphics."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("City style \"%s\": no city graphics."), city_style_rule_name(style)); } if (t->sprites.city.occupied->styles[style].land_num_thresholds == 0) { - tileset_error(LOG_FATAL, _("City style \"%s\": no occupied graphics."), + tileset_error(LOG_FATAL, tileset_name_get(t), + _("City style \"%s\": no occupied graphics."), city_style_rule_name(style)); } } diff --git a/client/tilespec.h b/client/tilespec.h index 5165322405..80f395e353 100644 --- a/client/tilespec.h +++ b/client/tilespec.h @@ -208,7 +208,8 @@ extern struct tileset *unscaled_tileset; struct strvec; const struct strvec *get_tileset_list(const struct option *poption); -void tileset_error(enum log_level level, const char *format, ...); +void tileset_error(enum log_level level, const char *tset_name, + const char *format, ...); void tileset_init(struct tileset *t); void tileset_free(struct tileset *tileset); -- 2.39.1