Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10566


Ignore:
Timestamp:
Sep 8, 2015, 3:42:30 PM (5 years ago)
Author:
landauf
Message:

moved destruction of all level objects from Client to GSLevel. (there's still a bug with unloading in client mode which was introduced in r10563)

Location:
code/branches/core7/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/network/Client.cc

    r10464 r10566  
    194194  void Client::connectionClosed()
    195195  {
    196     ObjectList<Synchronisable>::iterator it;
    197     for(it = ObjectList<Synchronisable>::begin(); it; )
    198     {
    199       if( it->getSyncMode() != 0x0 )
    200         (it++)->destroy();
    201       else
    202       {
    203         ++it;
    204       }
    205     }
    206196    Game::getInstance().popState();
    207197    Game::getInstance().popState();
  • code/branches/core7/src/orxonox/gamestates/GSLevel.cc

    r10508 r10566  
    9595        }
    9696
     97        this->prepareObjectTracking();
     98
    9799        if (GameMode::isMaster())
    98100        {
     
    128130        if (GameMode::isMaster())
    129131            this->unloadLevel();
     132        else
     133            this->unloadLevelAsClient();
     134
     135        this->performObjectTracking();
    130136
    131137        if (GameMode::showsGraphics())
     
    161167    }
    162168
    163     void GSLevel::loadLevel()
     169    void GSLevel::prepareObjectTracking()
    164170    {
    165171        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    166172            this->staticObjects_.insert(*it);
    167 
    168         // call the loader
    169         startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
    170         bool loaded = Loader::getInstance().load(startFile_);
    171 
    172         Core::getInstance().getConfig()->updateLastLevelTimestamp();
    173         if(!loaded)
    174             GSRoot::delayedStartMainMenu();
    175     }
    176 
    177     void GSLevel::unloadLevel()
    178     {
    179         Loader::getInstance().unload(startFile_);
    180         delete startFile_;
    181 
     173    }
     174
     175    void GSLevel::performObjectTracking()
     176    {
    182177        orxout(internal_info) << "Remaining objects:" << endl;
    183178        unsigned int i = 0;
     
    187182            if (find == this->staticObjects_.end())
    188183            {
    189                 orxout(internal_info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
     184                orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
    190185            }
    191186        }
     
    194189        else
    195190            orxout(internal_warning) << i << " objects remaining. Try harder!" << endl;
     191    }
     192
     193    void GSLevel::loadLevel()
     194    {
     195        // call the loader
     196        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
     197        bool loaded = Loader::getInstance().load(startFile_);
     198
     199        Core::getInstance().getConfig()->updateLastLevelTimestamp();
     200        if(!loaded)
     201            GSRoot::delayedStartMainMenu();
     202    }
     203
     204    void GSLevel::unloadLevel()
     205    {
     206        Loader::getInstance().unload(startFile_);
     207        delete startFile_;
     208    }
     209
     210    /**
     211     * Unloads a level when the game instance is (or was) a client in a multiplayer session.
     212     * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown.
     213     */
     214    void GSLevel::unloadLevelAsClient()
     215    {
     216        ObjectList<Synchronisable>::iterator it;
     217        for(it = ObjectList<Synchronisable>::begin(); it; )
     218        {
     219            if( it->getSyncMode() != 0x0 )
     220                (it++)->destroy();
     221            else
     222            {
     223                ++it;
     224            }
     225        }
    196226    }
    197227
  • code/branches/core7/src/orxonox/gamestates/GSLevel.h

    r10281 r10566  
    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
Note: See TracChangeset for help on using the changeset viewer.