Changeset 3278
- Timestamp:
- Jul 12, 2009, 11:06:41 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/Game.cc
r3247 r3278 248 248 it != this->activeStates_.end(); ++it) 249 249 { 250 bool threwException = false; 250 251 try 251 252 { … … 258 259 this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick)); 259 260 } 261 catch (const std::exception& ex) 262 { 263 threwException = true; 264 COUT(0) << "Exception while ticking: " << ex.what() << std::endl; 265 } 260 266 catch (...) 267 { 268 threwException = true; 269 } 270 if (threwException) 261 271 { 262 272 COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl; … … 343 353 344 354 // Check children first 345 s hared_ptr<GameStateTreeNode> requestedNode;355 std::vector<shared_ptr<GameStateTreeNode> > requestedNodes; 346 356 for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i) 347 357 { 348 358 if (lastRequestedNode->children_[i]->state_ == state) 349 359 { 350 requestedNode = lastRequestedNode->children_[i];360 requestedNodes.push_back(lastRequestedNode->children_[i]); 351 361 break; 352 362 } 353 363 } 354 364 355 // Check parent and all its grand parents 356 shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode; 357 while (requestedNode == NULL && currentNode != NULL) 358 { 359 if (currentNode->state_ == state) 360 requestedNode = currentNode; 361 currentNode = currentNode->parent_.lock(); 362 } 363 364 if (requestedNode == NULL) 365 if (requestedNodes.empty()) 366 { 367 // Check parent and all its grand parents 368 shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode; 369 while (currentNode != NULL) 370 { 371 if (currentNode->state_ == state) 372 break; 373 currentNode = currentNode->parent_.lock(); 374 requestedNodes.push_back(currentNode); 375 } 376 } 377 378 if (requestedNodes.empty()) 365 379 COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl; 366 380 else 367 this->requestedStateNodes_. push_back(requestedNode);381 this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end()); 368 382 } 369 383
Note: See TracChangeset
for help on using the changeset viewer.