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/BlockWallSign.h | 53 +++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'src/Blocks/BlockWallSign.h') diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h index 87c0355a9..1e9ea2e1f 100644 --- a/src/Blocks/BlockWallSign.h +++ b/src/Blocks/BlockWallSign.h @@ -15,16 +15,30 @@ class cBlockWallSignHandler: public: - cBlockWallSignHandler(BLOCKTYPE a_BlockType): - Super(a_BlockType) + using Super::Super; + + /** Converts the block face of the neighbor to which the wallsign is attached to the wallsign block's meta. */ + static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_NeighborBlockFace) { + switch (a_NeighborBlockFace) + { + case BLOCK_FACE_ZM: return 0x02; + case BLOCK_FACE_ZP: return 0x03; + case BLOCK_FACE_XM: return 0x04; + case BLOCK_FACE_XP: return 0x05; + case BLOCK_FACE_NONE: + case BLOCK_FACE_YP: + case BLOCK_FACE_YM: + { + break; + } + } + return 0x02; } +private: - - - - virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) override + virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const override { return cItem(E_ITEM_SIGN, 1, 0); } @@ -33,7 +47,7 @@ public: - virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) override + virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override { auto NeighborPos = a_RelPos + GetOffsetBehindTheSign(a_Chunk.GetMeta(a_RelPos)); BLOCKTYPE NeighborType; @@ -68,30 +82,7 @@ public: - /** Converts the block face of the neighbor to which the wallsign is attached to the wallsign block's meta. */ - static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_NeighborBlockFace) - { - switch (a_NeighborBlockFace) - { - case BLOCK_FACE_ZM: return 0x02; - case BLOCK_FACE_ZP: return 0x03; - case BLOCK_FACE_XM: return 0x04; - case BLOCK_FACE_XP: return 0x05; - case BLOCK_FACE_NONE: - case BLOCK_FACE_YP: - case BLOCK_FACE_YM: - { - break; - } - } - return 0x02; - } - - - - - - virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override + virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override { UNUSED(a_Meta); return 13; -- cgit v1.2.3