From: Holger Schemel Date: Wed, 6 Apr 2022 12:13:06 +0000 (+0200) Subject: moved code for buttons to stop game or tape to separate functions X-Git-Tag: 4.3.2.0~39 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c0f9aa871d5922a6343facd23b44c2d1cb1f8c92;p=rocksndiamonds.git moved code for buttons to stop game or tape to separate functions --- diff --git a/src/game.c b/src/game.c index 6a424064..f7392fe4 100644 --- a/src/game.c +++ b/src/game.c @@ -16577,13 +16577,7 @@ static void HandleGameButtonsExt(int id, int button) case GAME_CTRL_ID_STOP: case GAME_CTRL_ID_PANEL_STOP: case GAME_CTRL_ID_TOUCH_STOP: - if (game_status == GAME_MODE_MAIN) - break; - - if (tape.playing) - TapeStop(); - else - RequestQuitGame(FALSE); + TapeStopGame(); break; diff --git a/src/tape.c b/src/tape.c index 68ffadcf..d93c6632 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1088,6 +1088,27 @@ void TapeStop(void) } } +static void TapeStopGameOrTape(boolean stop_game) +{ + if (!tape.playing && stop_game) + RequestQuitGame(FALSE); + else + TapeStop(); +} + +void TapeStopGame(void) +{ + if (game_status == GAME_MODE_MAIN) + return; + + TapeStopGameOrTape(TRUE); +} + +void TapeStopTape(void) +{ + TapeStopGameOrTape(FALSE); +} + unsigned int GetTapeLengthFrames(void) { unsigned int tape_length_frames = 0; @@ -2393,7 +2414,7 @@ static void HandleTapeButtonsExt(int id) break; case TAPE_CTRL_ID_STOP: - TapeStop(); + TapeStopTape(); break; diff --git a/src/tape.h b/src/tape.h index 022e9ca5..b418ea33 100644 --- a/src/tape.h +++ b/src/tape.h @@ -263,6 +263,8 @@ void TapeStartPlaying(void); void TapeStopPlaying(void); byte *TapePlayAction(void); void TapeStop(void); +void TapeStopGame(void); +void TapeStopTape(void); void TapeErase(void); unsigned int GetTapeLengthFrames(void); unsigned int GetTapeLengthSeconds(void);