From 2e64b2e5f53239c47431710d2e5d97a26eaf8fd3 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 5 Jan 2013 19:05:15 +0000 Subject: Not sending multiple DC packets to the client. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1120 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/ClientHandle.cpp | 15 +++++++++------ source/ClientHandle.h | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 36a84ad41..dff95d89c 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -79,7 +79,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) , m_IPString(a_Socket->GetIPString()) , m_OutgoingData(64 KiB) , m_Player(NULL) - , m_bKicking(false) + , m_HasSentDC(false) , m_TimeSinceLastPacket(0) , m_bKeepThreadGoing(true) , m_Ping(1000) @@ -140,7 +140,7 @@ cClientHandle::~cClientHandle() } } - if (!m_bKicking) + if (!m_HasSentDC) { SendDisconnect("Server shut down? Kthnxbai"); } @@ -200,7 +200,6 @@ void cClientHandle::Kick(const AString & a_Reason) LOG("Kicking user \"%s\" for \"%s\"", m_Username.c_str(), a_Reason.c_str()); } SendDisconnect(a_Reason); - m_bKicking = true; } @@ -1151,8 +1150,12 @@ void cClientHandle::Tick(float a_Dt) void cClientHandle::SendDisconnect(const AString & a_Reason) { - LOGD("Sending a DC: \"%s\"", a_Reason.c_str()); - m_Protocol->SendDisconnect(a_Reason); + if (!m_HasSentDC) + { + LOGD("Sending a DC: \"%s\"", a_Reason.c_str()); + m_Protocol->SendDisconnect(a_Reason); + m_HasSentDC = true; + } } @@ -1768,7 +1771,7 @@ void cClientHandle::GetOutgoingData(AString & a_Data) } // Disconnect player after all packets have been sent - if (m_bKicking && a_Data.empty()) + if (m_HasSentDC && a_Data.empty()) { Destroy(); } diff --git a/source/ClientHandle.h b/source/ClientHandle.h index cf02bd107..806224333 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -204,7 +204,8 @@ private: Vector3d m_ConfirmPosition; cPlayer * m_Player; - bool m_bKicking; + + bool m_HasSentDC; // Chunk position when the last StreamChunks() was called; used to avoid re-streaming while in the same chunk int m_LastStreamedChunkX; -- cgit v1.2.3