From f8a3eabd9d6504cf3f3e093ccbb527e9dff0b551 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Tue, 16 Jan 2024 20:39:47 -0800 Subject: [PATCH] Start in first Magic tool group containing any tools i.e., if MAGIC_TYPE_DISTORTS (0) is empty, try MAGIC_TYPE_COLOR_FILTERS (1), etc. --- src/tuxpaint.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 6eabade57..f5d8f00d0 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -21373,7 +21373,7 @@ static SDL_Surface *load_kpx(const char *file) */ static void load_magic_plugins(void) { - int res, n, i, plc; + int res, n, i, plc, tries; char *place; int err; DIR *d; @@ -21858,6 +21858,15 @@ static void load_magic_plugins(void) DEBUG_PRINTF("Loaded %d magic tools from %d plug-in files\n", num_magics_total, num_plugin_files); DEBUG_PRINTF("\n"); + + /* Start out with the first magic group that _has_ any tools */ + tries = 0; + while (num_magics[magic_group] == 0 && tries < MAX_MAGIC_GROUPS) { + magic_group++; + if (magic_group >= MAX_MAGIC_GROUPS) { + magic_group = 0; + } + } }