Changeset 2907 for code/branches/questsystem5/src/orxonox/Main.cc
- Timestamp:
- Apr 8, 2009, 12:36:08 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/Main.cc
r2716 r2907 27 27 * 28 28 */ 29 30 /** 31 @mainpage Orxonox Documentation 32 */ 29 33 30 34 /** … … 34 38 35 39 #include "OrxonoxStableHeaders.h" 40 #include "OrxonoxConfig.h" 36 41 37 #include <exception> 38 #include <cassert> 42 #include "util/Debug.h" 43 #include "core/Identifier.h" 44 #include "core/Game.h" 39 45 40 #include "OrxonoxConfig.h" 41 #include "util/Debug.h" 42 #include "util/SignalHandler.h" 43 #include "core/ConfigFileManager.h" 44 #include "core/CommandLine.h" 45 #include "core/CommandExecutor.h" 46 #include "core/Identifier.h" 47 #include "core/Core.h" 48 #include "core/Language.h" 49 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 59 #ifdef ORXONOX_PLATFORM_APPLE 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 { 67 char path[1024]; 68 CFBundleRef mainBundle = CFBundleGetMainBundle(); 69 assert(mainBundle); 70 71 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); 72 assert(mainBundleURL); 73 74 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); 75 assert(cfStringRef); 76 77 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); 78 79 CFRelease(mainBundleURL); 80 CFRelease(cfStringRef); 81 82 return std::string(path); 83 } 84 #endif 85 86 87 SetCommandLineArgument(settingsFile, "orxonox.ini"); 88 SetCommandLineArgument(configFileDirectory, ""); 89 46 /* 47 @brief 48 Main method. Game starts here (except for static initialisations). 49 */ 90 50 int main(int argc, char** argv) 91 51 { 92 using namespace orxonox; 52 { 53 orxonox::Game orxonox(argc, argv); 93 54 94 // Parse command line arguments 95 try 96 { 97 CommandLine::parseAll(argc, argv); 98 } 99 catch (ArgumentException& ex) 100 { 101 COUT(1) << ex.what() << std::endl; 102 COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl; 103 } 55 orxonox.setStateHierarchy( 56 "root" 57 " graphics" 58 " mainMenu" 59 " standalone" 60 " level" 61 " server" 62 " level" 63 " client" 64 " level" 65 " dedicated" 66 " level" 67 " ioConsole" 68 ); 104 69 105 // Do this after parsing the command line to allow customisation 106 Core::postMainInitialisation(); 107 108 // create a signal handler (only active for linux) 109 SignalHandler signalHandler; 110 signalHandler.doCatch(argv[0], Core::getLogPathString() + "orxonox_crash.log"); 111 112 // Create the ConfigFileManager before creating the GameStates in order to have 113 // setConfigValues() in the constructor (required). 114 ConfigFileManager* configFileManager = new ConfigFileManager(); 115 configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString()); 116 // create the Core settings to configure the output level 117 Language* language = new Language(); 118 Core* core = new Core(); 119 120 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 121 { 122 // create the gamestates 123 GSRoot root; 124 GSGraphics graphics; 125 GSStandalone standalone; 126 GSServer server; 127 GSClient client; 128 GSDedicated dedicated; 129 GSGUI gui; 130 GSIOConsole ioConsole; 131 132 // make the hierarchy 133 root.addChild(&graphics); 134 graphics.addChild(&standalone); 135 graphics.addChild(&server); 136 graphics.addChild(&client); 137 graphics.addChild(&gui); 138 root.addChild(&ioConsole); 139 root.addChild(&dedicated); 140 141 // Here happens the game 142 root.start(); 143 } 144 145 // destroy singletons 146 delete core; 147 delete language; 148 delete configFileManager; 70 orxonox.run(); 71 } // orxonox gets destroyed right here! 149 72 150 73 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 151 Identifier::destroyAllIdentifiers(); 152 // destroy command line arguments 153 CommandLine::destroyAllArguments(); 154 // Also delete external console command that don't belong to an Identifier 155 CommandExecutor::destroyExternalCommands(); 74 // Needs to be done after Game destructor because of ~OrxonoxClass 75 orxonox::Identifier::destroyAllIdentifiers(); 156 76 157 77 return 0;
Note: See TracChangeset
for help on using the changeset viewer.