From 844a33933076a8e343de944b6eab26b4166e2f6f Mon Sep 17 00:00:00 2001 From: Simon Pribylski <66266021+Persson-dev@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:05:09 +0200 Subject: Protocol sources fixes (#5411) * Move HANDLE_READ to header * Fix compiler warnings * Removed unnecessary default statement --- src/Protocol/Packetizer.h | 31 +++++++++++++++++++++++++++++++ src/Protocol/Protocol_1_10.cpp | 13 ------------- src/Protocol/Protocol_1_11.cpp | 13 ------------- src/Protocol/Protocol_1_12.cpp | 13 ------------- src/Protocol/Protocol_1_13.cpp | 30 ------------------------------ src/Protocol/Protocol_1_14.cpp | 14 +------------- src/Protocol/Protocol_1_8.cpp | 30 ------------------------------ src/Protocol/Protocol_1_9.cpp | 13 ------------- 8 files changed, 32 insertions(+), 125 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/Packetizer.h b/src/Protocol/Packetizer.h index 679a26af4..ccf7234cd 100644 --- a/src/Protocol/Packetizer.h +++ b/src/Protocol/Packetizer.h @@ -24,6 +24,37 @@ class cUUID; +/** Macros used to read packets more easily */ +#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ + Type Var; \ + do { \ + if (!ByteBuf.Proc(Var))\ + {\ + return;\ + } \ + } while (false) + + + + + +#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var) \ + Type Var; \ + do { \ + { \ + if (!ByteBuf.Proc(Var)) \ + { \ + ByteBuf.CheckValid(); \ + return false; \ + } \ + ByteBuf.CheckValid(); \ + } \ + } while (false) + + + + + /** Composes an individual packet in the protocol's m_OutPacketBuffer; sends it just before being destructed. */ class cPacketizer { diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp index beca6db24..4f89cf6bd 100644 --- a/src/Protocol/Protocol_1_10.cpp +++ b/src/Protocol/Protocol_1_10.cpp @@ -48,19 +48,6 @@ Implements the 1.10 protocol classes: -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - // The disabled error is intended, since the Metadata have overlapping indexes // based on the type of the Entity. // diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp index 5a052b638..73951fb70 100644 --- a/src/Protocol/Protocol_1_11.cpp +++ b/src/Protocol/Protocol_1_11.cpp @@ -316,19 +316,6 @@ namespace Metadata_1_11 -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_11_0: diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp index c7f0ee31a..c0e2d65e6 100644 --- a/src/Protocol/Protocol_1_12.cpp +++ b/src/Protocol/Protocol_1_12.cpp @@ -307,19 +307,6 @@ namespace Metadata_1_12 -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_12: diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index 133d31ce4..8ac8916f4 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -41,36 +41,6 @@ Implements the 1.13 protocol classes: -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - -#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - { \ - if (!ByteBuf.Proc(Var)) \ - { \ - ByteBuf.CheckValid(); \ - return false; \ - } \ - ByteBuf.CheckValid(); \ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_13: diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp index dfe137c34..159bd7757 100644 --- a/src/Protocol/Protocol_1_14.cpp +++ b/src/Protocol/Protocol_1_14.cpp @@ -50,19 +50,6 @@ Implements the 1.14 protocol classes: -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_14: @@ -733,6 +720,7 @@ UInt8 cProtocol_1_14::GetProtocolEntityType(const cEntity & a_Entity) const case PType::pkFirework: return 26; case PType::pkWitherSkull: return 92; } + break; } case Type::etFloater: return 101; case Type::etItemFrame: return 35; diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 1d35b93f8..7a3cd3b90 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -55,36 +55,6 @@ Implements the 1.8 protocol classes: -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - -#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - { \ - if (!ByteBuf.Proc(Var)) \ - { \ - ByteBuf.CheckValid(); \ - return false; \ - } \ - ByteBuf.CheckValid(); \ - } \ - } while (false) - - - - - const int MAX_ENC_LEN = 512; // Maximum size of the encrypted message; should be 128, but who knows... static const UInt32 CompressionThreshold = 256; // After how large a packet should we compress it. diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 2b8e4e232..07ab4caf7 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -61,19 +61,6 @@ Implements the 1.9 protocol classes: -#define HANDLE_READ(ByteBuf, Proc, Type, Var) \ - Type Var; \ - do { \ - if (!ByteBuf.Proc(Var))\ - {\ - return;\ - } \ - } while (false) - - - - - //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_9_0: -- cgit v1.2.3