summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-02 19:52:29 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-02 19:52:29 +0000
commitc437c2564a45a47726a2a6aca313834ad27d6a4d (patch)
tree09487c3fbd669a32bc28bf757e2b073aa1b27609 /crawl-ref/source/monstuff.cc
parent4293d91bfd7e4b10b7cdee76dc7d5da7e5e3e001 (diff)
downloadcrawl-ref-c437c2564a45a47726a2a6aca313834ad27d6a4d.tar.gz
crawl-ref-c437c2564a45a47726a2a6aca313834ad27d6a4d.zip
And clean up the previous improvements.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6348 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index aa3f09573f..04f39dbaa7 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2386,8 +2386,7 @@ static void _mark_neighbours_target_unreachable(monsters *mon)
}
}
-static void _mons_find_all_level_exits(const monsters *mon,
- std::vector<level_exit> &e)
+static void _find_all_level_exits(std::vector<level_exit> &e)
{
e.clear();
@@ -2414,11 +2413,11 @@ static void _mons_find_all_level_exits(const monsters *mon,
static int _mons_find_nearest_level_exit(const monsters *mon,
std::vector<level_exit> &e,
- bool restart)
+ bool reset = false)
{
- if (e.empty())
- _mons_find_all_level_exits(mon, e);
+ if (e.empty() || reset)
+ _find_all_level_exits(e);
int retval = -1;
int old_dist = -1;
@@ -2426,12 +2425,7 @@ static int _mons_find_nearest_level_exit(const monsters *mon,
for (unsigned int i = 0; i < e.size(); ++i)
{
if (e[i].unreachable)
- {
- if (restart)
- e[i].unreachable = false;
- else
- continue;
- }
+ continue;
int dist = grid_distance(mon->x, mon->y, e[i].target.x,
e[i].target.y);
@@ -3033,14 +3027,15 @@ static void _handle_behaviour(monsters *mon)
{
// If a pacified monster isn't travelling toward
// someplace from which it can leave the level, make it
- // start doing so. If there's no such place, travel
+ // start doing so. If there's no such place, either
+ // search the level for such a place again, or travel
// randomly.
if (mon->travel_target != MTRAV_PATROL)
{
new_foe = MHITNOT;
mon->travel_path.clear();
- e_index = _mons_find_nearest_level_exit(mon, e, false);
+ e_index = _mons_find_nearest_level_exit(mon, e);
if (e_index == -1 && one_chance_in(20))
e_index = _mons_find_nearest_level_exit(mon, e, true);