diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/maps.cc | 29 | ||||
-rw-r--r-- | crawl-ref/source/maps.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/test/shoal-hut.lua | 15 |
3 files changed, 28 insertions, 20 deletions
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc index d48cdad5c0..1325ad63a3 100644 --- a/crawl-ref/source/maps.cc +++ b/crawl-ref/source/maps.cc @@ -33,10 +33,6 @@ #include "tags.h" #include "terrain.h" -static bool _safe_vault_place(const map_def &md, - const coord_def &c, - const coord_def &size); - static int write_vault(map_def &mdef, vault_placement &, bool check_place); @@ -50,7 +46,7 @@ static bool resolve_map(map_def &def); // Globals: Use unwind_var to modify! // Checks whether a map place is valid. -map_place_check_t map_place_valid = _safe_vault_place; +map_place_check_t map_place_valid = map_safe_vault_place; // If non-empty, any floating vault's @ exit must land on these point. point_vector map_anchor_points; @@ -334,9 +330,9 @@ static bool _may_overwrite_feature(const dungeon_feature_type grid, return (true); } -static bool _safe_vault_place(const map_def &map, - const coord_def &c, - const coord_def &size) +bool map_safe_vault_place(const map_def &map, + const coord_def &c, + const coord_def &size) { if (size.zero()) return (true); @@ -346,14 +342,21 @@ static bool _safe_vault_place(const map_def &map, for (rectangle_iterator ri(c, c + size - 1); ri; ++ri) { - const coord_def &cp(*ri); - const coord_def &dp(cp - c); + const coord_def cp(*ri); + const coord_def dp(cp - c); if (lines[dp.y][dp.x] == ' ') continue; - if (dgn_Map_Mask[cp.x][cp.y] & MMT_VAULT) - return (false); + // Also check adjacent squares for collisions, because being next + // to another vault may block off one of this vault's exits. + for (int y = -1; y <= 1; ++y) + for (int x = -1; x <= 1; ++x) + { + const coord_def vp(x + cp.x, y + cp.y); + if (map_bounds(vp) && (dgn_Map_Mask(vp) & MMT_VAULT)) + return (false); + } const dungeon_feature_type dfeat = grd(cp); @@ -491,7 +494,7 @@ static bool apply_vault_grid(map_def &def, if (!map_bounds(start)) return (false); - if (check_place && !_safe_vault_place(def, start, size)) + if (check_place && !map_place_valid(def, start, size)) { dprf("Bad vault place: (%d,%d) dim (%d,%d)", start.x, start.y, size.x, size.y); diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h index 5beee64992..ffcd6f2333 100644 --- a/crawl-ref/source/maps.h +++ b/crawl-ref/source/maps.h @@ -17,6 +17,10 @@ class map_def; struct map_file_place; struct vault_placement; +bool map_safe_vault_place(const map_def &md, + const coord_def &c, + const coord_def &size); + int vault_main(vault_placement &vp, const map_def *vault, bool check_place = false); diff --git a/crawl-ref/source/test/shoal-hut.lua b/crawl-ref/source/test/shoal-hut.lua index 392a57e42d..208d590a84 100644 --- a/crawl-ref/source/test/shoal-hut.lua +++ b/crawl-ref/source/test/shoal-hut.lua @@ -37,15 +37,16 @@ local function shoal_hut_doors() return doors end --- The hut door is blocked if there is no adjacent square that is not solid --- or in a vault. +-- The hut door is blocked if we cannot move from the door to a non-vault +-- square without crossing solid terrain. local function hut_door_blocked(door) - for p in iter.adjacent_iterator_to(door) do - if not feat.is_solid(dgn.grid(p.x, p.y)) then - return false - end + local function good_square(p) + return not dgn.in_vault(p.x, p.y) + end + local function passable_square(p) + return not feat.is_solid(dgn.grid(p.x, p.y)) end - return true + return not dgn.find_adjacent_point(door, good_square, passable_square) end local function verify_stair_connected(p) |