summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/beam.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-11 16:38:12 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-11 19:14:39 +0100
commitadb21570e7da7ff280113e938ee7a26089614e63 (patch)
tree3fe1dc829ae1826eac4a4081ed3e3c115a562d04 /crawl-ref/source/beam.cc
parent24636262aded779e9759895c536e0f42f79c4b52 (diff)
downloadcrawl-ref-adb21570e7da7ff280113e938ee7a26089614e63.tar.gz
crawl-ref-adb21570e7da7ff280113e938ee7a26089614e63.zip
Convert another 45 monster loops to monster_iterator.
A total of 53 have been converted; 39 left, of which some should stay. Now at a net loss of lines of code for monster_iterator. Occurrences of MAX_MONSTERS down to 65 from 116 in *.cc.
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc21
1 files changed, 7 insertions, 14 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 8a10cc4531..8203461539 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -45,6 +45,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"
@@ -2610,26 +2611,18 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin,
const kill_category kc = (origin == MHITYOU ? KC_YOU : KC_OTHER);
- 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())
- continue;
-
- if (!mons_near(monster))
- continue;
-
- if (monster->has_ench(wh_enchant))
+ if (mi->has_ench(wh_enchant))
continue;
if (m_attempted)
++*m_attempted;
- if (_monster_resists_mass_enchantment(monster, wh_enchant, pow))
+ if (_monster_resists_mass_enchantment(*mi, wh_enchant, pow))
continue;
- if (monster->add_ench(mon_enchant(wh_enchant, 0, kc)))
+ if (mi->add_ench(mon_enchant(wh_enchant, 0, kc)))
{
if (m_succumbed)
++*m_succumbed;
@@ -2644,11 +2637,11 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin,
default: msg = NULL; break;
}
if (msg)
- msg_generated = simple_monster_message(monster, msg);
+ msg_generated = simple_monster_message(*mi, msg);
// Extra check for fear (monster needs to reevaluate behaviour).
if (wh_enchant == ENCH_FEAR)
- behaviour_event(monster, ME_SCARE, origin);
+ behaviour_event(*mi, ME_SCARE, origin);
}
}