1
0

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
This commit is contained in:
faketruth 2012-01-20 17:39:16 +00:00
parent 50a7722242
commit 7b840aa5d8
5 changed files with 27 additions and 6 deletions

View File

@ -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!");

View File

@ -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 );

View File

@ -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

View File

@ -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;
}

View File

@ -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;
};