aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-02-03 18:15:03 -0500
committerShadowNinja <shadowninja@minetest.net>2014-02-03 18:15:03 -0500
commit458045d49fd96cf19bdd61b2f8dbdbc0fd11b587 (patch)
tree5ec938827e1b16d21b0e5de227174770879d2906
parentfbef701bcddb4a85e25fb9ff6ead07c820b1158d (diff)
downloadminetest-458045d49fd96cf19bdd61b2f8dbdbc0fd11b587.tar.gz
minetest-458045d49fd96cf19bdd61b2f8dbdbc0fd11b587.tar.bz2
minetest-458045d49fd96cf19bdd61b2f8dbdbc0fd11b587.zip
Fix crash when a error occurs in a globalstep callback
-rw-r--r--src/script/cpp_api/s_env.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/script/cpp_api/s_env.cpp b/src/script/cpp_api/s_env.cpp
index ef3a1dddf..2c2198edf 100644
--- a/src/script/cpp_api/s_env.cpp
+++ b/src/script/cpp_api/s_env.cpp
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h"
#include "mapgen.h"
#include "lua_api/l_env.h"
+#include "server.h"
void ScriptApiEnv::environment_OnGenerated(v3s16 minp, v3s16 maxp,
u32 blockseed)
@@ -50,7 +51,11 @@ void ScriptApiEnv::environment_Step(float dtime)
lua_getfield(L, -1, "registered_globalsteps");
// Call callbacks
lua_pushnumber(L, dtime);
- script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
+ try {
+ script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
+ } catch (LuaError &e) {
+ getServer()->setAsyncFatalError(e.what());
+ }
}
void ScriptApiEnv::environment_OnMapgenInit(MapgenParams *mgparams)