From 3fd63fd1559c678f0b63ba48d0de211aab1cf591 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 29 Sep 2020 21:35:09 +0200 Subject: [PATCH] fixed single-step mode for wrap-around levels in EM engine This fixes a graphical bug when wrapping around in single-step mode by drawing wrap-around animation before going to single step pause mode. --- src/engines.h | 2 +- src/game_em/game.c | 9 ++++++-- src/game_em/global.h | 2 ++ src/game_em/logic.c | 51 +++++++++++++++++++++++++++++++++----------- src/tools.c | 10 +++++---- 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/engines.h b/src/engines.h index 46cdbf4f..826ad964 100644 --- a/src/engines.h +++ b/src/engines.h @@ -33,7 +33,7 @@ boolean isActivePlayer_EM(int); void PlayLevelSound_EM(int, int, int, int); void InitGraphicInfo_EM(void); -void CheckSingleStepMode_EM(byte action[], int, boolean, boolean, boolean); +boolean CheckSingleStepMode_EM(byte action[], int, boolean, boolean, boolean); void SetGfxAnimation_EM(struct GraphicInfo_EM *, int, int, int, int); void getGraphicSourceObjectExt_EM(struct GraphicInfo_EM *, int, int, int, int); diff --git a/src/game_em/game.c b/src/game_em/game.c index 3115fb5a..8443ff05 100644 --- a/src/game_em/game.c +++ b/src/game_em/game.c @@ -108,8 +108,13 @@ void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode) ply[i].dynamite_cnt < 5) any_player_dropping = TRUE; - CheckSingleStepMode_EM(action, frame, game_em.any_player_moving, - game_em.any_player_snapping, any_player_dropping); + boolean single_step_mode_paused = + CheckSingleStepMode_EM(action, frame, game_em.any_player_moving, + game_em.any_player_snapping, any_player_dropping); + + // draw wrapping around before going to single step pause mode + if (single_step_mode_paused && logic_check_wrap()) + logic_move(); RedrawPlayfield_EM(FALSE); } diff --git a/src/game_em/global.h b/src/game_em/global.h index 3efba447..33b96423 100644 --- a/src/game_em/global.h +++ b/src/game_em/global.h @@ -19,6 +19,8 @@ void game_init_cave_buffers(void); void play_sound(int, int, int); void play_element_sound(int, int, int, int); +boolean logic_check_wrap(void); +void logic_move(void); void logic_init(void); void logic(void); diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 5055be5a..8b759630 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -7381,27 +7381,28 @@ static void handle_tile(int x, int y) } } -static void logic_players(void) +boolean logic_check_wrap(void) { - int start_check_nr; int i; - cave = lev.cave; - next = lev.next; - boom = lev.boom; - - game_em.any_player_moving = FALSE; - game_em.any_player_snapping = FALSE; - - /* must test for death and actually kill separately */ for (i = 0; i < MAX_PLAYERS; i++) { - boolean ply_kill = player_killed(&ply[i]); + if (!ply[i].alive) + continue; - if (ply[i].alive && ply_kill) - kill_player(&ply[i]); + /* check for wrap-around movement */ + if (ply[i].x < lev.left || + ply[i].x > lev.right - 1) + return TRUE; } + return FALSE; +} + +void logic_move(void) +{ + int i; + for (i = 0; i < MAX_PLAYERS; i++) { if (!ply[i].alive) @@ -7425,6 +7426,30 @@ static void logic_players(void) ply[i].prev_y = ply[i].y; ply[i].anim = PLY_still; } +} + +static void logic_players(void) +{ + int start_check_nr; + int i; + + cave = lev.cave; + next = lev.next; + boom = lev.boom; + + game_em.any_player_moving = FALSE; + game_em.any_player_snapping = FALSE; + + /* must test for death and actually kill separately */ + for (i = 0; i < MAX_PLAYERS; i++) + { + boolean ply_kill = player_killed(&ply[i]); + + if (ply[i].alive && ply_kill) + kill_player(&ply[i]); + } + + logic_move(); start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 + (game_em.random & 256 ? 0 : 1)); diff --git a/src/tools.c b/src/tools.c index 2c30df83..a4199a14 100644 --- a/src/tools.c +++ b/src/tools.c @@ -9078,10 +9078,10 @@ static void CheckSaveEngineSnapshot_MM(boolean element_clicked, } } -void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame, - boolean any_player_moving, - boolean any_player_snapping, - boolean any_player_dropping) +boolean CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame, + boolean any_player_moving, + boolean any_player_snapping, + boolean any_player_dropping) { if (tape.single_step && tape.recording && !tape.pausing) if (frame == 7 && !any_player_dropping) @@ -9089,6 +9089,8 @@ void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame, CheckSaveEngineSnapshot_EM(action, frame, any_player_moving, any_player_snapping, any_player_dropping); + + return tape.pausing; } void CheckSingleStepMode_SP(boolean murphy_is_waiting, -- 2.34.1