diff options
-rw-r--r-- | crawl-ref/source/dat/clua/loadmaps.lua | 15 | ||||
-rw-r--r-- | crawl-ref/source/luadgn.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/maps.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/maps.h | 1 |
4 files changed, 34 insertions, 8 deletions
diff --git a/crawl-ref/source/dat/clua/loadmaps.lua b/crawl-ref/source/dat/clua/loadmaps.lua new file mode 100644 index 0000000000..eb7f76e4c3 --- /dev/null +++ b/crawl-ref/source/dat/clua/loadmaps.lua @@ -0,0 +1,15 @@ +------------------------------------------------------------------------------ +-- loadmaps.lua: +-- +-- Compiles and loads .des files that Crawl needs. This only includes the +-- base .des files. Optional .des files that the user requests in .crawlrc +-- are handled separately. +------------------------------------------------------------------------------ + +local des_files = { + "entry.des", "splev.des", "ebranch.des", "vaults.des" +} + +for _, file in ipairs(des_files) do + dgn.load_des_file(file) +end
\ No newline at end of file diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index 65bc150799..3060248deb 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -10,6 +10,7 @@ #include "files.h" #include "luadgn.h" #include "mapdef.h" +#include "maps.h" #include "stuff.h" #include "dungeon.h" #include <sstream> @@ -730,6 +731,14 @@ static int dgn_original_map(lua_State *ls) return (1); } +static int dgn_load_des_file(lua_State *ls) +{ + const std::string &file = luaL_checkstring(ls, 1); + if (!file.empty()) + read_map(file); + return (0); +} + static const struct luaL_reg dgn_lib[] = { { "default_depth", dgn_default_depth }, @@ -758,6 +767,7 @@ static const struct luaL_reg dgn_lib[] = { "gly_point", dgn_gly_point }, { "gly_points", dgn_gly_points }, { "original_map", dgn_original_map }, + { "load_des_file", dgn_load_des_file }, { NULL, NULL } }; diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc index dd64467129..11eb43412f 100644 --- a/crawl-ref/source/maps.cc +++ b/crawl-ref/source/maps.cc @@ -575,16 +575,16 @@ static void parse_maps(const std::string &s) write_map_cache(s, file_start, vdefs.size()); } -void read_maps() +void read_map(const std::string &file) { - static const char *map_files[] = - { - "entry.des", "splev.des", "vaults.des", "ebranch.des" - }; - - for (unsigned i = 0; i < ARRAYSIZE(map_files); ++i) - parse_maps( lc_desfile = datafile_path( map_files[i] ) ); + parse_maps( lc_desfile = datafile_path(file) ); +} +void read_maps() +{ + if (dlua.execfile("clua/loadmaps.lua", true, true)) + end(1, false, "Lua error: %s", dlua.error.c_str()); + for (int i = 0, size = Options.extra_levels.size(); i < size; ++i) { lc_desfile = datafile_path( Options.extra_levels[i] + ".des", false ); diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h index d14119dd7d..4a1e9a1cf5 100644 --- a/crawl-ref/source/maps.h +++ b/crawl-ref/source/maps.h @@ -47,6 +47,7 @@ int random_map_for_tag(const std::string &tag, bool want_minivault, void add_parsed_map(const map_def &md); void read_maps(); +void read_map(const std::string &file); void run_map_preludes(); void reset_map_parser(); std::string get_descache_path(const std::string &file, |