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/BlockFarmland.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/Blocks/BlockFarmland.h') diff --git a/src/Blocks/BlockFarmland.h b/src/Blocks/BlockFarmland.h index 82c4db923..c6340f58a 100644 --- a/src/Blocks/BlockFarmland.h +++ b/src/Blocks/BlockFarmland.h @@ -23,16 +23,11 @@ class cBlockFarmlandHandler : public: - cBlockFarmlandHandler(BLOCKTYPE a_BlockType): - Super(a_BlockType) - { - } - - - + using Super::Super; +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_BLOCK_DIRT, 1, 0); } @@ -47,7 +42,7 @@ public: cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, const Vector3i a_RelPos - ) override + ) const override { auto BlockMeta = a_Chunk.GetMeta(a_RelPos); @@ -91,7 +86,7 @@ public: - 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 { // Don't care about any neighbor but the one above us (fix recursion loop in #2213): if (a_WhichNeighbor != BLOCK_FACE_YP) @@ -118,7 +113,7 @@ public: /** Returns true if there's either a water source block close enough to hydrate the specified position, or it's raining there. */ - bool IsWaterInNear(cChunk & a_Chunk, const Vector3i a_RelPos) + static bool IsWaterInNear(const cChunk & a_Chunk, const Vector3i a_RelPos) { const auto WorldPos = a_Chunk.RelativeToAbsolute(a_RelPos); if (a_Chunk.GetWorld()->IsWeatherWetAtXYZ(WorldPos)) @@ -154,7 +149,7 @@ public: - virtual bool CanSustainPlant(BLOCKTYPE a_Plant) override + virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override { return ( (a_Plant == E_BLOCK_BEETROOTS) || -- cgit v1.2.3