From: Holger Schemel Date: Fri, 6 Dec 2024 19:13:19 +0000 (+0100) Subject: fixed accessing invalid array position X-Git-Tag: 4.4.0.0-test-5~3 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=2dd4bcb6746420108015bef0b47d42c7d893076a;p=rocksndiamonds.git fixed accessing invalid array position --- 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;