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/misc.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/misc.cc')
-rw-r--r-- | crawl-ref/source/misc.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 0c4d997d89..d1744552bb 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -56,6 +56,7 @@ #include "mapmark.h" #include "message.h" #include "monplace.h" +#include "mon-iter.h" #include "mon-util.h" #include "monstuff.h" #include "ouch.h" @@ -2968,14 +2969,11 @@ static void monster_threat_values(double *general, double *highest, double sum = 0; int highest_xp = -1; - monsters *monster = NULL; - for (int it = 0; it < MAX_MONSTERS; it++) + for (monster_iterator mi(&you.get_los()); mi; ++mi) { - monster = &menv[it]; - - if (monster->alive() && mons_near(monster) && !monster->friendly()) + if (!mi->friendly()) { - const int xp = exper_value(monster); + const int xp = exper_value(*mi); const double log_xp = log((double)xp); sum += log_xp; if (xp > highest_xp) @@ -2983,7 +2981,7 @@ static void monster_threat_values(double *general, double *highest, highest_xp = xp; *highest = log_xp; } - if (!you.can_see(monster)) + if (!you.can_see(*mi)) *invis = true; } } |