summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-19 20:02:05 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-19 20:02:05 +0000
commitc2a18ff7903205165e6eab5c619a25e6cd2216cd (patch)
tree76eb21e2367896b126a5d7d2babef0c3c6a1bc08 /crawl-ref/source/initfile.cc
parentc110d51c2f1df0407515223236ac1e5310b04097 (diff)
downloadcrawl-ref-c2a18ff7903205165e6eab5c619a25e6cd2216cd.tar.gz
crawl-ref-c2a18ff7903205165e6eab5c619a25e6cd2216cd.zip
Set debug hooks in the Lua VM and interrupt scripts that are running too long.
(Necessary to make Lua usable on public servers.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1605 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/initfile.cc')
-rw-r--r--crawl-ref/source/initfile.cc25
1 files changed, 11 insertions, 14 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index cdf8a4f810..717446b8e0 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -1158,8 +1158,8 @@ void game_options::read_options(InitLineInput &il, bool runscript)
{
#ifdef CLUA_BINDINGS
clua.execstring(luacode.c_str());
- if (clua.error.length())
- fprintf(stderr, "Lua error: %s\n", clua.error.c_str());
+ if (!clua.error.empty())
+ mprf(MSGCH_WARN, "Lua error: %s\n", clua.error.c_str());
luacode.clear();
#endif
}
@@ -1173,9 +1173,8 @@ void game_options::read_options(InitLineInput &il, bool runscript)
if (runscript)
{
clua.execstring(luacode.c_str());
- if (clua.error.length())
- fprintf(stderr, "Lua error: %s\n",
- clua.error.c_str());
+ if (!clua.error.empty())
+ mprf(MSGCH_WARN, "Lua error: %s\n", clua.error.c_str());
}
#endif
luacode.clear();
@@ -1208,10 +1207,8 @@ void game_options::read_options(InitLineInput &il, bool runscript)
if (l_init)
luacond += "]] )\n";
clua.execstring(luacond.c_str());
- if (clua.error.length())
- {
- mpr( ("Lua error: " + clua.error).c_str() );
- }
+ if (!clua.error.empty())
+ mprf(MSGCH_WARN, "Lua error: %s\n", clua.error.c_str());
}
#endif
@@ -1571,8 +1568,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
else
{
clua.execfile(lua_file.c_str());
- if (clua.error.length())
- fprintf(stderr, "Lua error: %s\n", clua.error.c_str());
+ if (!clua.error.empty())
+ mprf(MSGCH_WARN, "Lua error: %s\n", clua.error.c_str());
}
#endif
}
@@ -2452,7 +2449,7 @@ void game_options::read_option_line(const std::string &str, bool runscript)
pickup_mode = read_bool_or_number(field, pickup_mode, "auto:");
}
// Catch-all else, copies option into map
- else
+ else if (runscript)
{
#ifdef CLUA_BINDINGS
if (!clua.callbooleanfn(false, "c_process_lua_option", "ss",
@@ -2460,8 +2457,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
#endif
{
#ifdef CLUA_BINDINGS
- if (clua.error.length())
- mpr(clua.error.c_str());
+ if (!clua.error.empty())
+ mprf(MSGCH_WARN, "Lua error: %s\n", clua.error.c_str());
#endif
named_options[key] = orig_field;
}