Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3278 for code/branches


Ignore:
Timestamp:
Jul 12, 2009, 11:06:41 PM (15 years ago)
Author:
rgrieder
Message:

Bugfix: When requesting a game that that wasn't child or parent but grad parent the unloading didn't work properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/Game.cc

    r3247 r3278  
    248248                it != this->activeStates_.end(); ++it)
    249249            {
     250                bool threwException = false;
    250251                try
    251252                {
     
    258259                        this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
    259260                }
     261                catch (const std::exception& ex)
     262                {
     263                    threwException = true;
     264                    COUT(0) << "Exception while ticking: " << ex.what() << std::endl;
     265                }
    260266                catch (...)
     267                {
     268                    threwException = true;
     269                }
     270                if (threwException)
    261271                {
    262272                    COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl;
     
    343353
    344354        // Check children first
    345         shared_ptr<GameStateTreeNode> requestedNode;
     355        std::vector<shared_ptr<GameStateTreeNode> > requestedNodes;
    346356        for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
    347357        {
    348358            if (lastRequestedNode->children_[i]->state_ == state)
    349359            {
    350                 requestedNode = lastRequestedNode->children_[i];
     360                requestedNodes.push_back(lastRequestedNode->children_[i]);
    351361                break;
    352362            }
    353363        }
    354364
    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())
    365379            COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
    366380        else
    367             this->requestedStateNodes_.push_back(requestedNode);
     381            this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
    368382    }
    369383
Note: See TracChangeset for help on using the changeset viewer.