Changeset 8858 for code/trunk/src/libraries/core/Game.cc
- Timestamp:
- Aug 23, 2011, 12:45:53 AM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 1 build 2 2 codeblocks 3 vs 3 4 dependencies
-
- Property svn:mergeinfo changed
/code/branches/output (added) merged: 8739-8740,8765,8771-8772,8774-8780,8787-8789,8794-8799,8801,8803-8812,8814,8816-8817,8820,8822,8825-8837,8840,8844,8846,8848-8850,8853-8854
- Property svn:ignore
-
code/trunk/src/libraries/core/Game.cc
r8729 r8858 40 40 41 41 #include "util/Clock.h" 42 #include "util/ Debug.h"42 #include "util/Output.h" 43 43 #include "util/Exception.h" 44 44 #include "util/Sleep.h" … … 60 60 SetConsoleCommand("exit", &stop_game); 61 61 static void printFPS() 62 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }62 { orxout(message) << Game::getInstance().getAvgFPS() << endl; } 63 63 SetConsoleCommand("Stats", "printFPS", &printFPS); 64 64 static void printTickTime() 65 { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }65 { orxout(message) << Game::getInstance().getAvgTickTime() << endl; } 66 66 SetConsoleCommand("Stats", "printTickTime", &printTickTime); 67 67 … … 84 84 , destructionHelper_(this) 85 85 { 86 orxout(internal_status) << "initializing Game object..." << endl; 87 86 88 #ifdef ORXONOX_PLATFORM_WINDOWS 87 89 minimumSleepTime_ = 1000/*us*/; … … 106 108 107 109 // Create the Core 110 orxout(internal_info) << "creating Core object:" << endl; 108 111 this->core_ = new Core(cmdLine); 109 112 … … 125 128 this->loadedTopStateNode_ = this->rootStateNode_; 126 129 this->loadedStates_.push_back(this->getState(rootStateNode_->name_)); 130 131 orxout(internal_status) << "finished initializing Game object" << endl; 127 132 } 128 133 129 134 void Game::destroy() 130 135 { 136 orxout(internal_status) << "destroying Game object..." << endl; 137 131 138 // Remove us from the object lists again to avoid problems when destroying them 132 139 this->unregisterObject(); … … 139 146 safeObjectDelete(&core_); 140 147 safeObjectDelete(&gameClock_); 148 149 orxout(internal_status) << "finished destroying Game object..." << endl; 141 150 } 142 151 … … 163 172 { 164 173 if (this->requestedStateNodes_.empty()) 165 COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl; 174 orxout(user_error) << "Starting game without requesting GameState. This automatically terminates the program." << endl; 175 176 // Update the GameState stack if required. We do this already here to have a properly initialized game before entering the main loop 177 this->updateGameStateStack(); 178 179 orxout(user_status) << "Game loaded" << endl; 180 orxout(internal_status) << "--------------------------------------------------" << endl; 181 orxout(internal_status) << "starting main loop..." << endl; 166 182 167 183 // START GAME … … 189 205 catch (...) 190 206 { 191 COUT(0) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << std::endl;192 COUT(0) << "This should really never happen! Closing the program." << std::endl;207 orxout(user_error) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << endl; 208 orxout(user_error) << "This should really never happen! Closing the program." << endl; 193 209 this->stop(); 194 210 break; … … 203 219 catch (...) 204 220 { 205 COUT(0) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << std::endl;206 COUT(0) << "This should really never happen! Closing the program." << std::endl;221 orxout(user_error) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << endl; 222 orxout(user_error) << "This should really never happen! Closing the program." << endl; 207 223 this->stop(); 208 224 break; … … 217 233 this->updateFPSLimiter(); 218 234 } 235 236 orxout(internal_status) << "finished main loop" << endl; 237 orxout(internal_status) << "--------------------------------------------------" << endl; 219 238 220 239 // UNLOAD all remaining states … … 241 260 catch (...) 242 261 { 243 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << std::endl;262 orxout(user_error) << "Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << endl; 244 263 // All scheduled operations have now been rendered inert --> flush them and issue a warning 245 264 if (this->requestedStateNodes_.size() > 1) 246 COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;265 orxout(internal_info) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << endl; 247 266 this->requestedStateNodes_.clear(); 248 267 break; … … 272 291 catch (...) 273 292 { 274 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << std::endl;275 COUT(1) << "This should really never happen!" << std::endl;276 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;293 orxout(user_error) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << endl; 294 orxout(user_error) << "This should really never happen!" << endl; 295 orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl; 277 296 shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_; 278 297 while (current->name_ != (*it)->getName() && current) … … 338 357 void Game::stop() 339 358 { 359 orxout(user_status) << "Exit" << endl; 340 360 this->bAbort_ = true; 341 361 } … … 355 375 if (!this->checkState(name)) 356 376 { 357 COUT(2) << "Warning: GameState named '" << name << "' doesn't exist!" << std::endl;377 orxout(user_warning) << "GameState named '" << name << "' doesn't exist!" << endl; 358 378 return; 359 379 } … … 361 381 if (this->bChangingState_) 362 382 { 363 COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;383 orxout(user_warning) << "Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << endl; 364 384 return; 365 385 } … … 372 392 if (name == lastRequestedNode->name_) 373 393 { 374 COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;394 orxout(user_warning) << "Requesting the currently active state! Ignoring." << endl; 375 395 return; 376 396 } … … 403 423 404 424 if (requestedNodes.empty()) 405 COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;425 orxout(user_error) << "Requested GameState transition is not allowed. Ignoring." << endl; 406 426 else 407 427 this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end()); … … 425 445 this->requestState(lastRequestedNode->parent_.lock()->name_); 426 446 else 427 COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;447 orxout(internal_warning) << "Can't pop the internal dummy root GameState" << endl; 428 448 } 429 449 … … 437 457 std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name); 438 458 if (it != gameStateDeclarations_s.end()) 439 COUT(1) << "Error: GameState '" << name << "' has not yet been loaded." << std::endl;459 orxout(internal_error) << "GameState '" << name << "' has not yet been loaded." << endl; 440 460 else 441 COUT(1) << "Error: Could not find GameState '" << name << "'." << std::endl;461 orxout(internal_error) << "Could not find GameState '" << name << "'." << endl; 442 462 return shared_ptr<GameState>(); 443 463 } … … 507 527 if (!GameMode::showsGraphics()) 508 528 { 529 orxout(user_status) << "Loading graphics" << endl; 530 orxout(internal_info) << "loading graphics in Game" << endl; 531 509 532 core_->loadGraphics(); 510 533 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics); … … 524 547 } 525 548 graphicsUnloader.Dismiss(); 549 550 orxout(internal_info) << "finished loading graphics in Game" << endl; 526 551 } 527 552 } … … 531 556 if (GameMode::showsGraphics()) 532 557 { 558 orxout(user_status) << "Unloading graphics" << endl; 559 orxout(internal_info) << "unloading graphics in Game" << endl; 560 533 561 // Destroy all the GameStates that require graphics 534 562 for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();) … … 555 583 void Game::loadState(const std::string& name) 556 584 { 585 orxout(internal_status) << "loading state '" << name << "'" << endl; 586 557 587 this->bChangingState_ = true; 558 588 LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState); (void)LOKI_ANONYMOUS_VARIABLE(scopeGuard); … … 577 607 void Game::unloadState(const std::string& name) 578 608 { 609 orxout(internal_status) << "unloading state '" << name << "'" << endl; 610 579 611 this->bChangingState_ = true; 580 612 try … … 589 621 catch (...) 590 622 { 591 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << std::endl;592 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;623 orxout(internal_warning) << "Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << endl; 624 orxout(internal_warning) << "There might be potential resource leaks involved! To avoid this, improve exception-safety." << endl; 593 625 } 594 626 // Check if graphics is still required
Note: See TracChangeset
for help on using the changeset viewer.