From f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 29 Aug 2012 21:02:39 +0000 Subject: Gotten completely rid of all cPackets. The cProtocol125 class now does all the parsing and writing by itself. git-svn-id: http://mc-server.googlecode.com/svn/trunk@802 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket.cpp | 153 --------------------------------------------- 1 file changed, 153 deletions(-) delete mode 100644 source/packets/cPacket.cpp (limited to 'source/packets/cPacket.cpp') diff --git a/source/packets/cPacket.cpp b/source/packets/cPacket.cpp deleted file mode 100644 index 8307e67fa..000000000 --- a/source/packets/cPacket.cpp +++ /dev/null @@ -1,153 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - -#include "cPacket.h" -#include "../Endianness.h" - - - - - -/* -// These checks cannot be done in preprocessor, since sizeof() is evaluated while compiling, so in preprocessing it's unknown. -// Check some basic type assumptions: -#if (sizeof(int) != 4) - #error "Bad size for int, protocol won't work" -#endif - -#if (sizeof(float) != 4) - #error "Bad size for float, protocol won't work" -#endif - -#if (sizeof(double) != 8) - #error "Bad size for double, protocol won't work" -#endif -*/ - - - - - -void cPacket::AppendString(AString & a_Dst, const AString & a_String) -{ - AppendShort(a_Dst, (unsigned short)a_String.size()); - a_Dst.append(a_String); -} - - - - - -void cPacket::AppendString16(AString & a_Dst, const AString & a_String) -{ - AppendShort(a_Dst, (unsigned short)a_String.size()); - AString UTF16; - UTF16.resize(a_String.size() * sizeof(short)); - for( unsigned int i = 0; i < a_String.size(); ++i ) - { - UTF16[i * sizeof( short )] = 0x00; - UTF16[i * sizeof( short ) + 1] = a_String[i]; - } - a_Dst.append(UTF16.data(), a_String.size() * sizeof(short)); -} - - - - - -void cPacket::AppendShort(AString & a_Dst, short a_Short) -{ - short ConvertedShort = htons( a_Short ); - a_Dst.append((const char *)&ConvertedShort, sizeof(short)); -} - - - - - -void cPacket::AppendShort(AString & a_Dst, unsigned short a_Short) -{ - short ConvertedShort = htons( a_Short ); - a_Dst.append((const char *)&ConvertedShort, sizeof(short)); -} - - - - - -void cPacket::AppendInteger(AString & a_Dst, int a_Integer) -{ - int ConvertedInt = htonl( a_Integer ); - a_Dst.append((const char *)&ConvertedInt, sizeof(int)); -} - - - - - -void cPacket::AppendInteger(AString & a_Dst, unsigned int a_Integer) -{ - unsigned int ConvertedInt = htonl( a_Integer ); - a_Dst.append((const char *)&ConvertedInt, sizeof(int)); -} - - - - - -void cPacket::AppendFloat(AString & a_Dst, float a_Float) -{ - unsigned int ConvertedFloat = HostToNetwork4(&a_Float); - a_Dst.append((const char *)&ConvertedFloat, sizeof(int)); -} - - - - - -void cPacket::AppendDouble(AString & a_Dst, const double & a_Double) -{ - unsigned long long ConvertedDouble = HostToNetwork8(&a_Double); - a_Dst.append((const char *)&ConvertedDouble, 8); -} - - - - - -void cPacket::AppendByte(AString & a_Dst, char a_Byte) -{ - a_Dst.append(&a_Byte, 1); -} - - - - - -void cPacket::AppendLong(AString & a_Dst, const long long & a_Long) -{ - unsigned long long ConvertedLong = HostToNetwork8(&a_Long); - a_Dst.append((const char *)&ConvertedLong, sizeof(a_Long)); -} - - - - - -void cPacket::AppendBool(AString & a_Dst, bool a_Bool) -{ - a_Dst.append((const char *)&a_Bool, 1); -} - - - - - -void cPacket::AppendData(AString & a_Dst, const char * a_Data, unsigned int a_Size) -{ - a_Dst.append(a_Data, a_Size); -} - - - - -- cgit v1.2.3