main.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2003
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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         // From main.h
00041         run_main(argc, argv, *ServerParams::instance());
00042 
00043         // Start SDL
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         // Load the server settings file
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         // Run Server
00089         consoleServer();
00090 
00091         SDL_Quit();
00092         return 0; // exit(0)
00093 }

Generated on Mon Feb 16 15:14:47 2009 for Scorched3D by  doxygen 1.5.3