Navigation Menu

Skip to content

Commit

Permalink
Run detach callbacks on player leave
Browse files Browse the repository at this point in the history
Correct docs regarding non-nil detaching children
  • Loading branch information
SmallJoker committed May 12, 2018
1 parent a292d19 commit 9dd432c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/lua_api.txt
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/server.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 9dd432c

Please sign in to comment.