X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_bd%2Fbd_caveengine.c;h=3019aeca80dea04636e5379ab4978c992781eb56;hb=0f4ca4876cd7e3ac7f05620a6d048f5cd7dac294;hp=bfb7dfbc004ea74428ac2494752c4beed588a341;hpb=39b7d2aa3bad6aea82451547e22b7354c0328679;p=rocksndiamonds.git diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index bfb7dfbc..3019aeca 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -526,6 +526,19 @@ static inline boolean is_space_dir(const GdCave *cave, const int x, const int y, return (e == O_SPACE || e == O_LAVA); } +static inline void store_dir_buffer(GdCave *cave, const int x, const int y, const GdDirection dir) +{ + /* raw values without range correction */ + int raw_x = x + gd_dx[dir]; + int raw_y = y + gd_dy[dir]; + /* final values with range correction */ + int new_x = getx(cave, raw_x, raw_y); + int new_y = gety(cave, raw_x, raw_y); + int new_dir = (dir > GD_MV_TWICE ? dir - GD_MV_TWICE : dir); + + game_bd.game->dir_buffer[new_y][new_x] = new_dir; +} + /* store an element at the given position */ static inline void store(GdCave *cave, const int x, const int y, const GdElement element) { @@ -551,6 +564,7 @@ static inline void store_sc(GdCave *cave, const int x, const int y, const GdElem static inline void store_dir(GdCave *cave, const int x, const int y, const GdDirection dir, const GdElement element) { + store_dir_buffer(cave, x, y, dir); store(cave, x + gd_dx[dir], y + gd_dy[dir], element | SCANNED); } @@ -558,6 +572,7 @@ static inline void store_dir(GdCave *cave, const int x, const int y, static inline void store_dir_no_scanned(GdCave *cave, const int x, const int y, const GdDirection dir, const GdElement element) { + store_dir_buffer(cave, x, y, dir); store(cave, x + gd_dx[dir], y + gd_dy[dir], element); }