From 412bcd6e779cd3883bc5c6ce29a8e79ad32c63f4 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 13 Feb 2009 00:47:33 +0000 Subject: 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 --- crawl-ref/source/spells2.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crawl-ref/source/spells2.cc') diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 508a83cb94..7188bc8bf4 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -198,9 +198,8 @@ int detect_creatures( int pow, bool telepathic ) for (radius_iterator ri(you.pos(), map_radius, true, false); ri; ++ri) { - if (mgrd(*ri) != NON_MONSTER) + if (monsters *mon = monster_at(*ri)) { - monsters *mon = &menv[ mgrd(*ri) ]; creatures_found++; _mark_detected_creature(*ri, mon, fuzz_chance, fuzz_radius); @@ -758,16 +757,14 @@ void drain_life(int pow) bool vampiric_drain(int pow, const dist &vmove) { - int mgr = mgrd(you.pos() + vmove.delta); + monsters *monster = monster_at(you.pos() + vmove.delta); - if (mgr == NON_MONSTER) + if (monster == NULL) { mpr("There isn't anything there!"); return (false); } - monsters *monster = &menv[mgr]; - god_conduct_trigger conducts[3]; disable_attack_conducts(conducts); @@ -1350,9 +1347,9 @@ bool cast_summon_elemental(int pow, god_type god, targ = you.pos() + smove.delta; - if (mgrd(targ) != NON_MONSTER) + if (const monsters *m = monster_at(targ)) { - if (player_monster_visible(&menv[mgrd(targ)])) + if (you.can_see(m)) mpr("There's something there already!"); else { -- cgit v1.2.3-54-g00ecf