diff options
author | Diego Martinez <kaeza@users.sf.net> | 2016-01-04 22:49:11 -0300 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-06-11 04:17:04 +0100 |
commit | dac40af6eeeb7205d507046fd4d9ae06ae182095 (patch) | |
tree | d8e968e144ef19f184cb3180f304bffbd143dbc1 /src/script/cpp_api | |
parent | b24d21d1ae25c377e14223ee20d9de9158fe916c (diff) | |
download | minetest-dac40af6eeeb7205d507046fd4d9ae06ae182095.tar.gz minetest-dac40af6eeeb7205d507046fd4d9ae06ae182095.tar.bz2 minetest-dac40af6eeeb7205d507046fd4d9ae06ae182095.zip |
Server: Add reason for leave to `on_leaveplayer` callbacks
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_player.cpp | 6 | ||||
-rw-r--r-- | src/script/cpp_api/s_player.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp index 807430678..a8c07476c 100644 --- a/src/script/cpp_api/s_player.cpp +++ b/src/script/cpp_api/s_player.cpp @@ -135,7 +135,8 @@ void ScriptApiPlayer::on_joinplayer(ServerActiveObject *player) runCallbacks(1, RUN_CALLBACKS_MODE_FIRST); } -void ScriptApiPlayer::on_leaveplayer(ServerActiveObject *player) +void ScriptApiPlayer::on_leaveplayer(ServerActiveObject *player, + bool timeout) { SCRIPTAPI_PRECHECKHEADER @@ -144,7 +145,8 @@ void ScriptApiPlayer::on_leaveplayer(ServerActiveObject *player) lua_getfield(L, -1, "registered_on_leaveplayers"); // Call callbacks objectrefGetOrCreate(L, player); - runCallbacks(1, RUN_CALLBACKS_MODE_FIRST); + lua_pushboolean(L, timeout); + runCallbacks(2, RUN_CALLBACKS_MODE_FIRST); } void ScriptApiPlayer::on_cheat(ServerActiveObject *player, diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h index 2e4dc2222..86ee1b024 100644 --- a/src/script/cpp_api/s_player.h +++ b/src/script/cpp_api/s_player.h @@ -38,7 +38,7 @@ public: bool on_prejoinplayer(const std::string &name, const std::string &ip, std::string *reason); void on_joinplayer(ServerActiveObject *player); - void on_leaveplayer(ServerActiveObject *player); + void on_leaveplayer(ServerActiveObject *player, bool timeout); void on_cheat(ServerActiveObject *player, const std::string &cheat_type); bool on_punchplayer(ServerActiveObject *player, ServerActiveObject *hitter, float time_from_last_punch, |