From c66f8a865056e7e2e8a9461d23691665b82dd59a Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 25 Jun 2007 16:35:03 +0000 Subject: 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 --- crawl-ref/source/clua.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/clua.cc') 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); } ///////////////////////////////////////////////////////////////////// -- cgit v1.2.3-54-g00ecf