summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Blocks/BlockLeaves.h16
-rw-r--r--src/Blocks/BlockTorch.h2
-rw-r--r--src/Broadcaster.cpp2
-rw-r--r--src/ByteBuffer.cpp4
-rw-r--r--src/Chunk.h2
-rw-r--r--src/Entities/Entity.cpp12
-rw-r--r--src/Entities/Entity.h10
-rw-r--r--src/Entities/Pickup.cpp2
-rw-r--r--src/Entities/Player.cpp4
-rw-r--r--src/Generating/PrefabPiecePool.cpp10
-rw-r--r--src/Generating/VerticalLimit.cpp10
-rw-r--r--src/Generating/VerticalStrategy.cpp10
-rw-r--r--src/Map.cpp5
-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
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h2
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h2
-rw-r--r--src/WorldStorage/FastNBT.cpp10
20 files changed, 95 insertions, 76 deletions
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 0d7500491..c1840c474 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -11,13 +11,15 @@
#define LEAVES_CHECK_DISTANCE 6
#define PROCESS_NEIGHBOR(x, y, z) \
- switch (a_Area.GetBlockType(x, y, z)) \
- { \
- case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; \
- case E_BLOCK_LOG: return true; \
- case E_BLOCK_NEW_LEAVES: a_Area.SetBlockType(x, y, z, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; \
- case E_BLOCK_NEW_LOG: return true; \
- }
+ do { \
+ switch (a_Area.GetBlockType(x, y, z)) \
+ { \
+ case E_BLOCK_LEAVES: a_Area.SetBlockType(x, y, z, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; \
+ case E_BLOCK_LOG: return true; \
+ case E_BLOCK_NEW_LEAVES: a_Area.SetBlockType(x, y, z, static_cast<BLOCKTYPE>(E_BLOCK_SPONGE + i + 1)); break; \
+ case E_BLOCK_NEW_LOG: return true; \
+ } \
+ } while (false)
bool HasNearLog(cBlockArea &a_Area, int a_BlockX, int a_BlockY, int a_BlockZ);
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index 8d1363a16..8f95fa344 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -62,7 +62,7 @@ public:
ASSERT(!"Unhandled torch direction!");
break;
}
- };
+ }
return 0x0;
}
diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp
index a96325e8f..3534e0bd0 100644
--- a/src/Broadcaster.cpp
+++ b/src/Broadcaster.cpp
@@ -54,7 +54,7 @@ namespace
{
a_Func(*Client);
}
- };
+ }
return true;
}
);
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index 246b075fb..6109afdee 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -26,8 +26,8 @@ Unfortunately it is very slow, so it is disabled even for regular DEBUG builds.
// If a string sent over the protocol is larger than this, a warning is emitted to the console
#define MAX_STRING_SIZE (512 KiB)
-#define NEEDBYTES(Num) if (!CanReadBytes(Num)) return false; // Check if at least Num bytes can be read from the buffer, return false if not
-#define PUTBYTES(Num) if (!CanWriteBytes(Num)) return false; // Check if at least Num bytes can be written to the buffer, return false if not
+#define NEEDBYTES(Num) if (!CanReadBytes(Num)) return false // Check if at least Num bytes can be read from the buffer, return false if not
+#define PUTBYTES(Num) if (!CanWriteBytes(Num)) return false // Check if at least Num bytes can be written to the buffer, return false if not
diff --git a/src/Chunk.h b/src/Chunk.h
index 8bec58c81..b1ea8be5e 100644
--- a/src/Chunk.h
+++ b/src/Chunk.h
@@ -40,7 +40,7 @@ class cSetChunkData;
typedef std::list<cClientHandle *> cClientHandleList;
// A convenience macro for calling GetChunkAndRelByAbsolute.
-#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk) cChunk * Chunk; Vector3i Rel; bool RelSuccess = (OriginalChunk).GetChunkAndRelByAbsolute(Position, &Chunk, Rel);
+#define PREPARE_REL_AND_CHUNK(Position, OriginalChunk) cChunk * Chunk; Vector3i Rel; bool RelSuccess = (OriginalChunk).GetChunkAndRelByAbsolute(Position, &Chunk, Rel)
#define PREPARE_BLOCKDATA BLOCKTYPE BlockType; NIBBLETYPE BlockMeta;
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 7546cc402..55f5ba144 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -414,7 +414,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack))
{
- a_TDI.FinalDamage *= 1.5; // 150% damage
+ a_TDI.FinalDamage *= 1.5f; // 150% damage
m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
}
}
@@ -427,7 +427,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (SharpnessLevel > 0)
{
- a_TDI.FinalDamage += 1.25 * SharpnessLevel;
+ a_TDI.FinalDamage += 1.25f * SharpnessLevel;
}
else if (SmiteLevel > 0)
{
@@ -441,7 +441,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case mtWither:
case mtZombiePigman:
{
- a_TDI.FinalDamage += 2.5 * SmiteLevel;
+ a_TDI.FinalDamage += 2.5f * SmiteLevel;
break;
}
default: break;
@@ -459,7 +459,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case mtCaveSpider:
case mtSilverfish:
{
- a_TDI.FinalDamage += 2.5 * BaneOfArthropodsLevel;
+ a_TDI.FinalDamage += 2.5f * BaneOfArthropodsLevel;
// The duration of the effect is a random value between 1 and 1.5 seconds at level I,
// increasing the max duration by 0.5 seconds each level
// Ref: https://minecraft.gamepedia.com/Enchanting#Bane_of_Arthropods
@@ -868,7 +868,7 @@ void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
// Position changed -> super::Tick() called:
- GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, POSX_TOINT, POSZ_TOINT)
+ GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, POSX_TOINT, POSZ_TOINT);
// Set swim states (water, lava, and fire):
SetSwimState(*NextChunk);
@@ -920,7 +920,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
int BlockZ = POSZ_TOINT;
// Position changed -> super::HandlePhysics() called
- GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ)
+ GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ);
// TODO Add collision detection with entities.
auto DtSec = std::chrono::duration_cast<std::chrono::duration<double>>(a_Dt);
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 282e8368a..594acdd89 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -33,10 +33,12 @@
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) \
cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); \
- if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) \
- { \
- return; \
- }
+ do { \
+ if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) \
+ { \
+ return; \
+ } \
+ } while (false)
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 4b983588c..c63c720c0 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -143,7 +143,7 @@ void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if ((BlockY >= 0) && (BlockY < cChunkDef::Height)) // Don't do anything except for falling when outside the world
{
// Position might have changed due to physics. So we have to make sure we have the correct chunk.
- GET_AND_VERIFY_CURRENT_CHUNK(CurrentChunk, BlockX, BlockZ)
+ GET_AND_VERIFY_CURRENT_CHUNK(CurrentChunk, BlockX, BlockZ);
// Destroy the pickup if it is on fire:
if (IsOnFire())
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 07962fec8..ef6afbff3 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2689,8 +2689,8 @@ void cPlayer::SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_R
for (int x = a_BlockX - a_Range + 1; x < a_BlockX + a_Range; x++)
{
blks.emplace_back(x, y, z, E_BLOCK_AIR, 0); // Use fake blocktype, it will get set later on.
- };
- };
+ }
+ }
} // for y
// Get the values of all the blocks:
diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp
index ed5283dec..d984912cb 100644
--- a/src/Generating/PrefabPiecePool.cpp
+++ b/src/Generating/PrefabPiecePool.cpp
@@ -16,10 +16,12 @@
// Conditionally log a warning
#define CONDWARNING(ShouldLog, ...) \
- if (ShouldLog) \
- { \
- LOGWARNING(__VA_ARGS__); \
- }
+ do { \
+ if (ShouldLog) \
+ { \
+ LOGWARNING(__VA_ARGS__); \
+ } \
+ } while (false)
diff --git a/src/Generating/VerticalLimit.cpp b/src/Generating/VerticalLimit.cpp
index 5cc003749..0d27c85bf 100644
--- a/src/Generating/VerticalLimit.cpp
+++ b/src/Generating/VerticalLimit.cpp
@@ -10,10 +10,12 @@
// Emit a warning if the first param is true
#define CONDWARNING(ShouldLog, Fmt, ...) \
- if (ShouldLog) \
- { \
- LOGWARNING(Fmt, __VA_ARGS__); \
- }
+ do { \
+ if (ShouldLog) \
+ { \
+ LOGWARNING(Fmt, __VA_ARGS__); \
+ } \
+ } while (false)
diff --git a/src/Generating/VerticalStrategy.cpp b/src/Generating/VerticalStrategy.cpp
index 4021dc4bb..fa85a05d7 100644
--- a/src/Generating/VerticalStrategy.cpp
+++ b/src/Generating/VerticalStrategy.cpp
@@ -20,10 +20,12 @@ static const int SEED_OFFSET = 135;
// Emit a warning if the first param is true
#define CONDWARNING(ShouldLog, Fmt, ...) \
- if (ShouldLog) \
- { \
- LOGWARNING(Fmt, __VA_ARGS__); \
- }
+ do { \
+ if (ShouldLog) \
+ { \
+ LOGWARNING(Fmt, __VA_ARGS__); \
+ } \
+ } while (false)
diff --git a/src/Map.cpp b/src/Map.cpp
index 5a0a4ea7c..479ea0bae 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -299,11 +299,6 @@ const cMapDecorator cMap::CreateDecorator(const cEntity * a_TrackedEntity)
}
else
{
- if ((PixelX > 320.0) || (PixelZ > 320.0))
- {
- ;
- }
-
Rot = 0;
Type = cMapDecorator::eType::E_TYPE_PLAYER_OUTSIDE;
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:
diff --git a/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h b/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h
index dd4188b56..05e21429d 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/SmallGateHandler.h
@@ -49,6 +49,6 @@ public:
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
- return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
+ return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
index 220d2537e..b7a4664cc 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
@@ -49,6 +49,6 @@ public:
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
- return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
+ return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp
index 99148e126..110bc68c8 100644
--- a/src/WorldStorage/FastNBT.cpp
+++ b/src/WorldStorage/FastNBT.cpp
@@ -143,10 +143,12 @@ std::error_code make_error_code(eNBTParseError a_Err) NOEXCEPT
// cParsedNBT:
#define NEEDBYTES(N, ERR) \
- if (m_Length - m_Pos < static_cast<size_t>(N)) \
- { \
- return ERR; \
- }
+ do { \
+ if (m_Length - m_Pos < static_cast<size_t>(N)) \
+ { \
+ return ERR; \
+ } \
+ } while (false)