Changeset 5695 for code/trunk/src/core/Game.cc
- Timestamp:
- Aug 30, 2009, 2:22:00 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/resource2 (added) merged: 3373-3374,5594,5597,5610-5611,5614,5624,5641,5644-5646,5650-5664,5667-5672,5682-5684,5688-5691,5694
- Property svn:mergeinfo changed
-
code/trunk/src/core/Game.cc
r5693 r5695 37 37 #include <exception> 38 38 #include <boost/weak_ptr.hpp> 39 #include <CEGUIExceptions.h> 39 40 40 41 #include "util/Debug.h" … … 54 55 namespace orxonox 55 56 { 56 using boost::shared_ptr;57 using boost::weak_ptr;58 59 57 static void stop_game() 60 58 { Game::getInstance().stop(); } … … 202 200 203 201 // Core preUpdate (doesn't throw) 204 if (!this->core_->preUpdate(*this->gameClock_)) 205 { 202 try 203 { this->core_->preUpdate(*this->gameClock_); } 204 catch (...) 205 { 206 COUT(0) << "An exception occurred in the Core preUpdate: " << Game::getExceptionMessage() << std::endl; 207 COUT(0) << "This should really never happen! Closing the program." << std::endl; 206 208 this->stop(); 207 209 break; … … 212 214 213 215 // Core postUpdate (doesn't throw) 214 if (!this->core_->postUpdate(*this->gameClock_)) 215 { 216 try 217 { this->core_->postUpdate(*this->gameClock_); } 218 catch (...) 219 { 220 COUT(0) << "An exception occurred in the Core postUpdate: " << Game::getExceptionMessage() << std::endl; 221 COUT(0) << "This should really never happen! Closing the program." << std::endl; 216 222 this->stop(); 217 223 break; … … 246 252 this->loadState(requestedStateNode->name_); 247 253 } 248 catch ( const std::exception& ex)254 catch (...) 249 255 { 250 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << ex.what() << std::endl;256 COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Game::getExceptionMessage() << std::endl; 251 257 // All scheduled operations have now been rendered inert --> flush them and issue a warning 252 258 if (this->requestedStateNodes_.size() > 1) 253 COUT( 1) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;259 COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl; 254 260 this->requestedStateNodes_.clear(); 255 261 break; … … 267 273 it != this->loadedStates_.end(); ++it) 268 274 { 269 std::string exceptionMessage;270 275 try 271 276 { 272 277 // Add tick time for most of the states 273 uint64_t timeBeforeTick ;278 uint64_t timeBeforeTick = 0; 274 279 if ((*it)->getInfo().bIgnoreTickTime) 275 280 timeBeforeTick = this->gameClock_->getRealMicroseconds(); … … 278 283 this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick)); 279 284 } 280 catch (const std::exception& ex)281 { exceptionMessage = ex.what(); }282 285 catch (...) 283 { exceptionMessage = "Unknown exception"; } 284 if (!exceptionMessage.empty()) 285 { 286 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << exceptionMessage << std::endl; 286 { 287 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Game::getExceptionMessage() << std::endl; 287 288 COUT(1) << "This should really never happen!" << std::endl; 288 289 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl; … … 590 591 state->deactivate(); 591 592 } 593 catch (...) 594 { 595 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Game::getExceptionMessage() << std::endl; 596 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl; 597 } 598 // Check if graphics is still required 599 if (!bAbort_) 600 { 601 bool graphicsRequired = false; 602 for (unsigned i = 0; i < loadedStates_.size(); ++i) 603 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode; 604 if (!graphicsRequired) 605 this->unloadGraphics(); 606 } 607 this->bChangingState_ = false; 608 } 609 610 /*static*/ std::string Game::getExceptionMessage() 611 { 612 std::string exceptionMessage; 613 try 614 { 615 // rethrow 616 throw; 617 } 592 618 catch (const std::exception& ex) 593 619 { 594 COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << ex.what() << std::endl; 595 COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl; 596 } 597 // Check if graphics is still required 598 bool graphicsRequired = false; 599 for (unsigned i = 0; i < loadedStates_.size(); ++i) 600 graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode; 601 if (!graphicsRequired) 602 this->unloadGraphics(); 603 this->bChangingState_ = false; 620 return ex.what(); 621 } 622 catch (const CEGUI::Exception& ex) 623 { 624 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6 625 return GeneralException(ex.getMessage().c_str()).getDescription(); 626 #else 627 return GeneralException(ex.getMessage().c_str(), ex.getLine(), 628 ex.getFileName().c_str(), ex.getName().c_str()).getDescription(); 629 #endif 630 } 631 catch (...) 632 { 633 return "Unknown exception"; 634 } 604 635 } 605 636
Note: See TracChangeset
for help on using the changeset viewer.