summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-pathfind.cc
diff options
context:
space:
mode:
authorJohanna Ploog <j-p-e-g@users.sourceforge.net>2011-02-23 21:47:41 +0100
committerJohanna Ploog <j-p-e-g@users.sourceforge.net>2011-02-23 21:50:30 +0100
commit51fe31ea0c5a85eeae74010c0d7c17059fb17224 (patch)
tree55755dedff50aea0bb7f53631e4ef1151b67ce47 /crawl-ref/source/mon-pathfind.cc
parenta887a8f038bf71d0f84f3e84d9b8824f2ea65d00 (diff)
downloadcrawl-ref-51fe31ea0c5a85eeae74010c0d7c17059fb17224.tar.gz
crawl-ref-51fe31ea0c5a85eeae74010c0d7c17059fb17224.zip
Fixes crashes during labyrinth shifts.
No calling monster functions if mon is not defined!
Diffstat (limited to 'crawl-ref/source/mon-pathfind.cc')
-rw-r--r--crawl-ref/source/mon-pathfind.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc
index 1ada5b2584..a2293d3e33 100644
--- a/crawl-ref/source/mon-pathfind.cc
+++ b/crawl-ref/source/mon-pathfind.cc
@@ -101,6 +101,7 @@ bool monster_pathfind::init_pathfind(const monster* mon, coord_def dest,
start = mon->pos();
target = dest;
pos = start;
+ clinging = mon->is_wall_clinging();
allow_diagonals = diag;
traverse_unmapped = pass_unmapped;
@@ -123,7 +124,6 @@ bool monster_pathfind::init_pathfind(coord_def src, coord_def dest, bool diag,
target = dest;
pos = start;
allow_diagonals = diag;
- clinging = mons->is_wall_clinging();
// Easy enough. :P
if (start == target)
@@ -178,7 +178,12 @@ bool monster_pathfind::calc_path_to_neighbours()
{
coord_def npos;
int distance, old_dist, total;
- clinging = mons->can_cling_to_walls() && cell_is_clingable(pos, clinging);
+ if (mons)
+ {
+ // Is this supposed to override the initial setting?
+ clinging = mons->can_cling_to_walls()
+ && cell_is_clingable(pos, clinging);
+ }
// For each point, we look at all neighbour points. Check the orthogonals
// last, so that, should an orthogonal and a diagonal direction have the