diff --git a/source/src/main.cpp b/source/src/main.cpp index ad8ccae9..4e2150ec 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -837,7 +837,7 @@ int main(int argc, char **argv) quitdirectly = true; } break; -// case 'd': dedicated = true; break; // FIXME why someone would run a dedicated client? + case 'd': dedicated = true; break; case 't': fullscreen = atoi(a); break; case 'w': scr_w = atoi(a); break; case 'h': scr_h = atoi(a); break; @@ -869,11 +869,12 @@ int main(int argc, char **argv) if(highprocesspriority) setprocesspriority(true); #endif - initlog("net"); + if (!dedicated) initlog("net"); if(enet_initialize()<0) fatal("Unable to initialise network module"); - initclient(); - initserver(dedicated); // never returns if dedicated // FIXME crashes if dedicated:: initserver(true) is called inside server.cpp::main + if (!dedicated) initclient(); + //FIXME the server executed in this way does not catch the SIGTERM or ^C + initserver(dedicated,argc,argv); // never returns if dedicated initlog("world"); empty_world(7, true); diff --git a/source/src/protos.h b/source/src/protos.h index 9c17c7db..6744d03c 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -714,7 +714,7 @@ extern const char *modestr(int n, bool acronyms = false); extern const char *voteerrorstr(int n); extern const char *mmfullname(int n); extern void fatal(const char *s, ...); -extern void initserver(bool dedicated); +extern void initserver(bool dedicated, int argc = 0, char **argv = NULL); extern void cleanupserver(); extern void localconnect(); extern void localdisconnect(); diff --git a/source/src/server.cpp b/source/src/server.cpp index 56794782..4e45a104 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -3792,8 +3792,42 @@ void processmasterinput(const char *cmd, int cmdlen, const char *args) addgban(val); } -void initserver(bool dedicated) +string server_name = "unarmed server"; + +void initserver(bool dedicated, int argc, char **argv) { + const char *service = NULL; + + for(int i = 1; iargc = argc; svcctrl->argv = argv; + svcctrl->start(); + } + } + + if ( strlen(scl.servdesc_full) ) global_name = scl.servdesc_full; + else global_name = server_name; + srand(time(NULL)); smapname[0] = '\0'; @@ -3864,8 +3898,6 @@ void fatal(const char *s, ...) exit(EXIT_FAILURE); } -string server_name = "unarmed server"; - int main(int argc, char **argv) { #ifdef WIN32 @@ -3877,43 +3909,13 @@ int main(int argc, char **argv) #endif #endif - const char *service = NULL; - for(int i = 1; iargc = argc; svcctrl->argv = argv; - svcctrl->start(); - } + if (!strncmp(argv[i],"--wizard",8)) return wizardmain(argc, argv); } if(enet_initialize()<0) fatal("Unable to initialise network module"); - initserver(true); + initserver(true, argc, argv); return EXIT_SUCCESS; #if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)