[Orxonox-commit 4589] r9260 - in code/trunk/src: modules/gametypes orxonox/gametypes

landauf at orxonox.net landauf at orxonox.net
Sat Jun 2 22:34:49 CEST 2012


Author: landauf
Date: 2012-06-02 22:34:48 +0200 (Sat, 02 Jun 2012)
New Revision: 9260

Modified:
   code/trunk/src/modules/gametypes/RaceCheckPoint.cc
   code/trunk/src/modules/gametypes/RaceCheckPoint.h
   code/trunk/src/modules/gametypes/SpaceRace.cc
   code/trunk/src/modules/gametypes/SpaceRace.h
   code/trunk/src/modules/gametypes/SpaceRaceManager.cc
   code/trunk/src/modules/gametypes/SpaceRaceManager.h
   code/trunk/src/orxonox/gametypes/Gametype.cc
   code/trunk/src/orxonox/gametypes/Gametype.h
Log:
cleaned up new SpaceRace classes (no functional code-changes):
 - formatting
 - naming of variables, arguments, functions
 - unused and duplicate code
 - public member variables

Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.cc	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.cc	2012-06-02 20:34:48 UTC (rev 9260)
@@ -41,79 +41,64 @@
 namespace orxonox
 {
     CreateFactory(RaceCheckPoint);
-    
-     
 
     RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
     {
         RegisterObject(RaceCheckPoint);
+
         this->setDistance(100);
         this->setBeaconMode("off");
         this->setBroadcast(false);
         this->setSimultaneousTriggerers(100);
-        this->bTimeLimit_ = 0;
 
         this->setRadarObjectColour(ColourValue::Blue);
         this->setRadarObjectShape(RadarViewable::Triangle);
         this->setRadarVisibility(false);
         this->settingsChanged();
-        this->reached_=NULL;
-      
+
+        this->checkpointIndex_ = 0;
+        this->nextcheckpoints_ = Vector3::ZERO;
+        this->bIsLast_ = false;
+        this->timeLimit_ = 0;
+        this->player_ = NULL;
     }
-    
 
+
    RaceCheckPoint::~RaceCheckPoint()
    {
-    
    }
 
-    void RaceCheckPoint::tick(float dt)
-    {
-        SUPER(RaceCheckPoint, tick, dt);
-
-        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
-        assert(gametype);
-    }
-
     void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
-        Vector3 v= Vector3(0,0,0);
+
         XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
-        XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
+        XMLPortParam(RaceCheckPoint, "islast", setLast, isLast, xmlelement, mode).defaultValues(false);
         XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
-    XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
+        XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode, const Vector3&).defaultValues(Vector3::ZERO);
     }
 
-    void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
+    void RaceCheckPoint::fire(bool bIsTriggered, BaseObject* originator)
     {
-        DistanceMultiTrigger::fire((bool)bIsTriggered,player);
-        
-        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
-        assert(gametype);
-        ControllableEntity* entity = (ControllableEntity*) player;
-     
-        PlayerInfo* player2 = entity->getPlayer();
-     
-        if(bIsTriggered)
-            this->reached_=player2;
+        DistanceMultiTrigger::fire(bIsTriggered, originator);
+
+        if (bIsTriggered)
+        {
+            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
+            if (entity)
+                this->player_ = entity->getPlayer();
+        }
     }
 
     void RaceCheckPoint::setTimelimit(float timeLimit)
     {
-        this->bTimeLimit_ = timeLimit;
-        if (this->bTimeLimit_ != 0)
+        this->timeLimit_ = timeLimit;
+        if (this->timeLimit_ != 0)
         {
-            SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
-            assert(gametype);
-            if (gametype)
-            {
-                const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)
-                            + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1);
-                const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
-                ChatManager::message(message);
-            }
+            std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
+                        + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
+            const_cast<GametypeInfo*>(this->getGametype()->getGametypeInfo())->sendAnnounceMessage(message);
+            ChatManager::message(message);
         }
     }
-
 }

Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.h	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.h	2012-06-02 20:34:48 UTC (rev 9260)
@@ -30,9 +30,6 @@
 #define _RaceCheckPoint_H__
 
 #include "gametypes/GametypesPrereqs.h"
-
-
-
 #include "objects/triggers/DistanceMultiTrigger.h"
 #include "interfaces/RadarViewable.h"
 
@@ -41,7 +38,7 @@
     /**
     @brief
         The RaceCheckPoint class enables the creation of a check point to use in a SpaceRace level.
-         Don't forget to control the indexes of your check points and to set one last check point
+        Don't forget to control the indexes of your check points and to set one last check point
     */
     class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable
     {
@@ -50,41 +47,45 @@
             virtual ~RaceCheckPoint();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void tick(float dt);
+
             inline void setCheckpointIndex(int checkpointIndex)
-                { this->bCheckpointIndex_ = checkpointIndex; }
-            inline int getCheckpointIndex()
-                { return this->bCheckpointIndex_; }
+                { this->checkpointIndex_ = checkpointIndex; }
+            inline int getCheckpointIndex() const
+                { return this->checkpointIndex_; }
 
             inline void setNextcheckpoint(const Vector3& checkpoints)
-                { this->nextcheckpoints_=checkpoints; }
+                { this->nextcheckpoints_ = checkpoints; }
             inline void setNextcheckpoint(float x, float y, float z)
                 { this->setNextcheckpoint(Vector3(x, y, z)); }
             inline const Vector3& getNextcheckpoint() const
                 { return this->nextcheckpoints_; }
+
             inline void setLast(bool isLast)
                 { this->bIsLast_ = isLast; }
-            inline bool getLast()
+            inline bool isLast() const
                 { return this->bIsLast_; }
 
-            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.
-            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.
-            PlayerInfo* reached_;
-                
-            inline float getTimeLimit()
-                { return this->bTimeLimit_; }
-    
+            virtual void setTimelimit(float timeLimit);
+            inline float getTimeLimit() const
+                { return this->timeLimit_; }
+
+            inline PlayerInfo* getPlayer() const
+                { return this->player_; }
+            inline void resetPlayer()
+                { this->player_ = NULL; }
+
         protected:
-            virtual void fire(bool bIsTriggered,BaseObject* player);
-            virtual void setTimelimit(float timeLimit);
-            
+            virtual void fire(bool bIsTriggered, BaseObject* originator);
+
             inline const WorldEntity* getWorldEntity() const
                 { return this; }
 
         private:
-            int bCheckpointIndex_; //The index of this check point. The race starts with the check point with the index 0
-            Vector3 nextcheckpoints_; //the indexes of the next check points
-            
+            int checkpointIndex_;     ///< The index of this check point. The race starts with the check point with the index 0
+            Vector3 nextcheckpoints_; ///< the indexes of the next check points
+            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.
+            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.
+            PlayerInfo* player_;      ///< The player that reached the checkpoint
     };
 }
 

Modified: code/trunk/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRace.cc	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/modules/gametypes/SpaceRace.cc	2012-06-02 20:34:48 UTC (rev 9260)
@@ -28,7 +28,6 @@
 
 #include "SpaceRace.h"
 
-
 #include "items/Engine.h"
 
 #include "core/CoreIncludes.h"
@@ -45,135 +44,84 @@
     SpaceRace::SpaceRace(BaseObject* creator) : Gametype(creator)
     {
         RegisterObject(SpaceRace);
-        
+
+        this->cantMove_ = false;
         this->bTimeIsUp_ = false;
-        this->numberOfBots_ = 0;
-        this->cantMove_=false;
-        
     }
-       
-    
-  // void SpaceRace::SetConfigValues(){
-    //SUPER(Gametype,setConfigValues);
-    //this->Gametype::SetConfigValue(initialStartCountdown_, 3.0f);}
 
     void SpaceRace::end()
     {
         this->Gametype::end();
 
+        this->clock_.capture();
+        int s = this->clock_.getSeconds();
+        int ms = static_cast<int>(this->clock_.getMilliseconds() - 1000*s);
+        std::string message;
+
         if (this->bTimeIsUp_)
         {
-            this->clock_.capture();
-            int s = this->clock_.getSeconds();
-            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
-            const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
+            message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
                         + "You didn't reach the check point  before the time limit. You lose!";
-            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
-            ChatManager::message(message);
         }
         else
         {
-            this->clock_.capture();
-            int s = this->clock_.getSeconds();
-            int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
-            const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
+            message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
                         + "." + multi_cast<std::string>(ms) + " seconds.";
-            const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
-            ChatManager::message(message);
-
-            float time = this->clock_.getSecondsPrecise();
-            this->scores_.insert(time);
-            std::set<float>::iterator it;
-            
-
         }
+
+        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+        ChatManager::message(message);
     }
 
     void SpaceRace::start()
     {
-
         this->spawnPlayersIfRequested();
-        Gametype::checkStart(); 
-        this->cantMove_=true; 
-        
-        for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 
-        {
+        Gametype::checkStart();
+        this->cantMove_ = true;
+
+        for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
             it->setActive(false);
-            
-        } 
-        this->addBots(this->numberOfBots_); 
+
+        this->addBots(this->numberOfBots_);
     }
-    
+
     void SpaceRace::tick(float dt)
     {
         SUPER(SpaceRace,tick,dt);
-    
-        if(!this->isStartCountdownRunning() && this->cantMove_)
+
+        if (!this->isStartCountdownRunning() && this->cantMove_)
         {
-            for(ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it) 
-            { 
+            for (ObjectList<Engine>::iterator it = ObjectList<Engine>::begin(); it; ++it)
                 it->setActive(true);
-                
-            }
+
             this->cantMove_= false;
-            
-            std::string message("The match has started! Reach the check points as quickly as possible!");
+
+            std::string message = "The match has started! Reach the check points as quickly as possible!";
             const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
-            ChatManager::message(message);            
+            ChatManager::message(message);
         }
-   
     }
 
-    
-    
-    void SpaceRace::newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl)
+    void SpaceRace::newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player)
     {
-        this->checkpointReached_[pl]=index;
+        int index = checkpoint->getCheckpointIndex();
+        this->checkpointReached_[player] = index;
         this->clock_.capture();
         int s = this->clock_.getSeconds();
-        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
+        int ms = this->clock_.getMilliseconds() % 1000;
         const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
-            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
-            + " seconds.";// Message is too long for a normal screen.
+            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds.";
         const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
         ChatManager::message(message);
     }
-   
-    void SpaceRace::newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl)
-    {   
-        int index = p->getCheckpointIndex();
-        this->checkpointReached_[pl]=index;
-        this->clock_.capture();
-        int s = this->clock_.getSeconds();
-        int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
-        const std::string& message = "Checkpoint " + multi_cast<std::string>(index)
-            + " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
-            + " seconds.";
-        const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
-        ChatManager::message(message);
-    }
-        
-    
+
     void SpaceRace::playerEntered(PlayerInfo* player)
     {
         Gametype::playerEntered(player);
-    
-        this->checkpointReached_[player]=-1;
-        //this->playersAlive_++;
-    }
-    
-    bool SpaceRace::playerLeft(PlayerInfo* player)
-    {
-        return Gametype::playerLeft(player);
-        // bool valid_player = true;
-        //if (valid_player)
-       // {
-        //    this->playersAlive_--;
-        //}
 
-       // return valid_player;
+        this->checkpointReached_[player] = -1;
     }
-    
+
     bool SpaceRace::allowPawnHit(Pawn* victim, Pawn* originator)
     {
         return false;

Modified: code/trunk/src/modules/gametypes/SpaceRace.h
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRace.h	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/modules/gametypes/SpaceRace.h	2012-06-02 20:34:48 UTC (rev 9260)
@@ -43,51 +43,49 @@
 
 namespace orxonox
 {
-  /**
-  @brief
-    The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
-  */
+    /**
+    @brief
+        The SpaceRace class enables the creation of a space race level, where the player has to reach check points in a given order.
+    */
     class _GametypesExport SpaceRace : public Gametype
     {
         friend class RaceCheckPoint;
-       
 
+
         public:
             SpaceRace(BaseObject* creator);
             virtual ~SpaceRace() {}
 
+            void tick(float dt);
+
             virtual void start();
             virtual void end();
 
-            virtual void newCheckpointReached(SpaceRaceManager* p, int index,PlayerInfo* pl);
-            virtual void newCheckpointReached(RaceCheckPoint* p, PlayerInfo* pl);
+            virtual void newCheckpointReached(RaceCheckPoint* checkpoint, PlayerInfo* player);
 
-            inline void setCheckpointReached(int n, PlayerInfo* p)
-                { this->checkpointReached_[p] = n;}
-            inline int getCheckpointReached(PlayerInfo* p)
-                { return this->checkpointReached_[p]; }
+            inline void setCheckpointReached(int index, PlayerInfo* player)
+                { this->checkpointReached_[player] = index;}
+            inline int getCheckpointReached(PlayerInfo* player)
+                { return this->checkpointReached_[player]; }
 
-            inline void timeIsUp()
+            inline void setTimeIsUp()
                 { this->bTimeIsUp_ = true;}
-            void tick(float dt);
-            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.
+            inline Clock& getClock()
+                { return this->clock_; }
 
-
             bool allowPawnHit(Pawn* victim, Pawn* originator);
-
             bool allowPawnDamage(Pawn* victim, Pawn* originator);
-
             bool allowPawnDeath(Pawn* victim, Pawn* originator);
+
         protected:
-            virtual void playerEntered(PlayerInfo* player); //!< Initializes values.
-            virtual bool playerLeft(PlayerInfo* player); //!< Manages all local variables.
+            virtual void playerEntered(PlayerInfo* player); ///< Initializes values.
+
         private:
             bool cantMove_;
-            std::map<PlayerInfo*, int>checkpointReached_; //The number of the last check point reached by each player.
-            std::set<float> scores_; //The times of the players are saved in a set.
-            bool bTimeIsUp_; //True if one of the check points is reached too late.
-            
-            int playersAlive_;
+            std::map<PlayerInfo*, int> checkpointReached_; ///< The number of the last check point reached by each player.
+            bool bTimeIsUp_;                               ///< True if one of the check points is reached too late.
+
+            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.
     };
 }
 

Modified: code/trunk/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRaceManager.cc	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/modules/gametypes/SpaceRaceManager.cc	2012-06-02 20:34:48 UTC (rev 9260)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *     Celine Eggenberger
+ *      Celine Eggenberger
  *   Co-authors:
  *      ...
  *
@@ -46,20 +46,40 @@
     SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
     {
         RegisterObject(SpaceRaceManager);
-         
-        this->firstcheckpointvisible_=false;
-         
+
+        this->firstcheckpointvisible_ = false;
     }
 
     SpaceRaceManager::~SpaceRaceManager()
     {
-        if (this->isInitialized())
+        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+            this->checkpoints_[i]->destroy();
+    }
+
+    void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
+
+        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
+    }
+
+    void SpaceRaceManager::tick(float dt)
+    {
+        SUPER(SpaceRaceManager,tick,dt);
+
+        if (this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
         {
-            for (size_t i = 0; i < this->checkpoints_.size(); ++i)
-                this->checkpoints_[i]->destroy();
+            this->checkpoints_[0]->setRadarVisibility(true);
+            this->firstcheckpointvisible_ = true;
         }
+
+        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+        {
+            if (this->checkpoints_[i]->getPlayer() != NULL)
+                this->checkpointReached(this->checkpoints_[i], this->checkpoints_[i]->getPlayer());
+        }
     }
-   
+
     void SpaceRaceManager::addCheckpoint(RaceCheckPoint* checkpoint)
     {
         this->checkpoints_.push_back(checkpoint);
@@ -72,124 +92,93 @@
         else
             return 0;
     }
-    
-    int SpaceRaceManager::getIndex(RaceCheckPoint* r) 
+
+    int SpaceRaceManager::getIndex(RaceCheckPoint* checkpoint)
     {
         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
-            if (this->checkpoints_[i]==r) {return i;}
-           
+            if (this->checkpoints_[i] == checkpoint)
+                return i;
+
         return -1;
     }
-    
-    void SpaceRaceManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
 
-        
-        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
-    }
-    
-    void SpaceRaceManager::tick(float dt)
-    {
-        SUPER(SpaceRaceManager,tick,dt);
-     
-        if(this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
-        {
-            this->checkpoints_[0]->setRadarVisibility(true);
-            this->firstcheckpointvisible_=true;
-        }
-         
-        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
-        {
-            if(this->checkpoints_[i]->reached_!=NULL)
-                this->checkpointReached(this->checkpoints_[i],this->checkpoints_[i]->reached_);
-        }
-    }
-    
-    
     void SpaceRaceManager::checkpointReached(RaceCheckPoint* check, PlayerInfo* player)
     {
         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
         assert(gametype);
-        
-        bool b =false;    
-            
-        int index=gametype->getCheckpointReached(player);
-        Vector3 v=Vector3 (-1,-1,-1);
-        if (index>-1)
+
+        bool reachedValidCheckpoint = false;
+
+        int index = gametype->getCheckpointReached(player);
+        if (index > -1)
         {
-            RaceCheckPoint* tmp= this->getCheckpoint(index);
-            v= tmp->getNextcheckpoint();
-       
+            Vector3 v = this->getCheckpoint(index)->getNextcheckpoint();
+
             if (this->getCheckpoint(v.x) == check)
             {
-                b = true;
-            }    
-       
+                reachedValidCheckpoint = true;
+            }
             if (this->getCheckpoint(v.y) == check)
             {
-                b = true;
-            }    
+                reachedValidCheckpoint = true;
+            }
             if (this->getCheckpoint(v.z) == check)
             {
-                b = true;
-            }    
+                reachedValidCheckpoint = true;
+            }
         }
         else
         {
-            b = (this->getIndex(check) == 0);
+            reachedValidCheckpoint = (this->getIndex(check) == 0);
         }
-            
-        if (gametype && b)
+
+        if (gametype && reachedValidCheckpoint)
         {
-            gametype->clock_.capture();
-            float time = gametype->clock_.getSecondsPrecise();
-            if (check->getTimeLimit()!=0 && time > check->getTimeLimit())
+            gametype->getClock().capture();
+            float time = gametype->getClock().getSecondsPrecise();
+            if (check->getTimeLimit() != 0 && time > check->getTimeLimit())
             {
-                gametype->timeIsUp();
+                gametype->setTimeIsUp();
                 gametype->end();
             }
-            else if (check->getLast())
+            else if (check->isLast())
                 gametype->end();
             else
-				{
-                if (index > -1)this->setRadVis(player,false);
-                	else this->getCheckpoint(0)->setRadarVisibility(false);
-                gametype->newCheckpointReached(check,player);
-               
-                
+			{
+                if (index > -1)
+                    this->setRadVis(player, false);
+                else
+                    this->getCheckpoint(0)->setRadarVisibility(false);
+
+                gametype->newCheckpointReached(check, player);
                 this->setRadVis(player, true);
             }
         }
-        check->reached_=NULL;
+
+        check->resetPlayer();
     }
-    
-    void SpaceRaceManager::setRadVis(PlayerInfo* player, bool b)
+
+    void SpaceRaceManager::setRadVis(PlayerInfo* player, bool bVisible)
     {
         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
         assert(gametype);
         int index = gametype->getCheckpointReached(player);
-        Vector3 v = Vector3(-1,-1,-1);
-        RaceCheckPoint* tmp = this->getCheckpoint(index);
-        v = tmp->getNextcheckpoint();
-    
-        if(v.x > -1)
+        Vector3 v = this->getCheckpoint(index)->getNextcheckpoint();
+
+        if (v.x > -1)
         {
-            this->getCheckpoint(v.x)->setRadarVisibility(b);
+            this->getCheckpoint(v.x)->setRadarVisibility(bVisible);
             this->getCheckpoint(v.x)->settingsChanged();
         }
-        if(v.y > -1)
+        if (v.y > -1)
         {
-            this->getCheckpoint(v.y)->setRadarVisibility(b);
+            this->getCheckpoint(v.y)->setRadarVisibility(bVisible);
             this->getCheckpoint(v.y)->settingsChanged();
         }
-        if(v.z > -1)
+        if (v.z > -1)
         {
-            this->getCheckpoint(v.z)->setRadarVisibility(b);
-           this->getCheckpoint(v.z)->settingsChanged();
+            this->getCheckpoint(v.z)->setRadarVisibility(bVisible);
+            this->getCheckpoint(v.z)->settingsChanged();
         }
-        
-        
     }
-    
 }

Modified: code/trunk/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRaceManager.h	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/modules/gametypes/SpaceRaceManager.h	2012-06-02 20:34:48 UTC (rev 9260)
@@ -45,34 +45,34 @@
 
 namespace orxonox
 {
-  /**
-  @brief
-    The SpaceRaceManager class controls a space race level, where the player has to reach check points in a given order.
-  */
+    /**
+    @brief
+        The SpaceRaceManager class controls a space race level, where the player has to reach check points in a given order.
+    */
     class _GametypesExport SpaceRaceManager : public BaseObject, public Tickable
     {
         friend class RaceCheckPoint;
-    
+
         public:
             SpaceRaceManager(BaseObject* creator);
             virtual ~SpaceRaceManager() ;
 
-            void XMLPort(Element& xmlelement, XMLPort::Mode mode); 
-            int getIndex(RaceCheckPoint* r);
+            void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
             void addCheckpoint(RaceCheckPoint* checkpoint);
             RaceCheckPoint* getCheckpoint(unsigned int index) const;
-        
+            int getIndex(RaceCheckPoint* checkpoint);
+
             void checkpointReached(RaceCheckPoint* check, PlayerInfo* player);
-        
+
             void tick(float dt);
-    
+
         protected:
-            void setRadVis(PlayerInfo* player, bool b);//sets RadarVisibility of the checkpoints the player can reach.
-    
+            void setRadVis(PlayerInfo* player, bool bVisible); ///< sets RadarVisibility of the checkpoints the player can reach.
+
         private:
             std::vector<RaceCheckPoint*> checkpoints_;
-            bool firstcheckpointvisible_;//true if the first check point is visible.
-        
+            bool firstcheckpointvisible_; ///< true if the first check point is visible.
     };
 }
 

Modified: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc	2012-06-02 20:34:48 UTC (rev 9260)
@@ -122,7 +122,7 @@
 
         if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
             this->gtinfo_->countdownStartCountdown(dt);
-			
+
         if (!this->gtinfo_->hasStarted())
         {
             for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
@@ -130,9 +130,8 @@
                 // Inform the GametypeInfo that the player is ready to spawn.
                 if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
                     this->gtinfo_->playerReadyToSpawn(it->first);
-                   
-                
             }
+
             this->checkStart();
         }
         else if (!this->gtinfo_->hasEnded())
@@ -143,14 +142,11 @@
 
     void Gametype::start()
     {
-         
         this->addBots(this->numberOfBots_);
 
         this->gtinfo_->start();
 
         this->spawnPlayersIfRequested();
-        
-        
     }
 
     void Gametype::end()
@@ -400,7 +396,7 @@
                         if (it->first->isHumanPlayer())
                             hashumanplayers = true;
                     }
-                         
+
                     if (allplayersready && hashumanplayers)
                     {
                         // If in developer's mode, there is no start countdown.
@@ -412,7 +408,6 @@
                     }
                 }
             }
-            
         }
     }
 

Modified: code/trunk/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.h	2012-05-28 14:47:47 UTC (rev 9259)
+++ code/trunk/src/orxonox/gametypes/Gametype.h	2012-06-02 20:34:48 UTC (rev 9260)
@@ -151,10 +151,9 @@
 
             virtual void resetTimer();
             virtual void resetTimer(float t);
-            inline unsigned int getNumberOfPlayers()
-              { return this->gtinfo_->getNumberOfPlayers(); }
 
-	
+            inline unsigned int getNumberOfPlayers() const
+                { return this->gtinfo_->getNumberOfPlayers(); }
 
         protected:
             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;




More information about the Orxonox-commit mailing list