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/mon-act.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/mon-act.cc')
-rw-r--r-- | crawl-ref/source/mon-act.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index e0b9dfbe94..0f17f8c53b 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -31,6 +31,7 @@ #include "mon-abil.h" #include "mon-behv.h" #include "mon-cast.h" +#include "mon-iter.h" #include "monplace.h" #include "monstuff.h" #include "mutation.h" @@ -2077,20 +2078,18 @@ void handle_monsters() // them to move again. memset(immobile_monster, 0, sizeof immobile_monster); - for (int i = 0; i < MAX_MONSTERS; ++i) + for (monster_iterator mi; mi; ++mi) { - monsters *monster = &menv[i]; - - if (!monster->alive() || immobile_monster[i]) + if (immobile_monster[mi->mindex()]) continue; - const coord_def oldpos = monster->pos(); + const coord_def oldpos = mi->pos(); - monster->update_los(); - _handle_monster_move(monster); + mi->update_los(); + _handle_monster_move(*mi); - if (!invalid_monster(monster) && monster->pos() != oldpos) - immobile_monster[i] = true; + if (!invalid_monster(*mi) && mi->pos() != oldpos) + immobile_monster[mi->mindex()] = true; // If the player got banished, discard pending monster actions. if (you.banished) |