diff options
-rw-r--r-- | COMPILING.md | 1 | ||||
-rw-r--r-- | src/ClientHandle.cpp | 8 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 14 |
3 files changed, 16 insertions, 7 deletions
diff --git a/COMPILING.md b/COMPILING.md index f8b292ebc..89f88bbb5 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -73,6 +73,7 @@ Install git, make, cmake and gcc or clang, using your platform's package manager ``` sudo apt-get install git make cmake gcc g++ ``` +(Ensure you have gcc/g++ 4.8 or higher installed to avoid errors during compilation) ### Getting the sources ### ``` diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index c774a92c2..2e0e86653 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1892,9 +1892,13 @@ void cClientHandle::Tick(float a_Dt) cCSLock Lock(m_CSOutgoingData); std::swap(OutgoingData, m_OutgoingData); } - if ((m_Link != nullptr) && !OutgoingData.empty()) + if (!OutgoingData.empty()) { - m_Link->Send(OutgoingData.data(), OutgoingData.size()); + cTCPLinkPtr Link(m_Link); // Grab a copy of the link in a multithread-safe way + if ((Link != nullptr)) + { + Link->Send(OutgoingData.data(), OutgoingData.size()); + } } m_TicksSinceLastPacket += 1; diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 9b0f1c37c..22280f800 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -874,11 +874,15 @@ void cProtocol180::SendPlayerListUpdatePing(const cPlayer & a_Player) { ASSERT(m_State == 3); // In game mode? - cPacketizer Pkt(*this, 0x38); // Playerlist Item packet - Pkt.WriteVarInt(2); - Pkt.WriteVarInt(1); - Pkt.WriteUUID(a_Player.GetUUID()); - Pkt.WriteVarInt((UInt32)a_Player.GetClientHandle()->GetPing()); + auto ClientHandle = a_Player.GetClientHandlePtr(); + if (ClientHandle != nullptr) + { + cPacketizer Pkt(*this, 0x38); // Playerlist Item packet + Pkt.WriteVarInt(2); + Pkt.WriteVarInt(1); + Pkt.WriteUUID(a_Player.GetUUID()); + Pkt.WriteVarInt(static_cast<UInt32>(ClientHandle->GetPing())); + } } |