1
0

Attempted fix for the client crash with the new protocols.

This commit is contained in:
madmaxoft 2014-04-15 23:40:06 +02:00
parent b5ea5fbf90
commit 99e4225269
2 changed files with 16 additions and 6 deletions

View File

@ -1718,6 +1718,8 @@ void cClientHandle::Tick(float a_Dt)
} }
// Send a ping packet: // Send a ping packet:
if (m_State == csPlaying)
{
cTimer t1; cTimer t1;
if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= t1.GetNowTime())) if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= t1.GetNowTime()))
{ {
@ -1726,6 +1728,7 @@ void cClientHandle::Tick(float a_Dt)
m_Protocol->SendKeepAlive(m_PingID); m_Protocol->SendKeepAlive(m_PingID);
m_LastPingTime = m_PingStartTime; m_LastPingTime = m_PingStartTime;
} }
}
// Handle block break animation: // Handle block break animation:
if (m_BlockDigAnimStage > -1) if (m_BlockDigAnimStage > -1)

View File

@ -538,6 +538,13 @@ void cProtocol172::SendInventorySlot(char a_WindowID, short a_SlotNum, const cIt
void cProtocol172::SendKeepAlive(int a_PingID) void cProtocol172::SendKeepAlive(int a_PingID)
{ {
// Drop the packet if the protocol is not in the Game state yet (caused a client crash):
if (m_State != 3)
{
LOGWARNING("Trying to send a KeepAlive packet to a player who's not yet fully logged in (%d). The protocol class prevented the packet.", m_State);
return;
}
cPacketizer Pkt(*this, 0x00); // Keep Alive packet cPacketizer Pkt(*this, 0x00); // Keep Alive packet
Pkt.WriteInt(a_PingID); Pkt.WriteInt(a_PingID);
} }