From 51891b766c733220b5267be1b4bcf6f04717e976 Mon Sep 17 00:00:00 2001 From: Anthony Birkett Date: Tue, 31 Mar 2015 14:50:03 +0100 Subject: 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. --- src/Root.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/Root.cpp') diff --git a/src/Root.cpp b/src/Root.cpp index 27d87c717..87bc29627 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -84,7 +84,10 @@ void cRoot::InputThread(cRoot & a_Params) if (m_TerminateEventRaised || !std::cin.good()) { // We have come here because the std::cin has received an EOF / a terminate signal has been sent, and the server is still running; stop the server: - a_Params.m_bStop = true; + if (m_RunAsService) // HACK: Dont kill if running as a service + { + a_Params.m_bStop = true; + } } } @@ -268,6 +271,13 @@ void cRoot::Start(void) +void cRoot::SetStopping(bool a_Stopping) +{ + m_bStop = a_Stopping; +} + + + void cRoot::LoadGlobalSettings() { -- cgit v1.2.3