From 97648ab29c587dee3e5fa5be3cc0cfda96543f22 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 14 Sep 2020 17:16:00 +0200 Subject: [PATCH] moved code for fixing single-player tapes to separate function --- src/events.c | 11 +---------- src/tape.c | 16 ++++++++++++++++ src/tape.h | 2 ++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/events.c b/src/events.c index d912e820..2df4eb7b 100644 --- a/src/events.c +++ b/src/events.c @@ -1858,16 +1858,7 @@ static void HandleKeysSpecial(Key key) else if (strSuffix(cheat_input, ":fix-tape") || strSuffix(cheat_input, ":ft")) { - /* fix single-player tapes that contain player input for more than one - player (due to a bug in 3.3.1.2 and earlier versions), which results - in playing levels with more than one player in multi-player mode, - even though the tape was originally recorded in single-player mode */ - - // remove player input actions for all players but the first one - for (i = 1; i < MAX_PLAYERS; i++) - tape.player_participates[i] = FALSE; - - tape.changed = TRUE; + FixTape_ForceSinglePlayer(); } else if (strSuffix(cheat_input, ":save-native-level") || strSuffix(cheat_input, ":snl")) diff --git a/src/tape.c b/src/tape.c index 4894f113..29886a5c 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1145,6 +1145,22 @@ boolean PlaySolutionTape(void) return TRUE; } +void FixTape_ForceSinglePlayer(void) +{ + int i; + + /* fix single-player tapes that contain player input for more than one + player (due to a bug in 3.3.1.2 and earlier versions), which results + in playing levels with more than one player in multi-player mode, + even though the tape was originally recorded in single-player mode */ + + // remove player input actions for all players but the first one + for (i = 1; i < MAX_PLAYERS; i++) + tape.player_participates[i] = FALSE; + + tape.changed = TRUE; +} + // ---------------------------------------------------------------------------- // tape autoplay functions diff --git a/src/tape.h b/src/tape.h index 341dca22..7b9c44f8 100644 --- a/src/tape.h +++ b/src/tape.h @@ -257,6 +257,8 @@ boolean hasSolutionTape(void); boolean InsertSolutionTape(void); boolean PlaySolutionTape(void); +void FixTape_ForceSinglePlayer(void); + void AutoPlayTapes(void); void PatchTapes(void); -- 2.34.1