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/ghost.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/ghost.cc')
-rw-r--r-- | crawl-ref/source/ghost.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc index 901a4b92d4..1886b65f8b 100644 --- a/crawl-ref/source/ghost.cc +++ b/crawl-ref/source/ghost.cc @@ -16,6 +16,7 @@ #include "externs.h" #include "itemname.h" #include "itemprop.h" +#include "mon-iter.h" #include "ng-input.h" #include "random.h" #include "skills2.h" @@ -846,16 +847,13 @@ void ghost_demon::announce_ghost(const ghost_demon &g) void ghost_demon::find_extra_ghosts( std::vector<ghost_demon> &gs, int n ) { - for (int i = 0; n > 0 && i < MAX_MONSTERS; ++i) + for (monster_iterator mi; mi; ++mi) { - if (!menv[i].alive()) - continue; - - if (menv[i].type == MONS_PLAYER_GHOST && menv[i].ghost.get()) + if (mi->type == MONS_PLAYER_GHOST && mi->ghost.get()) { // Bingo! - announce_ghost(*menv[i].ghost); - gs.push_back(*menv[i].ghost); + announce_ghost(*(mi->ghost)); + gs.push_back(*(mi->ghost)); --n; } } |