From 9dd432c29f662fc668cc2473a2e057acd8357a91 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 12 May 2018 10:55:43 +0200 Subject: Run detach callbacks on player leave Correct docs regarding non-nil detaching children --- doc/lua_api.txt | 4 ++-- src/server.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index dae3452a1..a4b797795 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -4869,9 +4869,9 @@ Registered entities * `killer`: an `ObjectRef` (can be `nil`) * `on_rightclick(self, clicker)` * `on_attach_child(self, child)` - * `child`: an `ObjectRef` (can be `nil`) of the child that attaches + * `child`: an `ObjectRef` of the child that attaches * `on_detach_child(self, child)` - * `child`: an `ObjectRef` (can be `nil`) of the child that detaches + * `child`: an `ObjectRef` of the child that detaches * `on_detach(self, parent)` * `parent`: an `ObjectRef` (can be `nil`) from where it got detached * This happens before the parent object is removed from the world diff --git a/src/server.cpp b/src/server.cpp index f151d09f0..d47b4ecd0 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2632,6 +2632,9 @@ void Server::DeleteClient(session_t peer_id, ClientDeletionReason reason) PlayerSAO *playersao = player->getPlayerSAO(); assert(playersao); + playersao->clearChildAttachments(); + playersao->clearParentAttachment(); + // inform connected clients NetworkPacket notice(TOCLIENT_UPDATE_PLAYER_LIST, 0, PEER_ID_INEXISTENT); // (u16) 1 + std::string represents a vector serialization representation -- cgit v1.2.3