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

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r5781 r5929  
    5454        if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_)
    5555        {
    56             this->gtinfo_.sendAnnounceMessage("Time's up - you have lost the match!");
     56            this->gtinfo_->sendAnnounceMessage("Time's up - you have lost the match!");
    5757            this->end();
    5858        }
     
    6363        if (victim && victim->getPlayer())
    6464        {
    65             this->gtinfo_.sendAnnounceMessage("You're dead - you have lost the match!");
     65            this->gtinfo_->sendAnnounceMessage("You're dead - you have lost the match!");
    6666            this->end();
    6767        }
  • 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    }
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r5781 r5929  
    3737
    3838#include "core/BaseObject.h"
    39 #include "core/Identifier.h"
     39#include "core/SubclassIdentifier.h"
    4040#include "tools/interfaces/Tickable.h"
    4141#include "infos/GametypeInfo.h"
     
    6868        public:
    6969            Gametype(BaseObject* creator);
    70             virtual ~Gametype() {}
     70            virtual ~Gametype();
    7171
    7272            void setConfigValues();
     
    7575
    7676            inline const GametypeInfo* getGametypeInfo() const
    77                 { return &this->gtinfo_; }
     77                { return this->gtinfo_; }
    7878
    7979            inline bool hasStarted() const
    80                 { return this->gtinfo_.bStarted_; }
     80                { return this->gtinfo_->bStarted_; }
    8181            inline bool hasEnded() const
    82                 { return this->gtinfo_.bEnded_; }
     82                { return this->gtinfo_->bEnded_; }
    8383
    8484            virtual void start();
     
    114114
    115115            inline bool isStartCountdownRunning() const
    116                 { return this->gtinfo_.bStartCountdownRunning_; }
     116                { return this->gtinfo_->bStartCountdownRunning_; }
    117117            inline float getStartCountdown() const
    118                 { return this->gtinfo_.startCountdown_; }
     118                { return this->gtinfo_->startCountdown_; }
    119119
    120120            inline void setHUDTemplate(const std::string& name)
    121                 { this->gtinfo_.hudtemplate_ = name; }
     121                { this->gtinfo_->hudtemplate_ = name; }
    122122            inline const std::string& getHUDTemplate() const
    123                 { return this->gtinfo_.hudtemplate_; }
     123                { return this->gtinfo_->hudtemplate_; }
    124124
    125125            void addBots(unsigned int amount);
     
    163163            virtual void spawnDeadPlayersIfRequested();
    164164
    165             GametypeInfo gtinfo_;
     165            SmartPtr<GametypeInfo> gtinfo_;
    166166
    167167            bool bAutoStart_;
     
    184184            // Config Values
    185185            std::string scoreboardTemplate_;
     186           
     187            /* HACK HACK HACK */
     188            ConsoleCommand* hackAddBots_;
     189            ConsoleCommand* hackKillBots_;
     190            /* HACK HACK HACK */
    186191    };
    187192}
  • code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc

    r5781 r5929  
    4242        RegisterObject(TeamBaseMatch);
    4343
    44         this->scoreTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::winPoints)));
    45         this->outputTimer_.setTimer(10, true, this, createExecutor(createFunctor(&TeamBaseMatch::showPoints)));
     44        this->scoreTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::winPoints, this)));
     45        this->outputTimer_.setTimer(10, true, createExecutor(createFunctor(&TeamBaseMatch::showPoints, this)));
    4646
    4747        this->pointsTeam1_ = 0;
     
    6767                {
    6868                    base->setState(BaseState::ControlTeam1);
    69                     this->gtinfo_.sendAnnounceMessage("The red team captured a base");
     69                    this->gtinfo_->sendAnnounceMessage("The red team captured a base");
    7070                }
    7171                if (teamnr == 1)
    7272                {
    7373                    base->setState(BaseState::ControlTeam2);
    74                     this->gtinfo_.sendAnnounceMessage("The blue team captured a base");
     74                    this->gtinfo_->sendAnnounceMessage("The blue team captured a base");
    7575                }
    7676            }
     
    194194
    195195                if (it->second == winningteam)
    196                     this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     196                    this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
    197197                else
    198                     this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     198                    this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    199199            }
    200200
  • code/trunk/src/orxonox/gametypes/TeamBaseMatch.h

    r5781 r5929  
    6565
    6666            std::set<TeamBaseMatchBase*> bases_;
    67             Timer<TeamBaseMatch> scoreTimer_;
    68             Timer<TeamBaseMatch> outputTimer_;
     67            Timer scoreTimer_;
     68            Timer outputTimer_;
    6969
    7070            //points for each team
  • code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc

    r5781 r5929  
    9393
    9494        if (valid_player)
    95             this->players_.erase(player);
     95            this->teamnumbers_.erase(player);
    9696
    9797        return valid_player;
     
    100100    bool TeamDeathmatch::allowPawnHit(Pawn* victim, Pawn* originator)
    101101    {
    102         return (!this->pawnsAreInTheSameTeam(victim, originator));
     102        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    103103    }
    104104
    105105    bool TeamDeathmatch::allowPawnDamage(Pawn* victim, Pawn* originator)
    106106    {
    107         return (!this->pawnsAreInTheSameTeam(victim, originator));
     107        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    108108    }
    109109
    110110    bool TeamDeathmatch::allowPawnDeath(Pawn* victim, Pawn* originator)
    111111    {
    112         return (!this->pawnsAreInTheSameTeam(victim, originator));
     112        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator);
    113113    }
    114114
  • code/trunk/src/orxonox/gametypes/UnderAttack.cc

    r5781 r5929  
    4646        this->teams_ = 2;
    4747        this->destroyer_ = 0;
     48        this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this));
    4849        this->gameEnded_ = false;
    4950
     
    6566
    6667
    67     void UnderAttack::destroyedPawn(Pawn* pawn)
     68    void UnderAttack::killedDestroyer()
    6869    {
    69         if (pawn == this->destroyer_)
     70        this->end(); //end gametype
     71        std::string message = "Ship destroyed! Team 0 has won!";
     72        COUT(0) << message << std::endl;
     73        Host::Broadcast(message);
     74        this->gameEnded_ = true;
     75
     76        for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
    7077        {
    71             this->end(); //end gametype
    72             std::string message = "Ship destroyed! Team 0 has won!";
    73             COUT(0) << message << std::endl;
    74             Host::Broadcast(message);
    75             this->gameEnded_ = true;
     78            if (it->first->getClientID() == CLIENTID_UNKNOWN)
     79                continue;
    7680
    77             for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
    78             {
    79                 if (it->first->getClientID() == CLIENTID_UNKNOWN)
    80                     continue;
    81 
    82                 if (it->second == 0)
    83                     this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
    84                 else
    85                     this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    86             }
     81            if (it->second == 0)
     82                this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
     83            else
     84                this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    8785        }
    8886    }
     
    164162
    165163                    if (it->second == 1)
    166                         this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
     164                        this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
    167165                    else
    168                         this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
     166                        this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    169167                }
    170168            }
     
    178176                Host::Broadcast(message);
    179177*/
    180                 this->gtinfo_.sendAnnounceMessage(message);
     178                this->gtinfo_->sendAnnounceMessage(message);
    181179
    182180                if (timesequence_ >= 30 && timesequence_ <= 60)
  • code/trunk/src/orxonox/gametypes/UnderAttack.h

    r5781 r5929  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "interfaces/PawnListener.h"
    3534#include "TeamDeathmatch.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport UnderAttack : public TeamDeathmatch, public PawnListener
     38    class _OrxonoxExport UnderAttack : public TeamDeathmatch
    4039    {
    4140        public:
     
    5453
    5554        protected:
    56             virtual void destroyedPawn(Pawn* pawn);
     55            virtual void killedDestroyer();
    5756
    58             Destroyer* destroyer_;
     57            WeakPtr<Destroyer> destroyer_;
    5958            unsigned int teams_;
    6059            float gameTime_;
Note: See TracChangeset for help on using the changeset viewer.