X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_bd%2Fbd_caveengine.c;h=9df249eba1fba020e9ef53063c92c0aed0b8dbe7;hb=ac8ca29d0e4dec7b621225457f6eb5179655ea14;hp=5b2bfcdfcd1292268083f70c45a5fa64fd235469;hpb=8fdd23c078934ae797980a824fd145903c84cae7;p=rocksndiamonds.git diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 5b2bfcdf..9df249eb 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -543,6 +543,9 @@ static inline boolean is_space_dir(const GdCave *cave, const int x, const int y, static inline void store_dir_buffer(GdCave *cave, const int x, const int y, const GdDirection dir) { + int old_x = x; + int old_y = y; + // raw values without range correction int raw_x = x + gd_dx[dir]; int raw_y = y + gd_dy[dir]; @@ -552,7 +555,18 @@ static inline void store_dir_buffer(GdCave *cave, const int x, const int y, cons 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; + // if tile is moving two steps at once, correct old position + if (dir > GD_MV_TWICE) + { + raw_x = x + gd_dx[new_dir]; + raw_y = y + gd_dy[new_dir]; + + old_x = getx(cave, raw_x, raw_y); + old_y = gety(cave, raw_x, raw_y); + } + + game_bd.game->dir_buffer_from[old_y][old_x] = new_dir; + game_bd.game->dir_buffer_to[new_y][new_x] = new_dir; } // store an element at the given position