summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-pathfind.cc
diff options
context:
space:
mode:
authorSamuel Bronson <naesten@gmail.com>2011-11-15 19:32:55 -0500
committerSamuel Bronson <naesten@gmail.com>2011-11-15 19:32:55 -0500
commit83a33ba1101d73943dd128d3620fd368ecd2cc3f (patch)
tree11aca42caed33d181b8762501cc0ac1be80795da /crawl-ref/source/mon-pathfind.cc
parent4da733a9287c7e203294f4d00c701c95dc2d1d1a (diff)
downloadcrawl-ref-83a33ba1101d73943dd128d3620fd368ecd2cc3f.tar.gz
crawl-ref-83a33ba1101d73943dd128d3620fd368ecd2cc3f.zip
Fix range check in monster_pathfind::calc_path_to_neighbours().
Not only was this a performance problem, it was also an AI buff for creatures with intelligence I_NORMAL and below!
Diffstat (limited to 'crawl-ref/source/mon-pathfind.cc')
-rw-r--r--crawl-ref/source/mon-pathfind.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc
index c22a49387f..61f0e1145c 100644
--- a/crawl-ref/source/mon-pathfind.cc
+++ b/crawl-ref/source/mon-pathfind.cc
@@ -211,12 +211,13 @@ bool monster_pathfind::calc_path_to_neighbours()
if (!traversable(npos) && npos != target)
continue;
+ distance = dist[pos.x][pos.y] + travel_cost(npos);
+ old_dist = dist[npos.x][npos.y];
+
// Ignore this grid if it takes us above the allowed distance.
- if (range && estimated_cost(npos) > range)
+ if (range && distance > range)
continue;
- distance = dist[pos.x][pos.y] + travel_cost(npos);
- old_dist = dist[npos.x][npos.y];
#ifdef DEBUG_PATHFIND
mprf("old dist: %d, new dist: %d, infinite: %d", old_dist, distance,
INFINITE_DISTANCE);