PrintLine("-", 79);
}
+void DumpLevels(void)
+{
+ static LevelDirTree *dumplevel_leveldir = NULL;
+
+ dumplevel_leveldir = getTreeInfoFromIdentifier(leveldir_first,
+ global.dumplevel_leveldir);
+
+ if (dumplevel_leveldir == NULL)
+ Fail("no such level identifier: '%s'", global.dumplevel_leveldir);
+
+ if (global.dumplevel_level_nr < dumplevel_leveldir->first_level ||
+ global.dumplevel_level_nr > dumplevel_leveldir->last_level)
+ Fail("no such level number: %d", global.dumplevel_level_nr);
+
+ leveldir_current = dumplevel_leveldir;
+
+ LoadLevel(global.dumplevel_level_nr);
+ DumpLevel(&level);
+
+ CloseAllAndExit(0);
+}
+
// ============================================================================
// tape file functions
PrintLine("-", 79);
}
+void DumpTapes(void)
+{
+ static LevelDirTree *dumptape_leveldir = NULL;
+
+ dumptape_leveldir = getTreeInfoFromIdentifier(leveldir_first,
+ global.dumptape_leveldir);
+
+ if (dumptape_leveldir == NULL)
+ Fail("no such level identifier: '%s'", global.dumptape_leveldir);
+
+ if (global.dumptape_level_nr < dumptape_leveldir->first_level ||
+ global.dumptape_level_nr > dumptape_leveldir->last_level)
+ Fail("no such level number: %d", global.dumptape_level_nr);
+
+ leveldir_current = dumptape_leveldir;
+
+ if (options.mytapes)
+ LoadTape(global.dumptape_level_nr);
+ else
+ LoadSolutionTape(global.dumptape_level_nr);
+
+ DumpTape(&tape);
+
+ CloseAllAndExit(0);
+}
+
// ============================================================================
// score file functions
void SaveLevelTemplate(void);
void SaveNativeLevel(struct LevelInfo *);
void DumpLevel(struct LevelInfo *);
+void DumpLevels(void);
boolean SaveLevelChecked(int);
void CopyNativeLevel_RND_to_Native(struct LevelInfo *);
void SaveTape(int);
void SaveScoreTape(int);
void DumpTape(struct TapeInfo *);
+void DumpTapes(void);
boolean SaveTapeChecked(int);
boolean SaveTapeChecked_LevelSolved(int);
global.autoplay_leveldir = NULL;
global.patchtapes_leveldir = NULL;
global.convert_leveldir = NULL;
+ global.dumplevel_leveldir = NULL;
+ global.dumptape_leveldir = NULL;
global.create_images_dir = NULL;
global.frames_per_second = 0;
{
char *filename = &command[11];
- if (!fileExists(filename))
+ if (fileExists(filename))
+ {
+ LoadLevelFromFilename(&level, filename);
+ DumpLevel(&level);
+
+ exit(0);
+ }
+
+ char *leveldir = getStringCopy(filename); // read command parameters
+ char *level_nr = strchr(leveldir, ' ');
+
+ if (level_nr == NULL)
Fail("cannot open file '%s'", filename);
- LoadLevelFromFilename(&level, filename);
- DumpLevel(&level);
+ *level_nr++ = '\0';
- exit(0);
+ global.dumplevel_leveldir = leveldir;
+ global.dumplevel_level_nr = atoi(level_nr);
+
+ program.headless = TRUE;
}
else if (strPrefix(command, "dump tape "))
{
char *filename = &command[10];
- if (!fileExists(filename))
+ if (fileExists(filename))
+ {
+ LoadTapeFromFilename(filename);
+ DumpTape(&tape);
+
+ exit(0);
+ }
+
+ char *leveldir = getStringCopy(filename); // read command parameters
+ char *level_nr = strchr(leveldir, ' ');
+
+ if (level_nr == NULL)
Fail("cannot open file '%s'", filename);
- LoadTapeFromFilename(filename);
- DumpTape(&tape);
+ *level_nr++ = '\0';
- exit(0);
+ global.dumptape_leveldir = leveldir;
+ global.dumptape_level_nr = atoi(level_nr);
+
+ program.headless = TRUE;
}
else if (strPrefix(command, "autoplay ") ||
strPrefix(command, "autoffwd ") ||
ConvertLevels();
return;
}
+ else if (global.dumplevel_leveldir)
+ {
+ DumpLevels();
+ return;
+ }
+ else if (global.dumptape_leveldir)
+ {
+ DumpTapes();
+ return;
+ }
else if (global.create_images_dir)
{
CreateLevelSketchImages();