00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <server/ScorchedServer.h>
00022 #include <server/ServerMain.h>
00023 #include <server/ServerParams.h>
00024 #include <engine/ModDirs.h>
00025 #include <common/OptionsGame.h>
00026 #include <common/ARGParser.h>
00027 #include <common/Defines.h>
00028 #include <common/OptionsTransient.h>
00029 #include <locale.h>
00030 #include <math.h>
00031 #include <signal.h>
00032 #include <float.h>
00033 #include <time.h>
00034 #include <common/main.h>
00035
00036 int main(int argc, char *argv[])
00037 {
00038 setlocale(LC_ALL, "C");
00039
00040
00041 run_main(argc, argv, *ServerParams::instance());
00042
00043
00044 unsigned int initFlags = 0;
00045 if (ServerParams::instance()->getAllowExceptions()) initFlags |= SDL_INIT_NOPARACHUTE;
00046 if (SDL_Init(initFlags) < 0)
00047 {
00048 S3D::dialogExit(
00049 scorched3dAppName,
00050 "The SDL library failed to initialize.");
00051 }
00052
00053
00054 if (ServerParams::instance()->getServerCustom())
00055 {
00056 ServerParams::instance()->setServerFile(
00057 S3D::getSettingsFile("server.xml"));
00058 }
00059 if (!ServerParams::instance()->getServerFile()[0])
00060 {
00061 aParser.showArgs();
00062 exit(64);
00063 }
00064 if (!S3D::fileExists(ServerParams::instance()->getServerFile()))
00065 {
00066 S3D::dialogExit(scorched3dAppName, S3D::formatStringBuffer(
00067 "Server file \"%s\" does not exist.",
00068 ServerParams::instance()->getServerFile()));
00069 }
00070 ScorchedServer::instance()->getOptionsGame().getMainOptions().readOptionsFromFile(
00071 (char *) ServerParams::instance()->getServerFile());
00072
00073 #ifdef WIN32
00074 if (ServerParams::instance()->getHideWindow())
00075 {
00076 char titleBuffer[MAX_PATH];
00077 GetConsoleTitle(titleBuffer, MAX_PATH);
00078 HWND window = FindWindow(NULL, titleBuffer);
00079 if (window != NULL)
00080 {
00081 ShowWindow(window, SW_HIDE);
00082 strcat(titleBuffer, " (HIDDEN)");
00083 SetWindowText(window, titleBuffer);
00084 }
00085 }
00086 #endif
00087
00088
00089 consoleServer();
00090
00091 SDL_Quit();
00092 return 0;
00093 }