summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua
diff options
context:
space:
mode:
authorEnne Walker <ennewalker@users.sourceforge.net>2009-11-28 18:06:49 -0500
committerEnne Walker <ennewalker@users.sourceforge.net>2009-11-28 20:53:42 -0500
commit4fe67e14cab6affd2a69a864dda356440d50e0ca (patch)
tree47da4f5b30a1534a818aedfd7ea92ea0995268ca /crawl-ref/source/dat/clua
parent13d037ff0e1c6394157ab5ccf5593458a167447a (diff)
downloadcrawl-ref-4fe67e14cab6affd2a69a864dda356440d50e0ca.tar.gz
crawl-ref-4fe67e14cab6affd2a69a864dda356440d50e0ca.zip
Subvaults.
Vaults can now include other vaults as a part of their definition. These subvaults are currently included by tag only and replace glyphs in their parent vault. See documentation for more details. Vault:8 has been modified to use subvaults.
Diffstat (limited to 'crawl-ref/source/dat/clua')
-rw-r--r--crawl-ref/source/dat/clua/iter.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/crawl-ref/source/dat/clua/iter.lua b/crawl-ref/source/dat/clua/iter.lua
index 904bd57151..f9371d81eb 100644
--- a/crawl-ref/source/dat/clua/iter.lua
+++ b/crawl-ref/source/dat/clua/iter.lua
@@ -283,3 +283,39 @@ function iter.stack_destroy(coord, extra)
end
end
end
+
+-------------------------------------------------------------------------------
+-- subvault_iterator
+-- Iterates through all map locations in a subvault that will get written
+-- back to a parent.
+-------------------------------------------------------------------------------
+function iter.subvault_iterator (e, filter)
+
+ if e == nil then
+ error("subvault_iterator requires the env to be passed, e.g. _G")
+ end
+
+ local top_corner = dgn.point(0, 0)
+ local bottom_corner
+
+ local w,h = e.subvault_size()
+ if w == 0 or h == 0 then
+ -- Construct a valid rectangle. subvault_cell_valid will always fail.
+ bottom_corner = top_corner
+ else
+ bottom_corner = dgn.point(w-1, h-1)
+ end
+
+
+ local function check_mask (point)
+ if filter ~= nil then
+ if not filter(point) then
+ return false
+ end
+ end
+
+ return e.subvault_cell_valid(point.x, point.y)
+ end
+
+ return iter.rect_iterator(top_corner, bottom_corner, check_mask)
+end