diff options
author | tycho <work.tycho@gmail.com> | 2015-11-08 22:19:20 +0100 |
---|---|---|
committer | tycho <work.tycho@gmail.com> | 2015-12-18 19:14:34 +0100 |
commit | 2b48f586aac6f15cb4e2c80bcf3a8eaeb8abda75 (patch) | |
tree | 72623b02dd7039a1218f082ba096a1b2134a16f2 /src/Protocol/LengthenedProtocol.cpp | |
parent | Broken (diff) | |
download | cuberite-ProtocolRefactor.tar cuberite-ProtocolRefactor.tar.gz cuberite-ProtocolRefactor.tar.bz2 cuberite-ProtocolRefactor.tar.lz cuberite-ProtocolRefactor.tar.xz cuberite-ProtocolRefactor.tar.zst cuberite-ProtocolRefactor.zip |
Diffstat (limited to 'src/Protocol/LengthenedProtocol.cpp')
-rw-r--r-- | src/Protocol/LengthenedProtocol.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Protocol/LengthenedProtocol.cpp b/src/Protocol/LengthenedProtocol.cpp index 7a6c5918f..8e16b7db2 100644 --- a/src/Protocol/LengthenedProtocol.cpp +++ b/src/Protocol/LengthenedProtocol.cpp @@ -1,5 +1,6 @@ #include "Globals.h" #include "LengthenedProtocol.h" +#include "ClientAction.h" cProtocol::cProtocolError cLengthenedProtocol::DataReceived(const char * a_Data, size_t a_Size, std::vector<std::unique_ptr<cClientAction>> & a_Actions) { @@ -85,3 +86,41 @@ cProtocol::cProtocolError cLengthenedProtocol::AddReceivedData(const char * a_Da } return cProtocolError::Success; } + +#define ADD_SIMPLE_ACTION(Name) a_Action.push_back(cpp14::make_unique<cSimpleAction>(cClientAction::Type::Name)); + +cProtocol::cProtocolError cLengthenedProtocol::HandleHandshake(cByteBuffer & a_ByteBuffer, std::vector<std::unique_ptr<cClientAction>> & a_Action) +{ + // these need to replace the values provided to the constructor in the old version + if (!a_ByteBuffer.ReadVarUTF8String(m_ServerAddress)) + { + return cProtocolError::PacketReadError; + } + if (!a_ByteBuffer.ReadBEUInt16(m_ServerPort)) + { + return cProtocolError::PacketReadError; + } + if (!a_ByteBuffer.ReadVarInt(m_State)) + { + return cProtocolError::PacketReadError; + } + a_ByteBuffer.CommitRead(); + + // BungeeCord handling: + // If BC is setup with ip_forward == true, it sends additional data in the login packet's ServerAddress field: + // hostname\00ip-address\00uuid\00profile-properties-as-json + AStringVector Params; + if (m_ShouldAllowBungeeCord && SplitZeroTerminatedStrings(m_ServerAddress, Params) && (Params.size() == 4)) + { + LOGD("Player at %s connected via BungeeCord", Params[1].c_str()); + m_ServerAddress = Params[0]; + //a_Client->SetIPString(Params[1]); + //a_Client->SetUUID(cMojangAPI::MakeUUIDShort(Params[2])); + //a_Client->SetProperties(Params[3]); + ADD_SIMPLE_ACTION(SetIPString); + ADD_SIMPLE_ACTION(SetUUID); + ADD_SIMPLE_ACTION(SetProperties); + } + return cProtocolError::Success; +} + |