summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-22 11:14:27 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-22 11:14:27 +0000
commit81612f62ebb9c6f74314875af2d4b92cfcdcfc67 (patch)
treedfb0d7bca291dfdfd9bc1520072e822da9ac1b05 /crawl-ref/source/dungeon.cc
parentdcde5bcfc99b2bd881f7ba3edd4e2b9cf37d3cf3 (diff)
downloadcrawl-ref-81612f62ebb9c6f74314875af2d4b92cfcdcfc67.tar.gz
crawl-ref-81612f62ebb9c6f74314875af2d4b92cfcdcfc67.zip
Labyrinths get tricoloured walls: rock at the periphery, stone further in, and
metal walls closest to the minotaur vault. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1620 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc108
1 files changed, 99 insertions, 9 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 90bb19a854..0ed4cfc8aa 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -78,6 +78,17 @@ struct spec_room
}
};
+struct dist_feat
+{
+ int dist;
+ dungeon_feature_type feat;
+
+ dist_feat(int _d = 0, dungeon_feature_type _f = DNGN_UNSEEN)
+ : dist(_d), feat(_f)
+ {
+ }
+};
+
// DUNGEON BUILDERS
static void build_dungeon_level(int level_number, int level_type);
static bool valid_dungeon_level(int level_number, int level_type);
@@ -4845,6 +4856,76 @@ static void pad_region(const dgn_region &reg, int pad_depth,
}
}
+static void change_walls_from_centre(const dgn_region &region,
+ const coord_def &centre,
+ bool rectangular,
+ const dgn_region_list &forbidden,
+ dungeon_feature_type wall,
+ const std::vector<dist_feat> &ldist)
+{
+ if (ldist.empty())
+ return;
+
+ const coord_def &end = region.pos + region.size;
+ for (int y = region.pos.y; y < end.y; ++y)
+ {
+ for (int x = region.pos.x; x < end.x; ++x)
+ {
+ const coord_def c(x, y);
+ if (grd(c) != wall || !unforbidden(c, forbidden))
+ continue;
+
+ const int distance =
+ rectangular? (c - centre).rdist() : (c - centre).abs();
+
+ for (int i = 0, size = ldist.size(); i < size; ++i)
+ {
+ if (distance <= ldist[i].dist)
+ {
+ grd(c) = ldist[i].feat;
+ break;
+ }
+ }
+ }
+ }
+}
+
+// Called as:
+// change_walls_from_centre( region_affected, centre, rectangular, wall,
+// dist1, feat1, dist2, feat2, ..., 0 )
+// What it does:
+// Examines each square in region_affected, calculates its distance from
+// "centre" (the centre need not be in region_affected). If the distance is
+// less than or equal to dist1, and the feature == wall, then it is replaced
+// by feat1. Otherwise, if the distance <= dist2 and feature == wall, it is
+// replaced by feat2, and so on. A distance of 0 indicates the end of the
+// list of distances.
+//
+static void change_walls_from_centre(const dgn_region &region,
+ const coord_def &c,
+ bool rectangular,
+ const dgn_region_list &forbidden,
+ dungeon_feature_type wall,
+ ...)
+{
+ std::vector<dist_feat> ldist;
+
+ va_list args;
+ va_start(args, wall);
+
+ while (true)
+ {
+ const int dist = va_arg(args, int);
+ if (!dist)
+ break;
+ const dungeon_feature_type feat =
+ static_cast<dungeon_feature_type>( va_arg(args, int) );
+ ldist.push_back(dist_feat(dist, feat));
+ }
+
+ change_walls_from_centre(region, c, rectangular, forbidden, wall, ldist);
+}
+
static void labyrinth_level(int level_number)
{
dgn_region lab =
@@ -4898,17 +4979,26 @@ static void labyrinth_level(int level_number)
pad_region(dgn_region(place.x, place.y, place.width, place.height),
1, DNGN_FLOOR);
}
-
- // turn rock walls into undiggable stone or metal:
- dungeon_feature_type wall_xform =
- ((random2(50) > 10) ? DNGN_STONE_WALL // 78.0%
- : DNGN_METAL_WALL); // 22.0%
-
+
dgn_region_list vaults;
- vaults.push_back(
- dgn_region(place.x, place.y, place.width, place.height));
+ if (vault != -1)
+ {
+ vaults.push_back(
+ dgn_region(place.x, place.y, place.width, place.height));
+ end = coord_def(place.x + place.width / 2,
+ place.y + place.height / 2);
+ }
+
+ change_walls_from_centre(lab, end, false, vaults, DNGN_ROCK_WALL,
+ 15 * 15, DNGN_METAL_WALL,
+ 34 * 34, DNGN_STONE_WALL,
+ 0);
- replace_area(0, 0, GXM - 1, GYM - 1, DNGN_ROCK_WALL, wall_xform, vaults);
+ // turn rock walls into undiggable stone or metal:
+ // dungeon_feature_type wall_xform =
+ // ((random2(50) > 10) ? DNGN_STONE_WALL // 78.0%
+ // : DNGN_METAL_WALL); // 22.0%
+ //replace_area(0, 0, GXM - 1, GYM - 1, DNGN_ROCK_WALL, wall_xform, vaults);
link_items();