summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-24 17:02:39 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-24 17:02:39 +0100
commit77ac1569d488fa383706415071216ececd7c6f35 (patch)
tree82f96e535d3f06baff1ad98f7856c3bf9192f356
parentf60ed1a40ececf01cb2f676c86508612251b22e9 (diff)
downloadcrawl-ref-77ac1569d488fa383706415071216ececd7c6f35.tar.gz
crawl-ref-77ac1569d488fa383706415071216ececd7c6f35.zip
Only destroy shaft traps if they exist.
Fixes crash for example when shafted by chaos weapons.
-rw-r--r--crawl-ref/source/misc.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 101f55a362..a4e977553e 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2112,6 +2112,13 @@ static void _player_change_level_downstairs(dungeon_feature_type stair_find,
}
}
+void _maybe_destroy_trap(const coord_def &p)
+{
+ trap_def* trap = find_trap(p);
+ if (trap)
+ trap->destroy();
+}
+
void down_stairs( int old_level, dungeon_feature_type force_stair,
entry_cause_type entry_cause )
{
@@ -2209,8 +2216,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
{
if (known_trap)
mpr("The shaft disappears is a puff of logic!");
-
- find_trap(you.pos())->destroy();
+ _maybe_destroy_trap(you.pos());
return;
}
@@ -2223,8 +2229,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
mpr("The strain on the space-time continuum destroys the "
"shaft!");
}
-
- find_trap(you.pos())->destroy();
+ _maybe_destroy_trap(you.pos());
return;
}
shaft_level = absdungeon_depth(shaft_dest.branch, shaft_dest.depth);
@@ -2234,7 +2239,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
// Shafts are one-time-use.
mpr("The shaft crumbles and collapses.");
- find_trap(you.pos())->destroy();
+ _maybe_destroy_trap(you.pos());
}
if (stair_find == DNGN_ENTER_ZOT && !you.opened_zot)