rnd-20030830-1-src
[rocksndiamonds.git] / src / libgame / setup.c
index 24e2471b723632f30eff5a570000d2c63973a6a8..4cd8921ee06d11326f84eca64bae5db3304c3e61 100644 (file)
@@ -98,25 +98,25 @@ static char *levelclass_desc[NUM_LEVELCLASS_DESC] =
 
 #define MAX_COOKIE_LEN                 256
 
-#define ARTWORKINFO_FILENAME(type)     ((type) == TREE_TYPE_GRAPHICS_DIR ? \
-                                        GRAPHICSINFO_FILENAME :            \
-                                        (type) == TREE_TYPE_SOUNDS_DIR ?   \
-                                        SOUNDSINFO_FILENAME :              \
-                                        (type) == TREE_TYPE_MUSIC_DIR ?    \
+#define ARTWORKINFO_FILENAME(type)     ((type) == ARTWORK_TYPE_GRAPHICS ? \
+                                        GRAPHICSINFO_FILENAME :           \
+                                        (type) == ARTWORK_TYPE_SOUNDS ?   \
+                                        SOUNDSINFO_FILENAME :             \
+                                        (type) == ARTWORK_TYPE_MUSIC ?    \
                                         MUSICINFO_FILENAME : "")
 
-#define ARTWORK_DIRECTORY(type)                ((type) == TREE_TYPE_GRAPHICS_DIR ? \
-                                        GRAPHICS_DIRECTORY :               \
-                                        (type) == TREE_TYPE_SOUNDS_DIR ?   \
-                                        SOUNDS_DIRECTORY :                 \
-                                        (type) == TREE_TYPE_MUSIC_DIR ?    \
+#define ARTWORK_DIRECTORY(type)                ((type) == ARTWORK_TYPE_GRAPHICS ? \
+                                        GRAPHICS_DIRECTORY :              \
+                                        (type) == ARTWORK_TYPE_SOUNDS ?   \
+                                        SOUNDS_DIRECTORY :                \
+                                        (type) == ARTWORK_TYPE_MUSIC ?    \
                                         MUSIC_DIRECTORY : "")
 
-#define OPTIONS_ARTWORK_DIRECTORY(type)        ((type) == TREE_TYPE_GRAPHICS_DIR ? \
-                                        options.graphics_directory :       \
-                                        (type) == TREE_TYPE_SOUNDS_DIR ?   \
-                                        options.sounds_directory :         \
-                                        (type) == TREE_TYPE_MUSIC_DIR ?    \
+#define OPTIONS_ARTWORK_DIRECTORY(type)        ((type) == ARTWORK_TYPE_GRAPHICS ? \
+                                        options.graphics_directory :      \
+                                        (type) == ARTWORK_TYPE_SOUNDS ?   \
+                                        options.sounds_directory :        \
+                                        (type) == ARTWORK_TYPE_MUSIC ?    \
                                         options.music_directory : "")
 
 
@@ -268,14 +268,21 @@ static char *getDefaultMusicDir(char *music_subdir)
   return music_dir;
 }
 
+static char *getDefaultArtworkSet(int type)
+{
+  return (type == TREE_TYPE_GRAPHICS_DIR ? GFX_CLASSIC_SUBDIR :
+         type == TREE_TYPE_SOUNDS_DIR   ? SND_CLASSIC_SUBDIR :
+         type == TREE_TYPE_MUSIC_DIR    ? MUS_CLASSIC_SUBDIR : "");
+}
+
 static char *getDefaultArtworkDir(int type)
 {
   return (type == TREE_TYPE_GRAPHICS_DIR ?
-         getDefaultGraphicsDir(GRAPHICS_SUBDIR) :
+         getDefaultGraphicsDir(GFX_CLASSIC_SUBDIR) :
          type == TREE_TYPE_SOUNDS_DIR ?
-         getDefaultSoundsDir(SOUNDS_SUBDIR) :
+         getDefaultSoundsDir(SND_CLASSIC_SUBDIR) :
          type == TREE_TYPE_MUSIC_DIR ?
-         getDefaultMusicDir(MUSIC_SUBDIR) : "");
+         getDefaultMusicDir(MUS_CLASSIC_SUBDIR) : "");
 }
 
 static char *getUserGraphicsDir()
@@ -320,28 +327,21 @@ static char *getSetupArtworkDir(TreeInfo *ti)
   return artwork_dir;
 }
 
-void setLevelArtworkDir(TreeInfo *ti)
+char *setLevelArtworkDir(TreeInfo *ti)
 {
-  char **artwork_path_ptr, *artwork_set;
+  char **artwork_path_ptr, **artwork_set_ptr;
   TreeInfo *level_artwork;
 
   if (ti == NULL || leveldir_current == NULL)
-    return;
-
-  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);
+    return NULL;
 
-  artwork_set =
-    (ti->type == TREE_TYPE_GRAPHICS_DIR ? leveldir_current->graphics_set :
-     ti->type == TREE_TYPE_SOUNDS_DIR   ? leveldir_current->sounds_set :
-     leveldir_current->music_set);
+  artwork_path_ptr = &(LEVELDIR_ARTWORK_PATH(leveldir_current, ti->type));
+  artwork_set_ptr  = &(LEVELDIR_ARTWORK_SET( leveldir_current, ti->type));
 
   if (*artwork_path_ptr != NULL)
     free(*artwork_path_ptr);
 
-  if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set)))
+  if ((level_artwork = getTreeInfoFromIdentifier(ti, *artwork_set_ptr)))
     *artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork));
   else
   {
@@ -354,29 +354,40 @@ void setLevelArtworkDir(TreeInfo *ti)
 
     char *dir = getPath2(getCurrentLevelDir(), ARTWORK_DIRECTORY(ti->type));
 
+    if (*artwork_set_ptr != NULL)
+      free(*artwork_set_ptr);
+
     if (fileExists(dir))
+    {
       *artwork_path_ptr = getStringCopy(getDefaultArtworkDir(ti->type));
+      *artwork_set_ptr = getStringCopy(getDefaultArtworkSet(ti->type));
+    }
     else
+    {
       *artwork_path_ptr = getStringCopy(UNDEFINED_FILENAME);
+      *artwork_set_ptr = NULL;
+    }
 
     free(dir);
   }
+
+  return *artwork_set_ptr;
 }
 
-static char *getLevelArtworkDir(int type)
+inline static char *getLevelArtworkSet(int type)
 {
-  char *artwork_path;
+  if (leveldir_current == NULL)
+    return NULL;
+
+  return LEVELDIR_ARTWORK_SET(leveldir_current, type);
+}
 
+inline static char *getLevelArtworkDir(int type)
+{
   if (leveldir_current == NULL)
     return UNDEFINED_FILENAME;
 
-  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 :
-     UNDEFINED_FILENAME);
-
-  return artwork_path;
+  return LEVELDIR_ARTWORK_PATH(leveldir_current, type);
 }
 
 char *getLevelFilename(int nr)
@@ -437,7 +448,7 @@ char *getSetupFilename()
   return filename;
 }
 
-static char *getCorrectedImageBasename(char *basename)
+static char *getCorrectedArtworkBasename(char *basename)
 {
   char *basename_corrected = basename;
 
@@ -452,7 +463,7 @@ static char *getCorrectedImageBasename(char *basename)
     /* if corrected filename is still longer than standard MS-DOS filename
        size (8 characters + 1 dot + 3 characters file extension), shorten
        filename by writing file extension after 8th basename character */
-    if (strlen(basename_corrected) > 8+1+3)
+    if (strlen(basename_corrected) > 8 + 1 + 3)
     {
       static char *msdos_filename = NULL;
 
@@ -460,7 +471,9 @@ static char *getCorrectedImageBasename(char *basename)
        free(msdos_filename);
 
       msdos_filename = getStringCopy(basename_corrected);
-      strncpy(&msdos_filename[8], &basename[strlen(basename) - 1+3], 1+3 + 1);
+      strncpy(&msdos_filename[8], &basename[strlen(basename) - (1+3)], 1+3 +1);
+
+      basename_corrected = msdos_filename;
     }
   }
 #endif
@@ -471,69 +484,49 @@ static char *getCorrectedImageBasename(char *basename)
 char *getCustomImageFilename(char *basename)
 {
   static char *filename = NULL;
+  boolean skip_setup_artwork = FALSE;
 
   if (filename != NULL)
     free(filename);
 
-  basename = getCorrectedImageBasename(basename);
+  basename = getCorrectedArtworkBasename(basename);
 
   if (!setup.override_level_graphics)
   {
-#if 0
-    /* 1st try: look for special artwork configured in level series config */
-    filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename);
-#if 0
-    if (strcmp(basename, "RocksScreen.pcx") == 0)
-      printf("::: trying 1 '%s' ...\n", filename);
-#endif
+    /* 1st try: look for special artwork in current level series directory */
+    filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
     if (fileExists(filename))
       return filename;
 
     free(filename);
-#endif
 
-    /* 2nd try: look for special artwork in current level series directory */
-    filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
-#if 0
-    if (strcmp(basename, "RocksScreen.pcx") == 0)
-      printf("::: trying 2 '%s' ...\n", filename);
-#endif
-    if (fileExists(filename))
-      return filename;
+    /* check if there is special artwork configured in level series config */
+    if (getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) != NULL)
+    {
+      /* 2nd try: look for special artwork configured in level series config */
+      filename = getPath2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename);
+      if (fileExists(filename))
+       return filename;
 
-    free(filename);
+      free(filename);
 
-#if 1
-    /* 1st try: look for special artwork configured in level series config */
-    filename = getPath2(getLevelArtworkDir(TREE_TYPE_GRAPHICS_DIR), basename);
-#if 0
-    if (strcmp(basename, "RocksScreen.pcx") == 0)
-      printf("::: trying 2.1 '%s' ...\n", filename);
-#endif
+      /* take missing artwork configured in level set config from default */
+      skip_setup_artwork = TRUE;
+    }
+  }
+
+  if (!skip_setup_artwork)
+  {
+    /* 3rd try: look for special artwork in configured artwork directory */
+    filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
     if (fileExists(filename))
       return filename;
 
     free(filename);
-#endif
   }
 
-  /* 3rd try: look for special artwork in configured artwork directory */
-  filename = getPath2(getSetupArtworkDir(artwork.gfx_current), basename);
-#if 0
-  if (strcmp(basename, "RocksScreen.pcx") == 0)
-    printf("::: trying 3 '%s' ...\n", filename);
-#endif
-  if (fileExists(filename))
-    return filename;
-
-  free(filename);
-
   /* 4th try: look for default artwork in new default artwork directory */
-  filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename);
-#if 0
-  if (strcmp(basename, "RocksScreen.pcx") == 0)
-    printf("::: trying 4 '%s' ...\n", filename);
-#endif
+  filename = getPath2(getDefaultGraphicsDir(GFX_CLASSIC_SUBDIR), basename);
   if (fileExists(filename))
     return filename;
 
@@ -541,10 +534,6 @@ char *getCustomImageFilename(char *basename)
 
   /* 5th try: look for default artwork in old default artwork directory */
   filename = getPath2(options.graphics_directory, basename);
-#if 0
-  if (strcmp(basename, "RocksScreen.pcx") == 0)
-    printf("::: trying 5 '%s' ...\n", filename);
-#endif
   if (fileExists(filename))
     return filename;
 
@@ -554,47 +543,49 @@ char *getCustomImageFilename(char *basename)
 char *getCustomSoundFilename(char *basename)
 {
   static char *filename = NULL;
+  boolean skip_setup_artwork = FALSE;
 
   if (filename != NULL)
     free(filename);
 
+  basename = getCorrectedArtworkBasename(basename);
+
   if (!setup.override_level_sounds)
   {
-#if 0
-    /* 1st try: look for special artwork configured in level series config */
-    filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
+    /* 1st try: look for special artwork in current level series directory */
+    filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
     if (fileExists(filename))
       return filename;
 
     free(filename);
-#endif
 
-    /* 2nd try: look for special artwork in current level series directory */
-    filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
-    if (fileExists(filename))
-      return filename;
+    /* check if there is special artwork configured in level series config */
+    if (getLevelArtworkSet(ARTWORK_TYPE_SOUNDS) != NULL)
+    {
+      /* 2nd try: look for special artwork configured in level series config */
+      filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
+      if (fileExists(filename))
+       return filename;
 
-    free(filename);
+      free(filename);
 
-#if 1
-    /* 1st try: look for special artwork configured in level series config */
-    filename = getPath2(getLevelArtworkDir(TREE_TYPE_SOUNDS_DIR), basename);
+      /* take missing artwork configured in level set config from default */
+      skip_setup_artwork = TRUE;
+    }
+  }
+
+  if (!skip_setup_artwork)
+  {
+    /* 3rd try: look for special artwork in configured artwork directory */
+    filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
     if (fileExists(filename))
       return filename;
 
     free(filename);
-#endif
   }
 
-  /* 3rd try: look for special artwork in configured artwork directory */
-  filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename);
-  if (fileExists(filename))
-    return filename;
-
-  free(filename);
-
   /* 4th try: look for default artwork in new default artwork directory */
-  filename = getPath2(getDefaultSoundsDir(SOUNDS_SUBDIR), basename);
+  filename = getPath2(getDefaultSoundsDir(SND_CLASSIC_SUBDIR), basename);
   if (fileExists(filename))
     return filename;
 
@@ -638,47 +629,47 @@ char *getCustomArtworkLevelConfigFilename(int type)
 char *getCustomMusicDirectory(void)
 {
   static char *directory = NULL;
+  boolean skip_setup_artwork = FALSE;
 
   if (directory != NULL)
     free(directory);
 
   if (!setup.override_level_music)
   {
-#if 0
-    /* 1st try: look for special artwork configured in level series config */
-    directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+    /* 1st try: look for special artwork in current level series directory */
+    directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
     if (fileExists(directory))
       return directory;
 
     free(directory);
-#endif
 
-    /* 2nd try: look for special artwork in current level series directory */
-    directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
-    if (fileExists(directory))
-      return directory;
+    /* check if there is special artwork configured in level series config */
+    if (getLevelArtworkSet(ARTWORK_TYPE_MUSIC) != NULL)
+    {
+      /* 2nd try: look for special artwork configured in level series config */
+      directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+      if (fileExists(directory))
+       return directory;
 
-    free(directory);
+      free(directory);
 
-#if 1
-    /* 1st try: look for special artwork configured in level series config */
-    directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+      /* take missing artwork configured in level set config from default */
+      skip_setup_artwork = TRUE;
+    }
+  }
+
+  if (!skip_setup_artwork)
+  {
+    /* 3rd try: look for special artwork in configured artwork directory */
+    directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
     if (fileExists(directory))
       return directory;
 
     free(directory);
-#endif
   }
 
-  /* 3rd try: look for special artwork in configured artwork directory */
-  directory = getStringCopy(getSetupArtworkDir(artwork.mus_current));
-  if (fileExists(directory))
-    return directory;
-
-  free(directory);
-
   /* 4th try: look for default artwork in new default artwork directory */
-  directory = getStringCopy(getDefaultMusicDir(MUSIC_SUBDIR));
+  directory = getStringCopy(getDefaultMusicDir(MUS_CLASSIC_SUBDIR));
   if (fileExists(directory))
     return directory;
 
@@ -1512,12 +1503,14 @@ static void setTreeInfoToDefaults(TreeInfo *ldi, int type)
   if (ldi->type == TREE_TYPE_LEVEL_DIR)
   {
     ldi->imported_from = NULL;
+
     ldi->graphics_set = NULL;
     ldi->sounds_set = NULL;
     ldi->music_set = NULL;
     ldi->graphics_path = getStringCopy(UNDEFINED_FILENAME);
     ldi->sounds_path = getStringCopy(UNDEFINED_FILENAME);
     ldi->music_path = getStringCopy(UNDEFINED_FILENAME);
+
     ldi->levels = 0;
     ldi->first_level = 0;
     ldi->last_level = 0;
@@ -1533,10 +1526,60 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent)
   {
     Error(ERR_WARN, "setTreeInfoToDefaultsFromParent(): parent == NULL");
 
-    setTreeInfoToDefaults(ldi, TREE_TYPE_GENERIC);
+    setTreeInfoToDefaults(ldi, TREE_TYPE_UNDEFINED);
+
     return;
   }
 
+#if 1
+  /* copy all values from the parent structure */
+
+  ldi->type = parent->type;
+
+  ldi->node_top = parent->node_top;
+  ldi->node_parent = parent;
+  ldi->node_group = NULL;
+  ldi->next = NULL;
+
+  ldi->cl_first = -1;
+  ldi->cl_cursor = -1;
+
+  ldi->filename = NULL;
+  ldi->fullpath = NULL;
+  ldi->basepath = NULL;
+  ldi->identifier = NULL;
+  ldi->name = getStringCopy(ANONYMOUS_NAME);
+  ldi->name_sorting = NULL;
+  ldi->author = getStringCopy(parent->author);
+
+  ldi->sort_priority = parent->sort_priority;
+  ldi->parent_link = FALSE;
+  ldi->user_defined = parent->user_defined;
+  ldi->color = parent->color;
+  ldi->class_desc = getStringCopy(parent->class_desc);
+
+  if (ldi->type == TREE_TYPE_LEVEL_DIR)
+  {
+    ldi->imported_from = getStringCopy(parent->imported_from);
+
+    ldi->graphics_set = NULL;
+    ldi->sounds_set = NULL;
+    ldi->music_set = NULL;
+    ldi->graphics_path = getStringCopy(UNDEFINED_FILENAME);
+    ldi->sounds_path = getStringCopy(UNDEFINED_FILENAME);
+    ldi->music_path = getStringCopy(UNDEFINED_FILENAME);
+
+    ldi->levels = 0;
+    ldi->first_level = 0;
+    ldi->last_level = 0;
+    ldi->level_group = FALSE;
+    ldi->handicap_level = 0;
+    ldi->readonly = TRUE;
+  }
+
+
+#else
+
   /* first copy all values from the parent structure ... */
   *ldi = *parent;
 
@@ -1554,7 +1597,16 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent)
   ldi->name = getStringCopy(ANONYMOUS_NAME);
   ldi->name_sorting = NULL;
   ldi->author = getStringCopy(parent->author);
+
   ldi->imported_from = getStringCopy(parent->imported_from);
+  ldi->class_desc = getStringCopy(parent->class_desc);
+
+  ldi->graphics_set = NULL;
+  ldi->sounds_set = NULL;
+  ldi->music_set = NULL;
+  ldi->graphics_path = NULL;
+  ldi->sounds_path = NULL;
+  ldi->music_path = NULL;
 
   ldi->level_group = FALSE;
   ldi->parent_link = FALSE;
@@ -1563,6 +1615,8 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ldi, TreeInfo *parent)
   ldi->node_parent = parent;
   ldi->node_group = NULL;
   ldi->next = NULL;
+
+#endif
 }
 
 void setSetupInfo(struct TokenInfo *token_info,
@@ -2119,7 +2173,7 @@ void LoadArtworkInfo()
     getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
   if (artwork.gfx_current == NULL)
     artwork.gfx_current =
-      getTreeInfoFromIdentifier(artwork.gfx_first, GRAPHICS_SUBDIR);
+      getTreeInfoFromIdentifier(artwork.gfx_first, GFX_CLASSIC_SUBDIR);
   if (artwork.gfx_current == NULL)
     artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
 
@@ -2127,7 +2181,7 @@ void LoadArtworkInfo()
     getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
   if (artwork.snd_current == NULL)
     artwork.snd_current =
-      getTreeInfoFromIdentifier(artwork.snd_first, SOUNDS_SUBDIR);
+      getTreeInfoFromIdentifier(artwork.snd_first, SND_CLASSIC_SUBDIR);
   if (artwork.snd_current == NULL)
     artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
 
@@ -2135,7 +2189,7 @@ void LoadArtworkInfo()
     getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
   if (artwork.mus_current == NULL)
     artwork.mus_current =
-      getTreeInfoFromIdentifier(artwork.mus_first, MUSIC_SUBDIR);
+      getTreeInfoFromIdentifier(artwork.mus_first, MUS_CLASSIC_SUBDIR);
   if (artwork.mus_current == NULL)
     artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
 
@@ -2222,7 +2276,7 @@ void LoadLevelArtworkInfo()
       getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
     if (artwork.gfx_current == NULL)
       artwork.gfx_current =
-       getTreeInfoFromIdentifier(artwork.gfx_first, GRAPHICS_SUBDIR);
+       getTreeInfoFromIdentifier(artwork.gfx_first, GFX_CLASSIC_SUBDIR);
     if (artwork.gfx_current == NULL)
       artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
   }
@@ -2233,7 +2287,7 @@ void LoadLevelArtworkInfo()
       getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
     if (artwork.snd_current == NULL)
       artwork.snd_current =
-       getTreeInfoFromIdentifier(artwork.snd_first, SOUNDS_SUBDIR);
+       getTreeInfoFromIdentifier(artwork.snd_first, SND_CLASSIC_SUBDIR);
     if (artwork.snd_current == NULL)
       artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
   }
@@ -2244,7 +2298,7 @@ void LoadLevelArtworkInfo()
       getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
     if (artwork.mus_current == NULL)
       artwork.mus_current =
-       getTreeInfoFromIdentifier(artwork.mus_first, MUSIC_SUBDIR);
+       getTreeInfoFromIdentifier(artwork.mus_first, MUS_CLASSIC_SUBDIR);
     if (artwork.mus_current == NULL)
       artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
   }
@@ -2278,15 +2332,28 @@ static void SaveUserLevelInfo()
   /* always start with reliable default values */
   setTreeInfoToDefaults(&ldi, TREE_TYPE_LEVEL_DIR);
 
+#if 0
+  /* !!! FIX ME !!! */
+  setString(&ldi.name, getLoginName());
+  setString(&ldi.author, getRealName());
+  ldi.levels = 100;
+  ldi.first_level = 1;
+  ldi.sort_priority = LEVELCLASS_USER_START;
+  ldi.readonly = FALSE;
+  setString(&ldi.graphics_set, GFX_CLASSIC_SUBDIR);
+  setString(&ldi.sounds_set,   SND_CLASSIC_SUBDIR);
+  setString(&ldi.music_set,    MUS_CLASSIC_SUBDIR);
+#else
   ldi.name = getStringCopy(getLoginName());
   ldi.author = getStringCopy(getRealName());
   ldi.levels = 100;
   ldi.first_level = 1;
   ldi.sort_priority = LEVELCLASS_USER_START;
   ldi.readonly = FALSE;
-  ldi.graphics_set = getStringCopy(GRAPHICS_SUBDIR);
-  ldi.sounds_set = getStringCopy(SOUNDS_SUBDIR);
-  ldi.music_set = getStringCopy(MUSIC_SUBDIR);
+  ldi.graphics_set = getStringCopy(GFX_CLASSIC_SUBDIR);
+  ldi.sounds_set = getStringCopy(SND_CLASSIC_SUBDIR);
+  ldi.music_set = getStringCopy(MUS_CLASSIC_SUBDIR);
+#endif
 
   fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER,
                                                 getCookie("LEVELINFO")));
@@ -2298,9 +2365,10 @@ static void SaveUserLevelInfo()
       fprintf(file, "%s\n", getSetupLine(levelinfo_tokens, "", i));
 
   fclose(file);
-  free(filename);
 
   SetFilePermissions(filename, PERMS_PRIVATE);
+
+  free(filename);
 }
 
 char *getSetupValue(int type, void *value)
@@ -2447,9 +2515,10 @@ void SaveLevelSetup_LastSeries()
                                               level_subdir));
 
   fclose(file);
-  free(filename);
 
   SetFilePermissions(filename, PERMS_PRIVATE);
+
+  free(filename);
 }
 
 static void checkSeriesInfo()
@@ -2596,7 +2665,8 @@ void SaveLevelSetup_SeriesInfo()
                                               handicap_level_str));
 
   fclose(file);
-  free(filename);
 
   SetFilePermissions(filename, PERMS_PRIVATE);
+
+  free(filename);
 }