rnd-20020824-3-src
authorHolger Schemel <info@artsoft.org>
Sat, 24 Aug 2002 21:56:19 +0000 (23:56 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:38:10 +0000 (10:38 +0200)
src/conftime.h
src/init.c
src/libgame/setup.c
src/libgame/setup.h

index ca2edc0d6562c2d493539fb9886fa1a5a6cf8e49..b80ee518ddfdd826f73218ec787c158211c69bde 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-08-24 22:54]"
+#define COMPILE_DATE_STRING "[2002-08-24 23:51]"
index 38aec9ae656aab1e178dc3bd8fb376a431eb44ca..26f0268c0481651f6f93b384e7bea57cf4513cfd 100644 (file)
@@ -453,48 +453,28 @@ void ReloadCustomArtwork()
       snd_new_identifier = identifier_new;
     if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
        getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
-      artwork.mus_current_identifier = NULL;
+      mus_new_identifier = identifier_new;
 
     leveldir_current_identifier = leveldir_current->identifier;
   }
 
   /* custom level artwork configured in level series configuration file
      always overrides custom level artwork stored in level series directory
-     and (level independant) custom artwork configured in setup menue
-     (the path entry is needed to send it to the sound child process) */
+     and (level independant) custom artwork configured in setup menue */
   if (leveldir_current->graphics_set != NULL)
-  {
-    if (leveldir_current->graphics_path)
-      free(leveldir_current->graphics_path);
-    leveldir_current->graphics_path = NULL;
-    leveldir_current->graphics_path =
-      getStringCopy(getLevelArtworkDir(artwork.gfx_first));
     gfx_new_identifier = leveldir_current->graphics_set;
-  }
   if (leveldir_current->sounds_set != NULL)
-  {
-    if (leveldir_current->sounds_path)
-      free(leveldir_current->sounds_path);
-    leveldir_current->sounds_path = NULL;
-    leveldir_current->sounds_path =
-      getStringCopy(getLevelArtworkDir(artwork.snd_first));
     snd_new_identifier = leveldir_current->sounds_set;
-  }
   if (leveldir_current->music_set != NULL)
-  {
-    if (leveldir_current->music_path)
-      free(leveldir_current->music_path);
-    leveldir_current->music_path = NULL;
-    leveldir_current->music_path =
-      getStringCopy(getLevelArtworkDir(artwork.mus_first));
     mus_new_identifier = leveldir_current->music_set;
-  }
 
   if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
       last_override_level_graphics != setup.override_level_graphics)
   {
     int i;
 
+    setLevelArtworkDir(artwork.gfx_first);
+
     ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
 
     for(i=0; i<NUM_PICTURES; i++)
@@ -518,6 +498,9 @@ void ReloadCustomArtwork()
   if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
       last_override_level_sounds != setup.override_level_sounds)
   {
+    /* set artwork path to send it to the sound server process */
+    setLevelArtworkDir(artwork.snd_first);
+
     InitReloadSounds(snd_new_identifier);
 
     artwork.snd_current_identifier = snd_new_identifier;
@@ -527,6 +510,9 @@ void ReloadCustomArtwork()
   if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
       last_override_level_music != setup.override_level_music)
   {
+    /* set artwork path to send it to the sound server process */
+    setLevelArtworkDir(artwork.mus_first);
+
     InitReloadMusic(mus_new_identifier);
 
     artwork.mus_current_identifier = mus_new_identifier;
index e69e592657c70979008231ba9dd493c87922dfed..f140d8fdd8a6b189379a83f0c0fbf75267dea17c 100644 (file)
@@ -309,35 +309,47 @@ static char *getSetupArtworkDir(TreeInfo *ti)
   return artwork_dir;
 }
 
-char *getLevelArtworkDir(TreeInfo *ti)
+void setLevelArtworkDir(TreeInfo *ti)
 {
-  char *artwork_path, *artwork_set;
+  char **artwork_path_ptr, *artwork_set;
+  TreeInfo *level_artwork;
 
   if (ti == NULL || leveldir_current == NULL)
-    return NOT_AVAILABLE;
-
-  artwork_path =
-    (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_path :
-     ti->type == TREE_TYPE_SOUNDS_DIR   ? leveldir_current->sounds_path :
-     ti->type == TREE_TYPE_MUSIC_DIR    ? leveldir_current->music_path : NULL);
+    return;
 
-  if (artwork_path != NULL)
-    return artwork_path;
+  artwork_path_ptr =
+    (ti->type == TREE_TYPE_GRAPHICS_DIR ? &leveldir_current->graphics_path :
+     ti->type == TREE_TYPE_SOUNDS_DIR   ? &leveldir_current->sounds_path :
+     &leveldir_current->music_path);
 
   artwork_set =
     (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_set :
      ti->type == TREE_TYPE_SOUNDS_DIR   ? leveldir_current->sounds_set :
-     ti->type == TREE_TYPE_MUSIC_DIR    ? leveldir_current->music_set : NULL);
+     leveldir_current->music_set);
 
-  if (artwork_set != NULL)
-  {
-    TreeInfo *level_artwork = getTreeInfoFromIdentifier(ti, artwork_set);
+  if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set)) == NULL)
+    return;
 
-    if (level_artwork != NULL)
-      return getSetupArtworkDir(level_artwork);
-  }
+  if (*artwork_path_ptr != NULL)
+    free(*artwork_path_ptr);
+
+  *artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork));
+}
+
+static char *getLevelArtworkDir(int type)
+{
+  char *artwork_path;
+
+  if (leveldir_current == NULL)
+    return NOT_AVAILABLE;
+
+  artwork_path =
+    (type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_path :
+     type == TREE_TYPE_SOUNDS_DIR   ? leveldir_current->sounds_path :
+     type == TREE_TYPE_MUSIC_DIR    ? leveldir_current->music_path :
+     NOT_AVAILABLE);
 
-  return NOT_AVAILABLE;
+  return artwork_path;
 }
 
 char *getLevelFilename(int nr)
@@ -432,7 +444,7 @@ char *getCustomImageFilename(char *basename)
   if (!setup.override_level_graphics)
   {
     /* 1st try: look for special artwork configured in level series config */
-    filename = getPath2(getLevelArtworkDir(artwork.gfx_first), basename);
+    filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename);
     if (fileExists(filename))
       return filename;
 
@@ -469,12 +481,10 @@ char *getCustomSoundFilename(char *basename)
 
   if (!setup.override_level_sounds)
   {
-#if 1
     /* 1st try: look for special artwork configured in level series config */
-    filename = getPath2(getLevelArtworkDir(artwork.snd_first), basename);
+    filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
     if (fileExists(filename))
       return filename;
-#endif
 
     /* 2nd try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
@@ -514,12 +524,10 @@ char *getCustomMusicDirectory(void)
 
   if (!setup.override_level_music)
   {
-#if 1
     /* 1st try: look for special artwork configured in level series config */
-    directory = getStringCopy(getLevelArtworkDir(artwork.mus_first));
+    directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
     if (fileExists(directory))
       return directory;
-#endif
 
     /* 2nd try: look for special artwork in current level series directory */
     directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
@@ -529,11 +537,6 @@ char *getCustomMusicDirectory(void)
 
   /* 3rd try: look for special artwork in configured artwork directory */
   directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
-
-#if 1
-  printf("DEBUG: checking directory '%s' ...\n", directory);
-#endif
-
   if (fileExists(directory))
     return directory;
 
index 67f42611ee0c3c7da4d1087789695cd942d8fc9a..3a5021beeb4f3893a798eb1fde5a48dfcf367e7d 100644 (file)
@@ -171,7 +171,7 @@ struct TokenInfo
                         ARTWORKCLASS_UNDEFINED)
 
 
-char *getLevelArtworkDir(TreeInfo *);
+void setLevelArtworkDir(TreeInfo *);
 char *getLevelFilename(int);
 char *getTapeFilename(int);
 char *getScoreFilename(int);