From e9d1a942d14de642ae9dae5974bffa0e5fdd6ec6 Mon Sep 17 00:00:00 2001 From: ElNounch Date: Mon, 22 Aug 2016 19:43:43 +0200 Subject: Delay EntityChangedWorld players' callback until Entity fully linked to world (#3330) Otherwise, some API calls just don't seem to happen .gitignore tweak for test executables --- src/World.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index c1794b159..a00e181b6 100644 --- a/src/World.h +++ b/src/World.h @@ -61,6 +61,7 @@ class cBroadcaster; typedef std::list< cPlayer * > cPlayerList; +typedef std::list< std::pair< cPlayer *, cWorld * > > cAwaitingPlayerList; typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 typedef std::vector cSetChunkDataPtrs; @@ -262,8 +263,9 @@ public: /** Adds the player to the world. Uses a queue to store the player object until the Tick thread processes the addition event. - Also adds the player as an entity in the chunkmap, and the player's ClientHandle, if any, for ticking. */ - void AddPlayer(cPlayer * a_Player); + Also adds the player as an entity in the chunkmap, and the player's ClientHandle, if any, for ticking. + If a_OldWorld is provided, a corresponding ENTITY_CHANGED_WORLD event is triggerred after the addition. */ + void AddPlayer(cPlayer * a_Player, cWorld * a_OldWorld = nullptr); /** Removes the player from the world. Removes the player from the addition queue, too, if appropriate. @@ -1006,7 +1008,7 @@ private: cCriticalSection m_CSPlayersToAdd; /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */ - cPlayerList m_PlayersToAdd; + cAwaitingPlayerList m_PlayersToAdd; /** CS protecting m_SetChunkDataQueue. */ cCriticalSection m_CSSetChunkDataQueue; -- cgit v1.2.3