fixed potential crash bug for special versions without "classic" artwork
authorHolger Schemel <info@artsoft.org>
Mon, 4 Feb 2019 21:44:54 +0000 (22:44 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 4 Feb 2019 21:44:54 +0000 (22:44 +0100)
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.

src/libgame/setup.c
src/libgame/system.h

index c64c95c8ee84c6d5fdb17d6b110eaded193a01a7..22fd408408e767508e4e336cd0cdf39781adb864 100644 (file)
@@ -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)
index 73fc371603eaf3d6afb3953e1f7b2908137ad545..c7df978523968fd7427ad9f16aa6060cf687272c 100644 (file)
                                 (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)     \