diff options
author | Mattes D <github@xoft.cz> | 2014-10-05 20:19:21 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-10-05 20:19:21 +0200 |
commit | a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7 (patch) | |
tree | ae3a23a0691b741c7b369f84a1de96126bf73aa6 /src | |
parent | Update README.md (diff) | |
download | cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.tar cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.tar.gz cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.tar.bz2 cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.tar.lz cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.tar.xz cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.tar.zst cuberite-a8aeceab9d6e5e5e36ef7bd58783b65aca4d8be7.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ClientHandle.cpp | 12 | ||||
-rw-r--r-- | src/ClientHandle.h | 9 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.cpp | 1 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.h | 2 |
4 files changed, 21 insertions, 3 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index a29bef0c0..3b677460b 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -92,7 +92,8 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : m_NumBlockChangeInteractionsThisTick(0), m_UniqueID(0), m_HasSentPlayerChunk(false), - m_Locale("en_GB") + m_Locale("en_GB"), + m_ProtocolVersion(0) { m_Protocol = new cProtocolRecognizer(this); @@ -583,15 +584,22 @@ void cClientHandle::HandlePing(void) bool cClientHandle::HandleLogin(int a_ProtocolVersion, const AString & a_Username) { + // If the protocol version hasn't been set yet, set it now: + if (m_ProtocolVersion == 0) + { + m_ProtocolVersion = a_ProtocolVersion; + } + m_Username = a_Username; + // Let the plugins know about this event, they may refuse the player: if (cRoot::Get()->GetPluginManager()->CallHookLogin(this, a_ProtocolVersion, a_Username)) { Destroy(); return false; } - // Schedule for authentication; until then, let them wait (but do not block) + // Schedule for authentication; until then, let the player wait (but do not block) m_State = csAuthenticating; cRoot::Get()->GetAuthenticator().Authenticate(GetUniqueID(), GetUsername(), m_Protocol->GetAuthServerID()); return true; diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 20592c190..a9cc29d50 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -316,6 +316,12 @@ public: /** Called when the player will enchant a Item */ void HandleEnchantItem(Byte & a_WindowID, Byte & a_Enchantment); + + /** Called by the protocol recognizer when the protocol version is known. */ + void SetProtocolVersion(UInt32 a_ProtocolVersion) { m_ProtocolVersion = a_ProtocolVersion; } + + /** Returns the protocol version number of the protocol that the client is talking. Returns zero if the protocol version is not (yet) known. */ + UInt32 GetProtocolVersion(void) const { return m_ProtocolVersion; } // tolua_export private: @@ -427,6 +433,9 @@ private: /** The brand identification of the client, as received in the MC|Brand plugin message or set from a plugin. */ AString m_ClientBrand; + /** The version of the protocol that the client is talking, or 0 if unknown. */ + UInt32 m_ProtocolVersion; + /** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */ void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler); diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 4f8eb59db..15bcd03b1 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -905,6 +905,7 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema { return false; } + m_Client->SetProtocolVersion(ProtocolVersion); switch (ProtocolVersion) { case PROTO_VERSION_1_7_2: diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index 96a7e17d2..b42cfdec2 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -134,7 +134,7 @@ protected: /// Tries to recognize protocol based on m_Buffer contents; returns true if recognized bool TryRecognizeProtocol(void); - /** Tries to recognize a protocol in the leghted family (1.7+), based on m_Buffer; returns true if recognized. + /** Tries to recognize a protocol in the lengthed family (1.7+), based on m_Buffer; returns true if recognized. The packet length and type have already been read, type is 0 The number of bytes remaining in the packet is passed as a_PacketLengthRemaining **/ |