diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-02-12 20:18:58 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-02-12 21:09:59 -0800 |
commit | b17b9021ecf9b16c265d0a6b60faa761b34eae35 (patch) | |
tree | e8192de5b2458864f0f5ce5edd0e1ccf5605c644 /src/map/path.cpp | |
parent | 80e36aa669274637bcd5956fbf4020dba1d4739c (diff) | |
download | tmwa-b17b9021ecf9b16c265d0a6b60faa761b34eae35.tar.gz tmwa-b17b9021ecf9b16c265d0a6b60faa761b34eae35.tar.bz2 tmwa-b17b9021ecf9b16c265d0a6b60faa761b34eae35.tar.xz tmwa-b17b9021ecf9b16c265d0a6b60faa761b34eae35.zip |
Replace mt_rand with <random>
Also add some utility methods and classes.
Diffstat (limited to 'src/map/path.cpp')
-rw-r--r-- | src/map/path.cpp | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/src/map/path.cpp b/src/map/path.cpp index 1a4385b..9c6ea28 100644 --- a/src/map/path.cpp +++ b/src/map/path.cpp @@ -1,5 +1,5 @@ #include "../common/cxxstdio.hpp" -#include "../common/mt_rand.hpp" +#include "../common/random.hpp" #include "../common/nullpo.hpp" #include "battle.hpp" @@ -222,57 +222,6 @@ int can_move(struct map_data *m, int x0, int y0, int x1, int y1, int flag) } /*========================================== - * (x0,y0)から(dx,dy)方向へcountセル分 - * 吹き飛ばしたあとの座標を所得 - *------------------------------------------ - */ -int path_blownpos(int m, int x0, int y0, int dx, int dy, int count) -{ - struct map_data *md; - - if (!map[m].gat) - return -1; - md = &map[m]; - - if (count > 15) - { // 最大10マスに制限 - if (battle_config.error_log) - PRINTF("path_blownpos: count too many %d !\n", count); - count = 15; - } - if (dx > 1 || dx < -1 || dy > 1 || dy < -1) - { - if (battle_config.error_log) - PRINTF("path_blownpos: illeagal dx=%d or dy=%d !\n", dx, dy); - dx = (dx >= 0) ? 1 : ((dx < 0) ? -1 : 0); - dy = (dy >= 0) ? 1 : ((dy < 0) ? -1 : 0); - } - - while ((count--) > 0 && (dx != 0 || dy != 0)) - { - if (!can_move(md, x0, y0, x0 + dx, y0 + dy, 0)) - { - int fx = (dx != 0 && can_move(md, x0, y0, x0 + dx, y0, 0)); - int fy = (dy != 0 && can_move(md, x0, y0, x0, y0 + dy, 0)); - if (fx && fy) - { - if (MRAND(2)) - dx = 0; - else - dy = 0; - } - if (!fx) - dx = 0; - if (!fy) - dy = 0; - } - x0 += dx; - y0 += dy; - } - return (x0 << 16) | y0; -} - -/*========================================== * path探索 (x0,y0)->(x1,y1) *------------------------------------------ */ |