Index: code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc	(revision 9437)
+++ code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc	(revision 9441)
@@ -43,10 +43,9 @@
     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);
@@ -62,4 +61,8 @@
         this->timeLimit_ = 0;
         //this->players_ = vector<PlayerInfo*>();
+
+        myPosition_= this->getPosition();
+        orxout(user_status) << "test" << std::endl;
+
     }
 
@@ -87,5 +90,5 @@
             ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
             if (entity)
-            this->players_.push_back(entity->getPlayer());
+                this->players_.push_back(entity->getPlayer());
         }
     }
Index: code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h	(revision 9437)
+++ code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h	(revision 9441)
@@ -104,4 +104,5 @@
             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
+            Vector3 myPosition_;
     };
 }
Index: code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc	(revision 9437)
+++ code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc	(revision 9441)
@@ -23,5 +23,9 @@
  *      Author: purgham
  */
-
+ /**
+  * Conventions:
+  * -first Checkpoint has index 0
+  *
+  */
 #include <gametypes/SpaceRaceController.h>
 #include "core/CoreIncludes.h"
@@ -29,6 +33,7 @@
 #include "gametypes/SpaceRaceManager.h"
 
-// WEnn RAcer nach start erstellt wird fehler in Tick
-// Fuer beide Spieler wird next point angezeigt
+
+
+
 namespace orxonox
 {
@@ -50,6 +55,13 @@
 
         OrxAssert(!checkpoints.empty(), "No Checkpoints in Level");
+        //OrxAssert(1==2, "Orxassert test");
         checkpoints_=checkpoints;
         staticRacePoints_ = findStaticCheckpoints(checkpoints);
+        for (int i=0; true; i++){
+            if(checkpoints_[i]->getCheckpointIndex()==0){
+                nextRaceCheckpoint_=checkpoints_[i];
+                break;
+            }
+        }
 
     }
@@ -66,10 +78,9 @@
     RaceCheckPoint* SpaceRaceController::nextPointFind(RaceCheckPoint* raceCheckpoint)
     {
-        int distances[] =
-        {   -1, -1, -1};
+        int distances[] ={   -1, -1, -1};
         int temp_i = 0;
         for (std::set<int>::iterator it =raceCheckpoint->getNextCheckpoints().begin(); it!= raceCheckpoint->getNextCheckpoints().end(); ++it)
         {
-            distances[temp_i] = recCalculateDistance(raceCheckpoint,this->getControllableEntity()->getPosition());
+            distances[temp_i] = recCalculateDistance(raceCheckpoint, this->getControllableEntity()->getPosition());
             temp_i++;
         }
@@ -119,4 +130,5 @@
     int SpaceRaceController::recCalculateDistance(RaceCheckPoint* currentCheckPoint, Vector3 currentPosition)
     {
+        orxout()<< "rec Aufruf" << endl;
         // if ( staticCheckPoint was reached)
         if (std::find(staticRacePoints_.begin(), staticRacePoints_.end(),currentCheckPoint) != staticRacePoints_.end())
@@ -127,8 +139,20 @@
         {
             int minimum = std::numeric_limits<int>::max();
+            int temp=0;
             for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it!= currentCheckPoint->getNextCheckpoints().end(); ++it)
-            {
-                minimum= std::min(minimum,(int) (currentPosition- currentCheckPoint->getPosition()).length() + recCalculateDistance(checkpoints_[(*it)], currentCheckPoint->getPosition()));
-            }//TODO: fix cast
+            { //temp++;
+                WorldEntity* ttt= dynamic_cast<WorldEntity*> (currentCheckPoint);
+                OrxAssert(!(ttt==NULL), "WorldEntity null");
+                OrxAssert(!(ttt->getNode()==NULL), "Node of WorldEntity is null");
+
+                //orxout()<< temp <<endl;
+                //if(temp==1){orxout()<<currentCheckPoint << " == null?  => "<<(currentCheckPoint==NULL)<<currentPosition<<endl;}
+                Vector3 t=(currentPosition- ttt->getPosition()); //TODO: Find Crash Reason. Why can't currentCheck access node.
+                int tt=static_cast<int>(t.length());
+                //OrxAssert(!currentCheckPoint.empty(), "currentCheckPoint == null");
+                //OrxAssert(!(it == currentCheckPoint->getNextCheckpoints().end()), "it is null");
+                minimum= std::min(minimum, tt+ recCalculateDistance(checkpoints_[(*it)], currentCheckPoint->getPosition()));
+                // minimum of distanz from 'currentPosition' to the next static Checkpoint
+            }//Error tritt manchmal auf
             return minimum;
         }
@@ -204,5 +228,5 @@
     void SpaceRaceController::tick(float dt)
     {
-        if (this->getControllableEntity() ==  NULL || this->getControllableEntity()->getPlayer() == NULL ){orxout()<<this->getControllableEntity()<<endl; return;}
+        if (this->getControllableEntity() ==  NULL || this->getControllableEntity()->getPlayer() == NULL ){orxout()<<this->getControllableEntity()<< " in tick"<<endl; return;}
         if (nextRaceCheckpoint_->playerWasHere(this->getControllableEntity()->getPlayer()))
         {//Checkpoint erreicht
Index: code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h
===================================================================
--- code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h	(revision 9437)
+++ code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.h	(revision 9441)
@@ -40,6 +40,6 @@
         private:
             std::vector<RaceCheckPoint*> staticRacePoints_;
-            RaceCheckPoint* nextRaceCheckpoint_;
-            RaceCheckPoint* currentRaceCheckpoint_;
+            RaceCheckPoint* nextRaceCheckpoint_;    // checkpoint that should be reached
+            RaceCheckPoint* currentRaceCheckpoint_; // last checkPoint (already reached)
             std::vector<RaceCheckPoint*> checkpoints_;
             int lastDistance;
