summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/abyss.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-11 16:38:12 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-11 19:14:39 +0100
commitadb21570e7da7ff280113e938ee7a26089614e63 (patch)
tree3fe1dc829ae1826eac4a4081ed3e3c115a562d04 /crawl-ref/source/abyss.cc
parent24636262aded779e9759895c536e0f42f79c4b52 (diff)
downloadcrawl-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/abyss.cc')
-rw-r--r--crawl-ref/source/abyss.cc28
1 files changed, 10 insertions, 18 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc
index cf3f74267d..e5d64fff31 100644
--- a/crawl-ref/source/abyss.cc
+++ b/crawl-ref/source/abyss.cc
@@ -18,6 +18,7 @@
#include "mapmark.h"
#include "message.h"
#include "misc.h"
+#include "mon-iter.h"
#include "mon-util.h"
#include "monplace.h"
#include "mtransit.h"
@@ -442,16 +443,11 @@ void area_shift(void)
_xom_check_nearness_setup();
- for (unsigned int i = 0; i < MAX_MONSTERS; i++)
+ // Remove non-nearby monsters.
+ for (monster_iterator mi; mi; ++mi)
{
- monsters &m = menv[i];
-
- if (!m.alive())
- continue;
-
- // Remove non-nearby monsters.
- if (grid_distance(m.pos(), you.pos()) > 10)
- _abyss_lose_monster(m);
+ if (grid_distance(mi->pos(), you.pos()) > 10)
+ _abyss_lose_monster(**mi);
}
for (rectangle_iterator ri(5); ri; ++ri)
@@ -546,12 +542,9 @@ void area_shift(void)
void save_abyss_uniques()
{
- for (int i = 0; i < MAX_MONSTERS; ++i)
- {
- monsters &m = menv[i];
- if (m.alive() && m.needs_transit())
- m.set_transit( level_id(LEVEL_ABYSS) );
- }
+ for (monster_iterator mi; mi; ++mi)
+ if (mi->needs_transit())
+ mi->set_transit(level_id(LEVEL_ABYSS));
}
void abyss_teleport( bool new_area )
@@ -602,9 +595,8 @@ void abyss_teleport( bool new_area )
tile_init_flavour();
#endif
- for (int i = 0; i < MAX_MONSTERS; ++i)
- if (menv[i].alive())
- _abyss_lose_monster(menv[i]);
+ for (monster_iterator mi; mi; ++mi)
+ _abyss_lose_monster(**mi);
// Orbs and fixed artefacts are marked as "lost in the abyss".
for (int i = 0; i < MAX_ITEMS; ++i)