rnd-20030729-1-src
[rocksndiamonds.git] / src / libgame / setup.c
index 940d6bad827d9fab1639f101e65d0505839bd7c3..24e2471b723632f30eff5a570000d2c63973a6a8 100644 (file)
@@ -268,6 +268,16 @@ static char *getDefaultMusicDir(char *music_subdir)
   return music_dir;
 }
 
   return music_dir;
 }
 
+static char *getDefaultArtworkDir(int type)
+{
+  return (type == TREE_TYPE_GRAPHICS_DIR ?
+         getDefaultGraphicsDir(GRAPHICS_SUBDIR) :
+         type == TREE_TYPE_SOUNDS_DIR ?
+         getDefaultSoundsDir(SOUNDS_SUBDIR) :
+         type == TREE_TYPE_MUSIC_DIR ?
+         getDefaultMusicDir(MUSIC_SUBDIR) : "");
+}
+
 static char *getUserGraphicsDir()
 {
   static char *usergraphics_dir = NULL;
 static char *getUserGraphicsDir()
 {
   static char *usergraphics_dir = NULL;
@@ -328,13 +338,29 @@ void setLevelArtworkDir(TreeInfo *ti)
      ti->type == TREE_TYPE_SOUNDS_DIR   ? leveldir_current->sounds_set :
      leveldir_current->music_set);
 
      ti->type == TREE_TYPE_SOUNDS_DIR   ? leveldir_current->sounds_set :
      leveldir_current->music_set);
 
-  if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set)) == NULL)
-    return;
-
   if (*artwork_path_ptr != NULL)
     free(*artwork_path_ptr);
 
   if (*artwork_path_ptr != NULL)
     free(*artwork_path_ptr);
 
-  *artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork));
+  if ((level_artwork = getTreeInfoFromIdentifier(ti, artwork_set)))
+    *artwork_path_ptr = getStringCopy(getSetupArtworkDir(level_artwork));
+  else
+  {
+    /* No (or non-existing) artwork configured in "levelinfo.conf". This would
+       normally result in using the artwork configured in the setup menu. But
+       if an artwork subdirectory exists (which might contain custom artwork
+       or an artwork configuration file), this level artwork must be treated
+       as relative to the default "classic" artwork, not to the artwork that
+       is currently configured in the setup menu. */
+
+    char *dir = getPath2(getCurrentLevelDir(), ARTWORK_DIRECTORY(ti->type));
+
+    if (fileExists(dir))
+      *artwork_path_ptr = getStringCopy(getDefaultArtworkDir(ti->type));
+    else
+      *artwork_path_ptr = getStringCopy(UNDEFINED_FILENAME);
+
+    free(dir);
+  }
 }
 
 static char *getLevelArtworkDir(int type)
 }
 
 static char *getLevelArtworkDir(int type)
@@ -361,7 +387,11 @@ char *getLevelFilename(int nr)
   if (filename != NULL)
     free(filename);
 
   if (filename != NULL)
     free(filename);
 
-  sprintf(basename, "%03d.%s", nr, LEVELFILE_EXTENSION);
+  if (nr < 0)
+    sprintf(basename, "template.%s", LEVELFILE_EXTENSION);
+  else
+    sprintf(basename, "%03d.%s", nr, LEVELFILE_EXTENSION);
+
   filename = getPath2(getCurrentLevelDir(), basename);
 
   return filename;
   filename = getPath2(getCurrentLevelDir(), basename);
 
   return filename;
@@ -449,23 +479,50 @@ char *getCustomImageFilename(char *basename)
 
   if (!setup.override_level_graphics)
   {
 
   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);
     /* 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
     if (fileExists(filename))
       return filename;
 
     free(filename);
     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);
 
     /* 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;
+
+    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
     if (fileExists(filename))
       return filename;
 
     free(filename);
     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);
   }
 
   /* 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;
 
   if (fileExists(filename))
     return filename;
 
@@ -473,6 +530,10 @@ char *getCustomImageFilename(char *basename)
 
   /* 4th try: look for default artwork in new default artwork directory */
   filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename);
 
   /* 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
   if (fileExists(filename))
     return filename;
 
   if (fileExists(filename))
     return filename;
 
@@ -480,6 +541,10 @@ char *getCustomImageFilename(char *basename)
 
   /* 5th try: look for default artwork in old default artwork directory */
   filename = getPath2(options.graphics_directory, 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;
 
   if (fileExists(filename))
     return filename;
 
@@ -495,12 +560,14 @@ char *getCustomSoundFilename(char *basename)
 
   if (!setup.override_level_sounds)
   {
 
   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);
     if (fileExists(filename))
       return filename;
 
     free(filename);
     /* 1st 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);
+#endif
 
     /* 2nd try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
 
     /* 2nd try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
@@ -508,6 +575,15 @@ char *getCustomSoundFilename(char *basename)
       return filename;
 
     free(filename);
       return filename;
 
     free(filename);
+
+#if 1
+    /* 1st 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);
+#endif
   }
 
   /* 3rd try: look for special artwork in configured artwork directory */
   }
 
   /* 3rd try: look for special artwork in configured artwork directory */
@@ -547,6 +623,18 @@ char *getCustomArtworkConfigFilename(int type)
   return getCustomArtworkFilename(ARTWORKINFO_FILENAME(type), type);
 }
 
   return getCustomArtworkFilename(ARTWORKINFO_FILENAME(type), type);
 }
 
+char *getCustomArtworkLevelConfigFilename(int type)
+{
+  static char *filename = NULL;
+
+  if (filename != NULL)
+    free(filename);
+
+  filename = getPath2(getLevelArtworkDir(type), ARTWORKINFO_FILENAME(type));
+
+  return filename;
+}
+
 char *getCustomMusicDirectory(void)
 {
   static char *directory = NULL;
 char *getCustomMusicDirectory(void)
 {
   static char *directory = NULL;
@@ -556,12 +644,14 @@ char *getCustomMusicDirectory(void)
 
   if (!setup.override_level_music)
   {
 
   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));
     if (fileExists(directory))
       return directory;
 
     free(directory);
     /* 1st try: look for special artwork configured in level series config */
     directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
     if (fileExists(directory))
       return directory;
 
     free(directory);
+#endif
 
     /* 2nd try: look for special artwork in current level series directory */
     directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
 
     /* 2nd try: look for special artwork in current level series directory */
     directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
@@ -569,6 +659,15 @@ char *getCustomMusicDirectory(void)
       return directory;
 
     free(directory);
       return directory;
 
     free(directory);
+
+#if 1
+    /* 1st try: look for special artwork configured in level series config */
+    directory = getStringCopy(getLevelArtworkDir(TREE_TYPE_MUSIC_DIR));
+    if (fileExists(directory))
+      return directory;
+
+    free(directory);
+#endif
   }
 
   /* 3rd try: look for special artwork in configured artwork directory */
   }
 
   /* 3rd try: look for special artwork in configured artwork directory */
@@ -1040,6 +1139,18 @@ char *getFormattedSetupEntry(char *token, char *value)
   return entry;
 }
 
   return entry;
 }
 
+SetupFileList *newSetupFileList(char *token, char *value)
+{
+  SetupFileList *new = checked_malloc(sizeof(SetupFileList));
+
+  new->token = getStringCopy(token);
+  new->value = getStringCopy(value);
+
+  new->next = NULL;
+
+  return new;
+}
+
 void freeSetupFileList(SetupFileList *list)
 {
   if (list == NULL)
 void freeSetupFileList(SetupFileList *list)
 {
   if (list == NULL)
@@ -1054,19 +1165,7 @@ void freeSetupFileList(SetupFileList *list)
   free(list);
 }
 
   free(list);
 }
 
-SetupFileList *newSetupFileList(char *token, char *value)
-{
-  SetupFileList *new = checked_malloc(sizeof(SetupFileList));
-
-  new->token = getStringCopy(token);
-  new->value = getStringCopy(value);
-
-  new->next = NULL;
-
-  return new;
-}
-
-char *getTokenValue(SetupFileList *list, char *token)
+char *getListEntry(SetupFileList *list, char *token)
 {
   if (list == NULL)
     return NULL;
 {
   if (list == NULL)
     return NULL;
@@ -1074,10 +1173,10 @@ char *getTokenValue(SetupFileList *list, char *token)
   if (strcmp(list->token, token) == 0)
     return list->value;
   else
   if (strcmp(list->token, token) == 0)
     return list->value;
   else
-    return getTokenValue(list->next, token);
+    return getListEntry(list->next, token);
 }
 
 }
 
-void setTokenValue(SetupFileList *list, char *token, char *value)
+void setListEntry(SetupFileList *list, char *token, char *value)
 {
   if (list == NULL)
     return;
 {
   if (list == NULL)
     return;
@@ -1092,7 +1191,7 @@ void setTokenValue(SetupFileList *list, char *token, char *value)
   else if (list->next == NULL)
     list->next = newSetupFileList(token, value);
   else
   else if (list->next == NULL)
     list->next = newSetupFileList(token, value);
   else
-    setTokenValue(list->next, token, value);
+    setListEntry(list->next, token, value);
 }
 
 #ifdef DEBUG
 }
 
 #ifdef DEBUG
@@ -1125,11 +1224,19 @@ static unsigned int get_hash_from_key(void *key)
   /*
     djb2
 
   /*
     djb2
 
-    this algorithm (k=33) was first reported by dan bernstein many years ago in
-    comp.lang.c. another version of this algorithm (now favored by bernstein)
-    uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why
+    This algorithm (k=33) was first reported by Dan Bernstein many years ago in
+    'comp.lang.c'. Another version of this algorithm (now favored by Bernstein)
+    uses XOR: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why
     it works better than many other constants, prime or not) has never been
     adequately explained.
     it works better than many other constants, prime or not) has never been
     adequately explained.
+
+    If you just want to have a good hash function, and cannot wait, djb2
+    is one of the best string hash functions i know. It has excellent
+    distribution and speed on many different sets of keys and table sizes.
+    You are not likely to do better with one of the "well known" functions
+    such as PJW, K&R, etc.
+
+    Ozan (oz) Yigit [http://www.cs.yorku.ca/~oz/hash.html]
   */
 
   char *str = (char *)key;
   */
 
   char *str = (char *)key;
@@ -1147,15 +1254,6 @@ static int keys_are_equal(void *key1, void *key2)
   return (strcmp((char *)key1, (char *)key2) == 0);
 }
 
   return (strcmp((char *)key1, (char *)key2) == 0);
 }
 
-void freeSetupFileHash(SetupFileHash *hash)
-{
-  if (hash == NULL)
-    return;
-
-  hashtable_destroy(hash, 1);  /* 1 == also free values */
-  free(hash);
-}
-
 SetupFileHash *newSetupFileHash()
 {
   SetupFileHash *new_hash =
 SetupFileHash *newSetupFileHash()
 {
   SetupFileHash *new_hash =
@@ -1164,6 +1262,14 @@ SetupFileHash *newSetupFileHash()
   return new_hash;
 }
 
   return new_hash;
 }
 
+void freeSetupFileHash(SetupFileHash *hash)
+{
+  if (hash == NULL)
+    return;
+
+  hashtable_destroy(hash, 1);  /* 1 == also free values stored in hash */
+}
+
 char *getHashEntry(SetupFileHash *hash, char *token)
 {
   if (hash == NULL)
 char *getHashEntry(SetupFileHash *hash, char *token)
 {
   if (hash == NULL)
@@ -1191,26 +1297,6 @@ void setHashEntry(SetupFileHash *hash, char *token, char *value)
 #ifdef DEBUG
 static void printSetupFileHash(SetupFileHash *hash)
 {
 #ifdef DEBUG
 static void printSetupFileHash(SetupFileHash *hash)
 {
-#if 0
-  if (hash == NULL)
-    return;
-
-  /* iterator constructor only returns valid iterator for non-empty hash */
-  if (hash != NULL && hashtable_count(hash) > 0)
-  {
-    struct hashtable_itr *itr = hashtable_iterator(hash);
-
-    do
-    {
-      printf("token: '%s'\n", (char *)hashtable_iterator_key(itr));
-      printf("value: '%s'\n", (char *)hashtable_iterator_value(itr));
-    }
-    while (hashtable_iterator_advance(itr));
-
-    free(itr);
-  }
-#endif
-
   BEGIN_HASH_ITERATION(hash, itr)
   {
     printf("token: '%s'\n", HASH_ITERATION_TOKEN(itr));
   BEGIN_HASH_ITERATION(hash, itr)
   {
     printf("token: '%s'\n", HASH_ITERATION_TOKEN(itr));
@@ -1221,14 +1307,19 @@ static void printSetupFileHash(SetupFileHash *hash)
 #endif
 #endif
 
 #endif
 #endif
 
-SetupFileHash *loadSetupFileHash(char *filename)
+static void *loadSetupFileData(char *filename, boolean use_hash)
 {
   int line_len;
   char line[MAX_LINE_LEN];
   char *token, *value, *line_ptr;
 {
   int line_len;
   char line[MAX_LINE_LEN];
   char *token, *value, *line_ptr;
-  SetupFileHash *setup_file_hash = newSetupFileHash();
+  void *setup_file_data;
   FILE *file;
 
   FILE *file;
 
+  if (use_hash)
+    setup_file_data = newSetupFileHash();
+  else
+    setup_file_data = newSetupFileList("", "");
+
   if (!(file = fopen(filename, MODE_READ)))
   {
     Error(ERR_WARN, "cannot open configuration file '%s'", filename);
   if (!(file = fopen(filename, MODE_READ)))
   {
     Error(ERR_WARN, "cannot open configuration file '%s'", filename);
@@ -1288,15 +1379,46 @@ SetupFileHash *loadSetupFileHash(char *filename)
        break;
 
     if (*token && *value)
        break;
 
     if (*token && *value)
-      setHashEntry(setup_file_hash, token, value);
+    {
+      if (use_hash)
+       setHashEntry((SetupFileHash *)setup_file_data, token, value);
+      else
+       setListEntry((SetupFileList *)setup_file_data, token, value);
+    }
   }
 
   fclose(file);
 
   }
 
   fclose(file);
 
-  if (hashtable_count(setup_file_hash) == 0)
-    Error(ERR_WARN, "configuration file '%s' is empty", filename);
+  if (use_hash)
+  {
+    if (hashtable_count((SetupFileHash *)setup_file_data) == 0)
+      Error(ERR_WARN, "configuration file '%s' is empty", filename);
+  }
+  else
+  {
+    SetupFileList *setup_file_list = (SetupFileList *)setup_file_data;
+    SetupFileList *first_valid_list_entry = setup_file_list->next;
+
+    /* free empty list header */
+    setup_file_list->next = NULL;
+    freeSetupFileList(setup_file_list);
+    setup_file_data = first_valid_list_entry;
+
+    if (first_valid_list_entry == NULL)
+      Error(ERR_WARN, "configuration file '%s' is empty", filename);
+  }
 
 
-  return setup_file_hash;
+  return setup_file_data;
+}
+
+SetupFileList *loadSetupFileList(char *filename)
+{
+  return (SetupFileList *)loadSetupFileData(filename, FALSE);
+}
+
+SetupFileHash *loadSetupFileHash(char *filename)
+{
+  return (SetupFileHash *)loadSetupFileData(filename, TRUE);
 }
 
 void checkSetupFileHashIdentifier(SetupFileHash *setup_file_hash,
 }
 
 void checkSetupFileHashIdentifier(SetupFileHash *setup_file_hash,
@@ -1995,16 +2117,25 @@ void LoadArtworkInfo()
   /* before sorting, the first entries will be from the user directory */
   artwork.gfx_current =
     getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
   /* before sorting, the first entries will be from the user directory */
   artwork.gfx_current =
     getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
+  if (artwork.gfx_current == NULL)
+    artwork.gfx_current =
+      getTreeInfoFromIdentifier(artwork.gfx_first, GRAPHICS_SUBDIR);
   if (artwork.gfx_current == NULL)
     artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
 
   artwork.snd_current =
     getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
   if (artwork.gfx_current == NULL)
     artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
 
   artwork.snd_current =
     getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
+  if (artwork.snd_current == NULL)
+    artwork.snd_current =
+      getTreeInfoFromIdentifier(artwork.snd_first, SOUNDS_SUBDIR);
   if (artwork.snd_current == NULL)
     artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
 
   artwork.mus_current =
     getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
   if (artwork.snd_current == NULL)
     artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
 
   artwork.mus_current =
     getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
+  if (artwork.mus_current == NULL)
+    artwork.mus_current =
+      getTreeInfoFromIdentifier(artwork.mus_first, MUSIC_SUBDIR);
   if (artwork.mus_current == NULL)
     artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
 
   if (artwork.mus_current == NULL)
     artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
 
@@ -2089,6 +2220,9 @@ void LoadLevelArtworkInfo()
   {
     artwork.gfx_current =
       getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
   {
     artwork.gfx_current =
       getTreeInfoFromIdentifier(artwork.gfx_first, setup.graphics_set);
+    if (artwork.gfx_current == NULL)
+      artwork.gfx_current =
+       getTreeInfoFromIdentifier(artwork.gfx_first, GRAPHICS_SUBDIR);
     if (artwork.gfx_current == NULL)
       artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
   }
     if (artwork.gfx_current == NULL)
       artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first);
   }
@@ -2097,6 +2231,9 @@ void LoadLevelArtworkInfo()
   {
     artwork.snd_current =
       getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
   {
     artwork.snd_current =
       getTreeInfoFromIdentifier(artwork.snd_first, setup.sounds_set);
+    if (artwork.snd_current == NULL)
+      artwork.snd_current =
+       getTreeInfoFromIdentifier(artwork.snd_first, SOUNDS_SUBDIR);
     if (artwork.snd_current == NULL)
       artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
   }
     if (artwork.snd_current == NULL)
       artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first);
   }
@@ -2105,6 +2242,9 @@ void LoadLevelArtworkInfo()
   {
     artwork.mus_current =
       getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
   {
     artwork.mus_current =
       getTreeInfoFromIdentifier(artwork.mus_first, setup.music_set);
+    if (artwork.mus_current == NULL)
+      artwork.mus_current =
+       getTreeInfoFromIdentifier(artwork.mus_first, MUSIC_SUBDIR);
     if (artwork.mus_current == NULL)
       artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
   }
     if (artwork.mus_current == NULL)
       artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first);
   }
@@ -2345,6 +2485,7 @@ static void checkSeriesInfo()
 
       levelnum_value = atoi(levelnum_str);
 
 
       levelnum_value = atoi(levelnum_str);
 
+#if 0
       if (levelnum_value < leveldir_current->first_level)
       {
        Error(ERR_WARN, "additional level %d found", levelnum_value);
       if (levelnum_value < leveldir_current->first_level)
       {
        Error(ERR_WARN, "additional level %d found", levelnum_value);
@@ -2355,6 +2496,7 @@ static void checkSeriesInfo()
        Error(ERR_WARN, "additional level %d found", levelnum_value);
        leveldir_current->last_level = levelnum_value;
       }
        Error(ERR_WARN, "additional level %d found", levelnum_value);
        leveldir_current->last_level = levelnum_value;
       }
+#endif
     }
   }
 
     }
   }