diff options
author | Jude Brown <bookofjude@users.sourceforge.net> | 2009-12-02 21:51:03 +1000 |
---|---|---|
committer | Jude Brown <bookofjude@users.sourceforge.net> | 2009-12-02 21:52:07 +1000 |
commit | 266060b5b8cf51252870eeaff9b76a54f26481ea (patch) | |
tree | 9325ef6519c52903cbc7bbfd5b18e54e91ddef95 /crawl-ref/source/spells3.cc | |
parent | 0bc6fd0fea9e2664f3ed8dfec030e66d18557fc1 (diff) | |
download | crawl-ref-266060b5b8cf51252870eeaff9b76a54f26481ea.tar.gz crawl-ref-266060b5b8cf51252870eeaff9b76a54f26481ea.zip |
Move teleport location checks into their own function.
Should be exactly the same as the previous incarnation, but considerably
more flexible.
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r-- | crawl-ref/source/spells3.cc | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 34940a3df1..e6b08556e6 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1410,6 +1410,33 @@ void you_teleport(void) } } +// Should return true if we don't want anyone to teleport here. +bool _cell_vetoes_teleport (const coord_def cell) +{ + // Monsters always veto teleport. + if (monster_at(cell)) + return (true); + + // As do all clouds; this may change. + if (env.cgrid(cell) != EMPTY_CLOUD) + return (true); + + // But not all features. + switch (grd(cell)) + { + case DNGN_FLOOR: + case DNGN_SHALLOW_WATER: + return (false); + + case DNGN_DEEP_WATER: + if (you.species == SP_MERFOLK) + return (false); + + default: + return (true); + } +} + static bool _teleport_player(bool allow_control, bool new_abyss_area, bool wizard_tele) { bool is_controlled = (allow_control && !you.confused() @@ -1540,12 +1567,7 @@ static bool _teleport_player(bool allow_control, bool new_abyss_area, bool wizar large_change = true; // Merfolk should be able to control-tele into deep water. - if (grd(pos) != DNGN_FLOOR - && grd(pos) != DNGN_SHALLOW_WATER - && (you.species != SP_MERFOLK - || grd(pos) != DNGN_DEEP_WATER) - || monster_at(pos) - || env.cgrid(pos) != EMPTY_CLOUD) + if (_cell_vetoes_teleport(pos)) { #if DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, |