Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (16 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/gamestates/GSLevel.cc

    r2460 r2485  
    4141#include "core/CoreIncludes.h"
    4242#include "core/Core.h"
    43 //#include "objects/Backlight.h"
    4443#include "objects/Tickable.h"
    4544#include "objects/Radar.h"
    46 //#include "tools/ParticleInterface.h"
    4745#include "CameraManager.h"
    4846#include "LevelManager.h"
     47#include "PlayerManager.h"
    4948#include "Settings.h"
    5049
     
    5554    GSLevel::GSLevel()
    5655//        : GameState<GSGraphics>(name)
    57         : timeFactor_(1.0f)
    58         , keyBinder_(0)
     56        : keyBinder_(0)
    5957        , inputState_(0)
    6058        , radar_(0)
     
    6462    {
    6563        RegisterObject(GSLevel);
     64
     65        this->ccKeybind_ = 0;
     66        this->ccTkeybind_ = 0;
     67
    6668        setConfigValues();
    6769    }
     
    9597        }
    9698
     99        this->playerManager_ = new PlayerManager();
     100
    97101        if (Core::isMaster())
    98102        {
    99103            // create the global LevelManager
    100104            this->levelManager_ = new LevelManager();
    101 
    102             // reset game speed to normal
    103             timeFactor_ = 1.0f;
    104105
    105106            this->loadLevel();
     
    114115            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    115116            functor1->setObject(this);
    116             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     117            ccKeybind_ = createConsoleCommand(functor1, "keybind");
     118            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
    117119            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    118120            functor2->setObject(this);
    119             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     121            ccTkeybind_ = createConsoleCommand(functor2, "tkeybind");
     122            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
    120123            // set our console command as callback for the key detector
    121124            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     
    124127            InputManager::getInstance().requestEnterState("game");
    125128        }
    126 
    127         if (Core::isMaster())
    128         {
    129             // time factor console command
    130             FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    131             functor->setObject(this);
    132             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    133         }
    134129    }
    135130
    136131    void GSLevel::leave()
    137132    {
     133        // destroy console commands
     134        if (this->ccKeybind_)
     135        {
     136            delete this->ccKeybind_;
     137            this->ccKeybind_ = 0;
     138        }
     139        if (this->ccTkeybind_)
     140        {
     141            delete this->ccTkeybind_;
     142            this->ccTkeybind_ = 0;
     143        }
     144
    138145        // this call will delete every BaseObject!
    139146        // But currently this will call methods of objects that exist no more
     
    149156
    150157        if (this->radar_)
     158        {
    151159            delete this->radar_;
     160            this->radar_ = 0;
     161        }
    152162
    153163        if (this->cameraManager_)
     164        {
    154165            delete this->cameraManager_;
     166            this->cameraManager_ = 0;
     167        }
    155168
    156169        if (this->levelManager_)
     170        {
    157171            delete this->levelManager_;
     172            this->levelManager_ = 0;
     173        }
     174
     175        if (this->playerManager_)
     176        {
     177            delete this->playerManager_;
     178            this->playerManager_ = 0;
     179        }
    158180
    159181        if (Core::showsGraphics())
     
    162184            InputManager::getInstance().requestDestroyState("game");
    163185            if (this->keyBinder_)
     186            {
    164187                delete this->keyBinder_;
     188                this->keyBinder_ = 0;
     189            }
    165190        }
    166191    }
     
    172197        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    173198        //    it->tick(time.getDeltaTime() * this->timeFactor_);
    174     }
    175 
    176     /**
    177     @brief
    178         Changes the speed of Orxonox
    179     */
    180     void GSLevel::setTimeFactor(float factor)
    181     {
    182 /*
    183         float change = factor / this->timeFactor_;
    184 */
    185         this->timeFactor_ = factor;
    186 /*
    187         for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    188             it->setSpeedFactor(it->getSpeedFactor() * change);
    189 
    190         for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    191             it->setTimeFactor(timeFactor_);
    192 */
    193199    }
    194200
Note: See TracChangeset for help on using the changeset viewer.