From: Holger Schemel Date: Sat, 16 Feb 2019 11:48:07 +0000 (+0100) Subject: fixed bug with using too large scroll delay value on smaller playfields X-Git-Tag: 4.1.2.0~10 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=453e58ce94fd8f1257b08c6ee273382ede528f1a;p=rocksndiamonds.git fixed bug with using too large scroll delay value on smaller playfields --- 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); }