From 9dc6a97ec5369d54c9c46c6bdced240ee56b1763 Mon Sep 17 00:00:00 2001 From: Jude Brown Date: Thu, 3 Dec 2009 20:48:58 +1000 Subject: Don't assume a square is safe if there are a monster there. Could be a lava snake, swamp worm, etc. --- crawl-ref/source/spells3.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/spells3.cc') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index e0b1ca50de..1c25a5ee72 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1411,10 +1411,10 @@ void you_teleport(void) } // Should return true if we don't want anyone to teleport here. -bool _cell_vetoes_teleport (const coord_def cell) +bool _cell_vetoes_teleport (const coord_def cell, bool check_monsters = true) { // Monsters always veto teleport. - if (monster_at(cell)) + if (monster_at(cell) && check_monsters) return (true); // As do all clouds; this may change. @@ -1431,9 +1431,19 @@ bool _cell_vetoes_teleport (const coord_def cell) case DNGN_DEEP_WATER: if (you.species == SP_MERFOLK) return (false); + else + return (true); - default: + case DNGN_LAVA: return (true); + + default: + // Lava is really the only non-solid glyph above DNGN_MAXSOLID that is + // not a safe teleport location, and that's handled above. + if (cell_is_solid(cell)) + return (true); + + return (false); } } @@ -1714,7 +1724,7 @@ bool you_teleport_to (const coord_def where_to, bool move_monsters) if (_cell_vetoes_teleport(where)) { - if (monster_at(where) && move_monsters) + if (monster_at(where) && move_monsters && !_cell_vetoes_teleport(where, false)) { monsters *mons = monster_at(where); mons->teleport(true); @@ -1729,7 +1739,8 @@ bool you_teleport_to (const coord_def where_to, bool move_monsters) } else { - if (monster_at(*ai) && move_monsters) + if (monster_at(*ai) && move_monsters + && !_cell_vetoes_teleport(*ai, false)) { monsters *mons = monster_at(*ai); mons->teleport(true); -- cgit v1.2.3-54-g00ecf