From 75cc675bf2fe0bf69c819b47a3235bbb6c14baaa Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 14 Mar 2013 20:34:37 +0000 Subject: Release 1.5 supported, yay :) Although some new blocks are still not recognized and behave badly, the protocol itself is working. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1273 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Protocol/Protocol14x.cpp | 6 ---- source/Protocol/Protocol15x.cpp | 59 ++++++++++++++++++++++++++++++++++ source/Protocol/Protocol15x.h | 36 +++++++++++++++++++++ source/Protocol/ProtocolRecognizer.cpp | 8 +++++ source/Protocol/ProtocolRecognizer.h | 8 +++-- 5 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 source/Protocol/Protocol15x.cpp create mode 100644 source/Protocol/Protocol15x.h (limited to 'source') diff --git a/source/Protocol/Protocol14x.cpp b/source/Protocol/Protocol14x.cpp index d19768c5c..c5597e041 100644 --- a/source/Protocol/Protocol14x.cpp +++ b/source/Protocol/Protocol14x.cpp @@ -44,12 +44,6 @@ Implements the 1.4.x protocol classes representing these protocols: -typedef unsigned char Byte; - - - - - enum { PACKET_UPDATE_TIME = 0x04, diff --git a/source/Protocol/Protocol15x.cpp b/source/Protocol/Protocol15x.cpp new file mode 100644 index 000000000..61358fcdb --- /dev/null +++ b/source/Protocol/Protocol15x.cpp @@ -0,0 +1,59 @@ + +// Protocol15x.cpp + +/* +Implements the 1.5.x protocol classes: + - cProtocol150 + - release 1.5 protocol (#60) +(others may be added later in the future for the 1.5 release series) +*/ + +#include "Globals.h" +#include "Protocol15x.h" + + + + + +enum +{ + PACKET_WINDOW_OPEN = 0x64, +} ; + + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cProtocol150: + +cProtocol150::cProtocol150(cClientHandle * a_Client) : + super(a_Client) +{ +} + + + + + +void cProtocol150::SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) +{ + if (a_WindowType < 0) + { + // Do not send for inventory windows + return; + } + cCSLock Lock(m_CSPacket); + WriteByte (PACKET_WINDOW_OPEN); + WriteByte (a_WindowID); + WriteByte (a_WindowType); + WriteString(a_WindowTitle); + WriteByte (a_NumSlots); + WriteByte (1); // Use title + Flush(); +} + + + + diff --git a/source/Protocol/Protocol15x.h b/source/Protocol/Protocol15x.h new file mode 100644 index 000000000..f09ba09d7 --- /dev/null +++ b/source/Protocol/Protocol15x.h @@ -0,0 +1,36 @@ + +// Protocol15x.h + +/* +Declares the 1.5.x protocol classes: + - cProtocol150 + - release 1.5 protocol (#60) +(others may be added later in the future for the 1.5 release series) +*/ + + + + + +#pragma once + +#include "Protocol14x.h" + + + + + +class cProtocol150 : + public cProtocol146 +{ + typedef cProtocol146 super; + +public: + cProtocol150(cClientHandle * a_Client); + + virtual void SendWindowOpen(char a_WindowID, char a_WindowType, const AString & a_WindowTitle, char a_NumSlots) override; +} ; + + + + diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp index 8a40376a3..935d89b9e 100644 --- a/source/Protocol/ProtocolRecognizer.cpp +++ b/source/Protocol/ProtocolRecognizer.cpp @@ -10,6 +10,7 @@ #include "Protocol125.h" #include "Protocol132.h" #include "Protocol14x.h" +#include "Protocol15x.h" #include "../ClientHandle.h" #include "../Root.h" #include "../World.h" @@ -48,6 +49,7 @@ AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion) case PROTO_VERSION_1_4_2: return "1.4.2"; case PROTO_VERSION_1_4_4: return "1.4.4"; case PROTO_VERSION_1_4_6: return "1.4.6"; + case PROTO_VERSION_1_5_0: return "1.5"; } ASSERT(!"Unknown protocol version"); return Printf("Unknown protocol (%d)", a_ProtocolVersion); @@ -629,6 +631,11 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void) m_Protocol = new cProtocol146(m_Client); return true; } + case PROTO_VERSION_1_5_0: + { + m_Protocol = new cProtocol150(m_Client); + return true; + } } m_Protocol = new cProtocol125(m_Client); return true; @@ -660,6 +667,7 @@ void cProtocolRecognizer::HandleServerPing(void) case PROTO_VERSION_1_4_2: case PROTO_VERSION_1_4_4: case PROTO_VERSION_1_4_6: + case PROTO_VERSION_1_5_0: { // 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 diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h index a4cec69f8..682e6fcf3 100644 --- a/source/Protocol/ProtocolRecognizer.h +++ b/source/Protocol/ProtocolRecognizer.h @@ -18,8 +18,8 @@ // 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, 1.4.4, 1.4.5, 1.4.6, 1.4.7" -#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51" +#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5" +#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60" @@ -38,8 +38,10 @@ public: PROTO_VERSION_1_4_2 = 47, PROTO_VERSION_1_4_4 = 49, PROTO_VERSION_1_4_6 = 51, + PROTO_VERSION_1_5_0 = 60, - PROTO_VERSION_LATEST = PROTO_VERSION_1_4_6, // Keep this up to date, this serves as the default for PrimaryServerVersion + PROTO_VERSION_NEXT, + PROTO_VERSION_LATEST = PROTO_VERSION_NEXT - 1, ///< Automatically assigned to the last protocol version, this serves as the default for PrimaryServerVersion } ; cProtocolRecognizer(cClientHandle * a_Client); -- cgit v1.2.3