Protocol sources fixes (#5411)

* Move HANDLE_READ to header

* Fix compiler warnings

* Removed unnecessary default statement
This commit is contained in:
Simon Pribylski 2022-04-21 18:05:09 +02:00 committed by GitHub
parent 21bcb2a757
commit 844a339330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 125 deletions

View File

@ -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
{

View File

@ -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.
//

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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;

View File

@ -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.

View File

@ -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: