summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-04 13:14:08 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-04 13:14:08 +0000
commit59b053efd22ccd197d042ed5731b117e4846599b (patch)
treeea7803c17c786ba173a4c938f999ea3815919188 /crawl-ref/source/dungeon.cc
parentf5e55fd944784181102ecdf93c6eca2da4e509b2 (diff)
downloadcrawl-ref-59b053efd22ccd197d042ed5731b117e4846599b.tar.gz
crawl-ref-59b053efd22ccd197d042ed5731b117e4846599b.zip
Apply the first part of the labyrinth tweaks:
* labyrinths are bordered by (undiggable) metal walls * teleporting inside a labyrinth will always send you away from the centre (as the crow flies: you'll end somewhere in the stone or rock area) Also make sure melded equipment cannot corrode. (I'm still undecided about whether curses should affect melded items.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7383 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index f3c51fedc7..6f4f28af82 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -6589,6 +6589,53 @@ static void _init_minivault_placement(int vault, vault_placement &place)
vault_main(vgrid, place, vault);
}
+// Checks whether a given grid has at least one neighbour surrounded
+// entirely by non-floor.
+static bool _has_no_floor_neighbours(const coord_def &pos, bool recurse = false)
+{
+ for (int x = -1; x <= 1; x++)
+ for (int y = -1; y <= 1; y++)
+ {
+ if (x == 0 && y == 0)
+ continue;
+
+ const coord_def p = pos + coord_def(x, y);
+ if (!in_bounds(p))
+ return (true);
+
+ if (recurse)
+ {
+ if (grd(p) == DNGN_FLOOR)
+ return (false);
+ }
+ else if (_has_no_floor_neighbours(p, true))
+ return (true);
+ }
+
+ return (recurse);
+}
+
+// Change the borders of the labyrinth to another (undiggable) wall type.
+static void _change_labyrinth_border(const dgn_region &region,
+ const dungeon_feature_type wall)
+{
+ const coord_def &end = region.pos + region.size;
+ for (int y = region.pos.y-1; y <= end.y; ++y)
+ for (int x = region.pos.x-1; x <= end.x; ++x)
+ {
+ const coord_def c(x, y);
+ if (!in_bounds(c)) // paranoia
+ continue;
+
+ if (grd(c) == wall || !grid_is_wall(grd(c)))
+ continue;
+
+ // All border grids have neighbours without any access to floor.
+ if (_has_no_floor_neighbours(c))
+ grd[x][y] = wall;
+ }
+}
+
static void _change_walls_from_centre(const dgn_region &region,
const coord_def &centre,
bool rectangular,
@@ -6783,6 +6830,8 @@ static void _labyrinth_level(int level_number)
34 * 34, DNGN_STONE_WALL,
0);
+ _change_labyrinth_border(lab, DNGN_METAL_WALL);
+
_labyrinth_place_entry_point(lab, end);
link_items();