summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-26 04:52:50 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-26 04:52:50 +0000
commit64b430b8e7e9f913af35f3749514968665e15eef (patch)
tree41824223de047eba5279b258ee6424fd0e41119b /crawl-ref/source
parentc9d3683f746b4b4d77747803e4bec9ca1e29f405 (diff)
downloadcrawl-ref-64b430b8e7e9f913af35f3749514968665e15eef.tar.gz
crawl-ref-64b430b8e7e9f913af35f3749514968665e15eef.zip
Adding lua function to fill in disconnected zones.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6689 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/layout.des9
-rw-r--r--crawl-ref/source/dungeon.cc23
-rw-r--r--crawl-ref/source/dungeon.h3
-rw-r--r--crawl-ref/source/luadgn.cc20
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 }
};