summaryrefslogtreecommitdiffstats
path: root/source/packets/cPacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/packets/cPacket.cpp')
-rw-r--r--source/packets/cPacket.cpp154
1 files changed, 0 insertions, 154 deletions
diff --git a/source/packets/cPacket.cpp b/source/packets/cPacket.cpp
index 6fad331ed..8307e67fa 100644
--- a/source/packets/cPacket.cpp
+++ b/source/packets/cPacket.cpp
@@ -28,160 +28,6 @@
-int cPacket::ReadString16(const char * a_Data, int a_Size, AString & a_OutString )
-{
- int TotalBytes = 0;
- short StrLen;
- HANDLE_PACKET_READ(ReadShort, StrLen, TotalBytes);
-
- if (2 * StrLen > a_Size - TotalBytes)
- {
- // The string is not yet complete in the buffer
- return PACKET_INCOMPLETE;
- }
-
- // Simple UTF-16 to UTF-8 conversion - discard higher bits, ignore multishort sequences:
- a_OutString.clear();
- a_OutString.reserve(StrLen);
- short * UTF16 = (short *)(a_Data + TotalBytes);
- for ( int i = 0; i < StrLen; ++i )
- {
- a_OutString.push_back( (char)ntohs(UTF16[i]) );
- }
-
- return TotalBytes + StrLen * sizeof(short);
-}
-
-
-
-
-
-int cPacket::ReadShort(const char * a_Data, int a_Size, short & a_OutShort )
-{
- if (a_Size < 2)
- {
- return PACKET_INCOMPLETE;
- }
- a_OutShort = ntohs(*((short *)a_Data));
- return 2;
-}
-
-
-
-
-
-int cPacket::ReadInteger(const char * a_Data, int a_Size, int & a_OutInteger )
-{
- if (a_Size < 4)
- {
- return PACKET_INCOMPLETE;
- }
- a_OutInteger = ntohl(*((int *)a_Data));
- return 4;
-}
-
-
-
-
-
-int cPacket::ReadInteger(const char * a_Data, int a_Size, unsigned int & a_OutInteger )
-{
- if (a_Size < 4)
- {
- return PACKET_INCOMPLETE;
- }
- a_OutInteger = ntohl(*((unsigned int *)a_Data));
- return 4;
-}
-
-
-
-
-
-int cPacket::ReadFloat(const char * a_Data, int a_Size, float & a_OutFloat )
-{
- if (a_Size < sizeof(float))
- {
- return PACKET_INCOMPLETE;
- }
- a_OutFloat = NetworkToHostFloat4(a_Data);
- return sizeof(float);
-}
-
-
-
-
-
-int cPacket::ReadDouble(const char * a_Data, int a_Size, double & a_OutDouble )
-{
- if (a_Size < sizeof(double))
- {
- return PACKET_INCOMPLETE;
- }
- a_OutDouble = NetworkToHostDouble8(a_Data);
- return sizeof(double);
-}
-
-
-
-
-
-int cPacket::ReadByte(const char * a_Data, int a_Size, char & a_OutByte )
-{
- if (a_Size < 1)
- {
- return PACKET_INCOMPLETE;
- }
- a_OutByte = *a_Data;
- return 1;
-}
-
-
-
-
-
-int cPacket::ReadByte(const char * a_Data, int a_Size, unsigned char & a_OutByte )
-{
- if (a_Size < 1)
- {
- return PACKET_INCOMPLETE;
- }
- a_OutByte = *((unsigned char *)a_Data);
- return 1;
-}
-
-
-
-
-
-int cPacket::ReadLong(const char * a_Data, int a_Size, long long & a_OutLong )
-{
- if (a_Size < sizeof(a_OutLong))
- {
- return PACKET_INCOMPLETE;
- }
- a_OutLong = NetworkToHostLong8(a_Data);
- return sizeof(a_OutLong);
-}
-
-
-
-
-
-int cPacket::ReadBool(const char * a_Data, int a_Size, bool & a_OutBool )
-{
- if (a_Size < sizeof(bool))
- {
- return PACKET_INCOMPLETE;
- }
- a_OutBool = (*a_Data != 0);
- return sizeof(bool);
-}
-
-
-
-
-
void cPacket::AppendString(AString & a_Dst, const AString & a_String)
{
AppendShort(a_Dst, (unsigned short)a_String.size());