diff options
Diffstat (limited to '')
-rw-r--r-- | src/Protocol/Protocol_1_12.h | 2 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_14.cpp | 46 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_14.h | 9 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.h | 36 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.h | 2 |
5 files changed, 46 insertions, 49 deletions
diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h index 80f0b4680..757ea9cc0 100644 --- a/src/Protocol/Protocol_1_12.h +++ b/src/Protocol/Protocol_1_12.h @@ -35,7 +35,6 @@ public: protected: virtual UInt32 GetPacketID(ePacketType a_Packet) override; - virtual Version GetProtocolVersion() override; virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; virtual void HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer); @@ -61,7 +60,6 @@ public: protected: virtual UInt32 GetPacketID(ePacketType a_Packet) override; - virtual Version GetProtocolVersion() override; virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; }; diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp index c31b3ddfb..c3e4a62d0 100644 --- a/src/Protocol/Protocol_1_14.cpp +++ b/src/Protocol/Protocol_1_14.cpp @@ -215,77 +215,77 @@ cProtocol::Version cProtocol_1_14::GetProtocolVersion() -bool cProtocol_1_14::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) +std::pair<short, short> cProtocol_1_14::GetItemFromProtocolID(UInt32 a_ProtocolID) { - if (m_State != 3) - { - return Super::HandlePacket(a_ByteBuffer, a_PacketType); - } - - // Game - switch (a_PacketType) - { - default: AString dum; a_ByteBuffer.ReadAll(dum); a_ByteBuffer.CommitRead(); a_ByteBuffer.Write(" ", 1); - return true; - } + return PaletteUpgrade::ToItem(Palette_1_14::ToItem(a_ProtocolID)); } -void cProtocol_1_14::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) +UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) { + return Palette_1_14::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); } -void cProtocol_1_14::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) +UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage) { + return Palette_1_14::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); } -void cProtocol_1_14::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) +UInt32 cProtocol_1_14::GetProtocolStatisticType(Statistic a_Statistic) { + return Palette_1_14::From(a_Statistic); } -std::pair<short, short> cProtocol_1_14::GetItemFromProtocolID(UInt32 a_ProtocolID) +bool cProtocol_1_14::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) { - return PaletteUpgrade::ToItem(Palette_1_14::ToItem(a_ProtocolID)); + if (m_State != 3) + { + return Super::HandlePacket(a_ByteBuffer, a_PacketType); + } + + // Game + switch (a_PacketType) + { + default: AString dum; a_ByteBuffer.ReadAll(dum); a_ByteBuffer.CommitRead(); a_ByteBuffer.Write(" ", 1); + return true; + } } -UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) +void cProtocol_1_14::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) { - return Palette_1_14::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); } -UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage) +void cProtocol_1_14::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) { - return Palette_1_14::FromItem(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); } -UInt32 cProtocol_1_14::GetProtocolStatisticType(Statistic a_Statistic) +void cProtocol_1_14::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) { - return Palette_1_14::From(a_Statistic); } diff --git a/src/Protocol/Protocol_1_14.h b/src/Protocol/Protocol_1_14.h index 54b9c080f..e9bbca6eb 100644 --- a/src/Protocol/Protocol_1_14.h +++ b/src/Protocol/Protocol_1_14.h @@ -42,17 +42,16 @@ protected: virtual UInt32 GetPacketID(ePacketType a_PacketType) override; virtual Version GetProtocolVersion() override; + virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) override; + virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) override; + virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) override; + virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) override; virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; virtual void HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) override; virtual void HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) override; virtual void HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) override; - virtual std::pair<short, short> GetItemFromProtocolID(UInt32 a_ProtocolID) override; - virtual UInt32 GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) override; - virtual UInt32 GetProtocolItemType(short a_ItemID, short a_ItemDamage) override; - virtual UInt32 GetProtocolStatisticType(Statistic a_Statistic) override; - virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override {} virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override {} }; diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h index 120676dd8..8ff0eec43 100644 --- a/src/Protocol/Protocol_1_8.h +++ b/src/Protocol/Protocol_1_8.h @@ -134,23 +134,6 @@ public: protected: - AString m_ServerAddress; - - UInt16 m_ServerPort; - - AString m_AuthServerID; - - /** State of the protocol. 1 = status, 2 = login, 3 = game */ - UInt32 m_State; - - bool m_IsEncrypted; - - cAesCfb128Decryptor m_Decryptor; - cAesCfb128Encryptor m_Encryptor; - - /** The logfile where the comm is logged, when g_ShouldLogComm is true */ - cFile m_CommLogFile; - /** 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); @@ -226,7 +209,7 @@ protected: /** Converts the BlockFace received by the protocol into eBlockFace constants. If the received value doesn't match any of our eBlockFace constants, BLOCK_FACE_NONE is returned. */ - eBlockFace FaceIntToBlockFace(Int32 a_FaceInt); + static eBlockFace FaceIntToBlockFace(Int32 a_FaceInt); /** Sends the entity type and entity-dependent data required for the entity to initially spawn. */ virtual void SendEntitySpawn(const cEntity & a_Entity, const UInt8 a_ObjectType, const Int32 a_ObjectData); @@ -246,6 +229,9 @@ 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: /** Sends an entity teleport packet. @@ -261,4 +247,18 @@ 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; + + UInt16 m_ServerPort; + + 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; } ; diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h index 5e444c4e1..84da2d686 100644 --- a/src/Protocol/Protocol_1_9.h +++ b/src/Protocol/Protocol_1_9.h @@ -99,7 +99,7 @@ protected: /** Converts the hand parameter received by the protocol into eHand constants. If the received value doesn't match any of the know value, raise an assertion fail or return hMain. */ - eHand HandIntToEnum(Int32 a_Hand); + static eHand HandIntToEnum(Int32 a_Hand); /** Sends the entity type and entity-dependent data required for the entity to initially spawn. */ virtual void SendEntitySpawn(const cEntity & a_Entity, const UInt8 a_ObjectType, const Int32 a_ObjectData) override; |