Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 11, 2012, 6:13:18 PM (11 years ago)
Author:
purgham
Message:

still not working!

File:
1 edited

Legend:

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

    r9470 r9508  
    6565        //orxout(user_status) << "test" << std::endl;
    6666
     67
    6768    }
    6869
     
    104105            ChatManager::message(message);
    105106        }
     107    }
     108
     109    //Must not be called before setNextCheckpointsAsVector3 at least once has been called
     110    void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){
     111        std::set<int> lastcheckpoints=this->nextCheckpoints_;
     112        nextCheckpoints_.clear();
     113        std::set<int>::iterator it = lastcheckpoints.begin();
     114        if(checkpoints.x<-1){
     115            virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.x,(*it)));
     116            it++;
     117        }
     118        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
     119
     120        if(checkpoints.y<-1){
     121                    virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.y,(*it)));
     122                    it++;
     123        }
     124        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
     125
     126        if(checkpoints.z<-1){
     127                    virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.z,(*it)));
     128                    it++;
     129        }
     130        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
    106131    }
    107132
     
    148173    }
    149174
    150     Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() const
     175    Vector3 RaceCheckPoint::getNextCheckpointsAsVector3()
     176    {
     177        Vector3 checkpoints = getVirtualNextCheckpointsAsVector3();
     178        int j[3];
     179        j[0]=changeVirtualToRealCheckPoint(checkpoints.x);
     180        j[1]=changeVirtualToRealCheckPoint(checkpoints.y);
     181        j[2]=changeVirtualToRealCheckPoint(checkpoints.z);
     182
     183
     184        return Vector3(j[0],j[1],j[2]);
     185
     186
     187    }
     188
     189    int RaceCheckPoint::changeVirtualToRealCheckPoint(int checkpointID) {
     190        int temp=checkpointID;
     191        while(temp<-1){
     192            temp = this->virtualToRealCheckPoints_[temp];
     193        }
     194        return temp;
     195    }
     196
     197
     198    Vector3 RaceCheckPoint::getVirtualNextCheckpointsAsVector3() const
    151199    {
    152200        Vector3 checkpoints = Vector3(-1, -1, -1);
Note: See TracChangeset for help on using the changeset viewer.