rnd-20021223-1-src
[rocksndiamonds.git] / src / libgame / misc.c
index 910a7e95ef1d18a725549daad837bbf26a3c9ded..e439e71d6cdbcecdaec8c2c9e245bc65b52ef3ff 100644 (file)
@@ -450,6 +450,7 @@ void GetOptions(char *argv[])
   options.graphics_directory = RO_BASE_PATH "/" GRAPHICS_DIRECTORY;
   options.sounds_directory = RO_BASE_PATH "/" SOUNDS_DIRECTORY;
   options.music_directory = RO_BASE_PATH "/" MUSIC_DIRECTORY;
+  options.autoplay_leveldir = NULL;
   options.serveronly = FALSE;
   options.network = FALSE;
   options.verbose = FALSE;
@@ -500,6 +501,7 @@ void GetOptions(char *argv[])
             "  -g, --graphics <directory>    alternative graphics directory\n"
             "  -s, --sounds <directory>      alternative sounds directory\n"
             "  -m, --music <directory>       alternative music directory\n"
+            "  -a, --autoplay <level series> automatically play level tapes\n"
             "  -n, --network                 network multiplayer game\n"
             "      --serveronly              only start network server\n"
             "  -v, --verbose                 verbose mode\n"
@@ -571,6 +573,15 @@ void GetOptions(char *argv[])
       if (option_arg == next_option)
        options_left++;
     }
+    else if (strncmp(option, "-autoplay", option_len) == 0)
+    {
+      if (option_arg == NULL)
+       Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
+
+      options.autoplay_leveldir = option_arg;
+      if (option_arg == next_option)
+       options_left++;
+    }
     else if (strncmp(option, "-network", option_len) == 0)
     {
       options.network = TRUE;
@@ -1439,7 +1450,7 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list,
   }
 
   if (list_pos != num_file_list_entries - 1)
-    Error(ERR_EXIT, "inconsistant config list information -- please fix");
+    Error(ERR_EXIT, "inconsistant config list information (%d != %d) -- please fix", list_pos, num_file_list_entries - 1);
 
   return file_list;
 }
@@ -1550,7 +1561,13 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
 
   if (filename == NULL)
   {
-    Error(ERR_WARN, "cannot find artwork file '%s'", basename);
+    int error_mode = ERR_WARN;
+
+    /* we can get away without sounds and music, but not without graphics */
+    if (*listnode == NULL && artwork_info->type == ARTWORK_TYPE_GRAPHICS)
+      error_mode = ERR_EXIT;
+
+    Error(error_mode, "cannot find artwork file '%s'", basename);
     return;
   }
 
@@ -1597,6 +1614,17 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
     addNodeToList(&artwork_info->content_list, (*listnode)->source_filename,
                  *listnode);
   }
+  else
+  {
+    int error_mode = ERR_WARN;
+
+    /* we can get away without sounds and music, but not without graphics */
+    if (artwork_info->type == ARTWORK_TYPE_GRAPHICS)
+      error_mode = ERR_EXIT;
+
+    Error(error_mode, "cannot load artwork file '%s'", basename);
+    return;
+  }
 }
 
 static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
@@ -1714,7 +1742,7 @@ void FreeCustomArtworkList(struct ArtworkListInfo *artwork_info)
 {
   int i;
 
-  if (artwork_info->artwork_list == NULL)
+  if (artwork_info == NULL || artwork_info->artwork_list == NULL)
     return;
 
 #if 0