Merge pull request #2157 from beeduck/Issue2106
Fix for chat and player lists with players in separate worlds
This commit is contained in:
commit
6adf5f5e00
@ -381,8 +381,8 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
|
|||||||
|
|
||||||
// Send player list items
|
// Send player list items
|
||||||
SendPlayerListAddPlayer(*m_Player);
|
SendPlayerListAddPlayer(*m_Player);
|
||||||
World->BroadcastPlayerListAddPlayer(*m_Player);
|
cRoot::Get()->BroadcastPlayerListsAddPlayer(*m_Player);
|
||||||
World->SendPlayerList(m_Player);
|
cRoot::Get()->SendPlayerLists(m_Player);
|
||||||
|
|
||||||
m_Player->Initialize(*World);
|
m_Player->Initialize(*World);
|
||||||
m_State = csAuthenticated;
|
m_State = csAuthenticated;
|
||||||
@ -1475,7 +1475,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
|
|||||||
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
|
Msg.AddTextPart(AString("<") + m_Player->GetName() + "> ", Color);
|
||||||
Msg.ParseText(Message);
|
Msg.ParseText(Message);
|
||||||
Msg.UnderlineUrls();
|
Msg.UnderlineUrls();
|
||||||
m_Player->GetWorld()->BroadcastChat(Msg);
|
cRoot::Get()->BroadcastChat(Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
19
src/Root.cpp
19
src/Root.cpp
@ -558,6 +558,23 @@ void cRoot::SaveAllChunks(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cRoot::SendPlayerLists(cPlayer * a_DestPlayer)
|
||||||
|
{
|
||||||
|
for (const auto & itr : m_WorldsByName)
|
||||||
|
{
|
||||||
|
itr.second->SendPlayerList(a_DestPlayer);
|
||||||
|
} // for itr - m_WorldsByName[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cRoot::BroadcastPlayerListsAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
for (const auto & itr : m_WorldsByName)
|
||||||
|
{
|
||||||
|
itr.second->BroadcastPlayerListAddPlayer(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)
|
||||||
@ -582,8 +599,6 @@ 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)
|
||||||
|
@ -145,6 +145,12 @@ public:
|
|||||||
/** Finds the player using it's complete username and calls the callback */
|
/** Finds the player using it's complete username and calls the callback */
|
||||||
bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback);
|
bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback);
|
||||||
|
|
||||||
|
/** Send playerlist of all worlds to player */
|
||||||
|
void SendPlayerLists(cPlayer * a_DestPlayer);
|
||||||
|
|
||||||
|
/** Broadcast Player through all worlds */
|
||||||
|
void BroadcastPlayerListsAddPlayer(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)
|
||||||
|
Loading…
Reference in New Issue
Block a user