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

Legend:

Unmodified
Added
Removed
  • code/trunk

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