diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-13 00:47:33 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-13 00:47:33 +0000 |
commit | 412bcd6e779cd3883bc5c6ce29a8e79ad32c63f4 (patch) | |
tree | 45316891325a63a834b5baef43896e464ed8fedb /crawl-ref/source/effects.cc | |
parent | 2dd4fe4a7f0b809a9f3a565f64ed6b5dcb1ab814 (diff) | |
download | crawl-ref-412bcd6e779cd3883bc5c6ce29a8e79ad32c63f4.tar.gz crawl-ref-412bcd6e779cd3883bc5c6ce29a8e79ad32c63f4.zip |
Remove a great many cases where mgrd is accessed directly in favour
of monster_at().
The hope is to eventually remove mgrd completely (in favour of scanning
through the monster list, or a different datastructure which gets updated
automatically when monsters move), and thus fix all the mgrd-out-of-sync
bugs in one fell swoop.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9056 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r-- | crawl-ref/source/effects.cc | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 300a5a8ded..b5766f12e1 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -122,13 +122,10 @@ int holy_word_monsters(coord_def where, int pow, int caster, retval = holy_word_player(pow, caster, attacker); // Is a monster in this cell? - const int mon = mgrd(where); - - if (mon == NON_MONSTER) + monsters *monster = monster_at(where); + if (monster == NULL) return (retval); - monsters *monster = &menv[mon]; - if (!monster->alive() || !mons_is_unholy(monster)) return (retval); @@ -265,13 +262,10 @@ int torment_monsters(coord_def where, int pow, int caster, actor *attacker) retval = torment_player(0, caster); // Is a monster in this cell? - const int mon = mgrd(where); - - if (mon == NON_MONSTER) + monsters *monster = monster_at(where); + if (monster == NULL) return (retval); - monsters *monster = &menv[mon]; - if (!monster->alive() || mons_res_negative_energy(monster) == 3) return (retval); @@ -2231,7 +2225,7 @@ void yell(bool force) } mpr("Gang up on whom?", MSGCH_PROMPT); - direction( targ, DIR_TARGET, TARG_ENEMY, -1, false, false ); + direction(targ, DIR_TARGET, TARG_ENEMY, -1, false, false); if (targ.isCancel) { @@ -2239,14 +2233,22 @@ void yell(bool force) return; } - if (!targ.isValid || mgrd(targ.target) == NON_MONSTER - || !player_monster_visible(&env.mons[mgrd(targ.target)])) { - mpr("Yeah, whatever."); - return; - } + bool cancel = !targ.isValid; + if (!cancel) + { + const monsters* m = monster_at(targ.target); + cancel = (m == NULL || !you.can_see(m)); + if (!cancel) + mons_targd = m->mindex(); + } - mons_targd = mgrd(targ.target); + if (cancel) + { + mpr("Yeah, whatever."); + return; + } + } break; default: @@ -2795,7 +2797,7 @@ void change_labyrinth(bool msg) continue; // We don't want to deal with monsters being shifted around. - if (mgrd(p) != NON_MONSTER) + if (monster_at(p)) continue; // Do not pick a grid right next to the original wall. @@ -3555,7 +3557,7 @@ static void _catchup_monster_moves(monsters *mon, int turns) const coord_def next(pos + inc); const dungeon_feature_type feat = grd(next); if (grid_is_solid(feat) - || mgrd(next) != NON_MONSTER + || monster_at(next) || !monster_habitable_grid(mon, feat)) { break; |