Run detach callbacks on player leave
authorSmallJoker <mk939@ymail.com>
Sat, 12 May 2018 08:55:43 +0000 (10:55 +0200)
committerSmallJoker <mk939@ymail.com>
Sat, 12 May 2018 09:50:04 +0000 (11:50 +0200)
Correct docs regarding non-nil detaching children

doc/lua_api.txt
src/server.cpp

index dae3452a1e67831e688cf9a4ccfda1d945b06959..a4b797795c5754a3259c6f8573ec22884c955de5 100644 (file)
@@ -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
index f151d09f024b863d63318481a831334cfc8f9539..d47b4ecd0ee64a60352ddc29867b55681ec8513a 100644 (file)
@@ -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