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:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r9945 r10624  
    310310        if (spaceship)
    311311        {
    312             WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
    313             if(ptr == NULL)
    314                 return;
    315312            spaceship->addSpeedFactor(5);
    316313            ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    317             executor->setDefaultValue(0, ptr);
     314            executor->setDefaultValue(0, spaceship);
    318315            new Timer(10, false, executor, true);
    319316        }
     
    593590    }
    594591
    595     void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function
    596     {
    597         if (*ptr)
    598         {
    599             (*ptr)->addSpeedFactor(1.0f/5.0f);
    600         }
    601         delete ptr;
     592    void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship)// helper function
     593    {
     594        if (spaceship)
     595        {
     596            spaceship->addSpeedFactor(1.0f/5.0f);
     597        }
    602598    }
    603599
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.h

    r9676 r10624  
    7777            virtual void rewardPig();
    7878            void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost.
    79             void resetSpeedFactor(WeakPtr<SpaceShip>* ptr);
     79            void resetSpeedFactor(SpaceShip* spaceship);
    8080            void tick (float dt);// used to end the game
    8181            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r10281 r10624  
    3434#include "core/config/ConfigValueIncludes.h"
    3535#include "core/GameMode.h"
    36 #include "core/command/ConsoleCommand.h"
     36#include "core/command/ConsoleCommandIncludes.h"
    3737#include "gamestates/GSLevel.h"
    3838
     
    4949namespace orxonox
    5050{
     51    static const std::string __CC_addBots_name  = "addBots";
     52    static const std::string __CC_killBots_name = "killBots";
     53
     54    SetConsoleCommand("Gametype", __CC_addBots_name,  &Gametype::addBots ).addShortcut().defaultValues(1);
     55    SetConsoleCommand("Gametype", __CC_killBots_name, &Gametype::killBots).addShortcut().defaultValues(0);
     56
    5157    RegisterUnloadableClass(Gametype);
    5258
     
    5561        RegisterObject(Gametype);
    5662
     63        this->setGametype(WeakPtr<Gametype>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
     64
    5765        this->gtinfo_ = new GametypeInfo(context);
    5866
    59         this->setGametype(SmartPtr<Gametype>(this, false));
    60 
    6167        this->defaultControllableEntity_ = Class(Spectator);
     68        this->scoreboard_ = 0;
    6269
    6370        this->bAutoStart_ = false;
     
    7481        this->setConfigValues();
    7582
     83        ModifyConsoleCommand(__CC_addBots_name).setObject(this);
     84        ModifyConsoleCommand(__CC_killBots_name).setObject(this);
     85    }
     86
     87    Gametype::~Gametype()
     88    {
     89        if (this->isInitialized())
     90        {
     91            if (this->gtinfo_)
     92                this->gtinfo_->destroy();
     93
     94            ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
     95            ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
     96        }
     97    }
     98
     99    /**
     100     * @brief Initializes sub-objects of the Gametype. This must be called after the constructor.
     101     * At this point, the context is expected to have the current gametype. This allows to pass the current gametype to the sub-objects via constructor.
     102     */
     103    void Gametype::init()
     104    {
    76105        // load the corresponding score board
    77106        if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
    78107        {
    79             this->scoreboard_ = new OverlayGroup(context);
     108            this->scoreboard_ = new OverlayGroup(this->getContext());
    80109            this->scoreboard_->addTemplate(this->scoreboardTemplate_);
    81             this->scoreboard_->setGametype(this);
    82         }
    83         else
    84             this->scoreboard_ = 0;
    85 
    86         /* HACK HACK HACK */
    87         this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
    88         this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
    89         /* HACK HACK HACK */
    90     }
    91 
    92     Gametype::~Gametype()
    93     {
    94         if (this->isInitialized())
    95         {
    96             this->gtinfo_->destroy();
    97             if( this->dedicatedAddBots_ )
    98                 delete this->dedicatedAddBots_;
    99             if( this->dedicatedKillBots_ )
    100                 delete this->dedicatedKillBots_;
    101110        }
    102111    }
     
    406415                    {
    407416                        // If in developer's mode, there is no start countdown.
    408                         if(Core::getInstance().inDevMode())
     417                        if(Core::getInstance().getConfig()->inDevMode())
    409418                            this->start();
    410419                        else
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r10281 r10624  
    7272            virtual ~Gametype();
    7373
     74            virtual void init();
     75
    7476            void setConfigValues();
    7577
     
    176178            virtual void importMementoState(const std::vector<GSLevelMementoState*>& states);
    177179
    178             SmartPtr<GametypeInfo> gtinfo_;
     180            WeakPtr<GametypeInfo> gtinfo_;
    179181
    180182            bool bAutoStart_;
     
    199201            std::string scoreboardTemplate_;
    200202
    201             /* HACK HACK HACK */
    202             ConsoleCommand* dedicatedAddBots_;
    203             ConsoleCommand* dedicatedKillBots_;
    204             /* HACK HACK HACK */
    205203            Timer showMenuTimer_;
    206204    };
  • code/trunk/src/orxonox/gametypes/Mission.cc

    r10258 r10624  
    3333
    3434#include "core/CoreIncludes.h"
    35 #include "core/command/ConsoleCommand.h"
     35#include "core/command/ConsoleCommandIncludes.h"
    3636#include "infos/PlayerInfo.h"
    3737#include "network/Host.h"
Note: See TracChangeset for help on using the changeset viewer.