diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-08-02 20:06:34 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-08-02 20:10:40 -0400 |
commit | 4e1b44a4905cccd1a8509a91f9d10d7a06f956e7 (patch) | |
tree | 62b76b8e00325f1f7a96c646f10b5a5fe62919e6 /crawl-ref/source/branch.h | |
parent | 756871af9b64cee576375e9ed5f73cf3cfa1b453 (diff) | |
download | crawl-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/branch.h')
-rw-r--r-- | crawl-ref/source/branch.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crawl-ref/source/branch.h b/crawl-ref/source/branch.h index 2c692ff43e..a77b092d92 100644 --- a/crawl-ref/source/branch.h +++ b/crawl-ref/source/branch.h @@ -44,6 +44,20 @@ struct Branch int ambient_noise; // affects noise loudness and player stealth }; +class branch_iterator { +public: + branch_iterator(); + + operator bool() const; + const Branch* operator*() const; + const Branch* operator->() const; + branch_iterator& operator++(); + branch_iterator operator++(int); + +protected: + int i; +}; + extern const Branch branches[NUM_BRANCHES]; extern FixedVector<level_id, NUM_BRANCHES> brentry; extern FixedVector<int, NUM_BRANCHES> brdepth; @@ -55,6 +69,7 @@ const Branch& your_branch(); bool at_branch_bottom(); bool is_hell_subbranch(branch_type branch); bool is_random_subbranch(branch_type branch); +bool is_connected_branch(const Branch *branch); bool is_connected_branch(branch_type branch); bool is_connected_branch(level_id place); level_id current_level_parent(); |