summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-12 19:01:03 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-12 19:01:03 +0000
commit71f58563eac0fc0508dd65e085b0fcd98b59fab9 (patch)
treef42c4ce2a6c3c9513d53f27ec72617652410ef3a
parent6dce7d753be877ebde49c4fe52b32029faac0a82 (diff)
downloadcrawl-ref-71f58563eac0fc0508dd65e085b0fcd98b59fab9.tar.gz
crawl-ref-71f58563eac0fc0508dd65e085b0fcd98b59fab9.zip
Call mons_clear_trapping_net() in monsters::moveto(), so it shouldn't
be needed in other places. Should fix [2456879]. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9051 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/abyss.cc6
-rw-r--r--crawl-ref/source/debug.cc21
-rw-r--r--crawl-ref/source/item_use.cc1
-rw-r--r--crawl-ref/source/mon-util.cc11
-rw-r--r--crawl-ref/source/monstuff.cc2
-rw-r--r--crawl-ref/source/mstuff2.cc2
-rw-r--r--crawl-ref/source/religion.cc2
-rw-r--r--crawl-ref/source/terrain.cc37
8 files changed, 38 insertions, 44 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc
index 38c9c782bd..352caeb7e2 100644
--- a/crawl-ref/source/abyss.cc
+++ b/crawl-ref/source/abyss.cc
@@ -471,7 +471,7 @@ void area_shift(void)
_abyss_lose_monster( menv[ mgrd(*ri) ] );
}
- // Shift all monsters & items to new area.
+ // Shift all monsters and items to new area.
for (radius_iterator ri(you.pos(), 10, true, false); ri; ++ri)
{
const coord_def newpos = abyss_center + *ri - you.pos();
@@ -488,10 +488,10 @@ void area_shift(void)
ri->x, ri->y, newpos.x, newpos.y);
}
#endif
- move_item_stack_to_grid( *ri, newpos );
+ move_item_stack_to_grid(*ri, newpos);
// Move monster.
- if ( mgrd(*ri) != NON_MONSTER )
+ if (mgrd(*ri) != NON_MONSTER)
{
menv[mgrd(*ri)].moveto(newpos);
mgrd(newpos) = mgrd(*ri);
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index e3e2931740..56ca4312e6 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -710,20 +710,21 @@ bool _take_portal_vault_stairs( const bool down )
coord_def stair_pos(-1, -1);
- for (int x = 0; x < GXM; x++)
- for (int y = 0; y < GYM; y++)
+ for (rectangle_iterator ri(1); ri; ++ri)
+ {
+ if (grid_stair_direction(grd(*ri)) == cmd)
{
- if (grid_stair_direction(grd[x][y]) == cmd)
- {
- stair_pos.set(x, y);
- break;
- }
+ stair_pos = *ri;
+ break;
}
+ }
if (!in_bounds(stair_pos))
return (false);
+ clear_trapping_net();
you.position = stair_pos;
+
if (down)
down_stairs(you.your_level);
else
@@ -5596,16 +5597,12 @@ static void _move_monster(const coord_def& where, int mid1)
return;
monsters* mon1 = &menv[mid1];
- mons_clear_trapping_net(mon1);
- int mid2 = mgrd(moves.target);
+ const int mid2 = mgrd(moves.target);
monsters* mon2 = NULL;
if (mid2 != NON_MONSTER)
- {
mon2 = &menv[mid2];
- mons_clear_trapping_net(mon2);
- }
mon1->moveto(moves.target);
mgrd(moves.target) = mid1;
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index f3b722f43f..c122f041a3 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -1908,7 +1908,6 @@ static bool _dispersal_hit_victim(bolt& beam, actor* victim, int dmg,
if (!(mon->flags & MF_WAS_IN_VIEW))
mon->seen_context = "thin air";
- mons_clear_trapping_net(mon);
mon->move_to_pos(pos);
mon->apply_location_effects(oldpos);
mon->check_redraw(oldpos);
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 0ccdc4307c..1b000516d3 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -5590,8 +5590,11 @@ int monsters::get_experience_level() const
return (hit_dice);
}
-void monsters::moveto( const coord_def& c )
+void monsters::moveto(const coord_def& c)
{
+ if (c != pos() && in_bounds(pos()))
+ mons_clear_trapping_net(this);
+
position = c;
}
@@ -7684,10 +7687,10 @@ bool monsters::move_to_pos(const coord_def &newpos)
mgrd(pos()) = NON_MONSTER;
// Set monster x,y to new value.
- position = newpos;
+ moveto(newpos);
- // set new monster grid pointer to this monster.
- mgrd(newpos) = monster_index(this);
+ // Set new monster grid pointer to this monster.
+ mgrd(newpos) = mindex();
return (true);
}
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 499ea9ab33..46513abcb7 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2175,8 +2175,6 @@ bool monster_blink(monsters *monster)
if (!(monster->flags & MF_WAS_IN_VIEW))
monster->seen_context = "thin air";
- mons_clear_trapping_net(monster);
-
const coord_def oldplace = monster->pos();
if (!monster->move_to_pos(near))
return (false);
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 5129d96d92..13ba57fea6 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -1143,8 +1143,6 @@ void monster_teleport(monsters *monster, bool instan, bool silent)
// Pick the monster up.
mgrd(oldplace) = NON_MONSTER;
- mons_clear_trapping_net(monster);
-
coord_def newpos;
if (monster_random_space(monster, newpos, !mons_wont_attack(monster)))
monster->moveto(newpos);
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index b3ad4908db..71836b9561 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -5672,7 +5672,7 @@ void yred_make_enslaved_soul(monsters *mon, bool force_hostile,
monster_type soul_type = mons_species(type);
const std::string whose =
player_monster_visible(mon) ? apostrophise(mon->name(DESC_CAP_THE))
- : mon->pronoun(PRONOUN_CAP_POSSESSIVE).c_str();
+ : mon->pronoun(PRONOUN_CAP_POSSESSIVE);
const bool twisted = coinflip();
int corps = -1;
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index aa3df3d151..18223a8afd 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -693,13 +693,13 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
const dungeon_feature_type feat2 = grd(pos2);
if (is_notable_terrain(feat1) && !see_grid(pos1)
- && is_terrain_known(pos1.x, pos1.y))
+ && is_terrain_known(pos1))
{
return (false);
}
if (is_notable_terrain(feat2) && !see_grid(pos2)
- && is_terrain_known(pos2.x, pos2.y))
+ && is_terrain_known(pos2))
{
return (false);
}
@@ -745,6 +745,8 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
return (false);
}
+ // OK, now we guarantee the move.
+
(void) move_notable_thing(pos1, temp);
env.markers.move(pos1, temp);
dungeon_events.move_listeners(pos1, temp);
@@ -761,17 +763,20 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
env.markers.move(temp, pos2);
dungeon_events.move_listeners(temp, pos2);
+ // Swap features and colours.
grd(pos2) = feat1;
grd(pos1) = feat2;
env.grid_colours(pos1) = col2;
env.grid_colours(pos2) = col1;
+ // Swap traps.
if (trap1)
trap1->pos = pos2;
if (trap2)
trap2->pos = pos1;
+ // Swap shops.
if (shop1)
shop1->pos = pos2;
if (shop2)
@@ -782,35 +787,28 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
_dgn_check_terrain_items(pos1, false);
_dgn_check_terrain_monsters(pos1);
_dgn_check_terrain_player(pos1);
- set_terrain_changed(pos1.x, pos1.y);
+ set_terrain_changed(pos1);
_dgn_check_terrain_items(pos2, false);
_dgn_check_terrain_monsters(pos2);
_dgn_check_terrain_player(pos2);
- set_terrain_changed(pos2.x, pos2.y);
+ set_terrain_changed(pos2);
if (announce)
_announce_swap(pos1, pos2);
return (true);
}
- const int i1 = igrd(pos1);
- const int i2 = igrd(pos2);
-
- igrd(pos1) = i2;
- igrd(pos2) = i1;
+ // Swap items.
+ for (stack_iterator si(pos1); si; ++si)
+ si->pos = pos1;
- if (igrd(pos1) != NON_ITEM)
- {
- for (stack_iterator si(igrd(pos1)); si; ++si)
- si->pos = pos1;
- }
- if (igrd(pos2) != NON_ITEM)
- {
- for (stack_iterator si(igrd(pos2)); si; ++si)
- si->pos = pos2;
- }
+ for (stack_iterator si(pos2); si; ++si)
+ si->pos = pos2;
+ // Swap monsters.
+ // Note that trapping nets, etc., move together
+ // with the monster/player, so don't clear them.
const int m1 = mgrd(pos1);
const int m2 = mgrd(pos1);
@@ -822,6 +820,7 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
if (mgrd(pos2) != NON_MONSTER)
menv[mgrd(pos2)].position = pos2;
+ // Swap clouds.
move_cloud(env.cgrid(pos1), temp);
move_cloud(env.cgrid(pos2), pos1);
move_cloud(env.cgrid(temp), pos2);