diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-29 23:02:39 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-29 23:02:39 +0200 |
commit | f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5 (patch) | |
tree | c57d967bab26888ae83692ab09cbbc7fabbae6f5 /source/packets/cPacket.cpp | |
parent | Added a check if torch is placed on the bottom face, temporarily fix the assert. (diff) | |
download | cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.gz cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.bz2 cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.lz cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.xz cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.tar.zst cuberite-f1d62b77cd1f9eb31cf508ee5eb54e09b9ca10e5.zip |
Diffstat (limited to 'source/packets/cPacket.cpp')
-rw-r--r-- | source/packets/cPacket.cpp | 153 |
1 files changed, 0 insertions, 153 deletions
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); -} - - - - |