From adb21570e7da7ff280113e938ee7a26089614e63 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 11 Nov 2009 16:38:12 +0100 Subject: 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. --- crawl-ref/source/mon-act.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'crawl-ref/source/mon-act.cc') 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) -- cgit v1.2.3-54-g00ecf