summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-08-11 11:39:43 +0200
committerpeterbell10 <peterbell10@live.co.uk>2019-08-11 11:39:43 +0200
commite0ca4d83991d80865781c1dbbbfa1f92259a366a (patch)
tree7a1ee18692772befe2c60bd304474fae99d51e1b /src/Protocol
parentWake up redstone simulator on slot changes for blockentities (#4348) (diff)
downloadcuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.gz
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.bz2
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.lz
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.xz
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.zst
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol_1_11.cpp10
-rw-r--r--src/Protocol/Protocol_1_12.cpp10
-rw-r--r--src/Protocol/Protocol_1_8.cpp24
-rw-r--r--src/Protocol/Protocol_1_9.cpp24
4 files changed, 40 insertions, 28 deletions
diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp
index f0f7f855a..bbfcd6d94 100644
--- a/src/Protocol/Protocol_1_11.cpp
+++ b/src/Protocol/Protocol_1_11.cpp
@@ -320,10 +320,12 @@ namespace Metadata
#define HANDLE_READ(ByteBuf, Proc, Type, Var) \
Type Var; \
- if (!ByteBuf.Proc(Var))\
- {\
- return;\
- }
+ do { \
+ if (!ByteBuf.Proc(Var))\
+ {\
+ return;\
+ } \
+ } while (false)
diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp
index bb6f7f6ba..13494625c 100644
--- a/src/Protocol/Protocol_1_12.cpp
+++ b/src/Protocol/Protocol_1_12.cpp
@@ -305,10 +305,12 @@ namespace Metadata
#define HANDLE_READ(ByteBuf, Proc, Type, Var) \
Type Var; \
- if (!ByteBuf.Proc(Var))\
- {\
- return;\
- }
+ do { \
+ if (!ByteBuf.Proc(Var))\
+ {\
+ return;\
+ } \
+ } while (false)
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index 3ff92400b..e3022ab73 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -61,10 +61,12 @@ static const Int16 SLOT_NUM_OUTSIDE = -999;
#define HANDLE_READ(ByteBuf, Proc, Type, Var) \
Type Var; \
- if (!ByteBuf.Proc(Var))\
- {\
- return;\
- }
+ do { \
+ if (!ByteBuf.Proc(Var))\
+ {\
+ return;\
+ } \
+ } while (false)
@@ -72,14 +74,16 @@ static const Int16 SLOT_NUM_OUTSIDE = -999;
#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var) \
Type Var; \
- { \
- if (!ByteBuf.Proc(Var)) \
+ do { \
{ \
+ if (!ByteBuf.Proc(Var)) \
+ { \
+ ByteBuf.CheckValid(); \
+ return false; \
+ } \
ByteBuf.CheckValid(); \
- return false; \
} \
- ByteBuf.CheckValid(); \
- }
+ } while (false)
@@ -2789,7 +2793,7 @@ void cProtocol_1_8_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con
{
if (a_Channel == "MC|AdvCdm")
{
- HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Mode)
+ HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Mode);
switch (Mode)
{
case 0x00:
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 00b233af5..f9a018a5c 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -70,10 +70,12 @@ static const UInt32 OFF_HAND = 1;
#define HANDLE_READ(ByteBuf, Proc, Type, Var) \
Type Var; \
- if (!ByteBuf.Proc(Var))\
- {\
- return;\
- }
+ do { \
+ if (!ByteBuf.Proc(Var))\
+ {\
+ return;\
+ } \
+ } while (false)
@@ -81,14 +83,16 @@ static const UInt32 OFF_HAND = 1;
#define HANDLE_PACKET_READ(ByteBuf, Proc, Type, Var) \
Type Var; \
- { \
- if (!ByteBuf.Proc(Var)) \
+ do { \
{ \
+ if (!ByteBuf.Proc(Var)) \
+ { \
+ ByteBuf.CheckValid(); \
+ return false; \
+ } \
ByteBuf.CheckValid(); \
- return false; \
} \
- ByteBuf.CheckValid(); \
- }
+ } while (false)
@@ -2922,7 +2926,7 @@ void cProtocol_1_9_0::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, con
{
if (a_Channel == "MC|AdvCdm")
{
- HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Mode)
+ HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Mode);
switch (Mode)
{
case 0x00: