From 453e58ce94fd8f1257b08c6ee273382ede528f1a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 16 Feb 2019 12:48:07 +0100 Subject: [PATCH] fixed bug with using too large scroll delay value on smaller playfields --- src/game.c | 4 +++- src/game_em/graphics.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/game.c b/src/game.c index c7589cf0..ad2f231f 100644 --- a/src/game.c +++ b/src/game.c @@ -12532,10 +12532,11 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) } else { - int offset = game.scroll_delay_value; + int offset_raw = game.scroll_delay_value; if (jx != old_jx) // player has moved horizontally { + int offset = MIN(offset_raw, (SCR_FIELDX - 2) / 2); int offset_x = offset * (player->MovDir == MV_LEFT ? +1 : -1); int new_scroll_x = jx - MIDPOSX + offset_x; @@ -12556,6 +12557,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) } else // player has moved vertically { + int offset = MIN(offset_raw, (SCR_FIELDY - 2) / 2); int offset_y = offset * (player->MovDir == MV_UP ? +1 : -1); int new_scroll_y = jy - MIDPOSY + offset_y; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index c1b02110..7a88ecf7 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -549,9 +549,9 @@ void RedrawPlayfield_EM(boolean force_redraw) int max_center_distance_player_nr = getMaxCenterDistancePlayerNr(screen_x, screen_y); int stepsize = TILEX / 8; - int offset = game.scroll_delay_value * TILEX; - int offset_x = offset; - int offset_y = offset; + int offset_raw = game.scroll_delay_value; + int offset_x = MIN(offset_raw, (SCR_FIELDX - 2) / 2) * TILEX; + int offset_y = MIN(offset_raw, (SCR_FIELDY - 2) / 2) * TILEY; int screen_x_old = screen_x; int screen_y_old = screen_y; int x, y, sx, sy; @@ -590,7 +590,7 @@ void RedrawPlayfield_EM(boolean force_redraw) if (game.centered_player_nr == -1) { - if (draw_new_player_location || offset == 0) + if (draw_new_player_location || offset_raw == 0) { setScreenCenteredToAllPlayers(&sx, &sy); } -- 2.34.1