From 59b053efd22ccd197d042ed5731b117e4846599b Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 4 Nov 2008 13:14:08 +0000 Subject: 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 --- crawl-ref/source/dungeon.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'crawl-ref/source/dungeon.cc') 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 ®ion, + 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 ®ion, const coord_def ¢re, 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(); -- cgit v1.2.3-54-g00ecf