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 <scorched/ScorchedParams.h>
00022 #include <engine/ModDirs.h>
00023 #include <common/OptionsGame.h>
00024 #include <common/ARGParser.h>
00025 #include <common/Defines.h>
00026 #include <graph/OptionsDisplay.h>
00027 #include <wx/wx.h>
00028 #include <wx/utils.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 bool newVersion = false;
00037 
00038 int main(int argc, char *argv[])
00039 {
00040         setlocale(LC_ALL, "C");
00041 
00042         // From main.h
00043         run_main(argc, argv, *ScorchedParams::instance());
00044 
00045         // Read display options from a file
00046         // **This NEEDS to be after the arg parser**
00047         if (!OptionsDisplay::instance()->readOptionsFromFile())
00048         {
00049                 return false;
00050         }
00051 
00052         // Get this host's description and username
00053         if (!OptionsDisplay::instance()->getHostDescription()[0])
00054         {
00055                 OptionsDisplay::instance()->getHostDescriptionEntry().setValue(S3D::getOSDesc());
00056                 OptionsDisplay::instance()->getOnlineUserNameEntry().setValue("Player");
00057         }
00058 
00059         // Check if this a new version we've seen
00060         if (S3D::stristr(S3D::ScorchedVersion.c_str(), "BETA"))
00061         {
00062                 newVersion = true;
00063         }
00064         else if (0 != strcmp(S3D::ScorchedVersion.c_str(), OptionsDisplay::instance()->getLastVersionPlayed()))
00065         {
00066                 newVersion = true;
00067                 OptionsDisplay::instance()->getLastVersionPlayedEntry().setValue(S3D::ScorchedVersion);
00068         }
00069 
00070         // Write the new options back the the file
00071         OptionsDisplay::instance()->writeOptionsToFile();
00072 
00073         // Init SDL
00074         unsigned int initFlags = SDL_INIT_VIDEO;
00075         if (ScorchedParams::instance()->getAllowExceptions()) initFlags |= SDL_INIT_NOPARACHUTE;
00076         if (SDL_Init(initFlags) < 0)
00077         {
00078                 S3D::dialogMessage(
00079                         scorched3dAppName,
00080                         "Warning: This game uses the SDL library to provide graphics.\n"
00081                         "The graphics section of this library failed to initialize.\n"
00082                         "You will only be able to run a server for this game.");
00083         }
00084         else
00085         {
00086                 ScorchedParams::instance()->getSDLInitVideo() = true;
00087         }
00088 
00089 #ifdef _WIN32
00090                 wxEntry((WXHINSTANCE) (HINSTANCE) GetModuleHandle(NULL),
00091                         (WXHINSTANCE) NULL, "", SW_SHOWNORMAL);
00092 #else
00093                 wxEntry(argc, argv);
00094 #endif
00095 
00096         SDL_Quit();
00097         return 0; // exit(0)
00098 }

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