diff options
-rw-r--r-- | crawl-ref/source/mon-util.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/mtransit.cc | 5 |
2 files changed, 10 insertions, 10 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index b2934c1f58..16f034d2be 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -6209,15 +6209,18 @@ bool monsters::find_place_near_player() bool monsters::find_home_anywhere() { - int tries = 600; - do + coord_def place(-1, -1); + int nvalid = 0; + for (int tries = 0; tries < 600; ++tries) { - position.set(random_range(6, GXM - 7), random_range(6, GYM - 7)); + if (check_set_valid_home(random_in_bounds(), place, nvalid)) + { + moveto(place); + return (true); + } } - while ((grd(pos()) != DNGN_FLOOR || mgrd(pos()) != NON_MONSTER) - && tries-- > 0); - return (tries >= 0); + return (false); } bool monsters::find_place_to_live(bool near_player) diff --git a/crawl-ref/source/mtransit.cc b/crawl-ref/source/mtransit.cc index 45f4c9ba3e..6f04a51138 100644 --- a/crawl-ref/source/mtransit.cc +++ b/crawl-ref/source/mtransit.cc @@ -208,10 +208,7 @@ void place_transiting_items() coord_def pos = item->pos; if (!in_bounds(pos)) - { - pos.x = random_range(X_BOUND_1 + 1, X_BOUND_2 - 1); - pos.y = random_range(Y_BOUND_1 + 1, Y_BOUND_2 - 1); - } + pos = random_in_bounds(); const coord_def where_to_go = dgn_find_nearby_stair(DNGN_ESCAPE_HATCH_DOWN, |