Added a basic protocol recognizer and the base for 1.3.2 protocol.
Also fixed a few type-related warnings. git-svn-id: http://mc-server.googlecode.com/svn/trunk@805 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
65
source/Protocol132.cpp
Normal file
65
source/Protocol132.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
// Protocol132.cpp
|
||||
|
||||
// Implements the cProtocol132 class representing the release 1.3.2 protocol (#39)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Protocol132.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define HANDLE_PACKET_READ(Proc, Type, Var) \
|
||||
Type Var; \
|
||||
{ \
|
||||
if (!m_ReceivedData.Proc(Var)) \
|
||||
{ \
|
||||
return PARSE_INCOMPLETE; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
typedef unsigned char Byte;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// cProtocol132:
|
||||
|
||||
cProtocol132::cProtocol132(cClientHandle * a_Client) :
|
||||
super(a_Client)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cProtocol132::DataReceived(const char * a_Data, int a_Size)
|
||||
{
|
||||
// TODO: Protocol decryption
|
||||
super::DataReceived(a_Data, a_Size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cProtocol132::ParseHandshake(void)
|
||||
{
|
||||
HANDLE_PACKET_READ(ReadByte, Byte, ProtocolVersion);
|
||||
HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
|
||||
HANDLE_PACKET_READ(ReadBEUTF16String16, AString, ServerHost);
|
||||
HANDLE_PACKET_READ(ReadBEInt, int, ServerPort);
|
||||
m_Username = Username;
|
||||
return PARSE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user