1
0

Fix building with clang 8.0 (#4346)

This commit is contained in:
Bond-009 2019-08-11 11:39:43 +02:00 committed by peterbell10
parent 4de232bdae
commit e0ca4d8399
20 changed files with 95 additions and 76 deletions

View File

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

View File

@ -62,7 +62,7 @@ public:
ASSERT(!"Unhandled torch direction!");
break;
}
};
}
return 0x0;
}

View File

@ -54,7 +54,7 @@ namespace
{
a_Func(*Client);
}
};
}
return true;
}
);

View File

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

View File

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

View File

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

View File

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

View File

@ -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())

View File

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

View File

@ -16,10 +16,12 @@
// Conditionally log a warning
#define CONDWARNING(ShouldLog, ...) \
if (ShouldLog) \
{ \
LOGWARNING(__VA_ARGS__); \
}
do { \
if (ShouldLog) \
{ \
LOGWARNING(__VA_ARGS__); \
} \
} while (false)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -49,6 +49,6 @@ public:
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};

View File

@ -49,6 +49,6 @@ public:
UNUSED(a_World);
UNUSED(a_BlockType);
UNUSED(a_Meta);
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());;
return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
}
};

View File

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