Skip to content

Commit

Permalink
Fix crash when a error occurs in a globalstep callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed Feb 3, 2014
1 parent fbef701 commit 458045d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/script/cpp_api/s_env.cpp
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 458045d

Please sign in to comment.