Attached Files |
0001-Forbid-very-small-maps.patch [^] (4,218 bytes) 2014-07-25 07:03 [Show Content] [Hide Content]From d44ce359bb6eef3ed640244c512176745bc0284b Mon Sep 17 00:00:00 2001
From: infiniplex <infiniplex@hotmail.com>
Date: Thu, 24 Jul 2014 22:56:48 -0600
Subject: [PATCH] Forbid very small maps
---
crawl-ref/source/dat/des/builder/layout.des | 6 ++++++
crawl-ref/source/dat/des/builder/layout_caves.des | 15 +++++++++++++--
crawl-ref/source/dat/des/builder/layout_halls.des | 14 ++++++++++++++
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/crawl-ref/source/dat/des/builder/layout.des b/crawl-ref/source/dat/des/builder/layout.des
index 90fa1c1..22646b0 100644
--- a/crawl-ref/source/dat/des/builder/layout.des
+++ b/crawl-ref/source/dat/des/builder/layout.des
@@ -232,6 +232,8 @@ ENDMAP
# TODO: Use "layout_type_open_caves" tag for cave version and
# "layout_type_open" tag for non-cave version.
#
+# TODO: A better way of preventing small maps
+#
NAME: layout_big_octagon
DEPTH: D:9-, Depths, Pan
WEIGHT: 3
@@ -422,6 +424,10 @@ TAGS: uniq_open_layout
theme.level_material(_G)
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ return count_feature_in_box { feat="." } > 1200
+}}
MAP
ENDMAP
diff --git a/crawl-ref/source/dat/des/builder/layout_caves.des b/crawl-ref/source/dat/des/builder/layout_caves.des
index 1032423..5344c8d 100644
--- a/crawl-ref/source/dat/des/builder/layout_caves.des
+++ b/crawl-ref/source/dat/des/builder/layout_caves.des
@@ -22,8 +22,6 @@ WEIGHT: 20, 15 (Snake)
ORIENT: encompass
TAGS: overwritable layout allow_dup unrand layout_type_narrow_caves
{{
- if is_validating() then return; end
-
local gxm,gym = dgn.max_bounds()
-- First pass
@@ -97,6 +95,12 @@ TAGS: overwritable layout allow_dup unrand layout_type_narrow_caves
theme.D.caves(_G)
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ return count_feature_in_box { feat="." } > 600
+}}
+MAP
+ENDMAP
##############################################################
# layout_cave_shapes
@@ -309,6 +313,13 @@ TAGS: overwritable layout allow_dup unrand no_pool_fixup layout_type_swamp
remove_isolated_glyphs { find = "W", percent = 80 }
zonify.grid_fill_water_zones(1,"t")
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ -- If we try to validate the map before without creating it,
+ -- we get a crash at start
+ if is_validating() then return end
+ return count_feature_in_box { feat="." } > 600
+}}
##############################################################
# layout_cave_pods
diff --git a/crawl-ref/source/dat/des/builder/layout_halls.des b/crawl-ref/source/dat/des/builder/layout_halls.des
index 9bfc89b..a66209f 100644
--- a/crawl-ref/source/dat/des/builder/layout_halls.des
+++ b/crawl-ref/source/dat/des/builder/layout_halls.des
@@ -339,6 +339,13 @@ TAGS: overwritable layout allow_dup unrand layout_type_open_caves
zonify.map_fill_zones(_G, 1, 'x')
theme.level_material(_G)
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ -- If we try to validate the map before without creating it,
+ -- we get a crash at start
+ if is_validating() then return end
+ return count_feature_in_box { feat="." } > 600
+}}
##############################################################
# layout_onion_interference
@@ -346,6 +353,8 @@ TAGS: overwritable layout allow_dup unrand layout_type_open_caves
# Layers two onions on top of each other to create an
# interference pattern (with option xor)
#
+# TODO: A better way of dealing with small maps
+#
NAME: layout_onion_interference
DEPTH: Snake, Zot:1-4
WEIGHT: 10
@@ -528,6 +537,7 @@ ENDMAP
#
# TODO: Use Snake variant in Lair, add with weight 3.
# TODO: Minimum area validation in Snake (can be disconnected).
+# Then remove minimum size validate as unneeded
#
NAME: layout_concentric_octagons
DEPTH: Snake, Zot
@@ -816,3 +826,7 @@ TAGS: no_rotate no_vmirror no_hmirror
mapgrd[gxm/2][gym/2] = '.'
end
}}
+# Enforce minimum floor size - remove when connection is working in Snake
+validate {{
+ return count_feature_in_box { feat="." } > 600
+}}
--
1.8.1.2
0001-Standardize-forbiddance-of-very-small-maps.patch [^] (11,331 bytes) 2014-07-25 08:21 [Show Content] [Hide Content]From 8c33ad7d9e6a6dc671ac38ea64d1b648114e9fe7 Mon Sep 17 00:00:00 2001
From: infiniplex <infiniplex@hotmail.com>
Date: Thu, 24 Jul 2014 22:56:48 -0600
Subject: [PATCH] Standardize forbiddance of very small maps
---
crawl-ref/source/dat/des/builder/layout.des | 13 ++++--
crawl-ref/source/dat/des/builder/layout_caves.des | 16 ++++++-
crawl-ref/source/dat/des/builder/layout_halls.des | 17 ++++++-
.../dat/des/builder/layout_overlapping_boxes.des | 5 ++-
crawl-ref/source/dat/des/builder/layout_pools.des | 12 +++--
.../source/dat/dlua/layout/minimum_map_area.lua | 52 ++++++++++++++++++++++
6 files changed, 101 insertions(+), 14 deletions(-)
create mode 100644 crawl-ref/source/dat/dlua/layout/minimum_map_area.lua
diff --git a/crawl-ref/source/dat/des/builder/layout.des b/crawl-ref/source/dat/des/builder/layout.des
index 90fa1c1..ad2af7f 100644
--- a/crawl-ref/source/dat/des/builder/layout.des
+++ b/crawl-ref/source/dat/des/builder/layout.des
@@ -8,6 +8,7 @@
: require("dlua/layout/zonify.lua")
: require("dlua/layout/theme.lua")
+: require("dlua/layout/minimum_map_area.lua")
{{
-- Call func num times around a circle of radius centered at (x, y)
@@ -232,6 +233,8 @@ ENDMAP
# TODO: Use "layout_type_open_caves" tag for cave version and
# "layout_type_open" tag for non-cave version.
#
+# TODO: A better way of preventing small maps
+#
NAME: layout_big_octagon
DEPTH: D:9-, Depths, Pan
WEIGHT: 3
@@ -422,6 +425,10 @@ TAGS: uniq_open_layout
theme.level_material(_G)
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.OPEN)
+}}
MAP
ENDMAP
@@ -843,7 +850,7 @@ TAGS: overwritable layout allow_dup unrand layout_type_open_caves
}}
# Enforce minimum floor size - otherwise we get very tiny floors sometimes
validate {{
- return count_feature_in_box { feat="." } > 600
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.OPEN_CAVES)
}}
MAP
ENDMAP
@@ -1466,7 +1473,7 @@ TAGS: no_rotate no_vmirror no_hmirror
}}
# Enforce minimum floor size - this is important with the alt version
validate {{
- return count_feature_in_box { feat="." } > 1200
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.DIVISIONS)
}}
COLOUR: G : cyan
TILE: G = dngn_statue_iron_golem
@@ -1913,7 +1920,7 @@ TAGS: no_rotate no_hmirror no_vmirror
}}
# Enforce minimum floor size - this is important
validate {{
- return count_feature_in_box { feat="." } > 600
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.NARROW_CAVES)
}}
MAP
ENDMAP
diff --git a/crawl-ref/source/dat/des/builder/layout_caves.des b/crawl-ref/source/dat/des/builder/layout_caves.des
index 1032423..0a6f3d8 100644
--- a/crawl-ref/source/dat/des/builder/layout_caves.des
+++ b/crawl-ref/source/dat/des/builder/layout_caves.des
@@ -9,6 +9,7 @@
: require("dlua/layout/hyper.lua")
: require("dlua/layout/hyper_caves.lua")
: require("dlua/layout/theme.lua")
+: require("dlua/layout/minimum_map_area.lua")
##############################################################
# layout_layer_cave
@@ -22,8 +23,6 @@ WEIGHT: 20, 15 (Snake)
ORIENT: encompass
TAGS: overwritable layout allow_dup unrand layout_type_narrow_caves
{{
- if is_validating() then return; end
-
local gxm,gym = dgn.max_bounds()
-- First pass
@@ -97,6 +96,12 @@ TAGS: overwritable layout allow_dup unrand layout_type_narrow_caves
theme.D.caves(_G)
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.NARROW_CAVES)
+}}
+MAP
+ENDMAP
##############################################################
# layout_cave_shapes
@@ -309,6 +314,13 @@ TAGS: overwritable layout allow_dup unrand no_pool_fixup layout_type_swamp
remove_isolated_glyphs { find = "W", percent = 80 }
zonify.grid_fill_water_zones(1,"t")
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ -- If we try to validate the map before without creating it,
+ -- we get a crash at start
+ if is_validating() then return end
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.SWAMP, ".W")
+}}
##############################################################
# layout_cave_pods
diff --git a/crawl-ref/source/dat/des/builder/layout_halls.des b/crawl-ref/source/dat/des/builder/layout_halls.des
index 9bfc89b..57e3292 100644
--- a/crawl-ref/source/dat/des/builder/layout_halls.des
+++ b/crawl-ref/source/dat/des/builder/layout_halls.des
@@ -9,6 +9,7 @@
: require("dlua/layout/procedural_transform.lua")
: require("dlua/layout/zonify.lua")
: require("dlua/layout/theme.lua")
+: require("dlua/layout/minimum_map_area.lua")
{{
@@ -339,6 +340,13 @@ TAGS: overwritable layout allow_dup unrand layout_type_open_caves
zonify.map_fill_zones(_G, 1, 'x')
theme.level_material(_G)
}}
+# Enforce minimum floor size - otherwise we get very tiny floors sometimes
+validate {{
+ -- If we try to validate the map before without creating it,
+ -- we get a crash at start
+ if is_validating() then return end
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.OPEN_CAVES, ".W")
+}}
##############################################################
# layout_onion_interference
@@ -346,6 +354,8 @@ TAGS: overwritable layout allow_dup unrand layout_type_open_caves
# Layers two onions on top of each other to create an
# interference pattern (with option xor)
#
+# TODO: A better way of dealing with small maps
+#
NAME: layout_onion_interference
DEPTH: Snake, Zot:1-4
WEIGHT: 10
@@ -400,7 +410,7 @@ TAGS: overwritable layout allow_dup unrand central layout_type_narrow_caves
zonify.map_fill_zones(_G, 1, 'x')
}}
validate {{
- return count_feature_in_box { feat="." } >= 750
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.NARROW_CAVES)
}}
##############################################################
@@ -528,6 +538,7 @@ ENDMAP
#
# TODO: Use Snake variant in Lair, add with weight 3.
# TODO: Minimum area validation in Snake (can be disconnected).
+# Then remove minimum size validate as unneeded
#
NAME: layout_concentric_octagons
DEPTH: Snake, Zot
@@ -816,3 +827,7 @@ TAGS: no_rotate no_vmirror no_hmirror
mapgrd[gxm/2][gym/2] = '.'
end
}}
+# Enforce minimum floor size - remove when connection is working in Snake
+validate {{
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.PASSAGES)
+}}
diff --git a/crawl-ref/source/dat/des/builder/layout_overlapping_boxes.des b/crawl-ref/source/dat/des/builder/layout_overlapping_boxes.des
index 6660c6e..105b74b 100644
--- a/crawl-ref/source/dat/des/builder/layout_overlapping_boxes.des
+++ b/crawl-ref/source/dat/des/builder/layout_overlapping_boxes.des
@@ -7,7 +7,10 @@
# out looking like a more regular form of layout_subdivisions
# with some of the rooms connected into open areas.
#
+
: require("dlua/layout/zonify.lua")
+: require("dlua/layout/minimum_map_area.lua")
+
NAME: layout_overlapping_boxes
DEPTH: Dis:1-6
WEIGHT: 5
@@ -56,7 +59,7 @@ TAGS: no_rotate no_vmirror no_hmirror
}}
# Enforce minimum floor size
validate {{
- return count_feature_in_box { feat="." } > 1200
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.DIVISIONS)
}}
MAP
ENDMAP
diff --git a/crawl-ref/source/dat/des/builder/layout_pools.des b/crawl-ref/source/dat/des/builder/layout_pools.des
index e7591e7..4c32605 100644
--- a/crawl-ref/source/dat/des/builder/layout_pools.des
+++ b/crawl-ref/source/dat/des/builder/layout_pools.des
@@ -10,6 +10,7 @@
: require("dlua/layout/zonify.lua")
: require("dlua/layout/theme.lua")
+: require("dlua/layout/minimum_map_area.lua")
##############################################################
#
@@ -38,9 +39,6 @@
-- longer and thus harder
STAIRS_PLACE_PERCENT = 20
- -- The minimum floor area for a layout
- FLOOR_AREA_MINIMUM = 750
-
-- The width of the path before the caves are grown is
-- 1 + 2 * PATH_SIZE_???
PATH_SIZE_BASIC = 2
@@ -191,7 +189,7 @@ TAGS: no_rotate no_vmirror no_hmirror
}}
# Enforce minimum floor size - this is important
validate {{
- return count_feature_in_box { feat="." } > 600
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.DIVISIONS)
}}
MAP
ENDMAP
@@ -328,7 +326,7 @@ TAGS: no_rotate no_vmirror no_hmirror
gehenna_layout_epilogue(_G)
}}
validate {{
- return count_feature_in_box { feat="." } >= FLOOR_AREA_MINIMUM
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.OPEN_CAVES)
}}
##############################################################
@@ -402,7 +400,7 @@ TAGS: no_rotate no_vmirror no_hmirror
gehenna_layout_epilogue(_G)
}}
validate {{
- return count_feature_in_box { feat="." } >= FLOOR_AREA_MINIMUM
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.OPEN_CAVES)
}}
##############################################################
@@ -535,5 +533,5 @@ TAGS: no_rotate no_vmirror no_hmirror
gehenna_layout_epilogue(_G)
}}
validate {{
- return count_feature_in_box { feat="." } >= FLOOR_AREA_MINIMUM
+ return minimum_map_area.is_map_big_enough(_G, minimum_map_area.OPEN_CAVES)
}}
diff --git a/crawl-ref/source/dat/dlua/layout/minimum_map_area.lua b/crawl-ref/source/dat/dlua/layout/minimum_map_area.lua
new file mode 100644
index 0000000..a2e990a
--- /dev/null
+++ b/crawl-ref/source/dat/dlua/layout/minimum_map_area.lua
@@ -0,0 +1,52 @@
+------------------------------------------------------------------------------
+-- minimum_map_area.lua: Constants and a function to enforce minimum map size.
+--
+------------------------------------------------------------------------------
+
+minimum_map_area = {}
+
+--
+-- The minimum area for each map type
+--
+
+minimum_map_area.BASE_AREA = 600
+
+minimum_map_area.CORRIDORS = minimum_map_area.BASE_AREA * 0.75
+minimum_map_area.ROOMS = minimum_map_area.BASE_AREA
+minimum_map_area.PASSAGES = minimum_map_area.BASE_AREA
+minimum_map_area.NARROW_CAVES = minimum_map_area.BASE_AREA
+minimum_map_area.OPEN_CAVES = minimum_map_area.BASE_AREA * 1.5
+minimum_map_area.CITY = minimum_map_area.BASE_AREA * 2
+minimum_map_area.OPEN = minimum_map_area.BASE_AREA * 2
+minimum_map_area.DIVISIONS = minimum_map_area.BASE_AREA * 1.5
+minimum_map_area.SWAMP = minimum_map_area.BASE_AREA
+
+
+
+--
+-- is_map_big_enough
+--
+-- This function returns whether the map is big enough to be a
+-- map of the specified type.
+--
+-- Parameter(s):
+-- -> e: A reference to the gobal enviroment. Pass in _G
+-- -> min_area: The minimum area for this map type
+-- Defaults to BASE_AREA
+-- -> floor: The glyphs to treat as floor glyphs
+-- Defaults to ".{([})]<>"
+--
+-- Returns: true if the map is large enough, false otherwise.
+--
+
+minimum_map_area.is_map_big_enough = function (e, min_area, floor)
+ if min_area == nil then
+ min_area = BASE_AREA
+ end
+ if floor == nil then
+ floor = ".{([})]<>"
+ end
+
+ return e.count_feature_in_box { feat = floor } > min_area
+end
+
--
1.8.1.2
|