Changeset 2805 for code/branches/gui/src/core/RootGameState.cc
- Timestamp:
- Mar 19, 2009, 4:59:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/RootGameState.cc
r2710 r2805 32 32 #include "util/Exception.h" 33 33 #include "Clock.h" 34 #include "CommandLine.h"35 34 36 35 namespace orxonox 37 36 { 38 SetCommandLineArgument(state, "gui").shortcut("s");39 40 37 RootGameState::RootGameState(const std::string& name) 41 38 : GameState<GameStateBase>(name) … … 119 116 this->stateRequest_ = name; 120 117 } 121 122 /**123 @brief124 Main loop of the orxonox game.125 Starts the game. The little 'while' denotes the main loop.126 Whenever the root state is selected, the game ends.127 @param name128 State to start with (usually main menu or specified by command line)129 @note130 We use the Ogre::Timer to measure time since it uses the most precise131 method an a platform (however the windows timer lacks time when under132 heavy kernel load!).133 */134 void RootGameState::start()135 {136 // Don't catch errors when having a debugger in msvc137 #if !defined(ORXONOX_COMPILER_MSVC) || defined(NDEBUG)138 try139 {140 #endif141 // start global orxonox time142 Clock clock;143 144 this->activate();145 146 // get initial state from command line147 gotoState(CommandLine::getValue("state"));148 149 while (this->activeChild_)150 {151 clock.capture();152 153 this->tick(clock);154 155 if (this->stateRequest_ != "")156 gotoState(stateRequest_);157 }158 159 this->deactivate();160 #if !defined(ORXONOX_COMPILER_MSVC) || defined(NDEBUG)161 }162 // Note: These are all unhandled exceptions that should not have made its way here!163 // almost complete game catch block to display the messages appropriately.164 catch (std::exception& ex)165 {166 COUT(0) << ex.what() << std::endl;167 COUT(0) << "Program aborted." << std::endl;168 abort();169 }170 // anything that doesn't inherit from std::exception171 catch (...)172 {173 COUT(0) << "An unidentifiable exception has occured. Program aborted." << std::endl;174 abort();175 }176 #endif177 }178 118 }
Note: See TracChangeset
for help on using the changeset viewer.