From ec8080afa4057a3e58be2b6d9f059a0e12d92eaa Mon Sep 17 00:00:00 2001 From: Jude Brown Date: Sat, 24 Oct 2009 20:21:15 +1000 Subject: Wrapper for find_map_by_name (dgn.map_by_name). Test set for generation of specific vaults multiple times, in order to test SUBSTs, SHUFFLEs, etc, quickly and easily. Signed-off-by: Darshan Shaligram --- crawl-ref/source/l_dgn.cc | 9 ++++++ crawl-ref/source/test/vault_generation.lua | 50 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 crawl-ref/source/test/vault_generation.lua diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc index 923a505cbc..ebb7cb598c 100644 --- a/crawl-ref/source/l_dgn.cc +++ b/crawl-ref/source/l_dgn.cc @@ -1354,6 +1354,14 @@ LUAFN(dgn_map_by_tag) return (0); } +LUAFN(dgn_map_by_name) +{ + if (const char *name = luaL_checkstring(ls, 1)) + return _lua_push_map(ls, find_map_by_name(name)); + + return (0); +} + LUAFN(dgn_map_in_depth) { const level_id lid = dlua_level_id(ls, 1); @@ -1567,6 +1575,7 @@ const struct luaL_reg dgn_dlib[] = { "with_map_anchors", dgn_with_map_anchors }, { "map_by_tag", dgn_map_by_tag }, +{ "map_by_name", dgn_map_by_name }, { "map_in_depth", dgn_map_in_depth }, { "map_by_place", dgn_map_by_place }, { "place_map", _dgn_place_map }, diff --git a/crawl-ref/source/test/vault_generation.lua b/crawl-ref/source/test/vault_generation.lua new file mode 100644 index 0000000000..1ded8fea35 --- /dev/null +++ b/crawl-ref/source/test/vault_generation.lua @@ -0,0 +1,50 @@ +-- Check specific map generation, useful for testing portal vault +-- generation (SUBSTs, NSBUSTs, SHUFFLEs, etc). + +-- Name of the map! +local map_to_test = "" +-- Which des file is the map in? +local des_file = "" +-- Change to true if the des file isn't specificed in dat/clua/loadmaps.lua +local need_to_load_des = false +-- How many times should we generate? +local checks = 10 +-- Output to this file, will append iteration to the end, ie, +-- output_to.map.1, output_to.map.2, etc. +local output_to = "" +-- Should we run these tests? +local run_test = false + +local function generate_map() + if map_to_test == "" or + (des_file == "" and need_to_load_des) or + output_to == "" then + assert(false, "Need a map, a des file (if not already loaded), and an output.") + end + + if need_to_load_des then + dgn.load_des_file(des_file) + end + + local map = dgn.map_by_name(map_to_test) + + if not map then + assert(false, "Couldn't find the map named " .. map_to_test) + end + + for iter_i = 1, checks do + debug.flush_map_memory() + crawl.mesclr() + dgn.reset_level() + dgn.tags(map, "no_rotate no_vmirror no_hmirror no_pool_fixup") + dgn.place_map(map, true, true) + crawl.mpr("Placed " .. map_to_test .. ":" .. iter_i .. ", dumping to " .. output_to .. "." .. iter_i) + debug.dump_map(map_to_test .. "." .. iter_i) + end +end + +if run_test then + generate_map() +else + crawl.mpr("Not running vault generation test.") +end -- cgit v1.2.3-54-g00ecf