Fixed BlockInfo initialization.
Now cBlockInfo is initialized in the getter, instead of "at any time during startup", which included "after it was already needed".
This commit is contained in:
parent
1da39568a3
commit
a1d2c114cf
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
cBlockInfo cBlockInfo::ms_Info[256];
|
cBlockInfo cBlockInfo::ms_Info[256];
|
||||||
|
static bool g_IsBlockInfoInitialized = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -43,6 +44,11 @@ cBlockInfo::~cBlockInfo()
|
|||||||
|
|
||||||
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
|
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
|
||||||
{
|
{
|
||||||
|
if (!g_IsBlockInfoInitialized)
|
||||||
|
{
|
||||||
|
cBlockInfo::Initialize();
|
||||||
|
g_IsBlockInfoInitialized = true;
|
||||||
|
}
|
||||||
return ms_Info[a_Type];
|
return ms_Info[a_Type];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,18 +454,3 @@ void cBlockInfo::Initialize(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This is actually just some code that needs to run at program startup, so it is wrapped into a global var's constructor:
|
|
||||||
class cBlockInfoInitializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cBlockInfoInitializer(void)
|
|
||||||
{
|
|
||||||
cBlockInfo::Initialize();
|
|
||||||
}
|
|
||||||
} BlockInfoInitializer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user