Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2009, 8:20:07 PM (15 years ago)
Author:
rgrieder
Message:

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r5781 r5929  
    3333#include "core/ConfigValueIncludes.h"
    3434#include "core/GameMode.h"
     35#include "core/ConsoleCommand.h"
    3536
    3637#include "infos/PlayerInfo.h"
     
    4748    CreateUnloadableFactory(Gametype);
    4849
    49     Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator)
     50    Gametype::Gametype(BaseObject* creator) : BaseObject(creator)
    5051    {
    5152        RegisterObject(Gametype);
    52 
    53         this->setGametype(this);
     53       
     54        this->gtinfo_ = new GametypeInfo(creator);
     55
     56        this->setGametype(SmartPtr<Gametype>(this, false));
    5457
    5558        this->defaultControllableEntity_ = Class(Spectator);
     
    7679        else
    7780            this->scoreboard_ = 0;
     81       
     82        /* HACK HACK HACK */
     83        this->hackAddBots_ = createConsoleCommand( createFunctor(&Gametype::addBots, this), "hackAddBots");
     84        this->hackKillBots_ = createConsoleCommand( createFunctor(&Gametype::killBots, this), "hackKillBots");
     85        CommandExecutor::addConsoleCommandShortcut( this->hackAddBots_ );
     86        CommandExecutor::addConsoleCommandShortcut( this->hackKillBots_ );
     87        /* HACK HACK HACK */
     88    }
     89   
     90    Gametype::~Gametype()
     91    {
     92        if (this->isInitialized())
     93        {
     94            this->gtinfo_->destroy();
     95            if( this->hackAddBots_ )
     96                delete this->hackAddBots_;
     97            if( this->hackKillBots_ )
     98                delete this->hackKillBots_;
     99        }
    78100    }
    79101
     
    100122        }
    101123
    102         if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_)
    103             this->gtinfo_.startCountdown_ -= dt;
    104 
    105         if (!this->gtinfo_.bStarted_)
     124        if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
     125            this->gtinfo_->startCountdown_ -= dt;
     126
     127        if (!this->gtinfo_->bStarted_)
    106128            this->checkStart();
    107         else if (!this->gtinfo_.bEnded_)
     129        else if (!this->gtinfo_->bEnded_)
    108130            this->spawnDeadPlayersIfRequested();
    109131
     
    115137        this->addBots(this->numberOfBots_);
    116138
    117         this->gtinfo_.bStarted_ = true;
     139        this->gtinfo_->bStarted_ = true;
    118140
    119141        this->spawnPlayersIfRequested();
     
    122144    void Gametype::end()
    123145    {
    124         this->gtinfo_.bEnded_ = true;
     146        this->gtinfo_->bEnded_ = true;
    125147
    126148        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    130152                ControllableEntity* oldentity = it->first->getControllableEntity();
    131153
    132                 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator());
     154                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity);
    133155                if (oldentity->getCamera())
    134156                {
     
    243265
    244266                        if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
    245                             this->gtinfo_.sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());
     267                            this->gtinfo_->sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());
    246268                        if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
    247                             this->gtinfo_.sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());
     269                            this->gtinfo_->sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());
    248270                    }
    249271                }
     
    308330                it->second.state_ = PlayerState::Dead;
    309331
    310                 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
     332                if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
    311333                {
    312334                    this->spawnPlayerAsDefaultPawn(it->first);
     
    319341    void Gametype::checkStart()
    320342    {
    321         if (!this->gtinfo_.bStarted_)
    322         {
    323             if (this->gtinfo_.bStartCountdownRunning_)
    324             {
    325                 if (this->gtinfo_.startCountdown_ <= 0)
    326                 {
    327                     this->gtinfo_.bStartCountdownRunning_ = false;
    328                     this->gtinfo_.startCountdown_ = 0;
     343        if (!this->gtinfo_->bStarted_)
     344        {
     345            if (this->gtinfo_->bStartCountdownRunning_)
     346            {
     347                if (this->gtinfo_->startCountdown_ <= 0)
     348                {
     349                    this->gtinfo_->bStartCountdownRunning_ = false;
     350                    this->gtinfo_->startCountdown_ = 0;
    329351                    this->start();
    330352                }
     
    349371                    if (allplayersready && hashumanplayers)
    350372                    {
    351                         this->gtinfo_.startCountdown_ = this->initialStartCountdown_;
    352                         this->gtinfo_.bStartCountdownRunning_ = true;
     373                        this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
     374                        this->gtinfo_->bStartCountdownRunning_ = true;
    353375                    }
    354376                }
     
    419441            if (it->getGametype() == this)
    420442            {
    421                 delete (*(it++));
     443                (it++)->destroy();
    422444                ++i;
    423445            }
     446            else
     447                ++it;
    424448        }
    425449    }
Note: See TracChangeset for help on using the changeset viewer.