From 5dd51e87e5b59e81287c2b29c2a82b4ac2c2a1d0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Jul 2020 20:49:29 +0100 Subject: [PATCH] Inherit constructors, remove duplication --- src/Protocol/Protocol_1_10.cpp | 9 ++------- src/Protocol/Protocol_1_10.h | 2 +- src/Protocol/Protocol_1_11.cpp | 20 ++++---------------- src/Protocol/Protocol_1_11.h | 4 ++-- src/Protocol/Protocol_1_12.cpp | 29 ++++------------------------- src/Protocol/Protocol_1_12.h | 6 +++--- src/Protocol/Protocol_1_9.cpp | 27 --------------------------- src/Protocol/Protocol_1_9.h | 6 +++--- 8 files changed, 19 insertions(+), 84 deletions(-) diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp index 3ace0fe43..5eafa9bad 100644 --- a/src/Protocol/Protocol_1_10.cpp +++ b/src/Protocol/Protocol_1_10.cpp @@ -305,14 +305,9 @@ namespace Metadata -cProtocol_1_10_0::cProtocol_1_10_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - +//////////////////////////////////////////////////////////////////////////////// +// cProtocol_1_10_0: void cProtocol_1_10_0::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) { diff --git a/src/Protocol/Protocol_1_10.h b/src/Protocol/Protocol_1_10.h index 8c4fc1f14..de968ce2f 100644 --- a/src/Protocol/Protocol_1_10.h +++ b/src/Protocol/Protocol_1_10.h @@ -26,7 +26,7 @@ class cProtocol_1_10_0: public: - cProtocol_1_10_0(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_9_4; protected: diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp index 20b26b31a..70d4ee210 100644 --- a/src/Protocol/Protocol_1_11.cpp +++ b/src/Protocol/Protocol_1_11.cpp @@ -333,14 +333,8 @@ namespace Metadata_1_11 -cProtocol_1_11_0::cProtocol_1_11_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - +//////////////////////////////////////////////////////////////////////////////// +// cProtocol_1_11_0: void cProtocol_1_11_0::SendCollectEntity(const cEntity & a_Collected, const cEntity & a_Collector, unsigned a_Count) { @@ -1185,14 +1179,8 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ -cProtocol_1_11_1::cProtocol_1_11_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - +//////////////////////////////////////////////////////////////////////////////// +// cProtocol_1_11_1: cProtocol::Version cProtocol_1_11_1::GetProtocolVersion() { diff --git a/src/Protocol/Protocol_1_11.h b/src/Protocol/Protocol_1_11.h index 6a348d5fc..86abaea6b 100644 --- a/src/Protocol/Protocol_1_11.h +++ b/src/Protocol/Protocol_1_11.h @@ -28,7 +28,7 @@ class cProtocol_1_11_0: public: - cProtocol_1_11_0(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_10_0; protected: @@ -62,7 +62,7 @@ class cProtocol_1_11_1: public: - cProtocol_1_11_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_11_0; protected: diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp index 804e26b40..29e6cbac8 100644 --- a/src/Protocol/Protocol_1_12.cpp +++ b/src/Protocol/Protocol_1_12.cpp @@ -318,14 +318,8 @@ namespace Metadata_1_12 -cProtocol_1_12::cProtocol_1_12(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - +//////////////////////////////////////////////////////////////////////////////// +// cProtocol_1_12: void cProtocol_1_12::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) { @@ -1118,14 +1112,8 @@ bool cProtocol_1_12::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTyp -cProtocol_1_12_1::cProtocol_1_12_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - +//////////////////////////////////////////////////////////////////////////////// +// cProtocol_1_12_1: UInt32 cProtocol_1_12_1::GetPacketID(ePacketType a_Packet) { @@ -1276,15 +1264,6 @@ bool cProtocol_1_12_1::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketT //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_12_2:: -cProtocol_1_12_2::cProtocol_1_12_2(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - - cProtocol::Version cProtocol_1_12_2::GetProtocolVersion() { return Version::Version_1_12_2; diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h index 266fc03bb..b0423f56c 100644 --- a/src/Protocol/Protocol_1_12.h +++ b/src/Protocol/Protocol_1_12.h @@ -31,7 +31,7 @@ class cProtocol_1_12: public: - cProtocol_1_12(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_11_1; protected: @@ -58,7 +58,7 @@ class cProtocol_1_12_1: public: - cProtocol_1_12_1(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_12; protected: @@ -80,7 +80,7 @@ class cProtocol_1_12_2: public: - cProtocol_1_12_2(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_12_1; protected: diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 73b499009..b6d8171f7 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -2155,15 +2155,6 @@ void cProtocol_1_9_0::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_9_1: -cProtocol_1_9_1::cProtocol_1_9_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - - void cProtocol_1_9_1::SendLogin(const cPlayer & a_Player, const cWorld & a_World) { // Send the Join Game packet: @@ -2211,15 +2202,6 @@ cProtocol::Version cProtocol_1_9_1::GetProtocolVersion() //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_9_2: -cProtocol_1_9_2::cProtocol_1_9_2(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - - cProtocol::Version cProtocol_1_9_2::GetProtocolVersion() { return Version::Version_1_9_2; @@ -2232,15 +2214,6 @@ cProtocol::Version cProtocol_1_9_2::GetProtocolVersion() //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_9_4: -cProtocol_1_9_4::cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : - Super(a_Client, a_ServerAddress, a_ServerPort, a_State) -{ -} - - - - - void cProtocol_1_9_4::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) { ASSERT(m_State == 3); // In game mode? diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h index 2debb9e13..74ec584f0 100644 --- a/src/Protocol/Protocol_1_9.h +++ b/src/Protocol/Protocol_1_9.h @@ -155,7 +155,7 @@ class cProtocol_1_9_1: public: - cProtocol_1_9_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_9_0; protected: @@ -177,7 +177,7 @@ class cProtocol_1_9_2: public: - cProtocol_1_9_2(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_9_1; protected: @@ -197,7 +197,7 @@ class cProtocol_1_9_4: public: - cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State); + using Super::cProtocol_1_9_2; protected: