Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 4, 2014, 2:56:03 PM (12 years ago)
Author:
landauf
Message:

several (potential) bugfixes in SpaceRaceController:

  • check if there is only 1 SpaceRaceManager (line 61)
  • zaehler.begin() is NOT necessarily the first checkpoint because the map is randomly sorted. use nextRaceCheckpoint_ instead (line 160)
  • don't recurse if the next checkpoint is invalid (line 198)

some cleanup in RaceCheckPoint; also fixed a potential floating point issue

File:
1 edited

Legend:

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

    r9967 r9973  
    105105        this->nextCheckpoints_.clear();
    106106
    107         if (checkpoints.x > -1)
    108         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
    109         if (checkpoints.y > -1)
    110         this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
    111         if (checkpoints.z > -1)
    112         this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     107        if (checkpoints.x > -0.5)
     108            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
     109        if (checkpoints.y > -0.5)
     110            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
     111        if (checkpoints.z > -0.5)
     112            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
    113113    }
    114114
     
    146146    {
    147147        Vector3 checkpoints(-1,-1,-1); int count=0;
    148         for (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ ){
     148        for (std::set<int>::iterator it= nextCheckpoints_.begin();it!=nextCheckpoints_.end(); it++ )
     149        {
    149150            switch (count)
    150                         {
    151                             case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
    152                             case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
    153                             case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
    154                         }
    155                         ++count;
     151            {
     152                case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
     153                case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
     154                case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
     155            }
     156            ++count;
    156157        }
    157158        return checkpoints;
Note: See TracChangeset for help on using the changeset viewer.