From 8c6f354ceb0f49857489ef2df0303e155e7f6846 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 31 Mar 2002 23:35:09 +0200 Subject: [PATCH] rnd-20020331-2-src --- src/files.c | 2 ++ src/game.c | 6 +++--- src/tape.c | 42 +++++++++++++++++++++++++++--------------- src/tape.h | 2 -- src/tools.c | 25 ++++++++++++++++--------- 5 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/files.c b/src/files.c index 3a53cb09..d5ad588b 100644 --- a/src/files.c +++ b/src/files.c @@ -798,6 +798,8 @@ static int LoadTape_BODY(FILE *file, int chunk_size, struct TapeInfo *tape) } else if (tape->file_version < FILE_VERSION_2_0) { + /* convert pre-2.0 tapes to new tape format */ + if (tape->pos[i].delay > 1) { /* action part */ diff --git a/src/game.c b/src/game.c index c8fadba4..0c369f03 100644 --- a/src/game.c +++ b/src/game.c @@ -4971,7 +4971,7 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) return FALSE; #else if (!FrameReached(&player->move_delay, player->move_delay_value) && - !(tape.playing && tape.game_version < FILE_VERSION_2_0)) + !(tape.playing && tape.game_version < GAME_VERSION_2_0)) return FALSE; #endif @@ -5829,7 +5829,7 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; #else if (!FrameReached(&player->push_delay, player->push_delay_value) && - !(tape.playing && tape.game_version < FILE_VERSION_2_0) && + !(tape.playing && tape.game_version < GAME_VERSION_2_0) && element != EL_SPRING) return MF_NO_ACTION; #endif @@ -6071,7 +6071,7 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; #else if (!FrameReached(&player->push_delay, player->push_delay_value) && - !(tape.playing && tape.game_version < FILE_VERSION_2_0) && + !(tape.playing && tape.game_version < GAME_VERSION_2_0) && element != EL_BALLOON) return MF_NO_ACTION; #endif diff --git a/src/tape.c b/src/tape.c index efa95156..96342603 100644 --- a/src/tape.c +++ b/src/tape.c @@ -30,6 +30,9 @@ #define NUM_TAPE_BUTTONS 6 +/* values for tape handling */ +#define TAPE_PAUSE_SECONDS_BEFORE_DEATH 5 + /* forward declaration for internal use */ static void HandleTapeButtons(struct GadgetInfo *); @@ -315,6 +318,8 @@ void TapeStartRecording() DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date); DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0); MapTapeIndexButton(); + + SetDrawDeactivationMask(REDRAW_NONE); } void TapeStopRecording() @@ -393,6 +398,14 @@ void TapeTogglePause() SetDrawDeactivationMask(REDRAW_NONE); RedrawPlayfield(TRUE, 0,0,0,0); } + + if (tape.index_search) + { + tape.index_search = FALSE; + + SetDrawDeactivationMask(REDRAW_NONE); + RedrawPlayfield(TRUE, 0,0,0,0); + } } void TapeStartPlaying() @@ -418,6 +431,8 @@ void TapeStartPlaying() DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date); DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0); MapTapeIndexButton(); + + SetDrawDeactivationMask(REDRAW_NONE); } void TapeStopPlaying() @@ -457,23 +472,13 @@ byte *TapePlayAction() } } - if (tape.index_search) + if (tape.counter >= tape.length) /* end of tape reached */ { - if (tape.counter >= tape.length) - { - tape.index_search = FALSE; - - SetDrawDeactivationMask(REDRAW_NONE); - RedrawPlayfield(TRUE, 0,0,0,0); - + if (tape.index_search) TapeTogglePause(); - return NULL; - } - } + else + TapeStop(); - if (tape.counter >= tape.length) - { - TapeStop(); return NULL; } @@ -687,7 +692,9 @@ static void HandleTapeButtons(struct GadgetInfo *gi) printf("Going to index mark ...\n"); tape.index_search = TRUE; - SetDrawDeactivationMask(REDRAW_FIELD); + + if (!tape.fast_forward || tape.pause_before_death) + SetDrawDeactivationMask(REDRAW_FIELD); } break; @@ -719,6 +726,11 @@ static void HandleTapeButtons(struct GadgetInfo *gi) { if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */ { + if (tape.game_version != GAME_VERSION_ACTUAL && + !Request("This may break old version tape ! Append anyway ?", + REQ_ASK)) + break; + tape.pos[tape.counter].delay = tape.delay_played; tape.playing = FALSE; tape.recording = TRUE; diff --git a/src/tape.h b/src/tape.h index 33fa8089..cfca6822 100644 --- a/src/tape.h +++ b/src/tape.h @@ -16,8 +16,6 @@ #include "main.h" -#define TAPE_PAUSE_SECONDS_BEFORE_DEATH 3 - /* some positions in the video tape control window */ #define VIDEO_DISPLAY1_XPOS 5 #define VIDEO_DISPLAY1_YPOS 5 diff --git a/src/tools.c b/src/tools.c index fe5c9f69..98292409 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1775,6 +1775,9 @@ int REQ_in_range(int x, int y) return 0; } +#define MAX_REQUEST_LINES 13 +#define MAX_REQUEST_LINE_LEN 7 + boolean Request(char *text, unsigned int req_state) { int mx, my, ty, result = -1; @@ -1803,31 +1806,35 @@ boolean Request(char *text, unsigned int req_state) ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE); /* write text for request */ - for(ty=0; ty<13; ty++) + for(ty=0; ty < MAX_REQUEST_LINES; ty++) { + char text_line[MAX_REQUEST_LINE_LEN + 1]; int tx, tl, tc; - char txt[256]; if (!*text) break; - for(tl=0,tx=0; tx<7; tl++,tx++) + for(tl=0,tx=0; tx < MAX_REQUEST_LINE_LEN; tl++,tx++) { tc = *(text + tx); - if (!tc || tc == 32) + if (!tc || tc == ' ') break; } + if (!tl) { text++; ty--; continue; } - sprintf(txt, text); - txt[tl] = 0; - DrawTextExt(drawto, DX + 51 - (tl * 14)/2, DY + 8 + ty * 16, - txt, FS_SMALL, FC_YELLOW); - text += tl + (tc == 32 ? 1 : 0); + + strncpy(text_line, text, tl); + text_line[tl] = 0; + + DrawTextExt(drawto, DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, + text_line, FS_SMALL, FC_YELLOW); + + text += tl + (tc == ' ' ? 1 : 0); } if (req_state & REQ_ASK) -- 2.34.1