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/spells3.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/spells3.cc')
-rw-r--r-- | crawl-ref/source/spells3.cc | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index ce60981602..145d90aa63 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -186,7 +186,9 @@ bool detect_curse(bool suppress_msg) bool cast_smiting(int power, const coord_def& where) { - if (invalid_monster_index(mgrd(where))) + monsters *m = monster_at(where); + + if (m == NULL) { mpr("There's nothing there!"); // Counts as a real cast, due to victory-dancing and @@ -194,22 +196,20 @@ bool cast_smiting(int power, const coord_def& where) return (true); } - monsters& m = menv[mgrd(where)]; - god_conduct_trigger conducts[3]; disable_attack_conducts(conducts); - const bool success = !stop_attack_prompt(&m, false, false); + const bool success = !stop_attack_prompt(m, false, false); if (success) { - set_attack_conducts(conducts, &m); + set_attack_conducts(conducts, m); - mprf("You smite %s!", m.name(DESC_NOCAP_THE).c_str()); + mprf("You smite %s!", m->name(DESC_NOCAP_THE).c_str()); - behaviour_event(&m, ME_ANNOY, MHITYOU); - if (mons_is_mimic(m.type)) - mimic_alert(&m); + behaviour_event(m, ME_ANNOY, MHITYOU); + if (mons_is_mimic(m->type)) + mimic_alert(m); } enable_attack_conducts(conducts); @@ -219,9 +219,9 @@ bool cast_smiting(int power, const coord_def& where) // Maxes out at around 40 damage at 27 Invocations, which is // plenty in my book (the old max damage was around 70, // which seems excessive). - m.hurt(&you, 7 + (random2(power) * 33 / 191)); - if (m.alive()) - print_wounds(&m); + m->hurt(&you, 7 + (random2(power) * 33 / 191)); + if (m->alive()) + print_wounds(m); } return (success); @@ -231,12 +231,12 @@ int airstrike(int power, dist &beam) { bool success = false; - if (mgrd(beam.target) == NON_MONSTER || beam.isMe) + monsters *monster = monster_at(beam.target); + + if (monster == NULL) canned_msg(MSG_SPELL_FIZZLES); else { - monsters *monster = &menv[mgrd(beam.target)]; - god_conduct_trigger conducts[3]; disable_attack_conducts(conducts); @@ -1330,7 +1330,7 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area ) if (grd(you.pos()) != DNGN_FLOOR && grd(you.pos()) != DNGN_SHALLOW_WATER - || mgrd(you.pos()) != NON_MONSTER + || monster_at(you.pos()) || env.cgrid(you.pos()) != EMPTY_CLOUD) { is_controlled = false; @@ -1382,7 +1382,7 @@ static bool _teleport_player( bool allow_control, bool new_abyss_area ) } while (grd(newpos) != DNGN_FLOOR && grd(newpos) != DNGN_SHALLOW_WATER - || mgrd(newpos) != NON_MONSTER + || monster_at(newpos) || env.cgrid(newpos) != EMPTY_CLOUD || need_distance_check && (newpos - centre).abs() < 34*34); @@ -1444,7 +1444,7 @@ bool entomb(int powc) for ( adjacent_iterator ai; ai; ++ai ) { // Tile already occupied by monster - if (mgrd(*ai) != NON_MONSTER) + if (monster_at(*ai)) continue; // This is where power comes in. @@ -1703,11 +1703,8 @@ bool cast_sanctuary(const int power) // scare all attacking monsters inside sanctuary, and make // all friendly monsters inside sanctuary stop attacking and // move towards the player. - int monster = mgrd(pos); - if (monster != NON_MONSTER) + if (monsters* mon = monster_at(pos)) { - monsters* mon = &menv[monster]; - if (mons_friendly(mon)) { mon->foe = MHITYOU; |