Index: code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc	(revision 9409)
+++ code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc	(revision 9412)
@@ -43,9 +43,10 @@
     CreateFactory(RaceCheckPoint);
 
-    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
+    RaceCheckPoint::RaceCheckPoint(BaseObject* creator) :
+        DistanceMultiTrigger(creator), RadarViewable(creator,
+                static_cast<WorldEntity*> (this))
     {
-        RegisterObject(RaceCheckPoint);
-
-        this->setDistance(100);
+        RegisterObject(RaceCheckPoint)
+;        this->setDistance(100);
         this->setBeaconMode("off");
         this->setBroadcast(false);
@@ -60,11 +61,11 @@
         this->bIsLast_ = false;
         this->timeLimit_ = 0;
-        this->player_ = NULL;
+        //this->players_ = vector<PlayerInfo*>();
     }
 
+    RaceCheckPoint::~RaceCheckPoint()
+    {
 
-   RaceCheckPoint::~RaceCheckPoint()
-   {
-   }
+    }
 
     void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -86,5 +87,5 @@
             ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
             if (entity)
-                this->player_ = entity->getPlayer();
+            this->players_.push_back(entity->getPlayer());
         }
     }
@@ -95,6 +96,6 @@
         if (this->timeLimit_ != 0)
         {
-            std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
-                        + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
+            std::string message = "You have " + multi_cast<std::string>(this->timeLimit_)
+            + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
             this->getGametype()->getGametypeInfo()->sendAnnounceMessage(message);
             ChatManager::message(message);
@@ -107,9 +108,39 @@
 
         if (checkpoints.x > -1)
-            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));
+        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));
         if (checkpoints.y > -1)
-            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
+        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
         if (checkpoints.z > -1)
-            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
+        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
+    }
+
+    PlayerInfo* RaceCheckPoint::getPlayer(unsigned int clientID) const
+    {
+        if (players_.size() > 0)
+        {
+            for (int i = 0; i < players_.size(); i++)
+            {
+                if (this->players_[i]->getClientID() == clientID)
+                {
+                    return players_[i];
+                }
+            }
+        }
+        return NULL;
+    }
+
+    bool RaceCheckPoint::playerWasHere(PlayerInfo* player) const
+    {
+        if (players_.size() > 0)
+        {
+            for (int i = 0; i < players_.size(); i++)
+            {
+                if (this->players_[i] == player)
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
     }
 
Index: code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h	(revision 9409)
+++ code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h	(revision 9412)
@@ -37,9 +37,10 @@
 {
     /**
-    @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
-    */
-    class _GametypesExport RaceCheckPoint : public DistanceMultiTrigger, public RadarViewable
+     @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
+     */
+    class _GametypesExport RaceCheckPoint: public DistanceMultiTrigger,
+            public RadarViewable
     {
         public:
@@ -50,26 +51,42 @@
 
             inline void setCheckpointIndex(int checkpointIndex)
-                { this->checkpointIndex_ = checkpointIndex; }
+            {
+                this->checkpointIndex_ = checkpointIndex;
+            }
             inline int getCheckpointIndex() const
-                { return this->checkpointIndex_; }
+            {
+                return this->checkpointIndex_;
+            }
 
             void setNextCheckpointsAsVector3(const Vector3& checkpoints);
             Vector3 getNextCheckpointsAsVector3() const;
             const std::set<int>& getNextCheckpoints() const
-                { return this->nextCheckpoints_; }
+            {
+                return this->nextCheckpoints_;
+            }
 
             inline void setLast(bool isLast)
-                { this->bIsLast_ = isLast; }
+            {
+                this->bIsLast_ = isLast;
+            }
             inline bool isLast() const
-                { return this->bIsLast_; }
+            {
+                return this->bIsLast_;
+            }
 
             virtual void setTimelimit(float timeLimit);
             inline float getTimeLimit() const
-                { return this->timeLimit_; }
+            {
+                return this->timeLimit_;
+            }
 
-            inline PlayerInfo* getPlayer() const
-                { return this->player_; }
+            PlayerInfo* getPlayer(unsigned int clientID) const;
+
+            bool playerWasHere(PlayerInfo* ) const;
+
             inline void resetPlayer()
-                { this->player_ = NULL; }
+            {
+                this->players_.clear();
+            }
 
         protected:
@@ -77,12 +94,14 @@
 
             inline const WorldEntity* getWorldEntity() const
-                { return this; }
+            {
+                return this;
+            }
 
         private:
-            int checkpointIndex_;           ///< The index of this check point. The race starts with the check point with the index 0
+            int checkpointIndex_; ///< The index of this check point. The race starts with the check point with the index 0
             std::set<int> 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
+            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.
+            std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
     };
 }
Index: code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc	(revision 9409)
+++ code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc	(revision 9412)
@@ -1,4 +1,22 @@
 /*
- * SpaceRaceController.cc
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *  Created on: Oct 8, 2012
@@ -9,4 +27,5 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
+#include "gametypes/SpaceRaceManager.h"
 
 
@@ -17,15 +36,43 @@
 {
 
+    /*
+     * Idea: Find static Point (checkpoints the spaceship has to reach)
+     */
 SpaceRaceController::SpaceRaceController(BaseObject* creator): ArtificialController(creator)
 {
 
-    std::vector<RaceCheckPoint*> wayOptions = NULL;
-    std::vector<RaceCheckPoint*> wayChosen = new std::vector<RaceCheckPoint*>();
+    std::vector<RaceCheckPoint*> checkpoints;
     // TODO Auto-generated constructor stub
     for (ObjectList<SpaceRaceManager >::iterator it = ObjectList<SpaceRaceManager>::begin(); it != ObjectList<SpaceRaceManager>::end(); ++it)
-        wayOptions=it->getAllCheckpoints();
+        checkpoints=it->getAllCheckpoints();
+    //OrxAssert(checkpoints, "No Checkpoints in Level");
 
 
 }
+/*
+RaceCheckPoint* SpaceRaceController::nextPoint(){
+    return NULL;
+}*/
+
+std::vector<RaceCheckPoint*> SpaceRaceController::findStaticCheckpoints(std::vector<RaceCheckPoint*> allCheckpoints){
+    std::map< RaceCheckPoint*, int> * zaehler= new std::map< RaceCheckPoint*, int>(); // counts how many times the checkpoit was reached for simulation
+    for (unsigned int i=0; i<allCheckpoints.size() ; i++){
+        zaehler->insert ( std::pair<RaceCheckPoint*,int>(allCheckpoints[i], 0));
+    }
+    rekSimulationCheckpointsReached(zaehler->begin()->first, & allCheckpoints, zaehler);
+    //Werte auslesen und statische Checkpoints bestimmen
+    delete zaehler;
+
+}
+
+void SpaceRaceController::rekSimulationCheckpointsReached(RaceCheckPoint* currentCheckpoint, std::vector<RaceCheckPoint*>* checkpoints, std::map< RaceCheckPoint*, int>* zaehler){
+    zaehler->at(currentCheckpoint)++;
+    if(!currentCheckpoint->isLast()){
+        for( std::set<int>::iterator it=currentCheckpoint->getNextCheckpoints().begin(); it != currentCheckpoint->getNextCheckpoints().end(); ++it){
+            rekSimulationCheckpointsReached( (*checkpoints)[(*it)], checkpoints, zaehler);
+        }
+    }
+}
+
 
 SpaceRaceController::~SpaceRaceController()
Index: code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h	(revision 9409)
+++ code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h	(revision 9412)
@@ -1,4 +1,23 @@
 /*
- * SpaceRaceController.h
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
  *
  *  Created on: Oct 8, 2012
@@ -12,5 +31,5 @@
 #include "controllers/ArtificialController.h"
 #include "gametypes/Gametype.h"
-
+#include "gametypes/RaceCheckPoint.h"
 
 
@@ -19,7 +38,11 @@
     class _GametypesExport SpaceRaceController : public ArtificialController, public Tickable
     {
-        private:
+        private:/*
             vector<RaceCheckPoint*> lastRaceCheckpoint;
-            vector<RaceCheckPoint*> nextRaceCheckpoint;
+            vector<RaceCheckPoint*> nextRaceCheckpoint;*/
+            //RaceCheckPoint* nextPoint();
+            std::vector<RaceCheckPoint*> findStaticCheckpoints(std::vector<RaceCheckPoint*>);
+            std::vector<RaceCheckPoint*> staticCheckpoints();
+            void rekSimulationCheckpointsReached(RaceCheckPoint* , std::vector<RaceCheckPoint*>* checkpoints, std::map< RaceCheckPoint*, int>*);
         public:
           SpaceRaceController(BaseObject* creator);
Index: code/branches/Racingbot/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/SpaceRaceManager.cc	(revision 9409)
+++ code/branches/Racingbot/src/modules/gametypes/SpaceRaceManager.cc	(revision 9412)
@@ -38,15 +38,17 @@
 #include "util/Math.h"
 
-
-
 namespace orxonox
 {
     CreateFactory(SpaceRaceManager);
 
-    SpaceRaceManager::SpaceRaceManager(BaseObject* creator) : BaseObject(creator)
+    SpaceRaceManager::SpaceRaceManager(BaseObject* creator) :
+        BaseObject(creator)
     {
-        RegisterObject(SpaceRaceManager);
-
+        RegisterObject(SpaceRaceManager)
+;        this->race_ = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        assert(race_);
+        //amountOfPlayers=(race_->getPlayers()).size();
         this->firstcheckpointvisible_ = false;
+        this->players_ = this->race_->getPlayers();
     }
 
@@ -54,5 +56,5 @@
     {
         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
-            this->checkpoints_[i]->destroy();
+        this->checkpoints_[i]->destroy();
     }
 
@@ -61,5 +63,5 @@
         SUPER(SpaceRaceManager, XMLPort, xmlelement, mode);
 
-        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint,  xmlelement, mode);
+        XMLPortObject(SpaceRaceManager, RaceCheckPoint, "checkpoints", addCheckpoint, getCheckpoint, xmlelement, mode);
     }
 
@@ -74,9 +76,13 @@
         }
 
-        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+        for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)
         {
-            if (this->checkpoints_[i]->getPlayer() != NULL)
-                this->checkpointReached(this->checkpoints_[i], this->checkpoints_[i]->getPlayer());
+            for (size_t i = 0; i < this->checkpoints_.size(); ++i)
+            {
+                if (this->checkpoints_[i]->playerWasHere(it->first))
+                this->checkpointReached(this->checkpoints_[i], it->first /*this->checkpoints_[i]->getPlayer()*/);
+            }
         }
+
     }
 
@@ -89,21 +95,22 @@
     {
         if (index < this->checkpoints_.size())
-            return this->checkpoints_[index];
+        return this->checkpoints_[index];
         else
-            return 0;
+        return 0;
     }
 
-    std::vector<RaceCheckPoint*> SpaceRaceManager::getAllCheckpoints(){
+    std::vector<RaceCheckPoint*> SpaceRaceManager::getAllCheckpoints()
+    {
         return checkpoints_;
     }
 
     /**
-        @brief Returns the checkpoint with the given checkpoint-index (@see RaceCheckPoint::getCheckpointIndex).
-    */
+     @brief Returns the checkpoint with the given checkpoint-index (@see RaceCheckPoint::getCheckpointIndex).
+     */
     RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const
     {
         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
-            if (this->checkpoints_[i]->getCheckpointIndex() == index)
-                return this->checkpoints_[i];
+        if (this->checkpoints_[i]->getCheckpointIndex() == index)
+        return this->checkpoints_[i];
         return 0;
     }
@@ -111,11 +118,11 @@
     bool SpaceRaceManager::reachedValidCheckpoint(RaceCheckPoint* oldCheckpoint, RaceCheckPoint* newCheckpoint, PlayerInfo* player) const
     {
-        if (oldCheckpoint)
+        if (oldCheckpoint != NULL)
         {
             // the player already visited an old checkpoint; see which checkpoints are possible now
             const std::set<int>& possibleCheckpoints = oldCheckpoint->getNextCheckpoints();
             for (std::set<int>::const_iterator it = possibleCheckpoints.begin(); it != possibleCheckpoints.end(); ++it)
-                if (this->findCheckpoint(*it) == newCheckpoint)
-                    return true;
+            if (this->findCheckpoint(*it) == newCheckpoint)
+            return true;
             return false;
         }
@@ -132,7 +139,7 @@
         assert(gametype);
         if (!gametype)
-            return;
+        return;
 
-        RaceCheckPoint* oldCheckpoint = gametype->getCheckpointReached(player);
+        RaceCheckPoint* oldCheckpoint = gametype->getCheckpointReached(player); // returns the last from player reached checkpoint
 
         if (this->reachedValidCheckpoint(oldCheckpoint, newCheckpoint, player))
@@ -160,5 +167,5 @@
         }
 
-        newCheckpoint->resetPlayer();
+        // newCheckpoint->resetPlayer(); loescht playerpointer TODO: check if problems occur
     }
 
@@ -169,5 +176,5 @@
             const std::set<int>& oldVisible = oldCheckpoint->getNextCheckpoints();
             for (std::set<int>::const_iterator it = oldVisible.begin(); it != oldVisible.end(); ++it)
-                this->findCheckpoint(*it)->setRadarVisibility(false);
+            this->findCheckpoint(*it)->setRadarVisibility(false);
         }
 
@@ -178,5 +185,5 @@
             const std::set<int>& newVisible = newCheckpoint->getNextCheckpoints();
             for (std::set<int>::const_iterator it = newVisible.begin(); it != newVisible.end(); ++it)
-                this->findCheckpoint(*it)->setRadarVisibility(true);
+            this->findCheckpoint(*it)->setRadarVisibility(true);
         }
     }
Index: code/branches/Racingbot/src/modules/gametypes/SpaceRaceManager.h
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/SpaceRaceManager.h	(revision 9409)
+++ code/branches/Racingbot/src/modules/gametypes/SpaceRaceManager.h	(revision 9412)
@@ -78,4 +78,7 @@
             std::vector<RaceCheckPoint*> checkpoints_;
             bool firstcheckpointvisible_; ///< true if the first check point is visible.
+            SpaceRace* race_; // needed to get the players
+            //int amountOfPlayers;
+            std::map<PlayerInfo*, Player> players_;
     };
 }
