summaryrefslogtreecommitdiffstats
path: root/src/BlockInfo.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-26 22:23:36 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-26 22:23:36 +0200
commitaf997a09ca1ff2bf3e93f9145edc50d29be28529 (patch)
tree8188753488f633407eea5aab0c9e6e0833300e43 /src/BlockInfo.h
parentFixed players custom name in 1.8 (diff)
parentMerge pull request #1455 from mc-server/includes (diff)
downloadcuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.tar
cuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.tar.gz
cuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.tar.bz2
cuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.tar.lz
cuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.tar.xz
cuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.tar.zst
cuberite-af997a09ca1ff2bf3e93f9145edc50d29be28529.zip
Diffstat (limited to 'src/BlockInfo.h')
-rw-r--r--src/BlockInfo.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/BlockInfo.h b/src/BlockInfo.h
index 567070a7f..1e4cf2ca0 100644
--- a/src/BlockInfo.h
+++ b/src/BlockInfo.h
@@ -11,14 +11,27 @@ class cBlockHandler;
-
// tolua_begin
class cBlockInfo
{
public:
/** Returns the associated BlockInfo structure for the specified block type. */
- static cBlockInfo & Get(BLOCKTYPE a_Type);
+
+ /** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
+ It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
+ It works only if it is called for the first time before the app spawns other threads. */
+ static cBlockInfo & Get(BLOCKTYPE a_Type)
+ {
+ static cBlockInfo ms_Info[256];
+ static bool IsBlockInfoInitialized = false;
+ if (!IsBlockInfoInitialized)
+ {
+ cBlockInfo::Initialize(ms_Info);
+ IsBlockInfoInitialized = true;
+ }
+ return ms_Info[a_Type];
+ }
/** How much light do the blocks emit on their own? */
@@ -78,7 +91,19 @@ protected:
typedef cBlockInfo cBlockInfoArray[256];
/** Creates a default BlockInfo structure, initializes all values to their defaults */
- cBlockInfo();
+ cBlockInfo()
+ : m_LightValue(0x00)
+ , m_SpreadLightFalloff(0x0f)
+ , m_Transparent(false)
+ , m_OneHitDig(false)
+ , m_PistonBreakable(false)
+ , m_IsSnowable(false)
+ , m_IsSolid(true)
+ , m_FullyOccupiesVoxel(false)
+ , m_CanBeTerraformed(false)
+ , m_PlaceSound("")
+ , m_Handler(NULL)
+ {}
/** Cleans up the stored values */
~cBlockInfo();