From: Holger Schemel Date: Tue, 2 Jul 2024 22:05:05 +0000 (+0200) Subject: fixed BD elements at wrap-around cave position killing player instantly X-Git-Tag: 4.4.0.0-test-3~7 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0f5d0658893fc245a4a8be939d57506ba3713fc3;p=rocksndiamonds.git fixed BD elements at wrap-around cave position killing player instantly --- diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 0f9eecc7..85d92411 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -132,6 +132,18 @@ static inline boolean el_can_fall(const int element) return (gd_elements[element & O_MASK].properties & P_CAN_FALL) != 0; } +// returns true if the element is diggable +static inline boolean el_diggable(const int element) +{ + return (gd_elements[element & O_MASK].properties & P_DIGGABLE) != 0; +} + +// returns true if the element can smash the player +static inline boolean el_can_smash_player(const int element) +{ + return (el_can_fall(element) && !el_diggable(element)); +} + // play diamond or stone sound of given element. static void play_sound_of_element(GdCave *cave, GdElement element, int x, int y) { @@ -610,6 +622,19 @@ static inline void store_dir_no_scanned(GdCave *cave, const int x, const int y, static inline void move(GdCave *cave, const int x, const int y, const GdDirection dir, const GdElement e) { + // falling/flying game elements at wrap-around cave position should not kill player instantly + if ((x + gd_dx[dir] == cave->w && dir == GD_MV_RIGHT) || + (y + gd_dy[dir] == cave->h && dir == GD_MV_DOWN)) + { + // cave width/height out of bounds, but due to wrap-around it's the first column/row again + if (el_can_smash_player(get(cave, x, y))) + { + store(cave, x, y, e); // change to falling element ... + + return; // ... but do not move element + } + } + store_dir(cave, x, y, dir, e); store(cave, x, y, O_SPACE); }