Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9260 for code/trunk/src


Ignore:
Timestamp:
Jun 2, 2012, 10:34:48 PM (12 years ago)
Author:
landauf
Message:

cleaned up new SpaceRace classes (no functional code-changes):

  • formatting
  • naming of variables, arguments, functions
  • unused and duplicate code
  • public member variables
Location:
code/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/gametypes/RaceCheckPoint.cc

    r9016 r9260  
    4242{
    4343    CreateFactory(RaceCheckPoint);
    44    
    45      
    4644
    4745    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
    4846    {
    4947        RegisterObject(RaceCheckPoint);
     48
    5049        this->setDistance(100);
    5150        this->setBeaconMode("off");
    5251        this->setBroadcast(false);
    5352        this->setSimultaneousTriggerers(100);
    54         this->bTimeLimit_ = 0;
    5553
    5654        this->setRadarObjectColour(ColourValue::Blue);
     
    5856        this->setRadarVisibility(false);
    5957        this->settingsChanged();
    60         this->reached_=NULL;
    61      
     58
     59        this->checkpointIndex_ = 0;
     60        this->nextcheckpoints_ = Vector3::ZERO;
     61        this->bIsLast_ = false;
     62        this->timeLimit_ = 0;
     63        this->player_ = NULL;
    6264    }
    63    
     65
    6466
    6567   RaceCheckPoint::~RaceCheckPoint()
    6668   {
    67    
    6869   }
    69 
    70     void RaceCheckPoint::tick(float dt)
    71     {
    72         SUPER(RaceCheckPoint, tick, dt);
    73 
    74         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    75         assert(gametype);
    76     }
    7770
    7871    void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7972    {
    8073        SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
    81         Vector3 v= Vector3(0,0,0);
     74
    8275        XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
    83         XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
     76        XMLPortParam(RaceCheckPoint, "islast", setLast, isLast, xmlelement, mode).defaultValues(false);
    8477        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
    85     XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
     78        XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode, const Vector3&).defaultValues(Vector3::ZERO);
    8679    }
    8780
    88     void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
     81    void RaceCheckPoint::fire(bool bIsTriggered, BaseObject* originator)
    8982    {
    90         DistanceMultiTrigger::fire((bool)bIsTriggered,player);
    91        
    92         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    93         assert(gametype);
    94         ControllableEntity* entity = (ControllableEntity*) player;
    95      
    96         PlayerInfo* player2 = entity->getPlayer();
    97      
    98         if(bIsTriggered)
    99             this->reached_=player2;
     83        DistanceMultiTrigger::fire(bIsTriggered, originator);
     84
     85        if (bIsTriggered)
     86        {
     87            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
     88            if (entity)
     89                this->player_ = entity->getPlayer();
     90        }
    10091    }
    10192
    10293    void RaceCheckPoint::setTimelimit(float timeLimit)
    10394    {
    104         this->bTimeLimit_ = timeLimit;
    105         if (this->bTimeLimit_ != 0)
     95        this->timeLimit_ = timeLimit;
     96        if (this->timeLimit_ != 0)
    10697        {
    107             SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    108             assert(gametype);
    109             if (gametype)
    110             {
    111                 const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)
    112                             + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1);
    113                 const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
    114                 ChatManager::message(message);
    115             }
     98            std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
     99                        + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
     100            const_cast<GametypeInfo*>(this->getGametype()->getGametypeInfo())->sendAnnounceMessage(message);
     101            ChatManager::message(message);
    116102        }
    117103    }
    118 
    119104}
  • code/trunk/src/modules/gametypes/RaceCheckPoint.h

    r9016 r9260  
    3131
    3232#include "gametypes/GametypesPrereqs.h"
    33 
    34 
    35 
    3633#include "objects/triggers/DistanceMultiTrigger.h"
    3734#include "interfaces/RadarViewable.h"
     
    4239    @brief
    4340        The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
    44          Don't forget to control the indexes of your check points and to set one last check point
     41        Don't forget to control the indexes of your check points and to set one last check point
    4542    */
    4643    class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable
     
    5148
    5249            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    53             virtual void tick(float dt);
     50
    5451            inline void setCheckpointIndex(int checkpointIndex)
    55                 { this->bCheckpointIndex_ = checkpointIndex; }
    56             inline int getCheckpointIndex()
    57                 { return this->bCheckpointIndex_; }
     52                { this->checkpointIndex_ = checkpointIndex; }
     53            inline int getCheckpointIndex() const
     54                { return this->checkpointIndex_; }
    5855
    5956            inline void setNextcheckpoint(const Vector3& checkpoints)
    60                 { this->nextcheckpoints_=checkpoints; }
     57                { this->nextcheckpoints_ = checkpoints; }
    6158            inline void setNextcheckpoint(float x, float y, float z)
    6259                { this->setNextcheckpoint(Vector3(x, y, z)); }
    6360            inline const Vector3& getNextcheckpoint() const
    6461                { return this->nextcheckpoints_; }
     62
    6563            inline void setLast(bool isLast)
    6664                { this->bIsLast_ = isLast; }
    67             inline bool getLast()
     65            inline bool isLast() const
    6866                { return this->bIsLast_; }
    6967
    70             bool bIsLast_; //True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
    71             float bTimeLimit_; //The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
    72             PlayerInfo* reached_;
    73                
    74             inline float getTimeLimit()
    75                 { return this->bTimeLimit_; }
    76    
     68            virtual void setTimelimit(float timeLimit);
     69            inline float getTimeLimit() const
     70                { return this->timeLimit_; }
     71
     72            inline PlayerInfo* getPlayer() const
     73                { return this->player_; }
     74            inline void resetPlayer()
     75                { this->player_ = NULL; }
     76
    7777        protected:
    78             virtual void fire(bool bIsTriggered,BaseObject* player);
    79             virtual void setTimelimit(float timeLimit);
    80            
     78            virtual void fire(bool bIsTriggered, BaseObject* originator);
     79
    8180            inline const WorldEntity* getWorldEntity() const
    8281                { return this; }
    8382
    8483        private:
    85             int bCheckpointIndex_; //The index of this check point. The race starts with the check point with the index 0
    86             Vector3 nextcheckpoints_; //the indexes of the next check points
    87            
     84            int checkpointIndex_;     ///< The index of this check point. The race starts with the check point with the index 0
     85            Vector3 nextcheckpoints_; ///< the indexes of the next check points
     86            bool bIsLast_;            ///< True if this check point is the last of the level. There can be only one last check point for each level and there must be a last check point in the level.
     87            float timeLimit_;         ///< The time limit (from the start of the level) to reach this check point. If the check point is reached after this time, the game ends and the player looses.
     88            PlayerInfo* player_;      ///< The player that reached the checkpoint
    8889    };
    8990}
  • code/trunk/src/modules/gametypes/SpaceRace.cc

    r9016 r9260  
    2929#include "SpaceRace.h"
    3030
    31 
    3231#include "items/Engine.h"
    3332
     
    4645    {
    4746        RegisterObject(SpaceRace);
    48        
     47
     48        this->cantMove_ = false;
    4949        this->bTimeIsUp_ = false;
    50         this->numberOfBots_ = 0;
    51         this->cantMove_=false;
    52        
    5350    }
    54        
    55    
    56   // void SpaceRace::SetConfigValues(){
    57     //SUPER(Gametype,setConfigValues);
    58     //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);}
    5951
    6052    void SpaceRace::end()
     
    6254        this->Gametype::end();
    6355
     56        this->clock_.capture();
     57        int s = this->clock_.getSeconds();
     58        int ms = static_cast<int>(this->clock_.getMilliseconds() - 1000*s);
     59        std::string message;
     60
    6461        if (this->bTimeIsUp_)
    6562        {
    66             this->clock_.capture();
    67             int s = this->clock_.getSeconds();
    68             int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    69             const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
     63            message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
    7064                        + "You didn't reach the check point  before the time limit. You lose!";
    71             const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    72             ChatManager::message(message);
    7365        }
    7466        else
    7567        {
    76             this->clock_.capture();
    77             int s = this->clock_.getSeconds();
    78             int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    79             const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
     68            message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
    8069                        + "." + multi_cast<std::string>(ms) + " seconds.";
    81             const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    82             ChatManager::message(message);
     70        }
    8371
    84             float time = this->clock_.getSecondsPrecise();
    85             this->scores_.insert(time);
    86             std::set<float>::iterator it;
    87            
    88 
    89         }
     72        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
     73        ChatManager::message(message);
    9074    }
    9175
    9276    void SpaceRace::start()
    9377    {
     78        this->spawnPlayersIfRequested();
     79        Gametype::checkStart();
     80        this->cantMove_ = true;
    9481
    95         this->spawnPlayersIfRequested();
    96         Gametype::checkStart();
    97         this->cantMove_=true;
    98        
    99         for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    100         {
     82        for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    10183            it->setActive(false);
    102            
    103         }
    104         this->addBots(this->numberOfBots_);
     84
     85        this->addBots(this->numberOfBots_);
    10586    }
    106    
     87
    10788    void SpaceRace::tick(float dt)
    10889    {
    10990        SUPER(SpaceRace,tick,dt);
    110    
    111         if(!this->isStartCountdownRunning() && this->cantMove_)
     91
     92        if (!this->isStartCountdownRunning() && this->cantMove_)
    11293        {
    113             for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    114             {
     94            for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
    11595                it->setActive(true);
    116                
    117             }
     96
    11897            this->cantMove_= false;
    119            
    120             std::string message("The match has started! Reach the check points as quickly as possible!");
     98
     99            std::string message = "The match has started! Reach the check points as quickly as possible!";
    121100            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    122             ChatManager::message(message);           
     101            ChatManager::message(message);
    123102        }
    124    
    125103    }
    126104
    127    
    128    
    129     void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
     105    void SpaceRace::newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player)
    130106    {
    131         this->checkpointReached_[pl]=index;
     107        int index = checkpoint->getCheckpointIndex();
     108        this->checkpointReached_[player] = index;
    132109        this->clock_.capture();
    133110        int s = this->clock_.getSeconds();
    134         int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
     111        int ms = this->clock_.getMilliseconds() % 1000;
    135112        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
    136             + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
    137             + " seconds.";// Message is too long for a normal screen.
     113            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds.";
    138114        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    139115        ChatManager::message(message);
    140116    }
    141    
    142     void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
    143     {   
    144         int index = p->getCheckpointIndex();
    145         this->checkpointReached_[pl]=index;
    146         this->clock_.capture();
    147         int s = this->clock_.getSeconds();
    148         int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
    149         const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
    150             + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
    151             + " seconds.";
    152         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
    153         ChatManager::message(message);
    154     }
    155        
    156    
     117
    157118    void SpaceRace::playerEntered(PlayerInfo* player)
    158119    {
    159120        Gametype::playerEntered(player);
    160    
    161         this->checkpointReached_[player]=-1;
    162         //this->playersAlive_++;
     121
     122        this->checkpointReached_[player] = -1;
    163123    }
    164    
    165     bool SpaceRace::playerLeft(PlayerInfo* player)
    166     {
    167         return Gametype::playerLeft(player);
    168         // bool valid_player = true;
    169         //if (valid_player)
    170        // {
    171         //    this->playersAlive_--;
    172         //}
    173124
    174        // return valid_player;
    175     }
    176    
    177125    bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
    178126    {
  • code/trunk/src/modules/gametypes/SpaceRace.h

    r9016 r9260  
    4444namespace orxonox
    4545{
    46   /**
    47   @brief
    48     The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
    49   */
     46    /**
     47    @brief
     48        The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
     49    */
    5050    class _GametypesExport SpaceRace : public Gametype
    5151    {
    5252        friend class RaceCheckPoint;
    53        
     53
    5454
    5555        public:
     
    5757            virtual ~SpaceRace() {}
    5858
     59            void tick(float dt);
     60
    5961            virtual void start();
    6062            virtual void end();
    6163
    62             virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl);
    63             virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl);
     64            virtual void newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player);
    6465
    65             inline void setCheckpointReached(int n, PlayerInfo* p)
    66                 { this->checkpointReached_[p] = n;}
    67             inline int getCheckpointReached(PlayerInfo* p)
    68                 { return this->checkpointReached_[p]; }
     66            inline void setCheckpointReached(int index, PlayerInfo* player)
     67                { this->checkpointReached_[player] = index;}
     68            inline int getCheckpointReached(PlayerInfo* player)
     69                { return this->checkpointReached_[player]; }
    6970
    70             inline void timeIsUp()
     71            inline void setTimeIsUp()
    7172                { this->bTimeIsUp_ = true;}
    72             void tick(float dt);
    73             Clock clock_; //The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
    74 
     73            inline Clock& getClock()
     74                { return this->clock_; }
    7575
    7676            bool allowPawnHit(Pawn* victim, Pawn* originator);
     77            bool allowPawnDamage(Pawn* victim, Pawn* originator);
     78            bool allowPawnDeath(Pawn* victim, Pawn* originator);
    7779
    78             bool allowPawnDamage(Pawn* victim, Pawn* originator);
     80        protected:
     81            virtual void playerEntered(PlayerInfo* player); ///< Initializes values.
    7982
    80             bool allowPawnDeath(Pawn* victim, Pawn* originator);
    81         protected:
    82             virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
    83             virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables.
    8483        private:
    8584            bool cantMove_;
    86             std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player.
    87             std::set<float> scores_; //The times of the players are saved in a set.
    88             bool bTimeIsUp_; //True if one of the check points is reached too late.
    89            
    90             int playersAlive_;
     85            std::map<PlayerInfo*, int> checkpointReached_; ///< The number of the last check point reached by each player.
     86            bool bTimeIsUp_;                               ///< True if one of the check points is reached too late.
     87
     88            Clock clock_; ///< The clock starts running at the beginning of the game. It is used to give the time at each check point, the give the time at the end of the game, and to stop the game if a check point is reached too late.
    9189    };
    9290}
  • code/trunk/src/modules/gametypes/SpaceRaceManager.cc

    r9016 r9260  
    2121 *
    2222 *   Author:
    23  *     Celine Eggenberger
     23 *      Celine Eggenberger
    2424 *   Co-authors:
    2525 *      ...
     
    4747    {
    4848        RegisterObject(SpaceRaceManager);
    49          
    50         this->firstcheckpointvisible_=false;
    51          
     49
     50        this->firstcheckpointvisible_ = false;
    5251    }
    5352
    5453    SpaceRaceManager::~SpaceRaceManager()
    5554    {
    56         if (this->isInitialized())
     55        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     56            this->checkpoints_[i]->destroy();
     57    }
     58
     59    void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     60    {
     61        SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
     62
     63        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
     64    }
     65
     66    void SpaceRaceManager::tick(float dt)
     67    {
     68        SUPER(SpaceRaceManager,tick,dt);
     69
     70        if (this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
    5771        {
    58             for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    59                 this->checkpoints_[i]->destroy();
     72            this->checkpoints_[0]->setRadarVisibility(true);
     73            this->firstcheckpointvisible_ = true;
     74        }
     75
     76        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     77        {
     78            if (this->checkpoints_[i]->getPlayer() != NULL)
     79                this->checkpointReached(this->checkpoints_[i], this->checkpoints_[i]->getPlayer());
    6080        }
    6181    }
    62    
     82
    6383    void SpaceRaceManager::addCheckpoint(RaceCheckPoint* checkpoint)
    6484    {
     
    7393            return 0;
    7494    }
    75    
    76     int SpaceRaceManager::getIndex(RaceCheckPoint* r)
     95
     96    int SpaceRaceManager::getIndex(RaceCheckPoint* checkpoint)
    7797    {
    7898        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    79             if (this->checkpoints_[i]==r) {return i;}
    80            
     99            if (this->checkpoints_[i] == checkpoint)
     100                return i;
     101
    81102        return -1;
    82103    }
    83    
    84     void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    85     {
    86         SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
    87104
    88        
    89         XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
    90     }
    91    
    92     void SpaceRaceManager::tick(float dt)
    93     {
    94         SUPER(SpaceRaceManager,tick,dt);
    95      
    96         if(this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
    97         {
    98             this->checkpoints_[0]->setRadarVisibility(true);
    99             this->firstcheckpointvisible_=true;
    100         }
    101          
    102         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    103         {
    104             if(this->checkpoints_[i]->reached_!=NULL)
    105                 this->checkpointReached(this->checkpoints_[i],this->checkpoints_[i]->reached_);
    106         }
    107     }
    108    
    109    
    110105    void SpaceRaceManager::checkpointReached(RaceCheckPoint* check, PlayerInfo* player)
    111106    {
    112107        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    113108        assert(gametype);
    114        
    115         bool b =false;   
    116            
    117         int index=gametype->getCheckpointReached(player);
    118         Vector3 v=Vector3 (-1,-1,-1);
    119         if (index>-1)
     109
     110        bool reachedValidCheckpoint = false;
     111
     112        int index = gametype->getCheckpointReached(player);
     113        if (index > -1)
    120114        {
    121             RaceCheckPoint* tmp= this->getCheckpoint(index);
    122             v= tmp->getNextcheckpoint();
    123        
     115            Vector3 v = this->getCheckpoint(index)->getNextcheckpoint();
     116
    124117            if (this->getCheckpoint(v.x) == check)
    125118            {
    126                 b = true;
    127             }   
    128        
     119                reachedValidCheckpoint = true;
     120            }
    129121            if (this->getCheckpoint(v.y) == check)
    130122            {
    131                 b = true;
    132             }   
     123                reachedValidCheckpoint = true;
     124            }
    133125            if (this->getCheckpoint(v.z) == check)
    134126            {
    135                 b = true;
    136             }   
     127                reachedValidCheckpoint = true;
     128            }
    137129        }
    138130        else
    139131        {
    140             b = (this->getIndex(check) == 0);
     132            reachedValidCheckpoint = (this->getIndex(check) == 0);
    141133        }
    142            
    143         if (gametype && b)
     134
     135        if (gametype && reachedValidCheckpoint)
    144136        {
    145             gametype->clock_.capture();
    146             float time = gametype->clock_.getSecondsPrecise();
    147             if (check->getTimeLimit()!=0 && time > check->getTimeLimit())
     137            gametype->getClock().capture();
     138            float time = gametype->getClock().getSecondsPrecise();
     139            if (check->getTimeLimit() != 0 && time > check->getTimeLimit())
    148140            {
    149                 gametype->timeIsUp();
     141                gametype->setTimeIsUp();
    150142                gametype->end();
    151143            }
    152             else if (check->getLast())
     144            else if (check->isLast())
    153145                gametype->end();
    154146            else
    155                                 {
    156                 if (index > -1)this->setRadVis(player,false);
    157                         else this->getCheckpoint(0)->setRadarVisibility(false);
    158                 gametype->newCheckpointReached(check,player);
    159                
    160                
     147                        {
     148                if (index > -1)
     149                    this->setRadVis(player, false);
     150                else
     151                    this->getCheckpoint(0)->setRadarVisibility(false);
     152
     153                gametype->newCheckpointReached(check, player);
    161154                this->setRadVis(player, true);
    162155            }
    163156        }
    164         check->reached_=NULL;
     157
     158        check->resetPlayer();
    165159    }
    166    
    167     void SpaceRaceManager::setRadVis(PlayerInfo* player, bool b)
     160
     161    void SpaceRaceManager::setRadVis(PlayerInfo* player, bool bVisible)
    168162    {
    169163        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    170164        assert(gametype);
    171165        int index = gametype->getCheckpointReached(player);
    172         Vector3 v = Vector3(-1,-1,-1);
    173         RaceCheckPoint* tmp = this->getCheckpoint(index);
    174         v = tmp->getNextcheckpoint();
    175    
    176         if(v.x > -1)
     166        Vector3 v = this->getCheckpoint(index)->getNextcheckpoint();
     167
     168        if (v.x > -1)
    177169        {
    178             this->getCheckpoint(v.x)->setRadarVisibility(b);
     170            this->getCheckpoint(v.x)->setRadarVisibility(bVisible);
    179171            this->getCheckpoint(v.x)->settingsChanged();
    180172        }
    181         if(v.y > -1)
     173        if (v.y > -1)
    182174        {
    183             this->getCheckpoint(v.y)->setRadarVisibility(b);
     175            this->getCheckpoint(v.y)->setRadarVisibility(bVisible);
    184176            this->getCheckpoint(v.y)->settingsChanged();
    185177        }
    186         if(v.z > -1)
     178        if (v.z > -1)
    187179        {
    188             this->getCheckpoint(v.z)->setRadarVisibility(b);
    189            this->getCheckpoint(v.z)->settingsChanged();
     180            this->getCheckpoint(v.z)->setRadarVisibility(bVisible);
     181            this->getCheckpoint(v.z)->settingsChanged();
    190182        }
    191        
    192        
    193183    }
    194    
    195184}
  • code/trunk/src/modules/gametypes/SpaceRaceManager.h

    r9016 r9260  
    4646namespace orxonox
    4747{
    48   /**
    49   @brief
    50     The SpaceRaceManager class controls a space race level, where the player has to reach check points in a given order.
    51   */
     48    /**
     49    @brief
     50        The SpaceRaceManager class controls a space race level, where the player has to reach check points in a given order.
     51    */
    5252    class _GametypesExport SpaceRaceManager : public BaseObject, public Tickable
    5353    {
    5454        friend class RaceCheckPoint;
    55    
     55
    5656        public:
    5757            SpaceRaceManager(BaseObject* creator);
    5858            virtual ~SpaceRaceManager() ;
    5959
    60             void XMLPort(Element& xmlelement, XMLPort::Mode mode); 
    61             int getIndex(RaceCheckPoint* r);
     60            void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     61
    6262            void addCheckpoint(RaceCheckPoint* checkpoint);
    6363            RaceCheckPoint* getCheckpoint(unsigned int index) const;
    64        
     64            int getIndex(RaceCheckPoint* checkpoint);
     65
    6566            void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
    66        
     67
    6768            void tick(float dt);
    68    
     69
    6970        protected:
    70             void setRadVis(PlayerInfo* player, bool b);//sets RadarVisibility of the checkpoints the player can reach.
    71    
     71            void setRadVis(PlayerInfo* player, bool bVisible); ///< sets RadarVisibility of the checkpoints the player can reach.
     72
    7273        private:
    7374            std::vector<RaceCheckPoint*> checkpoints_;
    74             bool firstcheckpointvisible_;//true if the first check point is visible.
    75        
     75            bool firstcheckpointvisible_; ///< true if the first check point is visible.
    7676    };
    7777}
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r9016 r9260  
    123123        if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
    124124            this->gtinfo_->countdownStartCountdown(dt);
    125                        
     125
    126126        if (!this->gtinfo_->hasStarted())
    127127        {
     
    131131                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
    132132                    this->gtinfo_->playerReadyToSpawn(it->first);
    133                    
    134                
    135             }
     133            }
     134
    136135            this->checkStart();
    137136        }
     
    144143    void Gametype::start()
    145144    {
    146          
    147145        this->addBots(this->numberOfBots_);
    148146
     
    150148
    151149        this->spawnPlayersIfRequested();
    152        
    153        
    154150    }
    155151
     
    401397                            hashumanplayers = true;
    402398                    }
    403                          
     399
    404400                    if (allplayersready && hashumanplayers)
    405401                    {
     
    413409                }
    414410            }
    415            
    416411        }
    417412    }
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r9016 r9260  
    152152            virtual void resetTimer();
    153153            virtual void resetTimer(float t);
    154             inline unsigned int getNumberOfPlayers()
    155               { return this->gtinfo_->getNumberOfPlayers(); }
    156154
    157        
     155            inline unsigned int getNumberOfPlayers() const
     156                { return this->gtinfo_->getNumberOfPlayers(); }
    158157
    159158        protected:
Note: See TracChangeset for help on using the changeset viewer.