From: Holger Schemel Date: Sun, 18 Oct 2020 22:54:09 +0000 (+0200) Subject: fixed bug with unnecessarily reloading custom artwork on ECS/AGA change X-Git-Tag: 4.2.1.0~37 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=4bc6719c189911811c4ae1f06ffd7131b3ba5d9d fixed bug with unnecessarily reloading custom artwork on ECS/AGA change This bug occurs when changing the setup option for ECS/AGA preference when there exists a level set with both ECS and AGA graphics sets in the available tree of level sets, and results in (visually) attempting to reload the current graphics even if the currently active level set does not have any such graphics variants. This fix prevents such unnecessary attempts to reload custom graphics, and adds a better check for changed graphics (also needed if graphics change from ECS to AGA variant) that really compares the previous with the current graphics (which may result in the need to reload graphics). --- diff --git a/src/init.c b/src/init.c index 1c715318..c5427aca 100644 --- a/src/init.c +++ b/src/init.c @@ -5910,6 +5910,7 @@ static void InitOverrideArtwork(void) static char *getNewArtworkIdentifier(int type) { static char *last_leveldir_identifier[3] = { NULL, NULL, NULL }; + static char *last_artwork_identifier[3] = { NULL, NULL, NULL }; static boolean last_override_level_artwork[3] = { FALSE, FALSE, FALSE }; static boolean last_has_level_artwork_set[3] = { FALSE, FALSE, FALSE }; static boolean initialized[3] = { FALSE, FALSE, FALSE }; @@ -5962,10 +5963,12 @@ static char *getNewArtworkIdentifier(int type) last_override_level_artwork[type] = setup_override_artwork; // ---------- reload if current artwork identifier has changed -------------- - if (!strEqual(ARTWORK_CURRENT_IDENTIFIER(artwork, type), - artwork_current_identifier)) + if (!strEqual(last_artwork_identifier[type], artwork_current_identifier)) artwork_new_identifier = artwork_current_identifier; + // (we cannot compare string pointers here, so copy string content itself) + setString(&last_artwork_identifier[type], artwork_current_identifier); + *(ARTWORK_CURRENT_IDENTIFIER_PTR(artwork, type)) = artwork_current_identifier; // ---------- do not reload directly after starting ------------------------- @@ -5990,8 +5993,8 @@ void ReloadCustomArtwork(int force_reload) InitOverrideArtwork(); - force_reload_gfx |= AdjustGraphicsForEMC(); - force_reload_snd |= AdjustSoundsForEMC(); + AdjustGraphicsForEMC(); + AdjustSoundsForEMC(); gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS); snd_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_SOUNDS);