Skip to content

Commit

Permalink
Fix building with clang 8.0 (cuberite#4346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bond-009 authored and peterbell10 committed Aug 11, 2019
1 parent 4de232b commit e0ca4d8
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 76 deletions.
16 changes: 9 additions & 7 deletions src/Blocks/BlockLeaves.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/BlockTorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class cBlockTorchHandler :
ASSERT(!"Unhandled torch direction!");
break;
}
};
}
return 0x0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace
{
a_Func(*Client);
}
};
}
return true;
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/ByteBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
2 changes: 1 addition & 1 deletion src/Chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
12 changes: 6 additions & 6 deletions src/Entities/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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)
{
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/Entities/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Pickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions src/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions src/Generating/PrefabPiecePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

// Conditionally log a warning
#define CONDWARNING(ShouldLog, ...) \
if (ShouldLog) \
{ \
LOGWARNING(__VA_ARGS__); \
}
do { \
if (ShouldLog) \
{ \
LOGWARNING(__VA_ARGS__); \
} \
} while (false)



Expand Down
10 changes: 6 additions & 4 deletions src/Generating/VerticalLimit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
10 changes: 6 additions & 4 deletions src/Generating/VerticalStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
5 changes: 0 additions & 5 deletions src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions src/Protocol/Protocol_1_11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
10 changes: 6 additions & 4 deletions src/Protocol/Protocol_1_12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
24 changes: 14 additions & 10 deletions src/Protocol/Protocol_1_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,29 @@ 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)





#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)



Expand Down Expand Up @@ -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:
Expand Down
24 changes: 14 additions & 10 deletions src/Protocol/Protocol_1_9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,29 @@ 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)





#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)



Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ class cSmallGateHandler : public cRedstoneHandler
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
2 changes: 1 addition & 1 deletion src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ class cTNTHandler : public cRedstoneHandler
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};
10 changes: 6 additions & 4 deletions src/WorldStorage/FastNBT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down

0 comments on commit e0ca4d8

Please sign in to comment.