Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (9 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r9667 r10624  
    3030
    3131#include "util/Exception.h"
    32 #include "core/config/CommandLineParser.h"
     32#include "core/commandline/CommandLineIncludes.h"
    3333#include "core/Game.h"
    3434#include "core/GameMode.h"
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r10299 r10624  
    4444#include "core/Loader.h"
    4545#include "core/XMLFile.h"
    46 #include "core/command/ConsoleCommand.h"
     46#include "core/command/ConsoleCommandIncludes.h"
    4747
    4848#include "LevelManager.h"
     49#include "Level.h"
    4950#include "PlayerManager.h"
    5051#include "GSRoot.h"
     
    9596        }
    9697
     98        this->prepareObjectTracking();
     99
    97100        if (GameMode::isMaster())
    98101        {
     
    128131        if (GameMode::isMaster())
    129132            this->unloadLevel();
     133        else
     134            this->unloadLevelAsClient();
     135
     136        this->performObjectTracking();
    130137
    131138        if (GameMode::showsGraphics())
     
    161168    }
    162169
    163     void GSLevel::loadLevel()
     170    void GSLevel::prepareObjectTracking()
    164171    {
    165172        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    166173            this->staticObjects_.insert(*it);
    167 
    168         // call the loader
    169         startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
    170         bool loaded = Loader::open(startFile_);
    171 
    172         Core::getInstance().updateLastLevelTimestamp();
    173         if(!loaded)
    174             GSRoot::delayedStartMainMenu();
    175     }
    176 
    177     void GSLevel::unloadLevel()
    178     {
    179         Loader::unload(startFile_);
    180         delete startFile_;
    181 
     174    }
     175
     176    void GSLevel::performObjectTracking()
     177    {
    182178        orxout(internal_info) << "Remaining objects:" << endl;
    183179        unsigned int i = 0;
     
    187183            if (find == this->staticObjects_.end())
    188184            {
    189                 orxout(internal_info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
     185                orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
    190186            }
    191187        }
     
    194190        else
    195191            orxout(internal_warning) << i << " objects remaining. Try harder!" << endl;
     192    }
     193
     194    void GSLevel::loadLevel()
     195    {
     196        // call the loader
     197        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
     198        bool loaded = Loader::getInstance().load(startFile_);
     199
     200        Core::getInstance().getConfig()->updateLastLevelTimestamp();
     201        if(!loaded)
     202            GSRoot::delayedStartMainMenu();
     203    }
     204
     205    void GSLevel::unloadLevel()
     206    {
     207        Loader::getInstance().unload(startFile_);
     208        delete startFile_;
     209    }
     210
     211    /**
     212     * Unloads a level when the game instance is (or was) a client in a multiplayer session.
     213     * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown.
     214     */
     215    void GSLevel::unloadLevelAsClient()
     216    {
     217        for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); )
     218        {
     219            StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it
     220            for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); )
     221                (it++)->destroy();
     222        }
     223
     224        for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); )
     225        {
     226            if (it->getSyncMode() != 0x0)
     227                (it++)->destroy();
     228            else
     229                ++it;
     230        }
    196231    }
    197232
     
    252287    ///////////////////////////////////////////////////////////////////////////
    253288
    254     RegisterAbstractClass(GSLevelMemento).inheritsFrom(Class(OrxonoxInterface));
     289    RegisterAbstractClass(GSLevelMemento).inheritsFrom<OrxonoxInterface>();
    255290
    256291    GSLevelMemento::GSLevelMemento()
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r10281 r10624  
    5353        void reloadLevel();
    5454
    55     protected:
     55    private:
    5656        void loadLevel();
    5757        void unloadLevel();
     58        void unloadLevelAsClient();
     59
     60        void prepareObjectTracking();
     61        void performObjectTracking();
    5862
    5963        InputState*              gameInputState_;          //!< input state for normal ingame playing
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r9944 r10624  
    3636#include "core/GraphicsManager.h"
    3737#include "core/GUIManager.h"
    38 #include "core/command/ConsoleCommand.h"
     38#include "core/command/ConsoleCommandIncludes.h"
    3939#include "core/input/KeyBinderManager.h"
    4040#include "network/Client.h"
     
    6363    SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
    6464
     65    RegisterAbstractClass(GSMainMenu).inheritsFrom<Configurable>();
     66
    6567    GSMainMenu::GSMainMenu(const GameStateInfo& info)
    6668        : GameState(info)
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r9348 r10624  
    3333#include "core/Game.h"
    3434#include "core/GameMode.h"
    35 #include "core/command/ConsoleCommand.h"
    36 #include "network/NetworkFunction.h"
     35#include "core/command/ConsoleCommandIncludes.h"
     36#include "network/NetworkFunctionIncludes.h"
    3737#include "tools/Timer.h"
    3838#include "tools/interfaces/Tickable.h"
     
    6868    GSRoot::~GSRoot()
    6969    {
    70         NetworkFunctionBase::destroyAllNetworkFunctions();
    7170    }
    7271
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r10197 r10624  
    3030
    3131#include "util/Output.h"
    32 #include "core/config/CommandLineParser.h"
     32#include "core/commandline/CommandLineIncludes.h"
    3333#include "core/Game.h"
    3434#include "core/GameMode.h"
Note: See TracChangeset for help on using the changeset viewer.