From 3ff57559e36d3254c64e334fbe3bdd47398fe16f Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Thu, 2 Dec 2021 00:31:10 +0100 Subject: ItemHandler initialisation is a constant expression (#5344) * Transition to non-pointer item handler * That is my destructor - I decide when I leave this world * I declare your destruction private and you final --- src/Items/ItemMobHead.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/Items/ItemMobHead.h') diff --git a/src/Items/ItemMobHead.h b/src/Items/ItemMobHead.h index 3d6f1d7aa..aa4189589 100644 --- a/src/Items/ItemMobHead.h +++ b/src/Items/ItemMobHead.h @@ -9,23 +9,20 @@ -class cItemMobHeadHandler: +class cItemMobHeadHandler final : public cItemHandler { using Super = cItemHandler; public: - cItemMobHeadHandler(int a_ItemType): - Super(a_ItemType) - { - } + using Super::Super; - virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) override + virtual bool CommitPlacement(cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override { // Cannot place a head at "no face" and from the bottom: if ((a_ClickedBlockFace == BLOCK_FACE_NONE) || (a_ClickedBlockFace == BLOCK_FACE_BOTTOM)) @@ -58,7 +55,7 @@ public: /** Called after placing a regular head block with no mob spawning. Adjusts the mob head entity based on the equipped item's data. */ - void RegularHeadPlaced(const cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace) + void RegularHeadPlaced(const cPlayer & a_Player, const cItem & a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace) const { const auto HeadType = static_cast(a_HeldItem.m_ItemDamage); const auto BlockMeta = static_cast(a_ClickedBlockFace); @@ -88,7 +85,7 @@ public: /** Spawns a wither if the wither skull placed at the specified coords completes wither's spawning formula. Returns true if the wither was created. */ - bool TrySpawnWitherAround(cPlayer & a_Player, const Vector3i a_BlockPos) + bool TrySpawnWitherAround(cPlayer & a_Player, const Vector3i a_BlockPos) const { // No wither can be created at Y < 2 - not enough space for the formula: if (a_BlockPos.y < 2) @@ -131,7 +128,7 @@ public: cWorld & a_World, cPlayer & a_Player, Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ - ) + ) const { // Image for the wither at the X axis: static const sSetBlock ImageWitherX[] = @@ -189,7 +186,7 @@ public: cWorld & a_World, cPlayer & a_Player, const sSetBlock (& a_Image)[9], Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ - ) + ) const { std::array PositionsToClear; @@ -280,7 +277,7 @@ public: /** Awards the achievement to all players close to the specified point. */ - void AwardSpawnWitherAchievement(cWorld & a_World, Vector3i a_BlockPos) + void AwardSpawnWitherAchievement(cWorld & a_World, Vector3i a_BlockPos) const { Vector3f Pos(a_BlockPos); a_World.ForEachPlayer([=](cPlayer & a_Player) @@ -323,7 +320,7 @@ public: - virtual bool IsPlaceable(void) override + virtual bool IsPlaceable(void) const override { return true; } -- cgit v1.2.3