diff options
author | Anthony Birkett <anthony@a-birkett.com> | 2015-03-31 15:50:03 +0200 |
---|---|---|
committer | Anthony Birkett <anthony@a-birkett.com> | 2015-04-01 01:03:37 +0200 |
commit | 51891b766c733220b5267be1b4bcf6f04717e976 (patch) | |
tree | 6af0b9ac70329a7e83ff5d68f548a6081c32b633 /src/BlockID.cpp | |
parent | QtBiomeVisualiser: Fixed compilation and INI loading. (diff) | |
download | cuberite-51891b766c733220b5267be1b4bcf6f04717e976.tar cuberite-51891b766c733220b5267be1b4bcf6f04717e976.tar.gz cuberite-51891b766c733220b5267be1b4bcf6f04717e976.tar.bz2 cuberite-51891b766c733220b5267be1b4bcf6f04717e976.tar.lz cuberite-51891b766c733220b5267be1b4bcf6f04717e976.tar.xz cuberite-51891b766c733220b5267be1b4bcf6f04717e976.tar.zst cuberite-51891b766c733220b5267be1b4bcf6f04717e976.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); } |