diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-01-20 18:39:16 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-01-20 18:39:16 +0100 |
commit | 7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b (patch) | |
tree | cde505c4726c53f67b168e7e4ce22007cc72ef1a | |
parent | Terrain generation is synchronous again, async generation has bugs. (diff) | |
download | cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.tar cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.tar.gz cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.tar.bz2 cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.tar.lz cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.tar.xz cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.tar.zst cuberite-7b840aa5d8c925f8ced6289a5ed3dde4a6f8e77b.zip |
-rw-r--r-- | source/cClientHandle.cpp | 8 | ||||
-rw-r--r-- | source/packets/cPacket_Login.cpp | 7 | ||||
-rw-r--r-- | source/packets/cPacket_Login.h | 8 | ||||
-rw-r--r-- | source/packets/cPacket_Respawn.cpp | 4 | ||||
-rw-r--r-- | source/packets/cPacket_Respawn.h | 6 |
5 files changed, 27 insertions, 6 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 46669848e..6e029e14a 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -85,7 +85,7 @@ typedef std::list<cPacket*> PacketList; struct cClientHandle::sClientHandleState
{
sClientHandleState()
- : ProtocolVersion( 22 )
+ : ProtocolVersion( 23 )
, pReceiveThread( 0 )
, pSendThread( 0 )
, pAuthenticateThread( 0 )
@@ -483,10 +483,14 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) {
LOG("LOGIN %s", GetUsername() );
cPacket_Login* PacketData = reinterpret_cast<cPacket_Login*>(a_Packet);
- if (PacketData->m_ProtocolVersion != m_pState->ProtocolVersion) {
+ if (PacketData->m_ProtocolVersion < m_pState->ProtocolVersion) {
Kick("Your client is outdated!");
return;
}
+ else if( PacketData->m_ProtocolVersion > m_pState->ProtocolVersion ) {
+ Kick("Your client version is higher than the server!");
+ return;
+ }
if( m_pState->Username.compare( PacketData->m_Username ) != 0 )
{
Kick("Login Username does not match Handshake username!");
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 <string>
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;
};
|