summaryrefslogtreecommitdiffstats
path: root/source/cClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-25 23:59:13 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-25 23:59:13 +0200
commit7cf9ddaa48b40e845a9317f1cf07f929d3c231b3 (patch)
tree21d1fd080fd0e653c9acb31bd0b37a2535ade583 /source/cClientHandle.cpp
parentcWorld doesn't use cPackets. (diff)
downloadcuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.tar
cuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.tar.gz
cuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.tar.bz2
cuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.tar.lz
cuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.tar.xz
cuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.tar.zst
cuberite-7cf9ddaa48b40e845a9317f1cf07f929d3c231b3.zip
Diffstat (limited to 'source/cClientHandle.cpp')
-rw-r--r--source/cClientHandle.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 206ad9acd..5cfd0a510 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -217,11 +217,9 @@ cClientHandle::~cClientHandle()
if (m_Socket.IsValid())
{
- if(!m_bKicking)
+ if (!m_bKicking)
{
- cPacket_Disconnect Disconnect;
- Disconnect.m_Reason = "Server shut down? Kthnxbai";
- m_Socket.Send(&Disconnect);
+ SendDisconnect("Server shut down? Kthnxbai");
}
}
@@ -295,7 +293,7 @@ void cClientHandle::Kick(const AString & a_Reason)
{
LOG("Kicking user \"%s\" for \"%s\"", m_Username.c_str(), a_Reason.c_str());
}
- Send(cPacket_Disconnect(a_Reason));
+ SendDisconnect(a_Reason);
m_bKicking = true;
}
@@ -1333,8 +1331,7 @@ void cClientHandle::Tick(float a_Dt)
(void)a_Dt;
if (cWorld::GetTime() - m_TimeLastPacket > 30.f) // 30 seconds time-out
{
- cPacket_Disconnect DC("Nooooo!! You timed out! D: Come back!");
- m_Socket.Send(&DC);
+ SendDisconnect("Nooooo!! You timed out! D: Come back!");
// TODO: Cannot sleep in the tick thread!
cSleep::MilliSleep(1000); // Give packet some time to be received
@@ -1506,7 +1503,7 @@ void cClientHandle::Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* =
void cClientHandle::SendDisconnect(const AString & a_Reason)
{
cPacket_Disconnect DC(a_Reason);
- m_Socket.Send(&DC); // Send it immediately to the socket, bypassing any packet buffers
+ Send(DC); // TODO: Send it immediately to the socket, bypassing any packet buffers (? is it safe? packet boundaries...)
}
@@ -2021,6 +2018,7 @@ void cClientHandle::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
ThunderboltPacket.m_xLBPos = a_BlockX;
ThunderboltPacket.m_yLBPos = a_BlockY;
ThunderboltPacket.m_zLBPos = a_BlockZ;
+ Send(ThunderboltPacket);
}
@@ -2198,8 +2196,7 @@ void cClientHandle::GetOutgoingData(AString & a_Data)
if (m_PendingNrmSendPackets.size() + m_PendingLowSendPackets.size() > MAX_OUTGOING_PACKETS)
{
LOGERROR("ERROR: Too many packets in queue for player %s !!", m_Username.c_str());
- cPacket_Disconnect DC("Too many packets in queue.");
- m_Socket.Send(DC);
+ SendDisconnect("Too many packets in queue.");
// DEBUG: Dump all outstanding packets' types to the log:
int Idx = 0;