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,6 +215,42 @@ cProtocol::Version cProtocol_1_14::GetProtocolVersion() +std::pair cProtocol_1_14::GetItemFromProtocolID(UInt32 a_ProtocolID) +{ + return PaletteUpgrade::ToItem(Palette_1_14::ToItem(a_ProtocolID)); +} + + + + + +UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) +{ + return Palette_1_14::From(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); +} + + + + + +UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage) +{ + return Palette_1_14::From(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); +} + + + + + +UInt32 cProtocol_1_14::GetProtocolStatisticType(Statistic a_Statistic) +{ + return Palette_1_14::From(a_Statistic); +} + + + + + bool cProtocol_1_14::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) { if (m_State != 3) @@ -253,39 +289,3 @@ void cProtocol_1_14::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) void cProtocol_1_14::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) { } - - - - - -std::pair cProtocol_1_14::GetItemFromProtocolID(UInt32 a_ProtocolID) -{ - return PaletteUpgrade::ToItem(Palette_1_14::ToItem(a_ProtocolID)); -} - - - - - -UInt32 cProtocol_1_14::GetProtocolBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) -{ - return Palette_1_14::FromBlock(PaletteUpgrade::FromBlock(a_BlockType, a_Meta)); -} - - - - - -UInt32 cProtocol_1_14::GetProtocolItemType(short a_ItemID, short a_ItemDamage) -{ - return Palette_1_14::FromItem(PaletteUpgrade::FromItem(a_ItemID, a_ItemDamage)); -} - - - - - -UInt32 cProtocol_1_14::GetProtocolStatisticType(Statistic a_Statistic) -{ - 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 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 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;