Index: /code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- /code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc	(revision 9507)
+++ /code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc	(revision 9508)
@@ -65,4 +65,5 @@
         //orxout(user_status) << "test" << std::endl;
 
+
     }
 
@@ -104,4 +105,28 @@
             ChatManager::message(message);
         }
+    }
+
+    //Must not be called before setNextCheckpointsAsVector3 at least once has been called
+    void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){
+        std::set<int> lastcheckpoints=this->nextCheckpoints_;
+        nextCheckpoints_.clear();
+        std::set<int>::iterator it = lastcheckpoints.begin();
+        if(checkpoints.x<-1){
+            virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.x,(*it)));
+            it++;
+        }
+        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5)); // the red number has the type double and for the cast (to int) is added 0.5 so that the cast works correctly
+
+        if(checkpoints.y<-1){
+                    virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.y,(*it)));
+                    it++;
+        }
+        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
+
+        if(checkpoints.z<-1){
+                    virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.z,(*it)));
+                    it++;
+        }
+        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     }
 
@@ -148,5 +173,28 @@
     }
 
-    Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() const
+    Vector3 RaceCheckPoint::getNextCheckpointsAsVector3()
+    {
+        Vector3 checkpoints = getVirtualNextCheckpointsAsVector3();
+        int j[3];
+        j[0]=changeVirtualToRealCheckPoint(checkpoints.x);
+        j[1]=changeVirtualToRealCheckPoint(checkpoints.y);
+        j[2]=changeVirtualToRealCheckPoint(checkpoints.z);
+
+
+        return Vector3(j[0],j[1],j[2]);
+
+
+    }
+
+    int RaceCheckPoint::changeVirtualToRealCheckPoint(int checkpointID) {
+        int temp=checkpointID;
+        while(temp<-1){
+            temp = this->virtualToRealCheckPoints_[temp];
+        }
+        return temp;
+    }
+
+
+    Vector3 RaceCheckPoint::getVirtualNextCheckpointsAsVector3() const
     {
         Vector3 checkpoints = Vector3(-1, -1, -1);
Index: /code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h
===================================================================
--- /code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h	(revision 9507)
+++ /code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.h	(revision 9508)
@@ -60,10 +60,22 @@
 
             void setNextCheckpointsAsVector3(const Vector3& checkpoints);
-            Vector3 getNextCheckpointsAsVector3() const;
-            const std::set<int>& getNextCheckpoints() const
+            Vector3 getNextCheckpointsAsVector3();
+            Vector3 getVirtualNextCheckpointsAsVector3() const;
+            void setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints);
+            int changeVirtualToRealCheckPoint(int);
+
+            const std::set<int>& getVirtualNextCheckpoints() const
             {
                 return this->nextCheckpoints_;
             }
-
+            std::set<int> getNextCheckpoints()
+            {
+                std::set<int> temp;
+                std::set<int> temp2=getVirtualNextCheckpoints();
+                for (std::set<int>::iterator it = temp2.begin(); it!=temp2.end(); ++it){
+                    temp.insert(changeVirtualToRealCheckPoint((*it)));
+                }
+                return temp;
+            }
             inline void setLast(bool isLast)
             {
@@ -91,4 +103,5 @@
 
         protected:
+
             virtual void fire(bool bIsTriggered, BaseObject* originator);
 
@@ -99,4 +112,5 @@
 
         private:
+
             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
@@ -105,4 +119,5 @@
             std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
             Vector3 myPosition_;
+            std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed
     };
 }
Index: /code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc
===================================================================
--- /code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc	(revision 9507)
+++ /code/branches/Racingbot/src/modules/gametypes/SpaceRaceController.cc	(revision 9508)
@@ -54,6 +54,8 @@
         ArtificialController(creator)
     {
-        RegisterObject(SpaceRaceController)
-;        std::vector<RaceCheckPoint*> checkpoints;
+        RegisterObject(SpaceRaceController);
+        std::vector<RaceCheckPoint*> checkpoints;
+
+        virtualCheckPointIndex=-2;
         for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it)
         {
@@ -64,9 +66,9 @@
         OrxAssert(!checkpoints.empty(), "No Checkpoints in Level");
         checkpoints_=checkpoints;
+
         for( std::vector<RaceCheckPoint*>::iterator it = checkpoints.begin(); it!=checkpoints.end(); ++it)
         {
             std::set<int> nextCheckPoints = ((*it)->getNextCheckpoints());
             if(!nextCheckPoints.empty()) {
-                orxout() << "yay" << endl;
                 for (std::set<int>::iterator numb = nextCheckPoints.begin(); numb!=nextCheckPoints.end(); numb++) {
                     RaceCheckPoint* point2 = findCheckpoint((*numb));
@@ -80,14 +82,11 @@
         // initialisation of currentRaceCheckpoint_
         currentRaceCheckpoint_ = NULL;
-        /*
-         // find first Checkpoint
-         for (int i=0; true; i++){
-         if(checkpoints_[i]->getCheckpointIndex()==0){
-         nextRaceCheckpoint_=checkpoints_[i];
-         break;
-         }
-         }*/
-
-        virtualCheckPointIndex=-2;
+
+        int i;
+        for (i=-2; findCheckpoint(i)!= NULL; i--){
+            continue;
+        }
+        orxout()<<"Die ANzahl der virtuellen CP betraegt: "<< (-i)-2<<endl;
+
     }
 
@@ -109,6 +108,5 @@
     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)
+        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++)
         {
@@ -140,5 +138,5 @@
         if (currentCheckpoint->isLast())
         {// last point reached
-            orxout() << "last one" << endl;
+
             (*zaehler)[currentCheckpoint] += 1;
             return 1; // 1 Way form the last point to this one
@@ -147,5 +145,5 @@
         {
             int numberOfWays = 0; // counts number of ways from this Point to the last point
-            for (std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it)
+            for (std::set<int>::iterator it = currentCheckpoint->getVirtualNextCheckpoints().begin(); it!= currentCheckpoint->getVirtualNextCheckpoints().end(); ++it)
             {
                 if(currentCheckpoint==findCheckpoint(*it)){
@@ -153,9 +151,5 @@
                     continue;
                 }
-                for (std::set<int>::iterator a = currentCheckpoint->getNextCheckpoints().begin(); a!= currentCheckpoint->getNextCheckpoints().end(); ++a){
-                    orxout() << "Nextcheckpoints: "<<(*a) << endl;
-                }
-                orxout() << "currentCheck; " << currentCheckpoint->getCheckpointIndex() << "findCheck; " << findCheckpoint(*it)->getCheckpointIndex() << endl;
-                numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler);
+               numberOfWays += rekSimulationCheckpointsReached(findCheckpoint(*it), zaehler);
             }
             (*zaehler)[currentCheckpoint] += numberOfWays;
@@ -185,5 +179,5 @@
         {   -1, -1, -1};
         int temp_i = 0;
-        for (std::set<int>::iterator it =raceCheckpoint->getNextCheckpoints().begin(); it!= raceCheckpoint->getNextCheckpoints().end(); ++it)
+        for (std::set<int>::iterator it =raceCheckpoint->getVirtualNextCheckpoints().begin(); it!= raceCheckpoint->getVirtualNextCheckpoints().end(); ++it)
         {
             distances[temp_i] = recCalculateDistance(findCheckpoint(*it), this->getControllableEntity()->getPosition());
@@ -194,9 +188,9 @@
             if (distances[2] < distances[1] && distances[2] != -1)
             {
-                return findCheckpoint(*raceCheckpoint->getNextCheckpoints().end()); // return checkpoint with ID of raceCheckpoint->getNextCheckpoints() [2]
+                return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().end()); // return checkpoint with ID of raceCheckpoint->getNextCheckpoints() [2]
             }
             else
             {
-                std::set<int>::iterator temp = raceCheckpoint->getNextCheckpoints().begin();
+                std::set<int>::iterator temp = raceCheckpoint->getVirtualNextCheckpoints().begin();
                 return findCheckpoint(*(++temp)); // return [1]
             }
@@ -206,9 +200,9 @@
             if (distances[2] < distances[0] && distances[2] != -1)
             {
-                return findCheckpoint(*raceCheckpoint->getNextCheckpoints().end()); // return [2]
+                return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().end()); // return [2]
             }
             else
             {
-                return findCheckpoint(*raceCheckpoint->getNextCheckpoints().begin()); // return [0]
+                return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().begin()); // return [0]
             }
         }
@@ -229,5 +223,5 @@
         {
             int minimum = std::numeric_limits<int>::max();
-            for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it!= currentCheckPoint->getNextCheckpoints().end(); ++it)
+            for (std::set<int>::iterator it = currentCheckPoint->getVirtualNextCheckpoints().begin(); it!= currentCheckPoint->getVirtualNextCheckpoints().end(); ++it)
             {
                 int dist_currentCheckPoint_currentPosition = static_cast<int> ((currentPosition- currentCheckPoint->getPosition()).length());
@@ -250,5 +244,5 @@
             return nextRaceCheckpoint_;
         }
-        if ((currentRaceCheckpoint_->getNextCheckpoints()).size() == 1) // no Adjust possible
+        if ((currentRaceCheckpoint_->getVirtualNextCheckpoints()).size() == 1) // no Adjust possible
 
         {
@@ -275,16 +269,17 @@
             newTempRaceCheckPoint = new RaceCheckPoint((*it));
         }
+        newTempRaceCheckPoint->setVisible(false);
         newTempRaceCheckPoint->setPosition(virtualCheckPointPosition);
         newTempRaceCheckPoint->setCheckpointIndex(virtualCheckPointIndex);
         newTempRaceCheckPoint->setLast(false);
-        newTempRaceCheckPoint->setNextCheckpointsAsVector3(Vector3(indexFollowingCheckPoint,-1,-1));
-
-        Vector3 temp = previousCheckpoint->getNextCheckpointsAsVector3();
+        newTempRaceCheckPoint->setNextVirtualCheckpointsAsVector3(Vector3(indexFollowingCheckPoint,-1,-1));
+
+        Vector3 temp = previousCheckpoint->getVirtualNextCheckpointsAsVector3();
         checkpoints_.insert(checkpoints_.end(), newTempRaceCheckPoint);
         int positionInNextCheckPoint;
         for (int i = 0; i <3; i++)
         {
-            if(previousCheckpoint->getNextCheckpointsAsVector3()[i]==indexFollowingCheckPoint)
-            positionInNextCheckPoint=i;
+            if(previousCheckpoint->getVirtualNextCheckpointsAsVector3()[i] == indexFollowingCheckPoint)
+                positionInNextCheckPoint=i;
         }
         switch(positionInNextCheckPoint)
@@ -294,7 +289,11 @@
             case 2: temp.z=virtualCheckPointIndex; break;
         }
-        previousCheckpoint->setNextCheckpointsAsVector3(temp);
+        previousCheckpoint->setNextVirtualCheckpointsAsVector3(temp); //Existiert internes Problem bei negativen index fueer next Checkpoint
         virtualCheckPointIndex--;
-        OrxAssert(virtualCheckPointIndex < -1, "TO much virtual cp");
+        //OrxAssert(virtualCheckPointIndex < -1, "TO much virtual cp");
+        /*orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<", following:"<<indexFollowingCheckPoint<<" :       "<<temp.x<<", "<<temp.y<<", "<<temp.z<<";       ";
+        temp=previousCheckpoint->getNextCheckpointsAsVector3();
+        orxout()<<"id: "<< previousCheckpoint->getCheckpointIndex() <<":       "<<temp.x<<", "<<temp.y<<", "<<temp.z<<";       ";
+        orxout()<<endl;*/
         return newTempRaceCheckPoint;
     }
@@ -315,9 +314,10 @@
         if(nextRaceCheckpoint_->getCheckpointIndex() < 0)
         {
-            if( distanceSpaceshipToCheckPoint(nextRaceCheckpoint_) < 30)
+            if( distanceSpaceshipToCheckPoint(nextRaceCheckpoint_) < 200)
             {
                 currentRaceCheckpoint_=nextRaceCheckpoint_;
                 nextRaceCheckpoint_ = nextPointFind(nextRaceCheckpoint_);
                 lastPositionSpaceship=this->getControllableEntity()->getPosition();
+                orxout()<< "CP "<< currentRaceCheckpoint_->getCheckpointIndex()<<" chanched to: "<< nextRaceCheckpoint_->getCheckpointIndex()<<endl;
             }
         }
@@ -325,8 +325,10 @@
         if (nextRaceCheckpoint_->playerWasHere(this->getControllableEntity()->getPlayer()))
         {//Checkpoint erreicht
+
             currentRaceCheckpoint_=nextRaceCheckpoint_;
             OrxAssert(nextRaceCheckpoint_, "next race checkpoint undefined");
             nextRaceCheckpoint_ = nextPointFind(nextRaceCheckpoint_);
             lastPositionSpaceship=this->getControllableEntity()->getPosition();
+            orxout()<< "CP "<< currentRaceCheckpoint_->getCheckpointIndex()<<" chanched to: "<< nextRaceCheckpoint_->getCheckpointIndex()<<endl;
         }
         else if ((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt > ADJUSTDISTANCE)
@@ -335,6 +337,6 @@
             lastPositionSpaceship=this->getControllableEntity()->getPosition();
         }
-        //TODO: korrigieren!
-
+
+        // Abmessung fuer MINDISTANCE gut;
         else if((lastPositionSpaceship-this->getControllableEntity()->getPosition()).length()/dt< MINDISTANCE )
         {
