summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol.h
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-04-04 10:13:25 +0200
committermadmaxoft <github@xoft.cz>2014-04-04 10:13:25 +0200
commit8825d30aabbee8cb2e452dc5a17deb6f9b6892a7 (patch)
tree1f06f2d45652458c0490b794eae6a9e17596c85e /src/Protocol/Protocol.h
parentFixed Clang warnings in itemhandlers. (diff)
downloadcuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.tar
cuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.tar.gz
cuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.tar.bz2
cuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.tar.lz
cuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.tar.xz
cuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.tar.zst
cuberite-8825d30aabbee8cb2e452dc5a17deb6f9b6892a7.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index d3383bf0d..8294fa8b7 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -132,7 +132,7 @@ protected:
cCriticalSection m_CSPacket; //< Each SendXYZ() function must acquire this CS in order to send the whole packet at once
/// A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it
- virtual void SendData(const char * a_Data, int a_Size) = 0;
+ virtual void SendData(const char * a_Data, size_t a_Size) = 0;
/// Called after writing each packet, enables descendants to flush their buffers
virtual void Flush(void) {};
@@ -143,10 +143,15 @@ protected:
SendData((const char *)&a_Value, 1);
}
+ void WriteChar(char a_Value)
+ {
+ SendData(&a_Value, 1);
+ }
+
void WriteShort(short a_Value)
{
- a_Value = htons(a_Value);
- SendData((const char *)&a_Value, 2);
+ u_short Value = htons((u_short)a_Value);
+ SendData((const char *)&Value, 2);
}
/*
@@ -159,8 +164,8 @@ protected:
void WriteInt(int a_Value)
{
- a_Value = htonl(a_Value);
- SendData((const char *)&a_Value, 4);
+ u_long Value = htonl((u_long)a_Value);
+ SendData((const char *)&Value, 4);
}
void WriteUInt(unsigned int a_Value)
@@ -171,19 +176,19 @@ protected:
void WriteInt64 (Int64 a_Value)
{
- a_Value = HostToNetwork8(&a_Value);
- SendData((const char *)&a_Value, 8);
+ UInt64 Value = HostToNetwork8(&a_Value);
+ SendData((const char *)Value, 8);
}
void WriteFloat (float a_Value)
{
- unsigned int val = HostToNetwork4(&a_Value);
+ UInt32 val = HostToNetwork4(&a_Value);
SendData((const char *)&val, 4);
}
void WriteDouble(double a_Value)
{
- unsigned long long val = HostToNetwork8(&a_Value);
+ UInt64 val = HostToNetwork8(&a_Value);
SendData((const char *)&val, 8);
}
@@ -191,7 +196,7 @@ protected:
{
AString UTF16;
UTF8ToRawBEUTF16(a_Value.c_str(), a_Value.length(), UTF16);
- WriteShort((unsigned short)(UTF16.size() / 2));
+ WriteShort((short)(UTF16.size() / 2));
SendData(UTF16.data(), UTF16.size());
}
@@ -224,7 +229,7 @@ protected:
void WriteVarUTF8String(const AString & a_String)
{
- WriteVarInt(a_String.size());
+ WriteVarInt((UInt32)a_String.size());
SendData(a_String.data(), a_String.size());
}
} ;