diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ClientHandle.cpp | 8 | ||||
-rw-r--r-- | src/Protocol/Protocol18x.cpp | 14 |
2 files changed, 15 insertions, 7 deletions
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())); + } } |