1
0
Fork 0

Broadcast playerlist removal in every world (#4201)

This commit is contained in:
mathiascode 2018-04-02 20:39:54 +03:00 committed by Alexander Harkness
parent 7d8f126ada
commit a879778968
3 changed files with 26 additions and 6 deletions

View File

@ -127,13 +127,11 @@ cClientHandle::~cClientHandle()
{ {
RemoveFromAllChunks(); RemoveFromAllChunks();
m_Player->GetWorld()->RemoveClientFromChunkSender(this); m_Player->GetWorld()->RemoveClientFromChunkSender(this);
if (!m_Username.empty())
{
// Send the Offline PlayerList packet:
World->BroadcastPlayerListRemovePlayer(*m_Player, this);
}
m_Player->DestroyNoScheduling(true); m_Player->DestroyNoScheduling(true);
} }
// Send the Offline PlayerList packet:
cRoot::Get()->BroadcastPlayerListsRemovePlayer(*m_Player);
m_PlayerPtr.reset(); m_PlayerPtr.reset();
m_Player = nullptr; m_Player = nullptr;
} }

View File

@ -755,6 +755,8 @@ void cRoot::SendPlayerLists(cPlayer * a_DestPlayer)
void cRoot::BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude) void cRoot::BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
{ {
for (const auto & itr : m_WorldsByName) 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) void cRoot::BroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix)
{ {
for (WorldMap::iterator itr = m_WorldsByName.begin(), end = m_WorldsByName.end(); itr != end; ++itr) 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) bool cRoot::ForEachPlayer(cPlayerListCallback a_Callback)
{ {
for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2) for (WorldMap::iterator itr = m_WorldsByName.begin(), itr2 = itr; itr != m_WorldsByName.end(); itr = itr2)

View File

@ -154,9 +154,12 @@ public:
/** Send playerlist of all worlds to player */ /** Send playerlist of all worlds to player */
void SendPlayerLists(cPlayer * a_DestPlayer); 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); 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 // tolua_begin
/** Sends a chat message to all connected clients (in all worlds) */ /** Sends a chat message to all connected clients (in all worlds) */