summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dbg-maps.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/dbg-maps.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/dbg-maps.cc')
-rw-r--r--crawl-ref/source/dbg-maps.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/crawl-ref/source/dbg-maps.cc b/crawl-ref/source/dbg-maps.cc
index 44caa43edf..4f12c867c8 100644
--- a/crawl-ref/source/dbg-maps.cc
+++ b/crawl-ref/source/dbg-maps.cc
@@ -183,21 +183,20 @@ static void _dungeon_places()
{
generated_levels.clear();
branch_count = 0;
- for (int br = BRANCH_DUNGEON; br < NUM_BRANCHES; ++br)
+ for (branch_iterator it; it; ++it)
{
- if (brdepth[br] == -1)
+ if (brdepth[it->id] == -1)
continue;
#if TAG_MAJOR_VERSION == 34
// Don't want to include Forest since it doesn't generate
- if (br == BRANCH_FOREST)
+ if (it->id == BRANCH_FOREST)
continue;
#endif
bool new_branch = true;
- const branch_type branch = static_cast<branch_type>(br);
- for (int depth = 1; depth <= brdepth[br]; ++depth)
+ for (int depth = 1; depth <= brdepth[it->id]; ++depth)
{
- level_id l(branch, depth);
+ level_id l(it->id, depth);
if (SysEnv.map_gen_range.get() && !SysEnv.map_gen_range->is_usable_in(l))
continue;
generated_levels.push_back(l);
@@ -325,15 +324,14 @@ static void _write_map_stats()
}
vector<level_id> mapless;
- for (int i = BRANCH_DUNGEON; i < NUM_BRANCHES; ++i)
+ for (branch_iterator it; it; ++it)
{
- if (brdepth[i] == -1)
+ if (brdepth[it->id] == -1)
continue;
- const branch_type br = static_cast<branch_type>(i);
- for (int dep = 1; dep <= brdepth[i]; ++dep)
+ for (int dep = 1; dep <= brdepth[it->id]; ++dep)
{
- const level_id lid(br, dep);
+ const level_id lid(it->id, dep);
if (SysEnv.map_gen_range.get()
&& !SysEnv.map_gen_range->is_usable_in(lid))
{