1
0

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 <me@bearbin.net>
This commit is contained in:
Tiger Wang
2020-09-20 14:50:52 +01:00
committed by GitHub
parent 6a0669fb98
commit 68cced73af
115 changed files with 1773 additions and 2242 deletions

View File

@@ -101,15 +101,7 @@ cBoundingBox::cBoundingBox(double, double, double, double, double, double)
cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
{
}
cBoundingBox cBlockHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP)
cBoundingBox cBlockHandler::GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const
{
return cBoundingBox(0, 0, 0, 0, 0, 0);
}
@@ -124,7 +116,7 @@ bool cBlockHandler::GetPlacementBlockTypeMeta(
eBlockFace a_BlockFace,
const Vector3i a_CursorPos,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
) const
{
return true;
}
@@ -133,7 +125,7 @@ bool cBlockHandler::GetPlacementBlockTypeMeta(
void cBlockHandler::OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, const Vector3i a_RelPos)
void cBlockHandler::OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, const Vector3i a_RelPos) const
{
}
@@ -141,7 +133,7 @@ void cBlockHandler::OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface
void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor)
void cBlockHandler::OnNeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
{
}
@@ -157,7 +149,7 @@ void cBlockHandler::NeighborChanged(cChunkInterface & a_ChunkInterface, Vector3i
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool)
cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_BlockEntity, const cEntity * a_Digger, const cItem * a_Tool) const
{
return cItems();
}
@@ -166,7 +158,7 @@ cItems cBlockHandler::ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity * a_
bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk)
bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const
{
return true;
}
@@ -175,7 +167,7 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a
bool cBlockHandler::IsUseable()
bool cBlockHandler::IsUseable() const
{
return false;
}
@@ -184,7 +176,7 @@ bool cBlockHandler::IsUseable()
bool cBlockHandler::IsClickedThrough(void)
bool cBlockHandler::IsClickedThrough(void) const
{
return false;
}
@@ -193,7 +185,7 @@ bool cBlockHandler::IsClickedThrough(void)
bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta)
bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface, Vector3i a_Pos, cPlayer & a_Player, NIBBLETYPE a_Meta) const
{
return (m_BlockType == E_BLOCK_AIR);
}
@@ -202,7 +194,7 @@ bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface,
bool cBlockHandler::DoesDropOnUnsuitable(void)
bool cBlockHandler::DoesDropOnUnsuitable(void) const
{
return true;
}
@@ -211,7 +203,7 @@ bool cBlockHandler::DoesDropOnUnsuitable(void)
void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, Vector3i a_RelPos, cChunk & a_Chunk)
void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, Vector3i a_RelPos, cChunk & a_Chunk) const
{
}
@@ -219,7 +211,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta) const
{
return 0;
}
@@ -228,7 +220,7 @@ ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
bool cBlockHandler::IsInsideBlock(Vector3d a_Position, const NIBBLETYPE a_BlockMeta)
bool cBlockHandler::IsInsideBlock(Vector3d a_Position, const NIBBLETYPE a_BlockMeta) const
{
return true;
}
@@ -237,6 +229,17 @@ bool cBlockHandler::IsInsideBlock(Vector3d a_Position, const NIBBLETYPE a_BlockM
const cBlockHandler & cBlockHandler::For(BLOCKTYPE a_BlockType)
{
// Dummy handler.
static cBlockHandler Handler(E_BLOCK_AIR);
return Handler;
}
OwnedBlockEntity cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld * a_World)
{
return nullptr;
@@ -401,14 +404,3 @@ cItem::cItem(
void cItem::Empty()
{
}
cBlockHandler & cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockType)
{
// Dummy handler.
static cBlockHandler Handler(E_BLOCK_AIR);
return Handler;
}