[Orxonox-commit 749] r3278 - branches/core4/src/core
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Jul 12 23:06:41 CEST 2009
Author: rgrieder
Date: 2009-07-12 23:06:41 +0200 (Sun, 12 Jul 2009)
New Revision: 3278
Modified:
branches/core4/src/core/Game.cc
Log:
Bugfix: When requesting a game that that wasn't child or parent but grad parent the unloading didn't work properly.
Modified: branches/core4/src/core/Game.cc
===================================================================
--- branches/core4/src/core/Game.cc 2009-07-12 17:20:39 UTC (rev 3277)
+++ branches/core4/src/core/Game.cc 2009-07-12 21:06:41 UTC (rev 3278)
@@ -247,6 +247,7 @@
for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin() + 1;
it != this->activeStates_.end(); ++it)
{
+ bool threwException = false;
try
{
// Add tick time for most of the states
@@ -257,8 +258,17 @@
if (!(*it)->ignoreTickTime())
this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
}
+ catch (const std::exception& ex)
+ {
+ threwException = true;
+ COUT(0) << "Exception while ticking: " << ex.what() << std::endl;
+ }
catch (...)
{
+ threwException = true;
+ }
+ if (threwException)
+ {
COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl;
COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
if ((*it)->getParent() != NULL)
@@ -342,29 +352,33 @@
}
// Check children first
- shared_ptr<GameStateTreeNode> requestedNode;
+ std::vector<shared_ptr<GameStateTreeNode> > requestedNodes;
for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
{
if (lastRequestedNode->children_[i]->state_ == state)
{
- requestedNode = lastRequestedNode->children_[i];
+ requestedNodes.push_back(lastRequestedNode->children_[i]);
break;
}
}
- // Check parent and all its grand parents
- shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
- while (requestedNode == NULL && currentNode != NULL)
+ if (requestedNodes.empty())
{
- if (currentNode->state_ == state)
- requestedNode = currentNode;
- currentNode = currentNode->parent_.lock();
+ // Check parent and all its grand parents
+ shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
+ while (currentNode != NULL)
+ {
+ if (currentNode->state_ == state)
+ break;
+ currentNode = currentNode->parent_.lock();
+ requestedNodes.push_back(currentNode);
+ }
}
- if (requestedNode == NULL)
+ if (requestedNodes.empty())
COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
else
- this->requestedStateNodes_.push_back(requestedNode);
+ this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
}
void Game::requestStates(const std::string& names)
More information about the Orxonox-commit
mailing list