Added support for 1.4.4 client, using the 1.4.2 protocol class
No MCServer-supported packets changed. Initial patch by Setimes. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1042 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
9f4b6ffc6c
commit
e41b15565c
@ -2,6 +2,7 @@
|
|||||||
// Protocol142.h
|
// Protocol142.h
|
||||||
|
|
||||||
// Interfaces to the cProtocol142 class representing the release 1.4.2 protocol (#47)
|
// Interfaces to the cProtocol142 class representing the release 1.4.2 protocol (#47)
|
||||||
|
// The same protocol class is used for 1.4.4 too, because the only difference is in a packet that MCServer doesn't implement yet (ITEM_DATA)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +39,22 @@ cProtocolRecognizer::~cProtocolRecognizer()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion)
|
||||||
|
{
|
||||||
|
switch (a_ProtocolVersion)
|
||||||
|
{
|
||||||
|
case PROTO_VERSION_1_2_5: return "1.2.5";
|
||||||
|
case PROTO_VERSION_1_3_2: return "1.3.2";
|
||||||
|
case PROTO_VERSION_1_4_2: return "1.4.2";
|
||||||
|
case PROTO_VERSION_1_4_4: return "1.4.4";
|
||||||
|
}
|
||||||
|
return Printf("Unknown protocol (%d)", a_ProtocolVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocolRecognizer::DataReceived(const char * a_Data, int a_Size)
|
void cProtocolRecognizer::DataReceived(const char * a_Data, int a_Size)
|
||||||
{
|
{
|
||||||
if (m_Protocol == NULL)
|
if (m_Protocol == NULL)
|
||||||
@ -541,7 +557,7 @@ void cProtocolRecognizer::SendData(const char * a_Data, int a_Size)
|
|||||||
bool cProtocolRecognizer::TryRecognizeProtocol(void)
|
bool cProtocolRecognizer::TryRecognizeProtocol(void)
|
||||||
{
|
{
|
||||||
// NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and
|
// NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and
|
||||||
// MCS_PROTOCOL_VERSIONS macros in the header file
|
// MCS_PROTOCOL_VERSIONS macros in the header file, as well as PROTO_VERSION_LATEST macro
|
||||||
|
|
||||||
// The first packet should be a Handshake, 0x02:
|
// The first packet should be a Handshake, 0x02:
|
||||||
unsigned char PacketType;
|
unsigned char PacketType;
|
||||||
@ -563,16 +579,20 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (ch == PROTO_VERSION_1_3_2)
|
switch (ch)
|
||||||
|
{
|
||||||
|
case PROTO_VERSION_1_3_2:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol132(m_Client);
|
m_Protocol = new cProtocol132(m_Client);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ch == PROTO_VERSION_1_4_2)
|
case PROTO_VERSION_1_4_2:
|
||||||
|
case PROTO_VERSION_1_4_4:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol142(m_Client);
|
m_Protocol = new cProtocol142(m_Client);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
m_Protocol = new cProtocol125(m_Client);
|
m_Protocol = new cProtocol125(m_Client);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -601,6 +621,7 @@ void cProtocolRecognizer::HandleServerPing(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case PROTO_VERSION_1_4_2:
|
case PROTO_VERSION_1_4_2:
|
||||||
|
case PROTO_VERSION_1_4_4:
|
||||||
{
|
{
|
||||||
// The server list ping now has 1 more byte of "magic". Mojang just loves to complicate stuff.
|
// The server list ping now has 1 more byte of "magic". Mojang just loves to complicate stuff.
|
||||||
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3101#Server_List_Ping_.280xFE.29
|
// http://wiki.vg/wiki/index.php?title=Protocol&oldid=3101#Server_List_Ping_.280xFE.29
|
||||||
@ -619,13 +640,17 @@ void cProtocolRecognizer::HandleServerPing(void)
|
|||||||
AString MaxPlayers;
|
AString MaxPlayers;
|
||||||
Printf(MaxPlayers, "%d", cRoot::Get()->GetDefaultWorld()->GetMaxPlayers());
|
Printf(MaxPlayers, "%d", cRoot::Get()->GetDefaultWorld()->GetMaxPlayers());
|
||||||
|
|
||||||
|
AString ProtocolVersionNum;
|
||||||
|
Printf(ProtocolVersionNum, "%d", cRoot::Get()->m_PrimaryServerVersion);
|
||||||
|
AString ProtocolVersionTxt(GetVersionTextFromInt(cRoot::Get()->m_PrimaryServerVersion));
|
||||||
|
|
||||||
// Cannot use Printf() because of in-string NUL bytes.
|
// Cannot use Printf() because of in-string NUL bytes.
|
||||||
Reply = cChatColor::Delimiter;
|
Reply = cChatColor::Delimiter;
|
||||||
Reply.append("1");
|
Reply.append("1");
|
||||||
Reply.push_back(0);
|
Reply.push_back(0);
|
||||||
Reply.append("47");
|
Reply.append(ProtocolVersionNum);
|
||||||
Reply.push_back(0);
|
Reply.push_back(0);
|
||||||
Reply.append("1.4.2");
|
Reply.append(ProtocolVersionTxt);
|
||||||
Reply.push_back(0);
|
Reply.push_back(0);
|
||||||
Reply.append(cRoot::Get()->GetDefaultWorld()->GetDescription());
|
Reply.append(cRoot::Get()->GetDefaultWorld()->GetDescription());
|
||||||
Reply.push_back(0);
|
Reply.push_back(0);
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
|
|
||||||
// Adjust these if a new protocol is added or an old one is removed:
|
// Adjust these if a new protocol is added or an old one is removed:
|
||||||
#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2"
|
#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4"
|
||||||
#define MCS_PROTOCOL_VERSIONS "29, 39, 47"
|
#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -36,13 +36,17 @@ public:
|
|||||||
PROTO_VERSION_1_2_5 = 29,
|
PROTO_VERSION_1_2_5 = 29,
|
||||||
PROTO_VERSION_1_3_2 = 39,
|
PROTO_VERSION_1_3_2 = 39,
|
||||||
PROTO_VERSION_1_4_2 = 47,
|
PROTO_VERSION_1_4_2 = 47,
|
||||||
|
PROTO_VERSION_1_4_4 = 49,
|
||||||
|
|
||||||
PROTO_VERSION_LATEST = PROTO_VERSION_1_4_2, // Keep this up to date, this serves as the default for PrimaryServerVersion
|
PROTO_VERSION_LATEST = PROTO_VERSION_1_4_4, // Keep this up to date, this serves as the default for PrimaryServerVersion
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
cProtocolRecognizer(cClientHandle * a_Client);
|
cProtocolRecognizer(cClientHandle * a_Client);
|
||||||
virtual ~cProtocolRecognizer();
|
virtual ~cProtocolRecognizer();
|
||||||
|
|
||||||
|
/// Translates protocol version number into protocol version text: 49 -> "1.4.4"
|
||||||
|
static AString GetVersionTextFromInt(int a_ProtocolVersion);
|
||||||
|
|
||||||
/// Called when client sends some data:
|
/// Called when client sends some data:
|
||||||
virtual void DataReceived(const char * a_Data, int a_Size) override;
|
virtual void DataReceived(const char * a_Data, int a_Size) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user