From ce6a7efb9404d67af78ecd3a42d2e4f430b8cbab Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 26 Oct 2007 11:32:57 +0000 Subject: Fix bug 1814617: teleport/banish not clearing being trapped in net git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2588 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/effects.cc | 4 ++++ crawl-ref/source/spells1.cc | 22 +++++----------------- crawl-ref/source/spells3.cc | 8 ++++++++ crawl-ref/source/traps.cc | 12 ++++++++++++ crawl-ref/source/traps.h | 1 + 5 files changed, 30 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 034a9885cd..05cf9168c3 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -49,6 +49,7 @@ #include "state.h" #include "stuff.h" #include "terrain.h" +#include "traps.h" #include "view.h" #include "xom.h" @@ -273,6 +274,9 @@ void banished(dungeon_feature_type gate_type, const std::string &who) take_note(Note(NOTE_MESSAGE, 0, 0, what.c_str()), true); } + // no longer held in net + clear_trapping_net(); + down_stairs(you.your_level, gate_type, you.entry_cause); // heh heh } diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index d297fbf181..6483f7d01a 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -152,15 +152,9 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink) } else { - if (you.attribute[ATTR_HELD]) - { - int net = get_trapping_net(you.x_pos, you.y_pos); - if (net != NON_ITEM) - remove_item_stationary(mitm[net]); - - you.attribute[ATTR_HELD] = 0; - } - + // no longer held in net + clear_trapping_net(); + move_player_to_grid(beam.tx, beam.ty, false, true, true); // controlling teleport contaminates the player -- bwr @@ -216,14 +210,8 @@ void random_blink(bool allow_partial_control, bool override_abyss) { mpr("You blink."); - if (you.attribute[ATTR_HELD]) - { - int net = get_trapping_net(you.x_pos, you.y_pos); - if (net != NON_ITEM) - remove_item_stationary(mitm[net]); - - you.attribute[ATTR_HELD] = 0; - } + // no longer held in net + clear_trapping_net(); succ = true; you.moveto(tx, ty); diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 9bbb8789e5..f0b8219b1c 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -600,6 +600,10 @@ static bool teleport_player( bool allow_control, bool new_abyss_area ) if (is_controlled) { + // no longer held in net + if (pos.x != you.x_pos && pos.y != you.y_pos) + clear_trapping_net(); + you.moveto(pos.x, pos.y); if ((grd[you.x_pos][you.y_pos] != DNGN_FLOOR @@ -630,6 +634,10 @@ static bool teleport_player( bool allow_control, bool new_abyss_area ) && grd[newx][newy] != DNGN_SHALLOW_WATER) || mgrd[newx][newy] != NON_MONSTER || env.cgrid[newx][newy] != EMPTY_CLOUD); + + // no longer held in net + if (newx != you.x_pos && newy != you.y_pos) + clear_trapping_net(); if ( newx == you.x_pos && newy == you.y_pos ) mpr("Your surroundings flicker for a moment."); diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index ce38b939d5..aa513293b1 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -780,6 +780,18 @@ void free_self_from_net() } } +void clear_trapping_net() +{ + if (!you.attribute[ATTR_HELD]) + return; + + const int net = get_trapping_net(you.x_pos, you.y_pos); + if (net != NON_ITEM) + remove_item_stationary(mitm[net]); + + you.attribute[ATTR_HELD] = 0; +} + bool trap_item(object_class_type base_type, char sub_type, char beam_x, char beam_y) { diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h index 224c147aa6..c86041840e 100644 --- a/crawl-ref/source/traps.h +++ b/crawl-ref/source/traps.h @@ -39,6 +39,7 @@ int get_trapping_net(int x, int y, bool trapped = true); void mark_net_trapping(int x, int y); void monster_caught_in_net(monsters *mon, bolt &pbolt); void player_caught_in_net(void); +void clear_trapping_net(void); // last updated 12may2000 {dlb} /* *********************************************************************** -- cgit v1.2.3-54-g00ecf