From 7f372b12cb01f7df9d5466de11b36494353613a8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Sep 2020 21:08:23 +0100 Subject: Add State enum to protocol --- src/Protocol/Protocol_1_8.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/Protocol/Protocol_1_8.h') diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h index 92eb4b88a..47e483941 100644 --- a/src/Protocol/Protocol_1_8.h +++ b/src/Protocol/Protocol_1_8.h @@ -31,7 +31,7 @@ class cProtocol_1_8_0: public: - cProtocol_1_8_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + cProtocol_1_8_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, State a_State); /** Called when client sends some data: */ virtual void DataReceived(cByteBuffer & a_Buffer, const char * a_Data, size_t a_Size) override; @@ -134,6 +134,9 @@ public: protected: + /** State of the protocol. */ + State m_State; + /** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */ virtual void AddReceivedData(cByteBuffer & a_Buffer, const char * a_Data, size_t a_Size); @@ -190,7 +193,6 @@ protected: The message payload is still in the bytebuffer, the handler reads it specifically for each handled channel */ virtual void HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel); - /** Sends the data to the client, encrypting them if needed. */ virtual void SendData(const char * a_Data, size_t a_Size) override; @@ -229,11 +231,20 @@ protected: /** Writes the block entity data for the specified block entity into the packet. */ virtual void WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_BlockEntity); - /** State of the protocol. 1 = status, 2 = login, 3 = game */ - UInt32 m_State; - private: + AString m_ServerAddress; + + AString m_AuthServerID; + + bool m_IsEncrypted; + + cAesCfb128Decryptor m_Decryptor; + cAesCfb128Encryptor m_Encryptor; + + /** The logfile where the comm is logged, when g_ShouldLogComm is true */ + cFile m_CommLogFile; + /** Sends an entity teleport packet. Mitigates a 1.8 bug where the position in the entity spawn packet is ignored, and so entities don't show up until a teleport is sent. */ @@ -247,16 +258,4 @@ private: Protocols <= 1.12 use strings, hence this is a static as the string-mapping was append-only for the versions that used it. Returns an empty string, handled correctly by the client, for newer, unsupported statistics. */ static const char * GetProtocolStatisticName(Statistic a_Statistic); - - AString m_ServerAddress; - - AString m_AuthServerID; - - bool m_IsEncrypted; - - cAesCfb128Decryptor m_Decryptor; - cAesCfb128Encryptor m_Encryptor; - - /** The logfile where the comm is logged, when g_ShouldLogComm is true */ - cFile m_CommLogFile; } ; -- cgit v1.2.3