summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/travel.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/travel.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/travel.cc')
-rw-r--r--crawl-ref/source/travel.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 41518104b8..5a53ebf797 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2112,9 +2112,9 @@ static vector<branch_type> _get_branches(bool (*selector)(const Branch &))
{
vector<branch_type> result;
- for (int i = 0; i < NUM_BRANCHES; ++i)
- if (selector(branches[i]))
- result.push_back(branches[i].id);
+ for (branch_iterator it; it; ++it)
+ if (selector(**it))
+ result.push_back(it->id);
return result;
}
@@ -3132,11 +3132,11 @@ level_id level_id::get_next_level_id(const coord_def &pos)
return stair_destination(pos);
#endif
- for (int i = 0; i < NUM_BRANCHES; ++i)
+ for (branch_iterator it; it; ++it)
{
- if (gridc == branches[i].entry_stairs)
+ if (gridc == it->entry_stairs)
{
- id.branch = static_cast<branch_type>(i);
+ id.branch = it->id;
id.depth = 1;
break;
}