summaryrefslogtreecommitdiffstats
path: root/source/ClientHandle.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/ClientHandle.cpp64
1 files changed, 17 insertions, 47 deletions
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 32bfb00f5..dce2bbd25 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -921,11 +921,24 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
void cClientHandle::HandleChat(const AString & a_Message)
{
- // We need to process messages in the Tick thread, to avoid deadlocks resulting from player-commands being processed
- // in the SocketThread and waiting for acquiring the ChunkMap CS with Plugin CS locked
+ // We no longer need to postpone message processing, because the messages already arrive in the Tick thread
- cCSLock Lock(m_CSMessages);
- m_PendingMessages.push_back(a_Message);
+ // If a command, perform it:
+ AString Message(a_Message);
+ if (cRoot::Get()->GetServer()->Command(*this, Message))
+ {
+ return;
+ }
+
+ // Not a command, broadcast as a simple message:
+ AString Msg;
+ Printf(Msg, "<%s%s%s> %s",
+ m_Player->GetColor().c_str(),
+ m_Player->GetName().c_str(),
+ cChatColor::White.c_str(),
+ Message.c_str()
+ );
+ m_Player->GetWorld()->BroadcastChat(Msg);
}
@@ -1446,9 +1459,6 @@ void cClientHandle::Tick(float a_Dt)
m_CurrentExplosionTick = (m_CurrentExplosionTick + 1) % ARRAYCOUNT(m_NumExplosionsPerTick);
m_RunningSumExplosions -= m_NumExplosionsPerTick[m_CurrentExplosionTick];
m_NumExplosionsPerTick[m_CurrentExplosionTick] = 0;
-
- // Process the queued messages:
- ProcessPendingMessages();
}
@@ -2096,46 +2106,6 @@ void cClientHandle::AddWantedChunk(int a_ChunkX, int a_ChunkZ)
-void cClientHandle::ProcessPendingMessages(void)
-{
- while (true)
- {
- AString Message;
-
- // Extract one message from the PendingMessages buffer:
- {
- cCSLock Lock(m_CSMessages);
- if (m_PendingMessages.empty())
- {
- // No more messages in the buffer, bail out
- return;
- }
- Message = m_PendingMessages.front();
- m_PendingMessages.pop_front();
- } // Lock(m_CSMessages)
-
- // If a command, perform it:
- if (cRoot::Get()->GetServer()->Command(*this, Message))
- {
- continue;
- }
-
- // Not a command, broadcast as a simple message:
- AString Msg;
- Printf(Msg, "<%s%s%s> %s",
- m_Player->GetColor().c_str(),
- m_Player->GetName().c_str(),
- cChatColor::White.c_str(),
- Message.c_str()
- );
- m_Player->GetWorld()->BroadcastChat(Msg);
- } // while (true)
-}
-
-
-
-
-
void cClientHandle::PacketBufferFull(void)
{
// Too much data in the incoming queue, the server is probably too busy, kick the client: