From 99e4225269776d4e79b7d0d14dc8bbe11a2ad32d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Apr 2014 23:40:06 +0200 Subject: Attempted fix for the client crash with the new protocols. --- src/ClientHandle.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 79738ff0b..9ab32d6ec 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1718,13 +1718,16 @@ void cClientHandle::Tick(float a_Dt) } // Send a ping packet: - cTimer t1; - if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= t1.GetNowTime())) + if (m_State == csPlaying) { - m_PingID++; - m_PingStartTime = t1.GetNowTime(); - m_Protocol->SendKeepAlive(m_PingID); - m_LastPingTime = m_PingStartTime; + cTimer t1; + if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= t1.GetNowTime())) + { + m_PingID++; + m_PingStartTime = t1.GetNowTime(); + m_Protocol->SendKeepAlive(m_PingID); + m_LastPingTime = m_PingStartTime; + } } // Handle block break animation: -- cgit v1.2.3