diff options
Diffstat (limited to '')
-rw-r--r-- | src/ClientHandle.cpp | 8 | ||||
-rw-r--r-- | src/Root.cpp | 19 | ||||
-rw-r--r-- | src/Root.h | 5 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 2d30224ad..3afd4cc83 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -127,13 +127,11 @@ cClientHandle::~cClientHandle() { RemoveFromAllChunks(); m_Player->GetWorld()->RemoveClientFromChunkSender(this); - if (!m_Username.empty()) - { - // Send the Offline PlayerList packet: - World->BroadcastPlayerListRemovePlayer(*m_Player, this); - } m_Player->DestroyNoScheduling(true); } + // Send the Offline PlayerList packet: + cRoot::Get()->BroadcastPlayerListsRemovePlayer(*m_Player); + m_PlayerPtr.reset(); m_Player = nullptr; } diff --git a/src/Root.cpp b/src/Root.cpp index 42ee00604..8372e8699 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -755,6 +755,8 @@ void cRoot::SendPlayerLists(cPlayer * a_DestPlayer) + + void cRoot::BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude) { for (const auto & itr : m_WorldsByName) @@ -764,6 +766,21 @@ void cRoot::BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClien } + + + +void cRoot::BroadcastPlayerListsRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude) +{ + for (const auto & itr : m_WorldsByName) + { + itr.second->BroadcastPlayerListRemovePlayer(a_Player); + } // for itr - m_WorldsByName[] +} + + + + + void cRoot::BroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix) { for (WorldMap::iterator itr = m_WorldsByName.begin(), end = m_WorldsByName.end(); itr != end; ++itr) @@ -786,6 +803,8 @@ void cRoot::BroadcastChat(const cCompositeChat & a_Message) + + bool cRoot::ForEachPlayer(cPlayerListCallback a_Callback) { for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2) diff --git a/src/Root.h b/src/Root.h index 0735d9493..aad7ccb14 100644 --- a/src/Root.h +++ b/src/Root.h @@ -154,9 +154,12 @@ public: /** Send playerlist of all worlds to player */ void SendPlayerLists(cPlayer * a_DestPlayer); - /** Broadcast Player through all worlds */ + /** Broadcast playerlist addition through all worlds */ void BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr); + /** Broadcast playerlist removal through all worlds */ + void BroadcastPlayerListsRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr); + // tolua_begin /** Sends a chat message to all connected clients (in all worlds) */ |