From e1ef489e08a91cce377617b99f4c3ed3df5e9d92 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 24 Mar 2012 11:40:29 +0000 Subject: Removed the split between 1.2.3 and 1.1, left only 1.2.3 code git-svn-id: http://mc-server.googlecode.com/svn/trunk@429 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket_Login.cpp | 14 ----------- source/packets/cPacket_Login.h | 17 ------------- source/packets/cPacket_MapChunk.cpp | 45 ----------------------------------- source/packets/cPacket_MapChunk.h | 30 +++-------------------- source/packets/cPacket_MultiBlock.cpp | 25 ++----------------- source/packets/cPacket_MultiBlock.h | 22 ++++------------- source/packets/cPacket_Respawn.cpp | 18 -------------- source/packets/cPacket_Respawn.h | 21 +--------------- 8 files changed, 10 insertions(+), 182 deletions(-) (limited to 'source/packets') diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp index bbb81ef52..588892b3a 100644 --- a/source/packets/cPacket_Login.cpp +++ b/source/packets/cPacket_Login.cpp @@ -21,16 +21,9 @@ int cPacket_Login::Parse(const char * a_Data, int a_Size) m_Username.clear(); HANDLE_PACKET_READ(ReadInteger, m_ProtocolVersion, TotalBytes); HANDLE_PACKET_READ(ReadString16, m_Username, TotalBytes); -#if (MINECRAFT_1_2_2 != 1 ) - HANDLE_PACKET_READ(ReadLong, m_MapSeed, TotalBytes); -#endif HANDLE_PACKET_READ(ReadString16, m_LevelType, TotalBytes); HANDLE_PACKET_READ(ReadInteger, m_ServerMode, TotalBytes); -#if (MINECRAFT_1_2_2 == 1 ) HANDLE_PACKET_READ(ReadInteger, m_Dimension, TotalBytes); -#else - HANDLE_PACKET_READ(ReadByte, m_Dimension, TotalBytes); -#endif HANDLE_PACKET_READ(ReadByte, m_Difficulty, TotalBytes); HANDLE_PACKET_READ(ReadByte, m_WorldHeight, TotalBytes); HANDLE_PACKET_READ(ReadByte, m_MaxPlayers, TotalBytes); @@ -46,16 +39,9 @@ void cPacket_Login::Serialize(AString & a_Data) const AppendByte (a_Data, m_PacketID); AppendInteger (a_Data, m_ProtocolVersion); AppendString16(a_Data, m_Username); -#if (MINECRAFT_1_2_2 != 1 ) - AppendLong (a_Data, m_MapSeed); -#endif AppendString16(a_Data, m_LevelType); AppendInteger (a_Data, m_ServerMode); -#if (MINECRAFT_1_2_2 == 1 ) AppendInteger (a_Data, m_Dimension); -#else - AppendByte (a_Data, m_Dimension); -#endif AppendByte (a_Data, m_Difficulty); AppendByte (a_Data, m_WorldHeight); AppendByte (a_Data, m_MaxPlayers); diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h index 7cab1141b..86666090c 100644 --- a/source/packets/cPacket_Login.h +++ b/source/packets/cPacket_Login.h @@ -12,9 +12,6 @@ class cPacket_Login : public cPacket //tolua_export public: cPacket_Login() : m_ProtocolVersion( 0 ) -#if (MINECRAFT_1_2_2 != 1) - , m_MapSeed( 0 ) -#endif , m_ServerMode( 0 ) , m_Dimension( 0 ) , m_Difficulty( 0 ) @@ -27,29 +24,15 @@ public: virtual int Parse(const char * a_Data, int a_Size) override; virtual void Serialize(AString & a_Data) const override; - // 1.2.2 http://wiki.vg/Pre-release_protocol#Login_Request_.280x01.29 int m_ProtocolVersion; //tolua_export AString m_Username; //tolua_export -#if (MINECRAFT_1_2_2 != 1) - long long m_MapSeed; -#endif AString m_LevelType; //tolua_export int m_ServerMode; //tolua_export -#if (MINECRAFT_1_2_2 == 1 ) int m_Dimension; -#else - char m_Dimension; -#endif char m_Difficulty; //tolua_export unsigned char m_WorldHeight; //tolua_export unsigned char m_MaxPlayers; //tolua_export -#if (MINECRAFT_1_2_2 == 1 ) - static const unsigned int c_Size = 1 + 4 + 2 + 2 + 4 + 4 + 1 + 1 + 1; -#else - static const unsigned int c_Size = 1 + 4 + 2 + 8 + 2 + 4 + 1 + 1 + 1 + 1; // Minimal size -#endif - static const AString LEVEL_TYPE_DEFAULT; static const AString LEVEL_TYPE_SUPERFLAT; }; //tolua_export diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp index 17249c25d..501e4df2d 100644 --- a/source/packets/cPacket_MapChunk.cpp +++ b/source/packets/cPacket_MapChunk.cpp @@ -23,9 +23,6 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, con { m_PacketID = E_MAP_CHUNK; -#if (MINECRAFT_1_2_2 == 1 ) - - // ... m_PosX = a_ChunkX; // Chunk coordinates now, instead of block coordinates m_PosZ = a_ChunkZ; @@ -113,24 +110,6 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, con m_CompressedData = CompressedBlockData; m_CompressedSize = CompressedSize; - -#else - m_PosX = a_ChunkX * cChunkDef::Width; // It has to be block coordinates - m_PosY = (short)(a_ChunkY * cChunkDef::Height); - m_PosZ = a_ChunkZ * cChunkDef::Width; - - m_SizeX = 15; - m_SizeY = 127; - m_SizeZ = 15; - - uLongf CompressedSize = compressBound( cChunkDef::BlockDataSize ); - char * CompressedBlockData = new char[CompressedSize]; - - compress2( (Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)a_BlockData, cChunkDef::BlockDataSize, Z_DEFAULT_COMPRESSION); - - m_CompressedData = CompressedBlockData; - m_CompressedSize = CompressedSize; -#endif } @@ -141,7 +120,6 @@ cPacket_MapChunk::cPacket_MapChunk( const cPacket_MapChunk & a_Copy ) { m_PacketID = E_MAP_CHUNK; -#if (MINECRAFT_1_2_2 == 1 ) m_PosX = a_Copy.m_PosX; m_PosZ = a_Copy.m_PosZ; m_bContiguous = a_Copy.m_bContiguous; @@ -151,18 +129,6 @@ cPacket_MapChunk::cPacket_MapChunk( const cPacket_MapChunk & a_Copy ) m_CompressedSize = a_Copy.m_CompressedSize; m_CompressedData = new char[m_CompressedSize]; memcpy( m_CompressedData, a_Copy.m_CompressedData, m_CompressedSize ); -#else - m_PosX = a_Copy.m_PosX; - m_PosY = a_Copy.m_PosY; - m_PosZ = a_Copy.m_PosZ; - m_SizeX = a_Copy.m_SizeX; - m_SizeY = a_Copy.m_SizeY; - m_SizeZ = a_Copy.m_SizeZ; - - m_CompressedSize = a_Copy.m_CompressedSize; - m_CompressedData = new char[m_CompressedSize]; - memcpy( m_CompressedData, a_Copy.m_CompressedData, m_CompressedSize ); -#endif } @@ -173,7 +139,6 @@ void cPacket_MapChunk::Serialize(AString & a_Data) const { AppendByte (a_Data, m_PacketID); -#if (MINECRAFT_1_2_2 == 1 ) AppendInteger(a_Data, m_PosX); AppendInteger(a_Data, m_PosZ); AppendBool (a_Data, m_bContiguous); @@ -182,16 +147,6 @@ void cPacket_MapChunk::Serialize(AString & a_Data) const AppendInteger(a_Data, m_CompressedSize); AppendInteger(a_Data, m_UnusedInt); AppendData (a_Data, m_CompressedData, m_CompressedSize); -#else - AppendInteger(a_Data, m_PosX); - AppendShort (a_Data, m_PosY); - AppendInteger(a_Data, m_PosZ); - AppendByte (a_Data, m_SizeX); - AppendByte (a_Data, m_SizeY); - AppendByte (a_Data, m_SizeZ); - AppendInteger(a_Data, m_CompressedSize); - AppendData (a_Data, m_CompressedData, m_CompressedSize); -#endif } diff --git a/source/packets/cPacket_MapChunk.h b/source/packets/cPacket_MapChunk.h index 0b2bef7ad..27e1ec8e5 100644 --- a/source/packets/cPacket_MapChunk.h +++ b/source/packets/cPacket_MapChunk.h @@ -13,7 +13,6 @@ class cPacket_MapChunk : { public: cPacket_MapChunk() -#if (MINECRAFT_1_2_2 == 1 ) : m_PosX( 0 ) , m_PosZ( 0 ) , m_bContiguous( false ) @@ -21,17 +20,8 @@ public: , m_BitMap2( 0 ) , m_CompressedSize( 0 ) , m_UnusedInt( 0 ) -#else - : m_PosX( 0 ) - , m_PosY( 0 ) - , m_PosZ( 0 ) - , m_SizeX( 0 ) - , m_SizeY( 0 ) - , m_SizeZ( 0 ) - , m_CompressedSize( 0 ) -#endif - , m_CompressedData( 0 ) - { m_PacketID = E_MAP_CHUNK; m_CompressedData = 0; } + , m_CompressedData( NULL ) + { m_PacketID = E_MAP_CHUNK; } cPacket_MapChunk( const cPacket_MapChunk & a_Copy ); cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const BLOCKTYPE * a_BlockData, const BIOMETYPE * a_BiomeData); @@ -40,27 +30,13 @@ public: virtual void Serialize(AString & a_Data) const override; -#if (MINECRAFT_1_2_2 == 1 ) int m_PosX; int m_PosZ; - bool m_bContiguous; // le fuck? + bool m_bContiguous; short m_BitMap1; short m_BitMap2; int m_CompressedSize; int m_UnusedInt; - static const unsigned int c_Size = 1 + 4 + 4 + 1 + 2 + 2 + 4 + 4; -#else - int m_PosX; // In block coordinates - short m_PosY; - int m_PosZ; - char m_SizeX; // Is actually size-1 (when size is 128, this is 127) - char m_SizeY; - char m_SizeZ; - int m_CompressedSize; - static const unsigned int c_Size = 1 + 4 + 2 + 4 + 1 + 1 + 1 + 4; -#endif - - char * m_CompressedData; }; diff --git a/source/packets/cPacket_MultiBlock.cpp b/source/packets/cPacket_MultiBlock.cpp index 0d73254ed..cfa13c4d4 100644 --- a/source/packets/cPacket_MultiBlock.cpp +++ b/source/packets/cPacket_MultiBlock.cpp @@ -13,20 +13,9 @@ cPacket_MultiBlock::cPacket_MultiBlock( const cPacket_MultiBlock & a_Copy ) m_ChunkX = a_Copy.m_ChunkX; m_ChunkZ = a_Copy.m_ChunkZ; m_NumBlocks = a_Copy.m_NumBlocks; - -#if (MINECRAFT_1_2_2 == 1) m_DataSize = a_Copy.m_DataSize; - m_Data = new sBlockChange[m_NumBlocks]; memcpy( m_Data, a_Copy.m_Data, sizeof(sBlockChange)*m_NumBlocks ); -#else - m_BlockCoordinates = new unsigned short[m_NumBlocks]; - memcpy( m_BlockCoordinates, a_Copy.m_BlockCoordinates, sizeof(short)*m_NumBlocks ); - m_BlockTypes = new char[m_NumBlocks]; - memcpy( m_BlockTypes, a_Copy.m_BlockTypes, m_NumBlocks ); - m_BlockMetas = new char[m_NumBlocks]; - memcpy( m_BlockMetas, a_Copy.m_BlockMetas, m_NumBlocks ); -#endif } @@ -35,13 +24,7 @@ cPacket_MultiBlock::cPacket_MultiBlock( const cPacket_MultiBlock & a_Copy ) cPacket_MultiBlock::~cPacket_MultiBlock() { -#if (MINECRAFT_1_2_2 == 1) delete [] m_Data; -#else - if( m_BlockCoordinates ) delete [] m_BlockCoordinates; - if( m_BlockTypes ) delete [] m_BlockTypes; - if( m_BlockMetas ) delete [] m_BlockMetas; -#endif } @@ -55,15 +38,11 @@ void cPacket_MultiBlock::Serialize(AString & a_Data) const AppendInteger(a_Data, m_ChunkZ); AppendShort (a_Data, m_NumBlocks); -#if (MINECRAFT_1_2_2 == 1) AppendInteger(a_Data, m_DataSize); for( int i = 0; i < m_NumBlocks; ++i ) + { AppendInteger(a_Data, m_Data[i].Data); -#else - AppendData (a_Data, (char *)m_BlockCoordinates, sizeof(short) * m_NumBlocks); - AppendData (a_Data, m_BlockTypes, m_NumBlocks); - AppendData (a_Data, m_BlockMetas, m_NumBlocks); -#endif + } } diff --git a/source/packets/cPacket_MultiBlock.h b/source/packets/cPacket_MultiBlock.h index cd2e5b8f7..31cb96628 100644 --- a/source/packets/cPacket_MultiBlock.h +++ b/source/packets/cPacket_MultiBlock.h @@ -24,15 +24,10 @@ public: : m_ChunkX( 0 ) , m_ChunkZ( 0 ) , m_NumBlocks( 0 ) -#if (MINECRAFT_1_2_2 == 1) , m_DataSize( 0 ) - , m_Data( 0 ) -#else - , m_BlockCoordinates( 0 ) - , m_BlockTypes( 0 ) - , m_BlockMetas( 0 ) -#endif + , m_Data( NULL ) { m_PacketID = E_MULTI_BLOCK; } + cPacket_MultiBlock( const cPacket_MultiBlock & a_Copy ); ~cPacket_MultiBlock(); virtual cPacket* Clone() const { return new cPacket_MultiBlock(*this); } @@ -43,17 +38,8 @@ public: int m_ChunkZ; short m_NumBlocks; -#if (MINECRAFT_1_2_2 == 1) - int m_DataSize; // Should be 4*m_NumBlocks ?? - sBlockChange* m_Data; - static const unsigned int cSize = 1 + 4 + 4 + 2 + 4; // Minimum size (when NumBlocks == 0) -#else - static const unsigned int c_Size = 1 + 4 + 4 + 2; // Minimum size (when NumBlocks == 0) - - unsigned short* m_BlockCoordinates; // x<<12 | z<<8 | y - char* m_BlockTypes; - char* m_BlockMetas; -#endif + int m_DataSize; // Should be 4 * m_NumBlocks ?? + sBlockChange * m_Data; }; diff --git a/source/packets/cPacket_Respawn.cpp b/source/packets/cPacket_Respawn.cpp index 12c30deaa..a6b3b5bc4 100644 --- a/source/packets/cPacket_Respawn.cpp +++ b/source/packets/cPacket_Respawn.cpp @@ -11,20 +11,11 @@ void cPacket_Respawn::Serialize(AString & a_Data) const { AppendByte (a_Data, m_PacketID); -#if (MINECRAFT_1_2_2 == 1) AppendInteger (a_Data, m_Dimension); AppendByte (a_Data, m_Difficulty); AppendByte (a_Data, m_CreativeMode); AppendShort (a_Data, m_WorldHeight); AppendString16(a_Data, m_LevelType); -#else - AppendByte (a_Data, m_World); - AppendByte (a_Data, m_Difficulty); - AppendByte (a_Data, m_CreativeMode); - AppendShort (a_Data, m_WorldHeight); - AppendLong (a_Data, m_MapSeed); - AppendString16(a_Data, m_LevelType); -#endif } @@ -35,20 +26,11 @@ int cPacket_Respawn::Parse(const char * a_Data, int a_Size) { int TotalBytes = 0; -#if (MINECRAFT_1_2_2 == 1) HANDLE_PACKET_READ(ReadInteger, m_Dimension, TotalBytes); HANDLE_PACKET_READ(ReadByte, m_Difficulty, TotalBytes); HANDLE_PACKET_READ(ReadByte, m_CreativeMode, TotalBytes); HANDLE_PACKET_READ(ReadShort, m_WorldHeight, TotalBytes); HANDLE_PACKET_READ(ReadString16, m_LevelType, TotalBytes); -#else - HANDLE_PACKET_READ(ReadByte, m_World, TotalBytes); - HANDLE_PACKET_READ(ReadByte, m_Difficulty, TotalBytes); - HANDLE_PACKET_READ(ReadByte, m_CreativeMode, TotalBytes); - HANDLE_PACKET_READ(ReadShort, m_WorldHeight, TotalBytes); - HANDLE_PACKET_READ(ReadLong, m_MapSeed, TotalBytes); - HANDLE_PACKET_READ(ReadString16, m_LevelType, TotalBytes); -#endif return TotalBytes; } diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h index dbb4957c5..b95ecc384 100644 --- a/source/packets/cPacket_Respawn.h +++ b/source/packets/cPacket_Respawn.h @@ -13,42 +13,23 @@ class cPacket_Respawn : public cPacket { public: cPacket_Respawn() -#if (MINECRAFT_1_2_2 == 1) : m_Dimension( 0 ) , m_Difficulty( 0 ) , m_CreativeMode( 0 ) , m_WorldHeight( 0 ) , m_LevelType( cPacket_Login::LEVEL_TYPE_DEFAULT ) -#else - : m_World( 0 ) - , m_Difficulty( 0 ) - , m_CreativeMode( 0 ) - , m_WorldHeight( 0 ) - , m_MapSeed( 0 ) - , m_LevelType( cPacket_Login::LEVEL_TYPE_DEFAULT ) -#endif { m_PacketID = E_RESPAWN; } + virtual cPacket* Clone() const { return new cPacket_Respawn( *this ); } virtual int Parse(const char * a_Data, int a_Size) override; virtual void Serialize(AString & a_Data) const override; -#if (MINECRAFT_1_2_2 == 1) int m_Dimension; char m_Difficulty; char m_CreativeMode; short m_WorldHeight; AString m_LevelType; -#else - char m_World; - char m_Difficulty; - char m_CreativeMode; - short m_WorldHeight; - long long m_MapSeed; - AString m_LevelType; -#endif - - static const unsigned int c_Size = 1 + 1 + 1 + 1 + 2 + 8 + 2; }; -- cgit v1.2.3