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:
@@ -29,15 +29,6 @@ cBlockInfo::cBlockInfoArray::cBlockInfoArray()
|
||||
|
||||
|
||||
|
||||
cBlockHandler * cBlockInfo::GetHandler(BLOCKTYPE a_Type)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cBoundingBox::cBoundingBox(double, double, double, double, double, double)
|
||||
{
|
||||
}
|
||||
@@ -46,15 +37,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);
|
||||
}
|
||||
@@ -69,7 +52,7 @@ bool cBlockHandler::GetPlacementBlockTypeMeta(
|
||||
eBlockFace a_BlockFace,
|
||||
const Vector3i a_CursorPos,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
)
|
||||
) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -78,7 +61,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
|
||||
{
|
||||
}
|
||||
|
||||
@@ -86,7 +69,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
|
||||
{
|
||||
}
|
||||
|
||||
@@ -102,7 +85,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();
|
||||
}
|
||||
@@ -111,7 +94,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;
|
||||
}
|
||||
@@ -120,7 +103,7 @@ bool cBlockHandler::CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a
|
||||
|
||||
|
||||
|
||||
bool cBlockHandler::IsUseable()
|
||||
bool cBlockHandler::IsUseable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -129,7 +112,7 @@ bool cBlockHandler::IsUseable()
|
||||
|
||||
|
||||
|
||||
bool cBlockHandler::IsClickedThrough(void)
|
||||
bool cBlockHandler::IsClickedThrough(void) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -138,7 +121,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);
|
||||
}
|
||||
@@ -147,7 +130,7 @@ bool cBlockHandler::DoesIgnoreBuildCollision(cChunkInterface & a_ChunkInterface,
|
||||
|
||||
|
||||
|
||||
bool cBlockHandler::DoesDropOnUnsuitable(void)
|
||||
bool cBlockHandler::DoesDropOnUnsuitable(void) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -156,7 +139,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
|
||||
{
|
||||
}
|
||||
|
||||
@@ -164,7 +147,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
|
||||
|
||||
|
||||
|
||||
ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
|
||||
ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -173,7 +156,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;
|
||||
}
|
||||
@@ -182,6 +165,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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cBlockEntity::IsBlockEntityBlockType(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user