diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-12 08:33:03 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-12 09:38:15 +0100 |
commit | bf9183f6523bf96750b50723fc0f783af6fc8e9c (patch) | |
tree | 0833c35f8b11d3f57ea22c57bcce48a15cf5319e /crawl-ref/source/arena.cc | |
parent | a32d122dd8d29cf5982ac1052d9c88c91ce0bcd3 (diff) | |
download | crawl-ref-bf9183f6523bf96750b50723fc0f783af6fc8e9c.tar.gz crawl-ref-bf9183f6523bf96750b50723fc0f783af6fc8e9c.zip |
More monster_iterator conversions.
Diffstat (limited to 'crawl-ref/source/arena.cc')
-rw-r--r-- | crawl-ref/source/arena.cc | 65 |
1 files changed, 24 insertions, 41 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc index 178a592129..31512cd621 100644 --- a/crawl-ref/source/arena.cc +++ b/crawl-ref/source/arena.cc @@ -22,6 +22,7 @@ #include "maps.h" #include "message.h" #include "mon-behv.h" +#include "mon-iter.h" #include "mon-pick.h" #include "mon-util.h" #include "mon-place.h" @@ -139,12 +140,8 @@ namespace arena void adjust_monsters() { - for (int i = 0; i < MAX_MONSTERS; i++) + for (monster_iterator mon; mon; ++mon) { - monsters *mon = &menv[i]; - if (!mon->alive()) - continue; - const bool friendly = mon->friendly(); // Set target to the opposite faction's home base. mon->target = friendly ? place_b : place_a; @@ -543,16 +540,12 @@ namespace arena faction_a.active_members = 0; faction_b.active_members = 0; - for (int i = 0; i < MAX_MONSTERS; ++i) + for (monster_iterator mons; mons; ++mons) { - const monsters *mons(&menv[i]); - if (mons->alive()) - { - if (mons->attitude == ATT_FRIENDLY) - faction_a.active_members++; - else if (mons->attitude == ATT_HOSTILE) - faction_b.active_members++; - } + if (mons->attitude == ATT_FRIENDLY) + faction_a.active_members++; + else if (mons->attitude == ATT_HOSTILE) + faction_b.active_members++; } if (orig_a != faction_a.active_members @@ -601,35 +594,27 @@ namespace arena void report_foes() { - for (int i = 0; i < MAX_MONSTERS; ++i) + for (monster_iterator mons; mons; ++mons) { - monsters *mons(&menv[i]); - if (mons->alive()) + if (mons->type == MONS_SIGMUND) { - if (mons->type == MONS_SIGMUND) - { - coord_def where; - if (mons->get_foe()) - where = mons->get_foe()->pos(); - mprf("%s (%d,%d) foe: %s (%d,%d)", - mons->name(DESC_PLAIN).c_str(), - mons->pos().x, mons->pos().y, - mons->get_foe()? mons->get_foe()->name(DESC_PLAIN).c_str() - : "(none)", - where.x, where.y); - } + coord_def where; + if (mons->get_foe()) + where = mons->get_foe()->pos(); + mprf("%s (%d,%d) foe: %s (%d,%d)", + mons->name(DESC_PLAIN).c_str(), + mons->pos().x, mons->pos().y, + mons->get_foe()? mons->get_foe()->name(DESC_PLAIN).c_str() + : "(none)", + where.x, where.y); } } } void fixup_foes() { - for (int i = 0; i < MAX_MONSTERS; ++i) - { - monsters *mons(&menv[i]); - if (mons->alive()) - behaviour_event(mons, ME_DISTURB, MHITNOT, mons->pos()); - } + for (monster_iterator mons; mons; ++mons) + behaviour_event(*mons, ME_DISTURB, MHITNOT, mons->pos()); } void dump_messages() @@ -718,15 +703,13 @@ namespace arena if (!miscasts) return; - for (int i = 0; i < MAX_MONSTERS; i++) + for (monster_iterator mon; mon; ++mon) { - monsters* mon = &menv[i]; - - if (!mon->alive() || mon->type == MONS_TEST_SPAWNER) + if (mon->type == MONS_TEST_SPAWNER) continue; - MiscastEffect(mon, i, SPTYP_RANDOM, random_range(1, 3), - "arena miscast", NH_NEVER); + MiscastEffect(*mon, mon->mindex(), SPTYP_RANDOM, + random_range(1, 3), "arena miscast", NH_NEVER); } } |