X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftape.c;h=f9c56d1ad12c2d4168522ee4b66c37abfc83a4cf;hb=08097448ca93da43b5f12df9fd180c2375eb6018;hp=4efba84a76f7c05072ca49121845334cc744b940;hpb=6d73c8c86a15e02051dfba65e436d38e4ebc3a36;p=rocksndiamonds.git diff --git a/src/tape.c b/src/tape.c index 4efba84a..f9c56d1a 100644 --- a/src/tape.c +++ b/src/tape.c @@ -629,6 +629,30 @@ static void CloseTapeLogfile(void) // tape control functions // ============================================================================ +void TapeSetDateFromIsoDateString(char *date) +{ + int i; + + // check ISO date string for correct length + if (strlen(date) != 10) + return; + + // check ISO date string for correct format + for (i = 0; i < strlen(date); i++) + if (((i != 4 && i != 7) && (date[i] < '0' || date[i] > '9')) || + ((i == 4 || i == 7) && (date[i] != '-'))) + return; + + int yy = (date[2] - '0') * 10 + (date[3] - '0'); + int mm = (date[5] - '0') * 10 + (date[6] - '0'); + int dd = (date[8] - '0') * 10 + (date[9] - '0'); + + if (mm < 1 || mm > 12 || dd < 1 || dd > 31) + return; + + tape.date = 10000 * yy + 100 * (mm - 1) + dd; +} + void TapeSetDateFromEpochSeconds(time_t epoch_seconds) { struct tm *lt = localtime(&epoch_seconds); @@ -779,7 +803,9 @@ static void TapeAppendRecording(void) void TapeHaltRecording(void) { - tape.counter++; + // only advance tape counter if any input events have been recorded + if (tape.pos[tape.counter].delay > 0) + tape.counter++; // initialize delay for next tape entry (to be able to continue recording) if (tape.counter < MAX_TAPE_LEN) @@ -834,6 +860,8 @@ boolean TapeAddAction(byte action[MAX_TAPE_ACTIONS]) tape.pos[tape.counter].delay++; } + tape.changed = TRUE; + return TRUE; } @@ -932,6 +960,10 @@ void TapeTogglePause(boolean toggle_mode) ModifyPauseButtons(); } + + // stop tape when leaving auto-pause after completely replaying tape + if (tape.playing && !tape.pausing && tape.counter >= tape.length) + TapeStop(); } void TapeStartPlaying(void) @@ -1185,22 +1217,25 @@ static void TapeSingleStep(void) void TapeQuickSave(void) { - if (game_status == GAME_MODE_MAIN) + if (game_status != GAME_MODE_PLAYING) { - Request("No game that can be saved!", REQ_CONFIRM); + Request("No game that could be saved!", REQ_CONFIRM); return; } - if (game_status != GAME_MODE_PLAYING) + if (!tape.recording) + { + Request("No recording that could be saved!", REQ_CONFIRM); + return; + } - if (tape.recording) - TapeHaltRecording(); // prepare tape for saving on-the-fly + TapeHaltRecording(); // prepare tape for saving on-the-fly if (TAPE_IS_EMPTY(tape)) { - Request("No tape that can be saved!", REQ_CONFIRM); + Request("No tape that could be saved!", REQ_CONFIRM); return; }