From 01b8ed5295875262a91b60af878bf2a18c1b7aae Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 3 Apr 2020 08:57:01 +0200 Subject: Pulled the BlockID and BlockInfo headers from Globals.h. (#4591) The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change) The BlockInfo.h file was removed from Globals.h (main change) The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics) The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor) Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header. That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified. eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values --- src/BlockInfo.h | 63 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 26 deletions(-) (limited to 'src/BlockInfo.h') diff --git a/src/BlockInfo.h b/src/BlockInfo.h index 9ba89858f..9644eb208 100644 --- a/src/BlockInfo.h +++ b/src/BlockInfo.h @@ -37,14 +37,7 @@ public: { return ((Get(a_Type).m_IsSkylightDispersant) || (Get(a_Type).m_SpreadLightFalloff > 1)); } - inline static bool IsSnowable (BLOCKTYPE a_Type) - { - return ( - (a_Type == E_BLOCK_ICE) || - (a_Type == E_BLOCK_LEAVES) || - (!IsTransparent(a_Type) && (a_Type != E_BLOCK_PACKED_ICE)) - ); - } + static bool IsSnowable(BLOCKTYPE a_Type); inline static bool IsSolid (BLOCKTYPE a_Type) { return Get(a_Type).m_IsSolid; } inline static bool IsUseableBySpectator (BLOCKTYPE a_Type) { return Get(a_Type).m_UseableBySpectator; } inline static bool FullyOccupiesVoxel (BLOCKTYPE a_Type) { return Get(a_Type).m_FullyOccupiesVoxel; } @@ -57,24 +50,8 @@ public: inline static cBlockHandler * GetHandler (BLOCKTYPE a_Type) { return Get(a_Type).m_Handler.get(); } /** Creates a default BlockInfo structure, initializes all values to their defaults */ - cBlockInfo(): - m_BlockType(E_BLOCK_STONE), - m_LightValue(0x00), - m_SpreadLightFalloff(0x0f), - m_Transparent(false), - m_OneHitDig(false), - m_PistonBreakable(false), - m_IsRainBlocker(false), - m_IsSkylightDispersant(false), - m_IsSolid(true), - m_UseableBySpectator(false), - m_FullyOccupiesVoxel(false), - m_CanBeTerraformed(false), - m_BlockHeight(1.0), - m_Hardness(0.0f), - m_Handler() - { - } + cBlockInfo(); + private: /** Storage for all the BlockInfo structures. */ @@ -133,6 +110,40 @@ private: +bool IsBlockWater(BLOCKTYPE a_BlockType); + +bool IsBlockIce(BLOCKTYPE a_BlockType); + +bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType); + +bool IsBlockLava(BLOCKTYPE a_BlockType); + +bool IsBlockLiquid(BLOCKTYPE a_BlockType); + +bool IsBlockRail(BLOCKTYPE a_BlockType); + +bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType); + +bool IsBlockFence(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialWood(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialPlants(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialVine(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialIron(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialLeaves(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialGourd(BLOCKTYPE a_BlockType); + +bool IsBlockMaterialRock(BLOCKTYPE a_BlockType); + + + + + class cBlockInfo::cBlockInfoArray: public std::array { -- cgit v1.2.3