From 730293f79740586678d8fd212313903f426757c1 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 11 Nov 2009 15:01:53 +0100 Subject: Convert cast_toxic_radiance to use monster_iterator. Testing monster_iterator functionality. --- crawl-ref/source/spells2.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'crawl-ref/source/spells2.cc') diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 57293bf40d..0f9df1d37b 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -33,6 +33,7 @@ #include "message.h" #include "misc.h" #include "mon-behv.h" +#include "mon-iter.h" #include "monplace.h" #include "monstuff.h" #include "mon-util.h" @@ -531,31 +532,29 @@ void cast_toxic_radiance() counted_monster_list affected_monsters; // determine which monsters are hit by the radiance: {dlb} - for (int i = 0; i < MAX_MONSTERS; ++i) + for (monster_iterator mi(&you.get_los()); mi; ++mi) { - monsters* const monster = &menv[i]; - - if (monster->alive() && mons_near(monster) && !monster->submerged()) + if (!mi->submerged()) { // Monsters affected by corona are still invisible in that // radiation passes through them without affecting them. Therefore, // this check should not be !monster->invisible(). - if (!monster->has_ench(ENCH_INVIS)) + if (!mi->has_ench(ENCH_INVIS)) { bool affected = - poison_monster(monster, KC_YOU, 1, false, false); + poison_monster(*mi, KC_YOU, 1, false, false); - if (coinflip() && poison_monster(monster, KC_YOU, false, false)) + if (coinflip() && poison_monster(*mi, KC_YOU, false, false)) affected = true; if (affected) - _record_monster_by_name(affected_monsters, monster); + _record_monster_by_name(affected_monsters, *mi); } else if (you.can_see_invisible()) { // message player re:"miss" where appropriate {dlb} mprf("The light passes through %s.", - monster->name(DESC_NOCAP_THE).c_str()); + mi->name(DESC_NOCAP_THE).c_str()); } } } -- cgit v1.2.3-54-g00ecf