summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-12-30 18:37:25 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-12-30 18:44:25 +0530
commit23a78d07d2d1db6096497dc226d90e12eb010926 (patch)
tree4345e28270effd523ddabbacac5508e687f511ec
parent30ad58ea18d6e4e2132d235e60f66f11131e17dc (diff)
downloadcrawl-ref-23a78d07d2d1db6096497dc226d90e12eb010926.tar.gz
crawl-ref-23a78d07d2d1db6096497dc226d90e12eb010926.zip
More sanity checks for Shoals vault and stair connectivity (due).
-rw-r--r--crawl-ref/source/dgn-shoals.cc6
-rw-r--r--crawl-ref/source/dungeon.cc43
-rw-r--r--crawl-ref/source/dungeon.h6
3 files changed, 45 insertions, 10 deletions
diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc
index 57025a67d4..e9e563cea3 100644
--- a/crawl-ref/source/dgn-shoals.cc
+++ b/crawl-ref/source/dgn-shoals.cc
@@ -392,16 +392,20 @@ static void _shoals_furniture(int margin)
{
if (at_branch_bottom())
{
+ unwind_var<dungeon_feature_set> vault_exc(dgn_Vault_Excavatable_Feats);
+ dgn_Vault_Excavatable_Feats.insert(DNGN_STONE_WALL);
+
const coord_def c = _pick_shoals_island();
// Put all the stairs on one island.
grd(c) = DNGN_STONE_STAIRS_UP_I;
grd(c + coord_def(1, 0)) = DNGN_STONE_STAIRS_UP_II;
grd(c - coord_def(1, 0)) = DNGN_STONE_STAIRS_UP_III;
+ dgn_excavate(c, dgn_random_direction());
const coord_def p = _pick_shoals_island_distant_from(c);
// Place the rune
const map_def *vault = random_map_for_tag("shoal_rune");
- dgn_ensure_vault_placed(dgn_place_map(vault, false, true, p),
+ dgn_ensure_vault_placed(dgn_place_map(vault, false, false, p),
false);
const int nhuts = std::min(8, int(_shoals_islands.size()));
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 5cae7491fe..cac0b160af 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -248,6 +248,7 @@ FixedVector<unique_item_status_type, MAX_UNRANDARTS> temp_unique_items;
std::set<std::string> Level_Unique_Maps;
std::set<std::string> Level_Unique_Tags;
+dungeon_feature_set dgn_Vault_Excavatable_Feats;
std::string dgn_Build_Method;
std::string dgn_Layout_Type;
@@ -971,6 +972,12 @@ static bool _valid_dungeon_level(int level_number, int level_type)
return (true);
}
+static void _dgn_init_vault_excavatable_feats()
+{
+ dgn_Vault_Excavatable_Feats.clear();
+ dgn_Vault_Excavatable_Feats.insert(DNGN_ROCK_WALL);
+}
+
void dgn_reset_level()
{
dgn_level_vetoed = false;
@@ -987,6 +994,8 @@ void dgn_reset_level()
level_clear_vault_memory();
dgn_colour_grid.reset(NULL);
+ _dgn_init_vault_excavatable_feats();
+
can_create_vault = true;
use_random_maps = true;
dgn_check_connectivity = false;
@@ -3835,12 +3844,22 @@ static coord_def _dig_away_dir(const vault_placement &place,
return (dig_dir);
}
-static void _dig_away_from(vault_placement &place, const coord_def &pos)
+// Returns true if the feature can be ovewritten by floor when digging a path
+// from a vault to its surroundings.
+bool dgn_vault_excavatable_feat(dungeon_feature_type feat)
{
- coord_def dig_dir = _dig_away_dir(place, pos);
- coord_def dig_at = pos;
- bool dug = false;
+ return (dgn_Vault_Excavatable_Feats.find(feat) !=
+ dgn_Vault_Excavatable_Feats.end());
+}
+coord_def dgn_random_direction()
+{
+ return Compass[random2(8)];
+}
+
+void dgn_excavate(coord_def dig_at, coord_def dig_dir)
+{
+ bool dug = false;
for (int i = 0; i < GXM; i++)
{
dig_at += dig_dir;
@@ -3851,12 +3870,13 @@ static void _dig_away_from(vault_placement &place, const coord_def &pos)
break;
}
- if (grd(dig_at) == DNGN_ROCK_WALL)
+ const dungeon_feature_type dig_feat(grd(dig_at));
+ if (dgn_vault_excavatable_feat(dig_feat))
{
grd(dig_at) = DNGN_FLOOR;
dug = true;
}
- else if (grd(dig_at) == DNGN_FLOOR && i > 0)
+ else if (dig_feat == DNGN_FLOOR && i > 0)
{
// If the floor square has at least two neighbouring
// non-solid squares, we're done.
@@ -3877,6 +3897,13 @@ static void _dig_away_from(vault_placement &place, const coord_def &pos)
}
}
+static void _dig_away_from(vault_placement &place, const coord_def &pos)
+{
+ coord_def dig_dir = _dig_away_dir(place, pos);
+ coord_def dig_at = pos;
+ dgn_excavate(dig_at, dig_dir);
+}
+
static void _dig_vault_loose( vault_placement &place,
std::vector<coord_def> &targets )
{
@@ -4162,9 +4189,7 @@ static bool _build_secondary_vault(int level_number, const map_def *vault,
no_exits, where))
{
const vault_placement &vp = Level_Vaults[ Level_Vaults.size() - 1 ];
- if (!player_in_branch(BRANCH_SHOALS))
- _connect_vault(vp);
-
+ _connect_vault(vp);
return (true);
}
return (false);
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index 38a9aef6d9..9eb1cf0eb2 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -275,6 +275,9 @@ void dgn_replace_area(int sx, int sy, int ex, int ey,
dungeon_feature_type feature,
unsigned mmask = 0, bool needs_update = false);
+void dgn_excavate(coord_def dig_at, coord_def dig_dir);
+coord_def dgn_random_direction();
+
bool dgn_ensure_vault_placed(bool vault_success,
bool disable_further_vaults);
@@ -297,4 +300,7 @@ std::string dump_vault_maps();
bool dgn_square_travel_ok(const coord_def &c);
+typedef std::set<dungeon_feature_type> dungeon_feature_set;
+extern dungeon_feature_set dgn_Vault_Excavatable_Feats;
+
#endif