summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-29 11:58:54 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-29 11:58:54 +0000
commitf0229aa5f1ecc1f23dcaa987075b9207784e9b91 (patch)
tree5916c258f2c103336cc470627873fc42b9749ec4 /crawl-ref/source
parent7d9814f3cbe24c356c75cf0363464303961ece59 (diff)
downloadcrawl-ref-f0229aa5f1ecc1f23dcaa987075b9207784e9b91.tar.gz
crawl-ref-f0229aa5f1ecc1f23dcaa987075b9207784e9b91.zip
Moved the list of required .des files into loadmaps.lua.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1687 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/clua/loadmaps.lua15
-rw-r--r--crawl-ref/source/luadgn.cc10
-rw-r--r--crawl-ref/source/maps.cc16
-rw-r--r--crawl-ref/source/maps.h1
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,