diff options
author | Mattes D <github@xoft.cz> | 2015-04-03 10:35:41 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-03 10:35:41 +0200 |
commit | 11f5ee27abd47204c6f973cec43e397732192545 (patch) | |
tree | 6af0b9ac70329a7e83ff5d68f548a6081c32b633 /src/BlockID.cpp | |
parent | QtBiomeVisualiser: Fixed compilation and INI loading. (diff) | |
parent | Working as a Windows service. Starts and stops correctly. (diff) | |
download | cuberite-11f5ee27abd47204c6f973cec43e397732192545.tar cuberite-11f5ee27abd47204c6f973cec43e397732192545.tar.gz cuberite-11f5ee27abd47204c6f973cec43e397732192545.tar.bz2 cuberite-11f5ee27abd47204c6f973cec43e397732192545.tar.lz cuberite-11f5ee27abd47204c6f973cec43e397732192545.tar.xz cuberite-11f5ee27abd47204c6f973cec43e397732192545.tar.zst cuberite-11f5ee27abd47204c6f973cec43e397732192545.zip |
Diffstat (limited to 'src/BlockID.cpp')
-rw-r--r-- | src/BlockID.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 06f4232d3..7f0db3cfc 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -26,8 +26,18 @@ class cBlockIDMap typedef std::map<AString, std::pair<short, short>, Comparator> ItemMap; public: + static bool m_bHasRunInit; + cBlockIDMap(void) { + // Dont load items.ini on construct, this will search the wrong path when running as a service. + } + + + void init() + { + m_bHasRunInit = true; + cIniFile Ini; if (!Ini.ReadFile("items.ini")) { @@ -174,7 +184,7 @@ protected: - +bool cBlockIDMap::m_bHasRunInit = false; static cBlockIDMap gsBlockIDMap; @@ -209,6 +219,10 @@ int BlockStringToType(const AString & a_BlockTypeString) return res; } + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } return gsBlockIDMap.Resolve(TrimString(a_BlockTypeString)); } @@ -222,6 +236,11 @@ bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item) { ItemName = ItemName.substr(10); } + + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } return gsBlockIDMap.ResolveItem(ItemName, a_Item); } @@ -231,6 +250,10 @@ bool StringToItem(const AString & a_ItemTypeString, cItem & a_Item) AString ItemToString(const cItem & a_Item) { + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } return gsBlockIDMap.Desolve(a_Item.m_ItemType, a_Item.m_ItemDamage); } @@ -240,6 +263,10 @@ AString ItemToString(const cItem & a_Item) AString ItemTypeToString(short a_ItemType) { + if (!gsBlockIDMap.m_bHasRunInit) + { + gsBlockIDMap.init(); + } return gsBlockIDMap.Desolve(a_ItemType, -1); } |