summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-pick.cc
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-08-02 20:06:34 -0400
committerJesse Luehrs <doy@tozt.net>2014-08-02 20:10:40 -0400
commit4e1b44a4905cccd1a8509a91f9d10d7a06f956e7 (patch)
tree62b76b8e00325f1f7a96c646f10b5a5fe62919e6 /crawl-ref/source/mon-pick.cc
parent756871af9b64cee576375e9ed5f73cf3cfa1b453 (diff)
downloadcrawl-ref-4e1b44a4905cccd1a8509a91f9d10d7a06f956e7.tar.gz
crawl-ref-4e1b44a4905cccd1a8509a91f9d10d7a06f956e7.zip
allow iterating over branches in a non-enum order (8742)
This allows us to have a consistent and logical ordering of branches without requiring the branch enum itself to be reordered (which could have save compatibility implications). The new ordering of branches just moves Depths to the place in the ordering that it already is planned to go on the next major save compat bump, but other changes are possible, if desired. All places in the code that iterate over branches have been updated to use the new iterator except for code dealing with save files, which still uses enum order, so that we can change the display ordering without affecting saves.
Diffstat (limited to 'crawl-ref/source/mon-pick.cc')
-rw-r--r--crawl-ref/source/mon-pick.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/crawl-ref/source/mon-pick.cc b/crawl-ref/source/mon-pick.cc
index f645be6100..4e74424ba5 100644
--- a/crawl-ref/source/mon-pick.cc
+++ b/crawl-ref/source/mon-pick.cc
@@ -169,13 +169,13 @@ monster_type pick_monster_all_branches(int absdepth0, monster_picker &picker,
memset(rarities, 0, sizeof(rarities));
int nvalid = 0;
- for (int br = 0; br < NUM_BRANCHES; br++)
+ for (branch_iterator it; it; ++it)
{
- int depth = absdepth0 - absdungeon_depth((branch_type)br, 0);
- if (depth < 1 || depth > branch_ood_cap((branch_type)br))
+ int depth = absdepth0 - absdungeon_depth(it->id, 0);
+ if (depth < 1 || depth > branch_ood_cap(it->id))
continue;
- for (const pop_entry *pop = population[br].pop; pop->value; pop++)
+ for (const pop_entry *pop = population[it->id].pop; pop->value; pop++)
{
if (depth < pop->minr || depth > pop->maxr)
continue;
@@ -254,9 +254,9 @@ void debug_monpick()
string fails;
// Tests for the legacy interface; shouldn't ever happen.
- for (int i = 0; i < NUM_BRANCHES; ++i)
+ for (branch_iterator it; it; ++it)
{
- branch_type br = (branch_type)i;
+ branch_type br = it->id;
for (monster_type m = MONS_0; m < NUM_MONSTERS; ++m)
{
@@ -266,22 +266,22 @@ void debug_monpick()
if (lev < DEPTH_NOWHERE && !rare)
{
fails += make_stringf("%s: no rarity for %s\n",
- branches[i].abbrevname,
+ it->abbrevname,
mons_class_name(m));
}
if (rare && lev >= DEPTH_NOWHERE)
{
fails += make_stringf("%s: no depth for %s\n",
- branches[i].abbrevname,
+ it->abbrevname,
mons_class_name(m));
}
}
}
// Legacy tests end.
- for (int i = 0; i < NUM_BRANCHES; ++i)
+ for (branch_iterator it; it; ++it)
{
- branch_type br = (branch_type)i;
+ branch_type br = it->id;
for (int d = 1; d <= branch_ood_cap(br); d++)
{