Changeset 10919 for code/branches/cpp11_v2/src/libraries/core/Game.cc
- Timestamp:
- Dec 5, 2015, 10:47:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/Game.cc
r10918 r10919 115 115 116 116 // After the core has been created, we can safely instantiate the GameStates that don't require graphics 117 for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin(); 118 it != gameStateDeclarations_s.end(); ++it) 119 { 120 if (!it->second.bGraphicsMode) 121 constructedStates_[it->second.stateName] = GameStateFactory::fabricate(it->second); 117 for (const auto& mapEntry : gameStateDeclarations_s) 118 { 119 if (!mapEntry.second.bGraphicsMode) 120 constructedStates_[mapEntry.second.stateName] = GameStateFactory::fabricate(mapEntry.second); 122 121 } 123 122 … … 262 261 { 263 262 // Note: The first element is the empty root state, which doesn't need ticking 264 for (GameStateVector::const_iterator it = this->loadedStates_.begin() + 1; 265 it != this->loadedStates_.end(); ++it) 263 for (const std::shared_ptr<GameState>& state : this->loadedStates_) 266 264 { 267 265 try … … 269 267 // Add tick time for most of the states 270 268 uint64_t timeBeforeTick = 0; 271 if ( (*it)->getInfo().bIgnoreTickTime)269 if (state->getInfo().bIgnoreTickTime) 272 270 timeBeforeTick = this->gameClock_->getRealMicroseconds(); 273 (*it)->update(*this->gameClock_);274 if ( (*it)->getInfo().bIgnoreTickTime)271 state->update(*this->gameClock_); 272 if (state->getInfo().bIgnoreTickTime) 275 273 this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick)); 276 274 } 277 275 catch (...) 278 276 { 279 orxout(user_error) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << endl;277 orxout(user_error) << "An exception occurred while updating '" << state->getName() << "': " << Exception::handleMessage() << endl; 280 278 orxout(user_error) << "This should really never happen!" << endl; 281 279 orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl; 282 280 std::shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_; 283 while (current->name_ != (*it)->getName() && current)281 while (current->name_ != state->getName() && current) 284 282 current = current->parent_.lock(); 285 283 if (current && current->parent_.lock()) … … 520 518 521 519 // Construct all the GameStates that require graphics 522 for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin(); 523 it != gameStateDeclarations_s.end(); ++it) 524 { 525 if (it->second.bGraphicsMode) 520 for (const auto& mapEntry : gameStateDeclarations_s) 521 { 522 if (mapEntry.second.bGraphicsMode) 526 523 { 527 524 // Game state loading failure is serious --> don't catch 528 std::shared_ptr<GameState> gameState = GameStateFactory::fabricate( it->second);525 std::shared_ptr<GameState> gameState = GameStateFactory::fabricate(mapEntry.second); 529 526 if (!constructedStates_.insert(std::make_pair( 530 it->second.stateName, gameState)).second)527 mapEntry.second.stateName, gameState)).second) 531 528 assert(false); // GameState was already created! 532 529 }
Note: See TracChangeset
for help on using the changeset viewer.