diff options
author | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-26 04:52:50 +0000 |
---|---|---|
committer | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-26 04:52:50 +0000 |
commit | 64b430b8e7e9f913af35f3749514968665e15eef (patch) | |
tree | 41824223de047eba5279b258ee6424fd0e41119b /crawl-ref/source/dungeon.cc | |
parent | c9d3683f746b4b4d77747803e4bec9ca1e29f405 (diff) | |
download | crawl-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/dungeon.cc')
-rw-r--r-- | crawl-ref/source/dungeon.cc | 23 |
1 files changed, 20 insertions, 3 deletions
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++) |