strPrefix(command, "autowarp ") ||
strPrefix(command, "autotest ") ||
strPrefix(command, "autosave ") ||
+ strPrefix(command, "autoupload ") ||
strPrefix(command, "autofix "))
{
char *arg_ptr = strchr(command, ' ');
strPrefix(command, "autowarp") ? AUTOPLAY_MODE_WARP :
strPrefix(command, "autotest") ? AUTOPLAY_MODE_TEST :
strPrefix(command, "autosave") ? AUTOPLAY_MODE_SAVE :
+ strPrefix(command, "autoupload") ? AUTOPLAY_MODE_UPLOAD :
strPrefix(command, "autofix") ? AUTOPLAY_MODE_FIX :
AUTOPLAY_MODE_NONE);
#define AUTOPLAY_WARP (1 << 2)
#define AUTOPLAY_TEST (1 << 3)
#define AUTOPLAY_SAVE (1 << 4)
-#define AUTOPLAY_FIX (1 << 5)
+#define AUTOPLAY_UPLOAD (1 << 5)
+#define AUTOPLAY_FIX (1 << 6)
#define AUTOPLAY_WARP_NO_DISPLAY AUTOPLAY_TEST
#define AUTOPLAY_MODE_NONE 0
#define AUTOPLAY_MODE_WARP (AUTOPLAY_MODE_FFWD | AUTOPLAY_WARP)
#define AUTOPLAY_MODE_TEST (AUTOPLAY_MODE_WARP | AUTOPLAY_TEST)
#define AUTOPLAY_MODE_SAVE (AUTOPLAY_MODE_TEST | AUTOPLAY_SAVE)
+#define AUTOPLAY_MODE_UPLOAD (AUTOPLAY_MODE_TEST | AUTOPLAY_UPLOAD)
#define AUTOPLAY_MODE_FIX (AUTOPLAY_MODE_TEST | AUTOPLAY_FIX)
#define AUTOPLAY_MODE_WARP_NO_DISPLAY AUTOPLAY_MODE_TEST
PrintLine("=", 79);
if (global.autoplay_mode == AUTOPLAY_MODE_FIX)
Print("Automatically fixing level tapes\n");
+ else if (global.autoplay_mode == AUTOPLAY_MODE_UPLOAD)
+ Print("Automatically uploading level tapes\n");
else
Print("Automatically playing level tapes\n");
PrintLine("-", 79);
}
}
+ if (global.autoplay_mode == AUTOPLAY_MODE_UPLOAD)
+ {
+ // set unique basename for score tape (for uploading to score server)
+ strcpy(tape.score_tape_basename, getScoreTapeBasename(setup.player_name));
+
+ // store score in first score entry
+ scores.last_added = 0;
+
+ struct ScoreEntry *entry = &scores.entry[scores.last_added];
+
+ strncpy(entry->tape_basename, tape.score_tape_basename, MAX_FILENAME_LEN);
+ strncpy(entry->name, setup.player_name, MAX_PLAYER_NAME_LEN);
+
+ entry->score = 0;
+ entry->time = 0;
+
+ Print("Tape %03d:\n", level_nr);
+ PrintNoLog("- uploading score tape to score server ... ");
+
+ server_scores.uploaded = FALSE;
+
+ if (tape_filename == NULL)
+ tape_filename = (options.mytapes ? getTapeFilename(level_nr) :
+ getSolutionTapeFilename(level_nr));
+
+ SaveServerScoreFromFile(level_nr, tape_filename);
+
+ // required for uploading multiple tapes
+ tape_filename = NULL;
+
+ unsigned int upload_delay = 0;
+ unsigned int upload_delay_value = 10000;
+
+ ResetDelayCounter(&upload_delay);
+
+ // wait for score tape to be successfully uploaded (and fail on timeout)
+ while (!server_scores.uploaded)
+ {
+ if (DelayReached(&upload_delay, upload_delay_value))
+ {
+ PrintNoLog("\r");
+ Print("- uploading score tape to score server - TIMEOUT.\n");
+
+ Fail("cannot upload score tape to score server");
+ }
+
+ Delay(20);
+ }
+
+ PrintNoLog("\r");
+ Print("- uploading score tape to score server - uploaded.\n");
+
+ continue;
+ }
+
InitCounter();
if (options.tape_log_filename != NULL)