X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftape.c;h=4406288567f7453dd81a7da6b3fb7b253e922b9c;hb=cdc3c940197937b0508a1eb7dcf44874951908b7;hp=f39c09ec7fff453a585f929008695f5936cf844b;hpb=78dc584e5e2a4afa8b5e5858a356f46a3880aee0;p=rocksndiamonds.git diff --git a/src/tape.c b/src/tape.c index f39c09ec..44062885 100644 --- a/src/tape.c +++ b/src/tape.c @@ -654,10 +654,16 @@ void TapeDeactivateDisplayOff(boolean redraw_display) /* tape control functions */ /* ========================================================================= */ -void TapeErase() +static void TapeSetDate() { time_t epoch_seconds = time(NULL); - struct tm *time = localtime(&epoch_seconds); + struct tm *now = localtime(&epoch_seconds); + + tape.date = 10000 * (now->tm_year % 100) + 100 * now->tm_mon + now->tm_mday; +} + +void TapeErase() +{ int i; tape.length = 0; @@ -670,13 +676,14 @@ void TapeErase() tape.pos[tape.counter].delay = 0; tape.changed = TRUE; - tape.date = 10000*(time->tm_year % 100) + 100*time->tm_mon + time->tm_mday; tape.random_seed = InitRND(NEW_RANDOMIZE); tape.file_version = FILE_VERSION_ACTUAL; tape.game_version = GAME_VERSION_ACTUAL; tape.engine_version = level.game_version; + TapeSetDate(); + #if 0 printf("::: tape.engine_version = level.game_version = %d \n", level.game_version); @@ -704,13 +711,19 @@ static void TapeRewind() InitRND(tape.random_seed); } -void TapeStartRecording() +static void TapeSetRandomSeed(long random_seed) +{ + tape.random_seed = InitRND(random_seed); +} + +void TapeStartRecording(long random_seed) { if (!TAPE_IS_STOPPED(tape)) TapeStop(); TapeErase(); TapeRewind(); + TapeSetRandomSeed(random_seed); tape.recording = TRUE; @@ -725,9 +738,9 @@ void TapeStartRecording() static void TapeStartGameRecording() { - TapeStartRecording(); + TapeStartRecording(NEW_RANDOMIZE); -#if defined(PLATFORM_UNIX) +#if defined(NETWORK_AVALIABLE) if (options.network) SendToServer_StartPlaying(); else @@ -749,7 +762,10 @@ static void TapeAppendRecording() tape.recording = TRUE; tape.changed = TRUE; - DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0); + TapeSetDate(); + + DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date); + DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON, 0); } void TapeHaltRecording() @@ -766,8 +782,10 @@ void TapeHaltRecording() void TapeStopRecording() { +#if 0 if (!tape.recording) return; +#endif TapeHaltRecording(); @@ -790,7 +808,7 @@ void TapeRecordAction(byte action[MAX_PLAYERS]) return; #endif - if (tape.counter >= MAX_TAPELEN - 1) + if (tape.counter >= MAX_TAPE_LEN - 1) { TapeStopRecording(); return; @@ -913,8 +931,10 @@ static void TapeStartGamePlaying() void TapeStopPlaying() { +#if 0 if (!tape.playing) return; +#endif tape.playing = FALSE; tape.pausing = FALSE; @@ -934,7 +954,7 @@ byte *TapePlayAction() if (!tape.playing || tape.pausing) return NULL; - if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */ + if (tape.pause_before_death) /* stop 10 seconds before player gets killed */ { if (!(FrameCounter % 20)) { @@ -952,9 +972,10 @@ byte *TapePlayAction() DrawVideoDisplay(VIDEO_STATE_WARP2_ON, VIDEO_DISPLAY_SYMBOL_ONLY); } - if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH) + if (TapeTime > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH) { TapeTogglePause(TAPE_TOGGLE_MANUAL); + return NULL; } } @@ -973,6 +994,7 @@ byte *TapePlayAction() DrawVideoDisplay(VIDEO_STATE_WARP2_ON, VIDEO_DISPLAY_SYMBOL_ONLY); } } + #if 0 /* !!! this makes things much slower !!! */ else if (tape.warp_forward) @@ -1142,6 +1164,23 @@ void TapeQuickSave() void TapeQuickLoad() { + char *filename = getTapeFilename(level_nr); + + if (!fileExists(filename)) + { + Request("No tape for this level !", REQ_CONFIRM); + + return; + } + + if (tape.recording && !Request("Stop recording and load tape ?", + REQ_ASK | REQ_STAY_CLOSED)) + { + OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + + return; + } + if (game_status == GAME_MODE_PLAYING || game_status == GAME_MODE_MAIN) { TapeStop(); @@ -1155,8 +1194,12 @@ void TapeQuickLoad() tape.quick_resume = TRUE; } - else - Request("No tape for this level !", REQ_CONFIRM); + else /* this should not happen (basically checked above) */ + { + int reopen_door = (game_status == GAME_MODE_PLAYING ? REQ_REOPEN : 0); + + Request("No tape for this level !", REQ_CONFIRM | reopen_door); + } } } @@ -1178,8 +1221,6 @@ void InsertSolutionTape() * tape autoplay functions * ------------------------------------------------------------------------- */ -#define MAX_NUM_AUTOPLAY_LEVELS 1000 - void AutoPlayTape() { static LevelDirTree *autoplay_leveldir = NULL; @@ -1187,7 +1228,9 @@ void AutoPlayTape() static int autoplay_level_nr = -1; static int num_levels_played = 0; static int num_levels_solved = 0; - static boolean levels_failed[MAX_NUM_AUTOPLAY_LEVELS]; + static int num_tape_missing = 0; + static boolean level_failed[MAX_TAPES_PER_SET]; + static boolean tape_missing[MAX_TAPES_PER_SET]; int i; if (autoplay_initialized) @@ -1196,10 +1239,11 @@ void AutoPlayTape() printf("%s.\n", tape.auto_play_level_solved ? "solved" : "NOT SOLVED"); num_levels_played++; + if (tape.auto_play_level_solved) num_levels_solved++; - else if (level_nr >= 0 && level_nr < MAX_NUM_AUTOPLAY_LEVELS) - levels_failed[level_nr] = TRUE; + else if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET) + level_failed[level_nr] = TRUE; } else { @@ -1215,11 +1259,10 @@ void AutoPlayTape() leveldir_current = autoplay_leveldir; - if (global.autoplay_level_nr != -1) - { - autoplay_leveldir->first_level = global.autoplay_level_nr; - autoplay_leveldir->last_level = global.autoplay_level_nr; - } + if (autoplay_leveldir->first_level < 0) + autoplay_leveldir->first_level = 0; + if (autoplay_leveldir->last_level >= MAX_TAPES_PER_SET) + autoplay_leveldir->last_level = MAX_TAPES_PER_SET - 1; autoplay_level_nr = autoplay_leveldir->first_level; @@ -1233,8 +1276,11 @@ void AutoPlayTape() printf_line("=", 79); printf("\n"); - for (i = 0; i < MAX_NUM_AUTOPLAY_LEVELS; i++) - levels_failed[i] = FALSE; + for (i = 0; i < MAX_TAPES_PER_SET; i++) + { + level_failed[i] = FALSE; + tape_missing[i] = FALSE; + } autoplay_initialized = TRUE; } @@ -1243,6 +1289,9 @@ void AutoPlayTape() { level_nr = autoplay_level_nr++; + if (!global.autoplay_all && !global.autoplay_level[level_nr]) + continue; + TapeErase(); printf("Level %03d: ", level_nr); @@ -1254,6 +1303,12 @@ void AutoPlayTape() continue; } +#if 0 + /* ACTIVATE THIS FOR LOADING/TESTING OF LEVELS ONLY */ + printf("(only testing level)\n"); + continue; +#endif + LoadSolutionTape(level_nr); #if 1 if (tape.no_valid_file) @@ -1261,6 +1316,10 @@ void AutoPlayTape() if (TAPE_IS_EMPTY(tape)) #endif { + num_tape_missing++; + if (level_nr >= 0 && level_nr < MAX_TAPES_PER_SET) + tape_missing[level_nr] = TRUE; + printf("(no tape)\n"); continue; } @@ -1283,13 +1342,25 @@ void AutoPlayTape() printf("LEVELDIR '%s', SOLVED %d/%d (%d%%)", autoplay_leveldir->identifier, num_levels_solved, num_levels_played, (num_levels_played ? num_levels_solved * 100 / num_levels_played :0)); + if (num_levels_played != num_levels_solved) { printf(", FAILED:"); - for (i = 0; i < MAX_NUM_AUTOPLAY_LEVELS; i++) - if (levels_failed[i]) + for (i = 0; i < MAX_TAPES_PER_SET; i++) + if (level_failed[i]) printf(" %03d", i); } + +#if 0 + if (num_tape_missing > 0) + { + printf(", NO TAPE:"); + for (i = 0; i < MAX_TAPES_PER_SET; i++) + if (tape_missing[i]) + printf(" %03d", i); + } +#endif + printf("\n"); printf_line("=", 79); @@ -1537,9 +1608,15 @@ static void HandleTapeButtons(struct GadgetInfo *gi) } else /* AUTO PAUSE -> NORMAL PLAY */ { +#if 1 + if (tape.warp_forward) + TapeStopWarpForward(); +#else + tape.warp_forward = FALSE; +#endif tape.fast_forward = FALSE; tape.pause_before_death = FALSE; - tape.warp_forward = FALSE; + #if 1 DrawVideoDisplay(VIDEO_STATE_PBEND_OFF | VIDEO_STATE_PLAY_ON, 0); #else