diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/dat/layout.des | 9 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 23 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/luadgn.cc | 20 |
4 files changed, 50 insertions, 5 deletions
diff --git a/crawl-ref/source/dat/layout.des b/crawl-ref/source/dat/layout.des index 6888c3af19..3fa39f1141 100644 --- a/crawl-ref/source/dat/layout.des +++ b/crawl-ref/source/dat/layout.des @@ -149,8 +149,9 @@ TAGS: layout allow_dup dgn.fill_area(0, 0, gxm - 1, gym - 1, "rock_wall") dgn.octa_room(10, 10, gxm - 10, gym - 10, oblique, "floor") - if crawl.coinflip() then - local iterations = 100 + crawl.random2(200) + local smear = crawl.coinflip() + if smear then + local iterations = 100 + crawl.random2(400) dgn.smear_feature(iterations, false, wall, 0, 0, gxm - 1, gym - 1) end @@ -242,6 +243,10 @@ TAGS: layout allow_dup assert(ret) end end + + if smear then + dgn.fill_disconnected_zones(0, 0, gxm - 1, gym - 1, wall) + end }} MAP ENDMAP diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index d24e9e2e34..e689a95188 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -595,12 +595,16 @@ static bool _is_exit_stair(const coord_def &c) // If count_stairless is true, returns the number of regions that have no // stairs in them. // -static int _dgn_count_disconnected_zones(bool choose_stairless) +// If fill is non-zero, it fills any disconnected regions with fill. +// +int process_disconnected_zones(int x1, int y1, int x2, int y2, + bool choose_stairless, + dungeon_feature_type fill) { memset(travel_point_distance, 0, sizeof(travel_distance_grid_t)); int nzones = 0; - for (int y = 0; y < GYM; ++y) - for (int x = 0; x < GXM; ++x) + for (int y = y1; y <= y1 ; ++y) + for (int x = x2; x <= x2; ++x) { if (!map_bounds(x, y) || travel_point_distance[x][y] @@ -619,11 +623,24 @@ static int _dgn_count_disconnected_zones(bool choose_stairless) // have stairs. if (choose_stairless && found_exit_stair) --nzones; + else if (fill) + { + for (int fy = y1; fy <= y1 ; ++fy) + for (int fx = x2; fx <= x2; ++x) + if (travel_point_distance[fx][fy] == nzones) + grd[fx][fy] = fill; + } } return (nzones); } +static int _dgn_count_disconnected_zones(bool choose_stairless) +{ + return process_disconnected_zones(0, 0, GXM-1, GYM-1, choose_stairless, + (dungeon_feature_type)0); +} + static void _fixup_pandemonium_stairs() { for (int i = 0; i < GXM; i++) diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h index fccda76c9f..be3c9d4cb3 100644 --- a/crawl-ref/source/dungeon.h +++ b/crawl-ref/source/dungeon.h @@ -360,6 +360,9 @@ bool join_the_dots(const coord_def &from, const coord_def &to, void spotty_level(bool seeded, int iterations, bool boxy); void smear_feature(int iterations, bool boxy, dungeon_feature_type feature, int x1, int y1, int x2, int y2); +int process_disconnected_zones(int x1, int y1, int x2, int y2, + bool choose_stairless, + dungeon_feature_type fill); bool octa_room(spec_room &sr, int oblique_max, dungeon_feature_type type_floor); diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index 60a33a077c..0804d859c7 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -2050,6 +2050,25 @@ static int dgn_join_the_dots(lua_State *ls) return 1; } +static int dgn_fill_disconnected_zones(lua_State *ls) +{ + int from_x = luaL_checkint(ls, 1); + int from_y = luaL_checkint(ls, 2); + int to_x = luaL_checkint(ls, 3); + int to_y = luaL_checkint(ls, 4); + + dungeon_feature_type feat = _get_lua_feature(ls, 5); + if (!feat) + { + luaL_argerror(ls, 5, "Invalid feature."); + return 0; + } + + process_disconnected_zones(from_x, from_y, to_x, to_y, true, feat); + + return 0; +} + static const struct luaL_reg dgn_lib[] = { { "default_depth", dgn_default_depth }, @@ -2132,6 +2151,7 @@ static const struct luaL_reg dgn_lib[] = { "count_antifeature_in_box", dgn_count_antifeature_in_box }, { "count_neighbours", dgn_count_neighbours }, { "join_the_dots", dgn_join_the_dots }, + { "fill_disconnected_zones", dgn_fill_disconnected_zones }, { NULL, NULL } }; |