From 2dd4bcb6746420108015bef0b47d42c7d893076a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 6 Dec 2024 20:13:19 +0100 Subject: [PATCH] fixed accessing invalid array position --- src/game.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/game.c b/src/game.c index bcc86408..ee067b8a 100644 --- a/src/game.c +++ b/src/game.c @@ -15275,12 +15275,6 @@ static boolean SnapField(struct PlayerInfo *player, int dx, int dy) { int jx = player->jx, jy = player->jy; int x = jx + dx, y = jy + dy; - int snap_direction = (dx == -1 ? MV_LEFT : - dx == +1 ? MV_RIGHT : - dy == -1 ? MV_UP : - dy == +1 ? MV_DOWN : MV_NONE); - boolean can_continue_snapping = (level.continuous_snapping && - WasJustFalling[x][y] < CHECK_DELAY_FALLING); if (player->MovPos != 0 && game.engine_version >= VERSION_IDENT(2,2,0,0)) return FALSE; @@ -15308,6 +15302,13 @@ static boolean SnapField(struct PlayerInfo *player, int dx, int dy) return FALSE; } + int snap_direction = (dx == -1 ? MV_LEFT : + dx == +1 ? MV_RIGHT : + dy == -1 ? MV_UP : + dy == +1 ? MV_DOWN : MV_NONE); + boolean can_continue_snapping = (level.continuous_snapping && + WasJustFalling[x][y] < CHECK_DELAY_FALLING); + // prevent snapping with already pressed snap key when not allowed if (player->is_snapping && !can_continue_snapping) return FALSE; -- 2.34.1