summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-20 01:06:59 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-20 01:06:59 +0000
commit41310a1c085fd2f8a94ff5d8c34d61414e8b72a3 (patch)
treeca021f865e8aa3f406856e38fa32fcc8d1b24256 /crawl-ref/source/dungeon.cc
parentfb2de3b69218f690d6e3fe70da95b6d895dc9209 (diff)
downloadcrawl-ref-41310a1c085fd2f8a94ff5d8c34d61414e8b72a3.tar.gz
crawl-ref-41310a1c085fd2f8a94ff5d8c34d61414e8b72a3.zip
[1914620] Adjusting duplicate stair removal logic (such as extra stone stairs being created by vaults) to try to preserve stone stairs from vaults.
Extra stone stairs (still) become escape hatches, except in Zot where they now become non-stairs, to coerce players into traveling through vaults. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4396 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc48
1 files changed, 46 insertions, 2 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 1c55e88d6c..c41cfc0f60 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -938,7 +938,7 @@ static void _fixup_branch_stairs()
}
}
-static void _fixup_duplicate_stairs()
+static bool _fixup_duplicate_stairs(bool preserve_vault_stairs)
{
// This function ensures that there is no more than one of each up and down
// stone stairs I, II, and III. More than three stairs will result in
@@ -969,6 +969,8 @@ static void _fixup_duplicate_stairs()
}
}
+ bool success = true;
+
for (unsigned int i = 0; i < 2; i++)
{
FixedVector<coord_def, max_stairs>& stair_list = (i == 0) ? up_stairs
@@ -990,6 +992,11 @@ static void _fixup_duplicate_stairs()
base = DNGN_STONE_STAIRS_DOWN_I;
}
+ // In Zot, don't create extra escape hatches, in order to force
+ // the player through vaults that use all three down stone stairs.
+ if (player_in_branch(BRANCH_HALL_OF_ZOT))
+ replace = DNGN_GRANITE_STATUE;
+
if (num_stairs > 3)
{
// Find pairwise stairs that are connected and turn one of them
@@ -1004,6 +1011,12 @@ static void _fixup_duplicate_stairs()
if (num_stairs <= 3)
break;
+ if (preserve_vault_stairs &&
+ (dgn_Map_Mask(stair_list[s2]) & MMT_VAULT))
+ {
+ continue;
+ }
+
flood_find<feature_grid, coord_predicate> ff(env.grid,
in_bounds);
@@ -1031,12 +1044,35 @@ static void _fixup_duplicate_stairs()
while (num_stairs > 3)
{
int remove = random2(num_stairs);
+ if (preserve_vault_stairs)
+ {
+ int start = remove;
+ do
+ {
+ if (!(dgn_Map_Mask(stair_list[remove]) & MMT_VAULT))
+ break;
+ remove = (remove + 1) % num_stairs;
+ }
+ while (start != remove);
+
+ // If we looped through all possibilities, then it
+ // means that there are more than 3 stairs in vaults and
+ // we can't preserve vault stairs.
+ if (start == remove)
+ break;
+ }
grd(stair_list[remove]) = replace;
stair_list[remove] = stair_list[--num_stairs];
}
}
+ if (num_stairs > 3 && preserve_vault_stairs)
+ {
+ success = false;
+ continue;
+ }
+
ASSERT(num_stairs <= 3);
if (num_stairs <= 1)
@@ -1058,6 +1094,8 @@ static void _fixup_duplicate_stairs()
}
}
}
+
+ return success;
}
static void _dgn_verify_connectivity(unsigned nvaults)
@@ -1201,7 +1239,13 @@ static void _build_dungeon_level(int level_number, int level_type)
if (level_type == LEVEL_PANDEMONIUM)
_fixup_pandemonium_stairs();
- _fixup_duplicate_stairs();
+ if (!_fixup_duplicate_stairs(true))
+ {
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS, "Warning: failed to preserve vault stairs.");
+#endif
+ _fixup_duplicate_stairs(false);
+ }
} // end builder()