Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 3, 2012, 12:04:35 AM (12 years ago)
Author:
landauf
Message:

store the next checkpoints in a set instead of Vector3
+ some refactoring in SpaceRaceManager

File:
1 edited

Legend:

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

    r9260 r9263  
    5858
    5959        this->checkpointIndex_ = 0;
    60         this->nextcheckpoints_ = Vector3::ZERO;
    6160        this->bIsLast_ = false;
    6261        this->timeLimit_ = 0;
     
    7675        XMLPortParam(RaceCheckPoint, "islast", setLast, isLast, xmlelement, mode).defaultValues(false);
    7776        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
    78         XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode, const Vector3&).defaultValues(Vector3::ZERO);
     77        XMLPortParam(RaceCheckPoint, "nextcheckpoints", setNextCheckpointsAsVector3, getNextCheckpointsAsVector3, xmlelement, mode);
    7978    }
    8079
     
    102101        }
    103102    }
     103
     104    void RaceCheckPoint::setNextCheckpointsAsVector3(const Vector3& checkpoints)
     105    {
     106        this->nextCheckpoints_.clear();
     107
     108        if (checkpoints.x > -1)
     109            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));
     110        if (checkpoints.y > -1)
     111            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
     112        if (checkpoints.z > -1)
     113            this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     114    }
     115
     116    Vector3 RaceCheckPoint::getNextCheckpointsAsVector3() const
     117    {
     118        Vector3 checkpoints = Vector3(-1, -1, -1);
     119
     120        size_t count = 0;
     121        for (std::set<int>::iterator it = this->nextCheckpoints_.begin(); it != this->nextCheckpoints_.end(); ++it)
     122        {
     123            switch (count)
     124            {
     125                case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
     126                case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
     127                case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
     128            }
     129            ++count;
     130        }
     131
     132        return checkpoints;
     133    }
    104134}
Note: See TracChangeset for help on using the changeset viewer.