summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-12 13:13:40 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-12 13:13:40 +0000
commited3c8c2ae59a947f065499f63daa03fec3a6840d (patch)
treefa2d6529968da6fa33359f3961697b6e405c65b3
parent2368157486f9e3c0806d3d79e939fbc3533eb105 (diff)
downloadcrawl-ref-ed3c8c2ae59a947f065499f63daa03fec3a6840d.tar.gz
crawl-ref-ed3c8c2ae59a947f065499f63daa03fec3a6840d.zip
Clearing trapping nets moved into player::moveto() and level change.
This fixes some bugs (e.g. Portal spell and nets interact properly.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9036 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/debug.cc3
-rw-r--r--crawl-ref/source/effects.cc3
-rw-r--r--crawl-ref/source/item_use.cc1
-rw-r--r--crawl-ref/source/misc.cc8
-rw-r--r--crawl-ref/source/player.cc5
-rw-r--r--crawl-ref/source/spells1.cc6
-rw-r--r--crawl-ref/source/spells3.cc14
-rw-r--r--crawl-ref/source/spells4.cc2
-rw-r--r--crawl-ref/source/traps.cc3
-rw-r--r--crawl-ref/source/traps.h4
10 files changed, 18 insertions, 31 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 5b467b6475..e3e2931740 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -5581,9 +5581,6 @@ void wizard_give_monster_item(monsters *mon)
#ifdef WIZARD
static void _move_player(const coord_def& where)
{
- // no longer held in net
- clear_trapping_net();
-
if (!you.can_pass_through_feat(grd(where)))
grd(where) = DNGN_FLOOR;
move_player_to_grid(where, false, true, true);
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index c9b70e45d0..300a5a8ded 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -548,9 +548,6 @@ 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/item_use.cc b/crawl-ref/source/item_use.cc
index f813fc121d..f3b722f43f 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -1898,7 +1898,6 @@ static bool _dispersal_hit_victim(bolt& beam, actor* victim, int dmg,
if (victim->atype() == ACT_PLAYER)
{
- clear_trapping_net();
victim->moveto(pos);
mpr("You blink!");
}
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 4587200875..e419a646fc 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1723,6 +1723,10 @@ void up_stairs(dungeon_feature_type force_stair,
if (_marker_vetoes_level_change())
return;
+ // Magical level changes (don't exist yet in this direction)
+ // need this.
+ clear_trapping_net();
+
// Checks are done, the character is committed to moving between levels.
leaving_level_now();
@@ -2096,6 +2100,10 @@ void down_stairs( int old_level, dungeon_feature_type force_stair,
const level_id destination_override(_stair_destination_override());
// All checks are done, the player is on the move now.
+
+ // Magical level changes (Portal, Banishment) need this.
+ clear_trapping_net();
+
// Fire level-leaving trigger.
leaving_level_now();
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 76bd7e5b0d..ee77d16af3 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -7248,6 +7248,9 @@ void player::base_moveto(const coord_def &c)
void player::moveto(const coord_def &c)
{
+ if (c != you.pos())
+ clear_trapping_net();
+
crawl_view.set_player_at(c);
base_moveto(c);
}
@@ -7260,7 +7263,7 @@ void player::shiftto(const coord_def &c)
void player::reset_prev_move()
{
- prev_move = coord_def(0,0);
+ prev_move.reset();
}
bool player::asleep() const
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 3358d99e6f..a520d86637 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -176,9 +176,6 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink)
}
else
{
- // No longer held in net.
- clear_trapping_net();
-
move_player_to_grid(beam.target, false, true, true);
// Controlling teleport contaminates the player. -- bwr
@@ -232,9 +229,6 @@ void random_blink(bool allow_partial_control, bool override_abyss)
{
mpr("You blink.");
- // No longer held in net.
- clear_trapping_net();
-
success = true;
you.moveto(target);
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index a80762d568..ce60981602 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1323,10 +1323,6 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area )
if (is_controlled)
{
- // no longer held in net
- if (pos != you.pos())
- clear_trapping_net();
-
if (!see_grid(pos))
large_change = true;
@@ -1390,10 +1386,6 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area )
|| env.cgrid(newpos) != EMPTY_CLOUD
|| need_distance_check && (newpos - centre).abs() < 34*34);
- // no longer held in net
- if (newpos != you.pos())
- clear_trapping_net();
-
if ( newpos == you.pos() )
mpr("Your surroundings flicker for a moment.");
else if ( see_grid(newpos) )
@@ -1404,11 +1396,7 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area )
large_change = true;
}
- you.position = newpos;
-
- // Necessary to update the view centre.
- you.moveto(you.pos());
-
+ you.moveto(newpos);
}
if (large_change)
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 70fc989e2f..ef1c31ffb9 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -2421,8 +2421,6 @@ static int _quadrant_blink(coord_def where, int pow, int, actor *)
if (!found)
return(0);
- clear_trapping_net();
-
you.moveto(target);
return 1;
}
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index c4a7cdd1f4..b46a9c59d6 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -1064,6 +1064,9 @@ void clear_trapping_net()
if (!you.attribute[ATTR_HELD])
return;
+ if (!in_bounds(you.pos()))
+ return;
+
const int net = get_trapping_net(you.pos());
if (net != NON_ITEM)
remove_item_stationary(mitm[net]);
diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h
index bfa5eaa528..5f2385169a 100644
--- a/crawl-ref/source/traps.h
+++ b/crawl-ref/source/traps.h
@@ -31,8 +31,8 @@ void handle_traps(trap_type trt, int i, bool trap_known);
int get_trapping_net(const coord_def& where, bool trapped = true);
void mark_net_trapping(const coord_def& where);
void monster_caught_in_net(monsters *mon, bolt &pbolt);
-void player_caught_in_net(void);
-void clear_trapping_net(void);
+void player_caught_in_net();
+void clear_trapping_net();
void check_net_will_hold_monster(monsters *mon);
void destroy_trap(const coord_def& pos);