Changeset 3349 for code/branches/resource/src/core/Game.cc
- Timestamp:
- Jul 25, 2009, 2:14:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource/src/core/Game.cc
r3323 r3349 245 245 } 246 246 247 // UPDATE, Core first 248 bool threwException = false; 249 try 250 { 251 this->core_->update(*this->gameClock_); 252 } 253 catch (const std::exception& ex) 254 { 255 threwException = true; 256 COUT(0) << "Exception while ticking the Core: " << ex.what() << std::endl; 257 } 258 catch (...) 259 { 260 threwException = true; 261 } 262 if (threwException) 263 { 264 COUT(0) << "An exception occured while ticking the Core. This should really never happen!" << std::endl; 265 COUT(0) << "Closing the program." << std::endl; 247 // UPDATE, Core preUpdate (doesn't throw) 248 if (!this->core_->preUpdate(*this->gameClock_)) 249 { 266 250 this->stop(); 267 251 break; … … 273 257 it != this->activeStates_.end(); ++it) 274 258 { 275 bool threwException = false;259 std::string exceptionMessage; 276 260 try 277 261 { 278 262 // Add tick time for most of the states 279 263 uint64_t timeBeforeTick; 280 if ( !(*it)->ignoreTickTime())264 if ((*it)->ignoreTickTime()) 281 265 timeBeforeTick = this->gameClock_->getRealMicroseconds(); 282 266 (*it)->update(*this->gameClock_); 283 if ( !(*it)->ignoreTickTime())284 this-> addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));267 if ((*it)->ignoreTickTime()) 268 this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick)); 285 269 } 286 270 catch (const std::exception& ex) 271 { exceptionMessage = ex.what(); } 272 catch (...) 273 { exceptionMessage = "Unknown exception"; } 274 if (!exceptionMessage.empty()) 287 275 { 288 threwException = true; 289 COUT(0) << "Exception while ticking: " << ex.what() << std::endl; 290 } 291 catch (...) 292 { 293 threwException = true; 294 } 295 if (threwException) 296 { 297 COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl; 276 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << exceptionMessage << std::endl; 277 COUT(1) << "This should really never happen!" << std::endl; 298 278 COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl; 299 279 if ((*it)->getParent() != NULL) … … 304 284 } 305 285 286 } 287 288 // UPDATE, Core postUpdate (doesn't throw) 289 if (!this->core_->postUpdate(*this->gameClock_)) 290 { 291 this->stop(); 292 break; 306 293 } 307 294 … … 344 331 } 345 332 346 void Game:: addTickTime(uint32_t length)333 void Game::subtractTickTime(int32_t length) 347 334 { 348 335 assert(!this->statisticsTickTimes_.empty()); 349 this->statisticsTickTimes_.back().tickLength += length;350 this->periodTickTime_ +=length;336 this->statisticsTickTimes_.back().tickLength -= length; 337 this->periodTickTime_ -= length; 351 338 } 352 339
Note: See TracChangeset
for help on using the changeset viewer.