Skip to content

Commit 458045d

Browse files
committedFeb 3, 2014
Fix crash when a error occurs in a globalstep callback
1 parent fbef701 commit 458045d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/script/cpp_api/s_env.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2424
#include "environment.h"
2525
#include "mapgen.h"
2626
#include "lua_api/l_env.h"
27+
#include "server.h"
2728

2829
void ScriptApiEnv::environment_OnGenerated(v3s16 minp, v3s16 maxp,
2930
u32 blockseed)
@@ -50,7 +51,11 @@ void ScriptApiEnv::environment_Step(float dtime)
5051
lua_getfield(L, -1, "registered_globalsteps");
5152
// Call callbacks
5253
lua_pushnumber(L, dtime);
53-
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
54+
try {
55+
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
56+
} catch (LuaError &e) {
57+
getServer()->setAsyncFatalError(e.what());
58+
}
5459
}
5560

5661
void ScriptApiEnv::environment_OnMapgenInit(MapgenParams *mgparams)

0 commit comments

Comments
 (0)
Please sign in to comment.