diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/scriptapi.cpp | 13 | ||||
-rw-r--r-- | src/scriptapi.h | 3 | ||||
-rw-r--r-- | src/server.cpp | 5 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 91100d311..e5815c462 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -5576,6 +5576,19 @@ bool scriptapi_on_chat_message(lua_State *L, const std::string &name, return ate; } +void scriptapi_on_shutdown(lua_State *L) +{ + realitycheck(L); + assert(lua_checkstack(L, 20)); + StackUnroller stack_unroller(L); + + // Get registered shutdown hooks + lua_getglobal(L, "minetest"); + lua_getfield(L, -1, "registered_on_shutdown"); + // Call callbacks + scriptapi_run_callbacks(L, 0, RUN_CALLBACKS_MODE_FIRST); +} + void scriptapi_on_newplayer(lua_State *L, ServerActiveObject *player) { realitycheck(L); diff --git a/src/scriptapi.h b/src/scriptapi.h index 144cb3bc6..d71b8fe41 100644 --- a/src/scriptapi.h +++ b/src/scriptapi.h @@ -55,6 +55,9 @@ void scriptapi_environment_step(lua_State *L, float dtime); void scriptapi_environment_on_generated(lua_State *L, v3s16 minp, v3s16 maxp, u32 blockseed); +/* server */ +void scriptapi_on_shutdown(lua_State *L); + /* misc */ void scriptapi_on_newplayer(lua_State *L, ServerActiveObject *player); void scriptapi_on_dieplayer(lua_State *L, ServerActiveObject *player); diff --git a/src/server.cpp b/src/server.cpp index 961bdeaf9..67c1ce927 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1112,6 +1112,11 @@ Server::~Server() {} } } + + /* + Execute script shutdown hooks + */ + scriptapi_on_shutdown(m_lua); { JMutexAutoLock envlock(m_env_mutex); |