From: Holger Schemel Date: Mon, 4 Feb 2019 21:44:54 +0000 (+0100) Subject: fixed potential crash bug for special versions without "classic" artwork X-Git-Tag: 4.1.2.0~31 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=81978d087d71b598d29647a007ae9f90077cab87 fixed potential crash bug for special versions without "classic" artwork This bug can happen when using the program binary within a special, customized version of R'n'D like "R'n'D jue" that does not contain the usual "classic" artwork (like the graphics set "gfx_classic"). The problem is solved by doing a fallback to the default artwork set (as it can be defined using "default_graphics_set") if the "classic" artwork set cannot be found. --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index c64c95c8..22fd4084 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -3967,8 +3967,17 @@ TreeInfo *getArtworkTreeInfoForUserLevelSet(int type) { char *artwork_set = getArtworkIdentifierForUserLevelSet(type); TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type); + TreeInfo *ti = getTreeInfoFromIdentifier(artwork_first_node, artwork_set); - return getTreeInfoFromIdentifier(artwork_first_node, artwork_set); + if (ti == NULL) + { + ti = getTreeInfoFromIdentifier(artwork_first_node, + ARTWORK_DEFAULT_SUBDIR(type)); + if (ti == NULL) + Error(ERR_EXIT, "cannot find default graphics -- should not happen"); + } + + return ti; } boolean checkIfCustomArtworkExistsForCurrentLevelSet(void) diff --git a/src/libgame/system.h b/src/libgame/system.h index 73fc3716..c7df9785 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -871,6 +871,13 @@ (type) == ARTWORK_TYPE_MUSIC ? \ getUserMusicDir() : "") +#define ARTWORK_DEFAULT_SUBDIR(type) \ + ((type) == ARTWORK_TYPE_GRAPHICS ? \ + GFX_DEFAULT_SUBDIR : \ + (type) == ARTWORK_TYPE_SOUNDS ? \ + SND_DEFAULT_SUBDIR : \ + MUS_DEFAULT_SUBDIR) + #define UPDATE_BUSY_STATE() \ { \ if (gfx.draw_busy_anim_function != NULL) \