From 7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b Mon Sep 17 00:00:00 2001 From: faketruth Date: Fri, 20 Jan 2012 17:39:16 +0000 Subject: MCServer is now compatible with Minecraft client 1.1 (as long as the client is not using any mods/plugins I think) git-svn-id: http://mc-server.googlecode.com/svn/trunk@165 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/packets/cPacket_Login.cpp | 7 ++++++- source/packets/cPacket_Login.h | 8 +++++++- source/packets/cPacket_Respawn.cpp | 4 +++- source/packets/cPacket_Respawn.h | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'source/packets') diff --git a/source/packets/cPacket_Login.cpp b/source/packets/cPacket_Login.cpp index f0a9aaf30..2716aaf97 100644 --- a/source/packets/cPacket_Login.cpp +++ b/source/packets/cPacket_Login.cpp @@ -1,5 +1,8 @@ #include "cPacket_Login.h" +const std::string cPacket_Login::LEVEL_TYPE_DEFAULT = "DEFAULT"; +const std::string cPacket_Login::LEVEL_TYPE_SUPERFLAT = "SUPERFLAT"; + bool cPacket_Login::Parse( cSocket & a_Socket ) { //printf("Parse: NEW Login\n"); @@ -10,6 +13,7 @@ bool cPacket_Login::Parse( cSocket & a_Socket ) if( !ReadInteger( m_ProtocolVersion ) ) return false; if( !ReadString16( m_Username ) ) return false; if( !ReadLong ( m_MapSeed ) ) return false; + if( !ReadString16( m_LevelType ) ) return false; if( !ReadInteger( m_ServerMode ) ) return false; if( !ReadByte ( m_Dimension ) ) return false; if( !ReadByte ( m_Difficulty ) ) return false; @@ -21,7 +25,7 @@ bool cPacket_Login::Parse( cSocket & a_Socket ) bool cPacket_Login::Send( cSocket & a_Socket ) { //printf("Send: NEW Login\n"); - unsigned int TotalSize = c_Size + m_Username.size() * sizeof(short); + unsigned int TotalSize = c_Size + m_Username.size() * sizeof(short) + m_LevelType.size() * sizeof(short); char* Message = new char[TotalSize]; unsigned int i = 0; @@ -29,6 +33,7 @@ bool cPacket_Login::Send( cSocket & a_Socket ) AppendInteger( m_ProtocolVersion, Message, i ); AppendString16 ( m_Username, Message, i ); AppendLong ( m_MapSeed, Message, i ); + AppendString16( m_LevelType, Message, i ); AppendInteger( m_ServerMode, Message, i ); AppendByte ( m_Dimension, Message, i ); AppendByte ( m_Difficulty, Message, i ); diff --git a/source/packets/cPacket_Login.h b/source/packets/cPacket_Login.h index 91919a799..71fa6e9c1 100644 --- a/source/packets/cPacket_Login.h +++ b/source/packets/cPacket_Login.h @@ -15,6 +15,7 @@ public: , m_Difficulty( 0 ) , m_WorldHeight( 0 ) , m_MaxPlayers( 0 ) + , m_LevelType( LEVEL_TYPE_DEFAULT ) { m_PacketID = E_LOGIN; } virtual cPacket* Clone() const { return new cPacket_Login(*this); } @@ -24,10 +25,15 @@ public: int m_ProtocolVersion; //tolua_export std::string m_Username; //tolua_export long long m_MapSeed; //tolua_export + std::string m_LevelType; //tolua_export int m_ServerMode; //tolua_export char m_Dimension; //tolua_export char m_Difficulty; //tolua_export unsigned char m_WorldHeight; //tolua_export unsigned char m_MaxPlayers; //tolua_export - static const unsigned int c_Size = 1 + 4 + 2 + 8 + 4 + 1 + 1 + 1 + 1; // Minimal size + static const unsigned int c_Size = 1 + 4 + 2 + 8 + 2 + 4 + 1 + 1 + 1 + 1; // Minimal size + + + static const std::string LEVEL_TYPE_DEFAULT; + static const std::string LEVEL_TYPE_SUPERFLAT; }; //tolua_export diff --git a/source/packets/cPacket_Respawn.cpp b/source/packets/cPacket_Respawn.cpp index e12ea1ace..1bc18d500 100644 --- a/source/packets/cPacket_Respawn.cpp +++ b/source/packets/cPacket_Respawn.cpp @@ -2,7 +2,7 @@ bool cPacket_Respawn::Send(cSocket & a_Socket) { - unsigned int TotalSize = c_Size; + unsigned int TotalSize = c_Size + m_LevelType.size() * sizeof(short); char* Message = new char[TotalSize]; @@ -13,6 +13,7 @@ bool cPacket_Respawn::Send(cSocket & a_Socket) AppendByte ( m_CreativeMode, Message, i ); AppendShort ( m_WorldHeight, Message, i ); AppendLong ( m_MapSeed, Message, i ); + AppendString16 ( m_LevelType, Message, i ); bool RetVal = !cSocket::IsSocketError( SendData( a_Socket, Message, TotalSize, 0 ) ); delete [] Message; @@ -27,5 +28,6 @@ bool cPacket_Respawn::Parse(cSocket & a_Socket) if( !ReadByte( m_CreativeMode ) ) return false; if( !ReadShort( m_WorldHeight ) ) return false; if( !ReadLong( m_MapSeed ) ) return false; + if( !ReadString16( m_LevelType ) ) return false; return true; } \ No newline at end of file diff --git a/source/packets/cPacket_Respawn.h b/source/packets/cPacket_Respawn.h index ab8fbe72a..a9a838167 100644 --- a/source/packets/cPacket_Respawn.h +++ b/source/packets/cPacket_Respawn.h @@ -2,6 +2,8 @@ #include "cPacket.h" #include "PacketID.h" +#include "cPacket_Login.h" +#include class cPacket_Respawn : public cPacket { @@ -12,6 +14,7 @@ public: , m_CreativeMode( 0 ) , m_WorldHeight( 0 ) , m_MapSeed( 0 ) + , m_LevelType( cPacket_Login::LEVEL_TYPE_DEFAULT ) { m_PacketID = E_RESPAWN; } virtual cPacket* Clone() const { return new cPacket_Respawn( *this ); } @@ -23,6 +26,7 @@ public: char m_CreativeMode; short m_WorldHeight; long long m_MapSeed; + std::string m_LevelType; - static const unsigned int c_Size = 1 + 1 + 1 + 1 + 2 + 8; + static const unsigned int c_Size = 1 + 1 + 1 + 1 + 2 + 8 + 2; }; -- cgit v1.2.3