From 6f00e679d1f90041599c50c3cc86ab4e499c9ba1 Mon Sep 17 00:00:00 2001 From: haranp Date: Wed, 23 Jul 2008 20:32:37 +0000 Subject: More cleanups and fixes. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6648 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/files.cc | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source/files.cc') diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 3a25835dde..f0f7c041c2 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -977,25 +977,22 @@ static bool _grab_follower_at(const coord_def &pos) static void _grab_followers() { const bool can_follow = level_type_allows_followers(you.level_type); - for (int i = you.x_pos - 1; i < you.x_pos + 2; i++) - for (int j = you.y_pos - 1; j < you.y_pos + 2; j++) - { - if (i == you.x_pos && j == you.y_pos) - continue; - if (mgrd[i][j] == NON_MONSTER) - continue; + // Handle nearby ghosts. + for ( adjacent_iterator ai; ai; ++ai ) + { + if (mgrd(*ai) == NON_MONSTER) + continue; - monsters *fmenv = &menv[mgrd[i][j]]; + monsters *fmenv = &menv[mgrd(*ai)]; - if (fmenv->type == MONS_PLAYER_GHOST - && fmenv->hit_points < fmenv->max_hit_points / 2) - { - mpr("The ghost fades into the shadows."); - monster_teleport(fmenv, true); - continue; - } + if (fmenv->type == MONS_PLAYER_GHOST + && fmenv->hit_points < fmenv->max_hit_points / 2) + { + mpr("The ghost fades into the shadows."); + monster_teleport(fmenv, true); } + } if (can_follow) { @@ -1218,8 +1215,8 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, crawl_view.set_player_at(you.pos(), load_mode != LOAD_VISITOR); // This should fix the "monster occurring under the player" bug? - if (make_changes && mgrd[you.x_pos][you.y_pos] != NON_MONSTER) - monster_teleport(&menv[mgrd[you.x_pos][you.y_pos]], true, true); + if (make_changes && mgrd(you.pos()) != NON_MONSTER) + monster_teleport(&menv[mgrd(you.pos())], true, true); // Actually "move" the followers if applicable. if (level_type_allows_followers(you.level_type) -- cgit v1.2.3-54-g00ecf