Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963)
* Fix cmake not adding Werror on clang, and _lots_ of warnings * WIP: Build fixes * Cannot make intermediate blockhandler instance * Tiger's changes * Fix BitIndex check * Handle invalid NextState values in cMultiVersionProtocol Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
co-authored by
Tiger Wang
parent
23021dd828
commit
a9031b6bae
@@ -74,7 +74,7 @@ void ForEachSourceCallback::CheckIndirectPower()
|
||||
ForEachSourceCallback QuasiQueryCallback(m_Chunk, Above, m_Chunk.GetBlock(Above));
|
||||
|
||||
// Manually feed the callback object all positions that may deliver power to Above:
|
||||
for (const auto QuasiPowerOffset : cSimulator::GetLinkedOffsets(OffsetYP))
|
||||
for (const auto & QuasiPowerOffset : cSimulator::GetLinkedOffsets(OffsetYP))
|
||||
{
|
||||
QuasiQueryCallback(m_Position + QuasiPowerOffset);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ PowerLevel ForEachSourceCallback::QueryLinkedPower(const cChunk & Chunk, const V
|
||||
PowerLevel Power = 0;
|
||||
|
||||
// Loop through all linked powerable offsets in the direction requested:
|
||||
for (const auto Offset : cSimulator::GetLinkedOffsets(SolidBlockPosition - QueryPosition))
|
||||
for (const auto & Offset : cSimulator::GetLinkedOffsets(SolidBlockPosition - QueryPosition))
|
||||
{
|
||||
auto SourcePosition = QueryPosition + Offset;
|
||||
if (!cChunk::IsValidHeight(SourcePosition.y))
|
||||
|
||||
@@ -39,7 +39,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(std::chrono::milliseconds a_Dt
|
||||
ProcessWorkItem(*NeighbourChunk, *a_Chunk, CurrentLocation);
|
||||
}
|
||||
|
||||
for (const auto Position : ChunkData.AlwaysTickedPositions)
|
||||
for (const auto & Position : ChunkData.AlwaysTickedPositions)
|
||||
{
|
||||
ChunkData.WakeUp(Position);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void cIncrementalRedstoneSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position
|
||||
// The only thing to do go one block farther than this cross-coord, in the direction of Offset
|
||||
// in order to notify linked-powered positions that there was a change
|
||||
|
||||
for (const auto Offset : cSimulator::GetLinkedOffsets(a_Offset))
|
||||
for (const auto & Offset : cSimulator::GetLinkedOffsets(a_Offset))
|
||||
{
|
||||
auto Relative = a_Position - a_Offset + Offset;
|
||||
if (!cChunkDef::IsValidHeight(Relative.y))
|
||||
|
||||
@@ -94,7 +94,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Simulate(float Dt) override {};
|
||||
virtual void Simulate(float Dt) override {}
|
||||
virtual void SimulateChunk(std::chrono::milliseconds Dt, int ChunkX, int ChunkZ, cChunk * Chunk) override;
|
||||
|
||||
void ProcessWorkItem(cChunk & Chunk, cChunk & TickingSource, const Vector3i Position);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace PistonHandler
|
||||
const auto Face = cBlockPistonHandler::MetaDataToDirection(a_Meta);
|
||||
const auto FrontOffset = AddFaceDirection(Vector3i(), Face);
|
||||
|
||||
for (const auto Offset : RelativeAdjacents)
|
||||
for (const auto & Offset : RelativeAdjacents)
|
||||
{
|
||||
if (Offset != FrontOffset)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
namespace PoweredRailHandler
|
||||
{
|
||||
Vector3i GetPoweredRailAdjacentXZCoordinateOffset(NIBBLETYPE a_Meta) // Not in cBlockRailHandler since specific to powered rails
|
||||
/** Get the offset along which the rail faces.
|
||||
Not in cBlockRailHandler since specific to powered rails. */
|
||||
inline Vector3i GetPoweredRailAdjacentXZCoordinateOffset(NIBBLETYPE a_Meta)
|
||||
{
|
||||
switch (a_Meta & 0x7)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PressurePlateHandler
|
||||
{
|
||||
inline unsigned char GetPowerLevel(const cChunk & Chunk, const Vector3i Position, const BLOCKTYPE BlockType)
|
||||
{
|
||||
unsigned NumberOfEntities = 0;
|
||||
Int64 NumberOfEntities = 0;
|
||||
bool FoundPlayer = false;
|
||||
|
||||
Chunk.ForEachEntityInBox(cBoundingBox(Vector3d(0.5, 0, 0.5) + Position, 0.5, 0.5), [&](cEntity & Entity)
|
||||
@@ -39,7 +39,7 @@ namespace PressurePlateHandler
|
||||
}
|
||||
case E_BLOCK_WOODEN_PRESSURE_PLATE:
|
||||
{
|
||||
return (NumberOfEntities != 0 ? 15 : 0);
|
||||
return (NumberOfEntities > 0 ? 15 : 0);
|
||||
}
|
||||
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
|
||||
{
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace RedstoneComparatorHandler
|
||||
|
||||
const auto RearPower = GetPowerLevel(a_Chunk, a_Position, a_BlockType, a_Meta);
|
||||
const auto FrontPower = GetFrontPowerLevel(a_Meta, Power, RearPower);
|
||||
const auto NewMeta = (FrontPower > 0) ? (a_Meta | 0x8) : (a_Meta & 0x7);
|
||||
const NIBBLETYPE NewMeta = (FrontPower > 0) ? (a_Meta | 0x08u) : (a_Meta & 0x07u);
|
||||
|
||||
// Don't care about the previous power level so return value ignored
|
||||
Data.ExchangeUpdateOncePowerData(a_Position, FrontPower);
|
||||
|
||||
@@ -12,7 +12,7 @@ inline void UpdateAdjustedRelative(const cChunk & From, const cChunk & To, const
|
||||
{
|
||||
DataForChunk(To).WakeUp(cIncrementalRedstoneSimulatorChunkData::RebaseRelativePosition(From, To, Position + Offset));
|
||||
|
||||
for (const auto LinkedOffset : cSimulator::GetLinkedOffsets(Offset))
|
||||
for (const auto & LinkedOffset : cSimulator::GetLinkedOffsets(Offset))
|
||||
{
|
||||
DataForChunk(To).WakeUp(cIncrementalRedstoneSimulatorChunkData::RebaseRelativePosition(From, To, Position + LinkedOffset));
|
||||
}
|
||||
@@ -21,7 +21,7 @@ inline void UpdateAdjustedRelative(const cChunk & From, const cChunk & To, const
|
||||
template <typename ArrayType>
|
||||
inline void UpdateAdjustedRelatives(const cChunk & From, const cChunk & To, const Vector3i Position, const ArrayType & Relative)
|
||||
{
|
||||
for (const auto Offset : Relative)
|
||||
for (const auto & Offset : Relative)
|
||||
{
|
||||
UpdateAdjustedRelative(From, To, Position, Offset);
|
||||
}
|
||||
@@ -30,12 +30,18 @@ inline void UpdateAdjustedRelatives(const cChunk & From, const cChunk & To, cons
|
||||
template <typename ArrayType>
|
||||
inline void InvokeForAdjustedRelatives(ForEachSourceCallback & Callback, const Vector3i Position, const ArrayType & Relative)
|
||||
{
|
||||
for (const auto Offset : Relative)
|
||||
for (const auto & Offset : Relative)
|
||||
{
|
||||
Callback(Position + Offset);
|
||||
}
|
||||
}
|
||||
|
||||
// Warning shouldn't trigger for inline variables, this is fixed in clang 7
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
|
||||
#endif
|
||||
|
||||
inline constexpr Vector3i OffsetYP{ 0, 1, 0 };
|
||||
|
||||
inline constexpr Vector3i OffsetYM{ 0, -1, 0 };
|
||||
@@ -61,3 +67,7 @@ inline constexpr std::array<Vector3i, 4> RelativeLaterals
|
||||
{ 0, 0, -1 },
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
@@ -30,56 +30,59 @@
|
||||
|
||||
|
||||
|
||||
#define INVOKE_FOR_HANDLERS(Callback) \
|
||||
switch (BlockType) \
|
||||
{ \
|
||||
case E_BLOCK_ACTIVATOR_RAIL: \
|
||||
case E_BLOCK_DETECTOR_RAIL: \
|
||||
case E_BLOCK_POWERED_RAIL: return PoweredRailHandler::Callback; \
|
||||
case E_BLOCK_ACTIVE_COMPARATOR: \
|
||||
case E_BLOCK_INACTIVE_COMPARATOR: return RedstoneComparatorHandler::Callback; \
|
||||
case E_BLOCK_DISPENSER: \
|
||||
case E_BLOCK_DROPPER: return DropSpenserHandler::Callback; \
|
||||
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: \
|
||||
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: \
|
||||
case E_BLOCK_STONE_PRESSURE_PLATE: \
|
||||
case E_BLOCK_WOODEN_PRESSURE_PLATE: return PressurePlateHandler::Callback; \
|
||||
case E_BLOCK_ACACIA_FENCE_GATE: \
|
||||
case E_BLOCK_BIRCH_FENCE_GATE: \
|
||||
case E_BLOCK_DARK_OAK_FENCE_GATE: \
|
||||
case E_BLOCK_FENCE_GATE: \
|
||||
case E_BLOCK_IRON_TRAPDOOR: \
|
||||
case E_BLOCK_JUNGLE_FENCE_GATE: \
|
||||
case E_BLOCK_SPRUCE_FENCE_GATE: \
|
||||
case E_BLOCK_TRAPDOOR: return SmallGateHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_LAMP_OFF: \
|
||||
case E_BLOCK_REDSTONE_LAMP_ON: return RedstoneLampHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_REPEATER_OFF: \
|
||||
case E_BLOCK_REDSTONE_REPEATER_ON: return RedstoneRepeaterHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_TORCH_OFF: \
|
||||
case E_BLOCK_REDSTONE_TORCH_ON: return RedstoneTorchHandler::Callback; \
|
||||
case E_BLOCK_OBSERVER: return ObserverHandler::Callback; \
|
||||
case E_BLOCK_PISTON: \
|
||||
case E_BLOCK_STICKY_PISTON: return PistonHandler::Callback; \
|
||||
case E_BLOCK_LEVER: \
|
||||
case E_BLOCK_STONE_BUTTON: \
|
||||
case E_BLOCK_WOODEN_BUTTON: return RedstoneToggleHandler::Callback; \
|
||||
case E_BLOCK_BLOCK_OF_REDSTONE: return RedstoneBlockHandler::Callback; \
|
||||
case E_BLOCK_COMMAND_BLOCK: return CommandBlockHandler::Callback; \
|
||||
case E_BLOCK_HOPPER: return HopperHandler::Callback; \
|
||||
case E_BLOCK_NOTE_BLOCK: return NoteBlockHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_WIRE: return RedstoneWireHandler::Callback; \
|
||||
case E_BLOCK_TNT: return TNTHandler::Callback; \
|
||||
case E_BLOCK_TRAPPED_CHEST: return TrappedChestHandler::Callback; \
|
||||
case E_BLOCK_TRIPWIRE_HOOK: return TripwireHookHandler::Callback; \
|
||||
default: \
|
||||
{ \
|
||||
if (cBlockDoorHandler::IsDoorBlockType(BlockType)) \
|
||||
{ \
|
||||
return DoorHandler::Callback; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define INVOKE_FOR_HANDLERS(Callback) \
|
||||
do \
|
||||
{ \
|
||||
switch (BlockType) \
|
||||
{ \
|
||||
case E_BLOCK_ACTIVATOR_RAIL: \
|
||||
case E_BLOCK_DETECTOR_RAIL: \
|
||||
case E_BLOCK_POWERED_RAIL: return PoweredRailHandler::Callback; \
|
||||
case E_BLOCK_ACTIVE_COMPARATOR: \
|
||||
case E_BLOCK_INACTIVE_COMPARATOR: return RedstoneComparatorHandler::Callback; \
|
||||
case E_BLOCK_DISPENSER: \
|
||||
case E_BLOCK_DROPPER: return DropSpenserHandler::Callback; \
|
||||
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: \
|
||||
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: \
|
||||
case E_BLOCK_STONE_PRESSURE_PLATE: \
|
||||
case E_BLOCK_WOODEN_PRESSURE_PLATE: return PressurePlateHandler::Callback; \
|
||||
case E_BLOCK_ACACIA_FENCE_GATE: \
|
||||
case E_BLOCK_BIRCH_FENCE_GATE: \
|
||||
case E_BLOCK_DARK_OAK_FENCE_GATE: \
|
||||
case E_BLOCK_FENCE_GATE: \
|
||||
case E_BLOCK_IRON_TRAPDOOR: \
|
||||
case E_BLOCK_JUNGLE_FENCE_GATE: \
|
||||
case E_BLOCK_SPRUCE_FENCE_GATE: \
|
||||
case E_BLOCK_TRAPDOOR: return SmallGateHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_LAMP_OFF: \
|
||||
case E_BLOCK_REDSTONE_LAMP_ON: return RedstoneLampHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_REPEATER_OFF: \
|
||||
case E_BLOCK_REDSTONE_REPEATER_ON: return RedstoneRepeaterHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_TORCH_OFF: \
|
||||
case E_BLOCK_REDSTONE_TORCH_ON: return RedstoneTorchHandler::Callback; \
|
||||
case E_BLOCK_OBSERVER: return ObserverHandler::Callback; \
|
||||
case E_BLOCK_PISTON: \
|
||||
case E_BLOCK_STICKY_PISTON: return PistonHandler::Callback; \
|
||||
case E_BLOCK_LEVER: \
|
||||
case E_BLOCK_STONE_BUTTON: \
|
||||
case E_BLOCK_WOODEN_BUTTON: return RedstoneToggleHandler::Callback; \
|
||||
case E_BLOCK_BLOCK_OF_REDSTONE: return RedstoneBlockHandler::Callback; \
|
||||
case E_BLOCK_COMMAND_BLOCK: return CommandBlockHandler::Callback; \
|
||||
case E_BLOCK_HOPPER: return HopperHandler::Callback; \
|
||||
case E_BLOCK_NOTE_BLOCK: return NoteBlockHandler::Callback; \
|
||||
case E_BLOCK_REDSTONE_WIRE: return RedstoneWireHandler::Callback; \
|
||||
case E_BLOCK_TNT: return TNTHandler::Callback; \
|
||||
case E_BLOCK_TRAPPED_CHEST: return TrappedChestHandler::Callback; \
|
||||
case E_BLOCK_TRIPWIRE_HOOK: return TripwireHookHandler::Callback; \
|
||||
default: \
|
||||
{ \
|
||||
if (cBlockDoorHandler::IsDoorBlockType(BlockType)) \
|
||||
{ \
|
||||
return DoorHandler::Callback; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace RedstoneTorchHandler
|
||||
a_Chunk.FastSetBlock(a_Position, ShouldPowerOn ? E_BLOCK_REDSTONE_TORCH_ON : E_BLOCK_REDSTONE_TORCH_OFF, a_Meta);
|
||||
Data.m_MechanismDelays.erase(a_Position);
|
||||
|
||||
for (const auto Adjacent : RelativeAdjacents)
|
||||
for (const auto & Adjacent : RelativeAdjacents)
|
||||
{
|
||||
// Update all adjacents (including linked power positions)
|
||||
// apart from our attachment, which can't possibly need an update:
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace RedstoneWireHandler
|
||||
const bool IsYPTerracingBlocked = cBlockInfo::IsSolid(YPTerraceBlock) && !cBlockInfo::IsTransparent(YPTerraceBlock);
|
||||
|
||||
// Loop through laterals, discovering terracing connections:
|
||||
for (const auto Offset : RelativeLaterals)
|
||||
for (const auto & Offset : RelativeLaterals)
|
||||
{
|
||||
auto Adjacent = Position + Offset;
|
||||
auto NeighbourChunk = Chunk.GetRelNeighborChunkAdjustCoords(Adjacent);
|
||||
@@ -268,7 +268,7 @@ namespace RedstoneWireHandler
|
||||
a_Chunk.SetMeta(a_Position, Power);
|
||||
|
||||
// Notify all positions, sans YP, to update:
|
||||
for (const auto Offset : RelativeAdjacents)
|
||||
for (const auto & Offset : RelativeAdjacents)
|
||||
{
|
||||
if (Offset == OffsetYP)
|
||||
{
|
||||
@@ -291,7 +291,7 @@ namespace RedstoneWireHandler
|
||||
const auto Block = Data.WireStates.find(a_Position)->second;
|
||||
|
||||
// Figure out, based on our pre-computed block, where we connect to:
|
||||
for (const auto Offset : RelativeLaterals)
|
||||
for (const auto & Offset : RelativeLaterals)
|
||||
{
|
||||
const auto Relative = a_Position + Offset;
|
||||
Callback(Relative);
|
||||
@@ -311,10 +311,10 @@ namespace RedstoneWireHandler
|
||||
|
||||
const auto YMDiagonalPosition = Relative + OffsetYM;
|
||||
if (
|
||||
BLOCKTYPE Block;
|
||||
BLOCKTYPE QueryBlock;
|
||||
cChunkDef::IsValidHeight(YMDiagonalPosition.y) &&
|
||||
a_Chunk.UnboundedRelGetBlockType(YMDiagonalPosition, Block) &&
|
||||
(Block == E_BLOCK_REDSTONE_WIRE)
|
||||
a_Chunk.UnboundedRelGetBlockType(YMDiagonalPosition, QueryBlock) &&
|
||||
(QueryBlock == E_BLOCK_REDSTONE_WIRE)
|
||||
)
|
||||
{
|
||||
Callback(YMDiagonalPosition);
|
||||
|
||||
Reference in New Issue
Block a user