Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem3/src/orxonox/Main.cc @ 2690

Last change on this file since 2690 was 2690, checked in by rgrieder, 15 years ago
  • Moved def_keybindings to media repository in folder defaultConfig
  • If you have a better name for that folder, you're welcome
  • the "def_" prefix has been removed
  • ConfigFileManager now looks for a file in media/defaultConfig with the same name if the config file does not exist yet
  • No file gets written while only loading
  • Removed hacky GCC 3 warning code for each library and instead just put "Wno-sign-compare" to the GCC 3 flags (that will remove all boost::filesystem warnings)
  • ogre.cfg still remains on tardis for the development build (not install though)
  • Property svn:eol-style set to native
File size: 4.8 KB
RevLine 
[612]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1293]3 *                    > www.orxonox.net <
[612]4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
[1755]24 *      Reto Grieder
[612]25 *   Co-authors:
26 *      ...
27 *
28 */
29
30 /**
[1021]31 @file
[2685]32 @brief Entry point of the program.
[612]33  */
34
[1293]35#include "OrxonoxStableHeaders.h"
[612]36
[1293]37#include <exception>
[1755]38#include <cassert>
[1293]39
[2664]40#include "OrxonoxConfig.h"
[1891]41#include "util/Debug.h"
[2087]42#include "util/SignalHandler.h"
[1891]43#include "core/ConfigFileManager.h"
[2103]44#include "core/CommandLine.h"
[2662]45#include "core/CommandExecutor.h"
46#include "core/Identifier.h"
47#include "core/Core.h"
48#include "core/Language.h"
[612]49
[1755]50#include "gamestates/GSRoot.h"
51#include "gamestates/GSGraphics.h"
52#include "gamestates/GSStandalone.h"
53#include "gamestates/GSServer.h"
54#include "gamestates/GSClient.h"
55#include "gamestates/GSDedicated.h"
56#include "gamestates/GSGUI.h"
57#include "gamestates/GSIOConsole.h"
58
[2664]59#ifdef ORXONOX_PLATFORM_APPLE
[612]60#include <CoreFoundation/CoreFoundation.h>
61
62// This function will locate the path to our application on OS X,
63// unlike windows you can not rely on the curent working directory
64// for locating your configuration files and resources.
65             std::string macBundlePath()
66{
[1755]67    char path[1024];
68    CFBundleRef mainBundle = CFBundleGetMainBundle();
69    assert(mainBundle);
[612]70
[1755]71    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
72    assert(mainBundleURL);
[612]73
[1755]74    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
75    assert(cfStringRef);
[612]76
[1755]77    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
[612]78
[1755]79    CFRelease(mainBundleURL);
80    CFRelease(cfStringRef);
[612]81
[1755]82    return std::string(path);
[612]83}
84#endif
85
86
[2103]87SetCommandLineArgument(settingsFile, "orxonox.ini");
[2685]88SetCommandLineArgument(configFileDirectory, "");
[2103]89
[1755]90int main(int argc, char** argv)
[622]91{
[2103]92    using namespace orxonox;
93
[2685]94    // First, determine whether we have an installed or a binary dir run
95    // The latter occurs when simply running from the build directory
[2690]96    Core::checkDevBuild();
[2685]97
[2690]98    // Make sure the directories we write in exist or else make them
99    Core::createDirectories();
100
[2685]101    // create a signal handler (only active for linux)
[2662]102    SignalHandler signalHandler;
[2685]103    signalHandler.doCatch(argv[0], Core::getLogPath() + "orxonox_crash.log");
[1021]104
[2103]105    // Parse command line arguments
106    try
107    {
108        CommandLine::parseAll(argc, argv);
109    }
110    catch (ArgumentException& ex)
111    {
112        COUT(1) << ex.what() << std::endl;
113        COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
114    }
115
116    // Create the ConfigFileManager before creating the GameStates in order to have
[1891]117    // setConfigValues() in the constructor (required).
[2103]118    ConfigFileManager* configFileManager = new ConfigFileManager();
119    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
[2662]120    // create the Core settings to configure the output level
121    Language* language = new Language();
122    Core*     core     = new Core();
[1891]123
[2662]124    // put GameStates in its own scope so we can destroy the identifiers at the end of main().
125    {
126        // create the gamestates
127        GSRoot root;
128        GSGraphics graphics;
129        GSStandalone standalone;
130        GSServer server;
131        GSClient client;
132        GSDedicated dedicated;
133        GSGUI gui;
134        GSIOConsole ioConsole;
[612]135
[2662]136        // make the hierarchy
137        root.addChild(&graphics);
138        graphics.addChild(&standalone);
139        graphics.addChild(&server);
140        graphics.addChild(&client);
141        graphics.addChild(&gui);
142        root.addChild(&ioConsole);
143        root.addChild(&dedicated);
[1755]144
[2662]145        // Here happens the game
146        root.start();
147    }
[1755]148
[2662]149    // destroy singletons
150    delete core;
151    delete language;
[2103]152    delete configFileManager;
153
[2662]154    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
155    Identifier::destroyAllIdentifiers();
156    // destroy command line arguments
157    CommandLine::destroyAllArguments();
158    // Also delete external console command that don't belong to an Identifier
159    CommandExecutor::destroyExternalCommands();
160
[1755]161    return 0;
[612]162}
Note: See TracBrowser for help on using the repository browser.