rnd-20040606-1-src
[rocksndiamonds.git] / src / init.c
index bbc20e0dfbf51dbd757cfb9bce1abf97c18d1d57..02b29cdc66275026b1f57773c30654ef56a791c0 100644 (file)
@@ -3656,6 +3656,7 @@ void InitElementPropertiesEngine(int engine_version)
 static void InitGlobal()
 {
   global.autoplay_leveldir = NULL;
+  global.convert_leveldir = NULL;
 
   global.frames_per_second = 0;
   global.fps_slowdown = FALSE;
@@ -3791,6 +3792,20 @@ void Execute_Command(char *command)
       global.autoplay_level_nr = atoi(str_ptr);        /* get level_nr value */
     }
   }
+  else if (strncmp(command, "convert ", 8) == 0)
+  {
+    char *str_copy = getStringCopy(&command[8]);
+    char *str_ptr = strchr(str_copy, ' ');
+
+    global.convert_leveldir = str_copy;
+    global.convert_level_nr = -1;
+
+    if (str_ptr != NULL)
+    {
+      *str_ptr++ = '\0';                       /* terminate leveldir string */
+      global.convert_level_nr = atoi(str_ptr); /* get level_nr value */
+    }
+  }
   else
   {
     Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
@@ -4396,6 +4411,11 @@ void OpenAll()
     AutoPlayTape();
     return;
   }
+  else if (global.convert_leveldir)
+  {
+    ConvertLevels();
+    return;
+  }
 
   game_status = GAME_MODE_MAIN;