summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/clua.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-25 16:35:03 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-25 16:35:03 +0000
commitc66f8a865056e7e2e8a9461d23691665b82dd59a (patch)
tree636ea6ab6b590f06a48828d8c5ff39e5827fa470 /crawl-ref/source/clua.cc
parente079a2dd1b6c583624f32a097f4a946d3c6c89c7 (diff)
downloadcrawl-ref-c66f8a865056e7e2e8a9461d23691665b82dd59a.tar.gz
crawl-ref-c66f8a865056e7e2e8a9461d23691665b82dd59a.zip
Croak if necessary Lua files are missing, instead of failing subtly later.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1651 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/clua.cc')
-rw-r--r--crawl-ref/source/clua.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 7e2c43a98a..63f901f051 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -229,7 +229,8 @@ bool CLua::is_path_safe(std::string s, bool trusted)
&& (trusted || s.find("clua") == std::string::npos));
}
-int CLua::loadfile(lua_State *ls, const char *filename, bool trusted)
+int CLua::loadfile(lua_State *ls, const char *filename, bool trusted,
+ bool die_on_fail)
{
if (!ls)
return (-1);
@@ -242,11 +243,11 @@ int CLua::loadfile(lua_State *ls, const char *filename, bool trusted)
return (-1);
}
- const std::string file = datafile_path(filename, false);
+ const std::string file = datafile_path(filename, die_on_fail);
return (luaL_loadfile(ls, file.c_str()));
}
-int CLua::execfile(const char *filename, bool trusted)
+int CLua::execfile(const char *filename, bool trusted, bool die_on_fail)
{
if (sourced_files.find(filename) != sourced_files.end())
return 0;
@@ -254,7 +255,7 @@ int CLua::execfile(const char *filename, bool trusted)
sourced_files.insert(filename);
lua_State *ls = state();
- int err = loadfile(ls, filename, trusted || !managed_vm);
+ int err = loadfile(ls, filename, trusted || !managed_vm, die_on_fail);
lua_call_throttle strangler(this);
if (!err)
err = lua_pcall(ls, 0, 0, 0);
@@ -598,7 +599,7 @@ void CLua::init_lua()
lua_register(_state, "loadfile", clua_loadfile);
lua_register(_state, "dofile", clua_dofile);
- execfile("clua/userbase.lua", true);
+ execfile("clua/userbase.lua", true, true);
}
}
@@ -613,7 +614,7 @@ void CLua::load_chooks()
void CLua::load_cmacro()
{
- execfile("clua/macro.lua", true);
+ execfile("clua/macro.lua", true, true);
}
/////////////////////////////////////////////////////////////////////