Working as a Windows service. Starts and stops correctly.
Added "/service" switch, to prompt the binary to attempt starting as a service. Added service* methods, to control service startup. Split up main() into universalMain(), which contains the startup code for both service and normal start. Added cRoot::m_RunningAsService bool, Added cRoot::SetStopping(bool) to allow a stop request to be sent by the service controller. Added cBlockIDMap::init() to avoid loading items.ini before the working directory has been set.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user