diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-11 16:38:12 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-11 19:14:39 +0100 |
commit | adb21570e7da7ff280113e938ee7a26089614e63 (patch) | |
tree | 3fe1dc829ae1826eac4a4081ed3e3c115a562d04 /crawl-ref/source/decks.cc | |
parent | 24636262aded779e9759895c536e0f42f79c4b52 (diff) | |
download | crawl-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/decks.cc')
-rw-r--r-- | crawl-ref/source/decks.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index e82ba90e70..cdd4626e99 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -31,6 +31,7 @@ #include "maps.h" #include "message.h" #include "misc.h" +#include "mon-iter.h" #include "monplace.h" #include "monstuff.h" #include "mutation.h" @@ -2513,16 +2514,13 @@ static void _crusade_card(int power, deck_rarity_type rarity) if (power_level >= 1) { // A chance to convert opponents. - 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->friendly() - || monster->holiness() != MH_NATURAL - || mons_is_unique(monster->type) - || mons_immune_magic(monster) - || player_will_anger_monster(monster)) + if (mi->friendly() + || mi->holiness() != MH_NATURAL + || mons_is_unique(mi->type) + || mons_immune_magic(*mi) + || player_will_anger_monster(*mi)) { continue; } @@ -2531,35 +2529,35 @@ static void _crusade_card(int power, deck_rarity_type rarity) // (though not immunity) check. Specifically, // you can convert Killer Klowns this way. // Might be too good. - if (monster->hit_dice * 35 < random2(power)) + if (mi->hit_dice * 35 < random2(power)) { - simple_monster_message(monster, " is converted."); + simple_monster_message(*mi, " is converted."); if (one_chance_in(5 - power_level)) { - monster->attitude = ATT_FRIENDLY; + mi->attitude = ATT_FRIENDLY; // If you worship a god that lets you recruit // permanent followers, or a god allied with one, // count this as a recruitment. if (is_good_god(you.religion) || you.religion == GOD_BEOGH - && mons_species(monster->type) == MONS_ORC - && !monster->is_summoned() - && !monster->is_shapeshifter()) + && mons_species(mi->type) == MONS_ORC + && !mi->is_summoned() + && !mi->is_shapeshifter()) { // Prevent assertion if the monster was // previously worshipping a different god, // rather than already worshipping your god or // being an atheist. - monster->god = GOD_NO_GOD; + mi->god = GOD_NO_GOD; - mons_make_god_gift(monster, is_good_god(you.religion) ? + mons_make_god_gift(*mi, is_good_god(you.religion) ? GOD_SHINING_ONE : GOD_BEOGH); } } else - monster->add_ench(ENCH_CHARM); + mi->add_ench(ENCH_CHARM); } } } |