Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2009, 2:22:00 AM (15 years ago)
Author:
rgrieder
Message:

Merged resource2 branch back to trunk.

IMPORTANT NOTE:
Upon this merge you need to specifically call your data directory "data_extern" when checking it out (when you don't provide a name, it will be just called 'trunk').
The new CMake variable is EXTERNAL_DATA_DIRECTORY. DATA_DIRECTORY now points to the one the source part of the repository.
UPDATE YOUR DATA DIRECTORY AS WELL!!!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/Game.cc

    r5693 r5695  
    3737#include <exception>
    3838#include <boost/weak_ptr.hpp>
     39#include <CEGUIExceptions.h>
    3940
    4041#include "util/Debug.h"
     
    5455namespace orxonox
    5556{
    56     using boost::shared_ptr;
    57     using boost::weak_ptr;
    58 
    5957    static void stop_game()
    6058        { Game::getInstance().stop(); }
     
    202200
    203201            // Core preUpdate (doesn't throw)
    204             if (!this->core_->preUpdate(*this->gameClock_))
    205             {
     202            try
     203                { this->core_->preUpdate(*this->gameClock_); }
     204            catch (...)
     205            {
     206                COUT(0) << "An exception occurred in the Core preUpdate: " << Game::getExceptionMessage() << std::endl;
     207                COUT(0) << "This should really never happen! Closing the program." << std::endl;
    206208                this->stop();
    207209                break;
     
    212214
    213215            // Core postUpdate (doesn't throw)
    214             if (!this->core_->postUpdate(*this->gameClock_))
    215             {
     216            try
     217                { this->core_->postUpdate(*this->gameClock_); }
     218            catch (...)
     219            {
     220            COUT(0) << "An exception occurred in the Core postUpdate: " << Game::getExceptionMessage() << std::endl;
     221            COUT(0) << "This should really never happen! Closing the program." << std::endl;
    216222                this->stop();
    217223                break;
     
    246252                    this->loadState(requestedStateNode->name_);
    247253                }
    248                 catch (const std::exception& ex)
     254                catch (...)
    249255                {
    250                     COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << ex.what() << std::endl;
     256                    COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Game::getExceptionMessage() << std::endl;
    251257                    // All scheduled operations have now been rendered inert --> flush them and issue a warning
    252258                    if (this->requestedStateNodes_.size() > 1)
    253                         COUT(1) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
     259                        COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
    254260                    this->requestedStateNodes_.clear();
    255261                    break;
     
    267273            it != this->loadedStates_.end(); ++it)
    268274        {
    269             std::string exceptionMessage;
    270275            try
    271276            {
    272277                // Add tick time for most of the states
    273                 uint64_t timeBeforeTick;
     278                uint64_t timeBeforeTick = 0;
    274279                if ((*it)->getInfo().bIgnoreTickTime)
    275280                    timeBeforeTick = this->gameClock_->getRealMicroseconds();
     
    278283                    this->subtractTickTime(static_cast<int32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
    279284            }
    280             catch (const std::exception& ex)
    281             { exceptionMessage = ex.what(); }
    282285            catch (...)
    283             { exceptionMessage = "Unknown exception"; }
    284             if (!exceptionMessage.empty())
    285             {
    286                 COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << exceptionMessage << std::endl;
     286            {
     287                COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Game::getExceptionMessage() << std::endl;
    287288                COUT(1) << "This should really never happen!" << std::endl;
    288289                COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
     
    590591            state->deactivate();
    591592        }
     593        catch (...)
     594        {
     595            COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Game::getExceptionMessage() << std::endl;
     596            COUT(2) << "         There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
     597        }
     598        // Check if graphics is still required
     599        if (!bAbort_)
     600        {
     601            bool graphicsRequired = false;
     602            for (unsigned i = 0; i < loadedStates_.size(); ++i)
     603                graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
     604            if (!graphicsRequired)
     605                this->unloadGraphics();
     606        }
     607        this->bChangingState_ = false;
     608    }
     609
     610    /*static*/ std::string Game::getExceptionMessage()
     611    {
     612        std::string exceptionMessage;
     613        try
     614        {
     615            // rethrow
     616            throw;
     617        }
    592618        catch (const std::exception& ex)
    593619        {
    594             COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << ex.what() << std::endl;
    595             COUT(2) << "         There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
    596         }
    597         // Check if graphics is still required
    598         bool graphicsRequired = false;
    599         for (unsigned i = 0; i < loadedStates_.size(); ++i)
    600             graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
    601         if (!graphicsRequired)
    602             this->unloadGraphics();
    603         this->bChangingState_ = false;
     620            return ex.what();
     621        }
     622        catch (const CEGUI::Exception& ex)
     623        {
     624#if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6
     625            return GeneralException(ex.getMessage().c_str()).getDescription();
     626#else
     627            return GeneralException(ex.getMessage().c_str(), ex.getLine(),
     628                ex.getFileName().c_str(), ex.getName().c_str()).getDescription();
     629#endif
     630        }
     631        catch (...)
     632        {
     633            return "Unknown exception";
     634        }
    604635    }
    605636
Note: See TracChangeset for help on using the changeset viewer.