summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ng-init.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-11-02 06:48:20 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-11-02 13:44:54 +0100
commit6a31aa9e10181fa0bcdebe7ab263b7e428bd605a (patch)
treec62b9cdb1363bf1eb979f545dd66fa322df4a7b9 /crawl-ref/source/ng-init.cc
parentea129f0f56d9dfc1b3abd5653b1737c2a6089684 (diff)
downloadcrawl-ref-6a31aa9e10181fa0bcdebe7ab263b7e428bd605a.tar.gz
crawl-ref-6a31aa9e10181fa0bcdebe7ab263b7e428bd605a.zip
Store the entry level for every branch (rather than just depth).
This allows moving branches around without breaking save compat or at least serious hacks. The portal stack can be probably dropped now: two copies of the same level can't exist anyway.
Diffstat (limited to 'crawl-ref/source/ng-init.cc')
-rw-r--r--crawl-ref/source/ng-init.cc51
1 files changed, 29 insertions, 22 deletions
diff --git a/crawl-ref/source/ng-init.cc b/crawl-ref/source/ng-init.cc
index 7f5c46b3c6..6660769a44 100644
--- a/crawl-ref/source/ng-init.cc
+++ b/crawl-ref/source/ng-init.cc
@@ -55,13 +55,34 @@ void initialise_branch_depths()
{
root_branch = BRANCH_MAIN_DUNGEON;
- for (int branch = BRANCH_ECUMENICAL_TEMPLE; branch < NUM_BRANCHES; ++branch)
+ for (int br = 0; br < NUM_BRANCHES; ++br)
+ brentry[br].clear();
+
+ if (crawl_state.game_is_sprint())
+ {
+ brdepth.init(-1);
+ brdepth[BRANCH_MAIN_DUNGEON] = 1;
+ return;
+ }
+
+ if (crawl_state.game_is_zotdef())
+ {
+ root_branch = BRANCH_HALL_OF_ZOT;
+ brdepth.init(-1);
+ brdepth[BRANCH_HALL_OF_ZOT] = 1;
+ brdepth[BRANCH_BAZAAR] = 1;
+ return;
+ }
+
+ for (int branch = 0; branch < NUM_BRANCHES; ++branch)
{
const Branch *b = &branches[branch];
- if (branch_is_unfinished(b->id))
- startdepth[branch] = -1;
- else
- startdepth[branch] = random_range(b->mindepth, b->maxdepth);
+ ASSERT(b->id == branch);
+ if (!branch_is_unfinished(b->id) && b->parent_branch != NUM_BRANCHES)
+ {
+ brentry[branch] = level_id(b->parent_branch,
+ random_range(b->mindepth, b->maxdepth));
+ }
}
// You will get one of Shoals/Swamp and one of Spider/Snake.
@@ -78,24 +99,10 @@ void initialise_branch_depths()
for (unsigned int i = 0; i < ARRAYSZ(disabled_branch); ++i)
{
dprf("Disabling branch: %s", branches[disabled_branch[i]].shortname);
- startdepth[disabled_branch[i]] = -1;
- }
-
- if (crawl_state.game_is_sprint())
- {
- brdepth.init(-1);
- brdepth[BRANCH_MAIN_DUNGEON] = 1;
- return;
- }
-
- if (crawl_state.game_is_zotdef())
- {
- root_branch = BRANCH_HALL_OF_ZOT;
- brdepth.init(-1);
- brdepth[BRANCH_HALL_OF_ZOT] = 1;
- brdepth[BRANCH_BAZAAR] = 1;
- return;
+ brentry[disabled_branch[i]].clear();
}
+ if (brentry[BRANCH_FOREST].is_valid())
+ brentry[BRANCH_TOMB].branch = BRANCH_FOREST;
for (int i = 0; i < NUM_BRANCHES; i++)
brdepth[i] = branches[i].numlevels;