diff --git a/source/src/server.cpp b/source/src/server.cpp index bbb3c59b..aedc55d2 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1838,21 +1838,7 @@ int main(int argc, char **argv) { int uprate = 0, maxcl = DEFAULTCLIENTS, scthreshold = -5; char *sdesc = "", *ip = "", *master = NULL, *passwd = "", *maprot = "", *adminpasswd = NULL, *srvmsg = NULL; - - if(isdedicated && !svcctrl) - { - #ifdef WIN32 - svcctrl = new winservice(); - #endif - if(svcctrl) - { - svcctrl->argc = argc; svcctrl->argv = argv; - int c = svcctrl->start(); - #ifdef WIN32 - return c; - #endif - } - } + bool service = false; for(int i = 1; iargc = argc; svcctrl->argv = argv; + svcctrl->start(); + } + } + if(enet_initialize()<0) fatal("Unable to initialise network module"); initserver(true, uprate, sdesc, ip, master, passwd, maxcl, maprot, adminpasswd, srvmsg, scthreshold); return EXIT_SUCCESS; diff --git a/source/src/servercontroller.h b/source/src/servercontroller.h index 9b49c825..70ffc789 100644 --- a/source/src/servercontroller.h +++ b/source/src/servercontroller.h @@ -2,7 +2,7 @@ struct servercontroller { - virtual bool start() = 0; + virtual void start() = 0; virtual void keepalive() = 0; virtual void stop() = 0; int argc; @@ -24,10 +24,11 @@ struct winservice : servercontroller callbacks::svc = NULL; } - bool start() // starts the server again on a new thread and returns once the windows service has stopped + void start() // starts the server again on a new thread and returns once the windows service has stopped { SERVICE_TABLE_ENTRY dispatchtable[] = { "assaultcubeserver", (LPSERVICE_MAIN_FUNCTION)callbacks::main, NULL, NULL }; - return StartServiceCtrlDispatcher(dispatchtable); + if(StartServiceCtrlDispatcher(dispatchtable)) exit(EXIT_SUCCESS); + else fatal("an error occurred running the AC server as windows service"); } void keepalive()