struct AutoPlayInfo
{
LevelDirTree *leveldir;
- boolean initialized;
boolean all_levelsets;
int last_level_nr;
int level_nr;
Print("Number of levels: %d\n", autoplay->leveldir->levels);
PrintLine("=", 79);
Print("\n");
+
+ DrawInitTextItem(autoplay->leveldir->name);
}
static void PrintTapeReplayProgress(boolean replay_finished)
// tape autoplay functions
// ----------------------------------------------------------------------------
+static TreeInfo *getNextValidAutoPlayEntry(TreeInfo *node)
+{
+ node = getNextValidTreeInfoEntry(node);
+
+ while (node && node->is_copy)
+ node = getNextValidTreeInfoEntry(node);
+
+ return node;
+}
+
+static TreeInfo *getFirstValidAutoPlayEntry(TreeInfo *node)
+{
+ node = getFirstValidTreeInfoEntry(node);
+
+ if (node && node->is_copy)
+ return getNextValidAutoPlayEntry(node);
+
+ return node;
+}
+
static void AutoPlayTapes_SetScoreEntry(int score, int time)
{
// set unique basename for score tape (for uploading to score server)
Fail("cannot upload score tape to score server");
}
+ UPDATE_BUSY_STATE();
+
Delay(20);
}
Print("- uploading score tape to score server - uploaded.\n");
}
-void AutoPlayTapes(void)
+static int AutoPlayTapesExt(boolean initialize)
{
static struct AutoPlayInfo autoplay;
+ static int num_tapes = 0;
static int patch_nr = 0;
static char *patch_name[] =
{
boolean init_level_set = FALSE;
int i;
- if (autoplay.initialized)
+ if (!initialize)
{
if (global.autoplay_mode == AUTOPLAY_MODE_FIX)
{
Fail("specify player name when uploading solution tapes");
}
- DrawCompleteVideoDisplay();
+ if (global.autoplay_mode != AUTOPLAY_MODE_UPLOAD)
+ DrawCompleteVideoDisplay();
- audio.sound_enabled = FALSE;
- setup.engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_OFF);
+ if (program.headless)
+ {
+ audio.sound_enabled = FALSE;
+ setup.engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_OFF);
+ }
if (strSuffix(global.autoplay_leveldir, ".tape"))
{
if (autoplay.all_levelsets)
{
// start auto-playing first level set
- autoplay.leveldir = getFirstValidTreeInfoEntry(leveldir_first);
+ autoplay.leveldir = getFirstValidAutoPlayEntry(leveldir_first);
}
else
{
// auto-play selected level set
autoplay.leveldir = getTreeInfoFromIdentifier(leveldir_first,
global.autoplay_leveldir);
-
}
if (autoplay.leveldir == NULL)
if (global.autoplay_mode == AUTOPLAY_MODE_FIX)
options.mytapes = TRUE;
- init_level_set = TRUE;
+ num_tapes = 0;
- autoplay.initialized = TRUE;
+ init_level_set = TRUE;
}
while (1)
if (global.autoplay_mode != AUTOPLAY_MODE_FIX || patch_nr == 0)
level_nr = autoplay.level_nr++;
+ UPDATE_BUSY_STATE();
+
// check if all tapes for this level set have been processed
if (level_nr > autoplay.leveldir->last_level)
{
break;
// continue with next level set
- autoplay.leveldir = getNextValidTreeInfoEntry(autoplay.leveldir);
+ autoplay.leveldir = getNextValidAutoPlayEntry(autoplay.leveldir);
// all level sets processed
if (autoplay.leveldir == NULL)
}
}
+ num_tapes++;
+
if (global.autoplay_mode == AUTOPLAY_MODE_UPLOAD)
{
boolean use_temporary_tape_file = FALSE;
autoplay.last_level_nr = level_nr;
- return;
+ return num_tapes;
}
- CloseAllAndExit(0);
+ if (program.headless)
+ CloseAllAndExit(0);
+
+ return num_tapes;
+}
+
+int AutoPlayTapes(void)
+{
+ return AutoPlayTapesExt(TRUE);
+}
+
+int AutoPlayTapesContinue(void)
+{
+ return AutoPlayTapesExt(FALSE);
}