From 68cced73afe546328cf94ed07c57deee47bfadec Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 20 Sep 2020 14:50:52 +0100 Subject: BlockHandler initialisation is a constant expression (#4891) * BlockHandler initialisation is a constant expression If we can't make it all namespaces, this is the next best I guess. + Tag handlers constexpr, const as needed + Inherit constructors * Privatise handler functions * More constexpr Co-authored-by: Alexander Harkness --- src/Blocks/BlockConcretePowder.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/Blocks/BlockConcretePowder.h') diff --git a/src/Blocks/BlockConcretePowder.h b/src/Blocks/BlockConcretePowder.h index 7cd99149e..83a475b88 100644 --- a/src/Blocks/BlockConcretePowder.h +++ b/src/Blocks/BlockConcretePowder.h @@ -14,27 +14,26 @@ class cBlockConcretePowderHandler : public: - cBlockConcretePowderHandler(BLOCKTYPE a_BlockType): - Super(a_BlockType) - { - } + using Super::Super; + +private: virtual void OnPlaced( cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta - ) override + ) const override { OnNeighborChanged(a_ChunkInterface, a_BlockPos, BLOCK_FACE_NONE); } - virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override + virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override { a_ChunkInterface.DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) { CheckSoaked(a_Chunk.AbsoluteToRelative(a_BlockPos), a_Chunk); return true; }); } /** Check blocks above and around to see if they are water. If one is, converts this into concrete block. */ - void CheckSoaked(Vector3i a_Rel, cChunk & a_Chunk) + static void CheckSoaked(Vector3i a_Rel, cChunk & a_Chunk) { const auto & WaterCheck = cSimulator::AdjacentOffsets; const bool ShouldSoak = std::any_of(WaterCheck.cbegin(), WaterCheck.cend(), [a_Rel, & a_Chunk](Vector3i a_Offset) @@ -54,7 +53,7 @@ public: } } - virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { switch (a_Meta) { -- cgit v1.2.3