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

@@ -3,14 +3,14 @@
#include "Globals.h"
#include "Map.h"
#include "BlockInfo.h"
#include "World.h"
#include "Blocks/BlockHandler.h"
#include "Chunk.h"
#include "ClientHandle.h"
#include "Entities/Player.h"
#include "FastRandom.h"
#include "Blocks/BlockHandler.h"
#include "ClientHandle.h"
#include "Map.h"
#include "World.h"
@@ -139,7 +139,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
auto Height = a_Chunk.GetHeight(RelX, RelZ);
auto ChunkHeight = cChunkDef::Height;
a_Chunk.GetBlockTypeMeta(RelX, Height, RelZ, TargetBlock, TargetMeta);
auto ColourID = BlockHandler(TargetBlock)->GetMapBaseColourID(TargetMeta);
auto ColourID = cBlockHandler::For(TargetBlock).GetMapBaseColourID(TargetMeta);
if (IsBlockWater(TargetBlock))
{
@@ -151,7 +151,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
}
else if (ColourID == 0)
{
while (((--Height) != -1) && ((ColourID = BlockHandler(a_Chunk.GetBlock(RelX, Height, RelZ))->GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
while (((--Height) != -1) && ((ColourID = cBlockHandler::For(a_Chunk.GetBlock(RelX, Height, RelZ)).GetMapBaseColourID(a_Chunk.GetMeta(RelX, Height, RelZ))) == 0))
{
continue;
}