Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9964 for code/trunk


Ignore:
Timestamp:
Jan 3, 2014, 9:44:23 PM (10 years ago)
Author:
landauf
Message:

removed unused code (some of the code was after a 'return' statement and thus never executed)

Location:
code/trunk/src/modules/gametypes
Files:
3 edited

Legend:

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

    r9963 r9964  
    104104    }
    105105
    106     //Must not be called before setNextCheckpointsAsVector3 at least once has been called
    107     void RaceCheckPoint::setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints){
    108         /*std::set<int> lastcheckpoints=this->nextCheckpoints_;
    109         nextCheckpoints_.clear();
    110         std::set<int>::iterator it = lastcheckpoints.begin();
    111         if(checkpoints.x<-1){
    112             virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.x,(*it)));
    113             it++;
    114         }
    115         if(checkpoints.x!=-1)
    116             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
    117 
    118         if(checkpoints.y<-1){
    119                     virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.y,(*it)));
    120                     it++;
    121         }
    122         if(checkpoints.y!=-1)
    123             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
    124 
    125         if(checkpoints.z<-1){
    126                     virtualToRealCheckPoints_.insert(std::pair<int,int>(checkpoints.z,(*it)));
    127                     it++;
    128         }
    129         if(checkpoints.z!=-1)
    130             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));*/
    131         nextCheckpointsVirtual_.clear();
    132         if(checkpoints.x!=-1)
    133             nextCheckpointsVirtual_.insert(checkpoints.x);
    134         if(checkpoints.y!=-1)
    135                 nextCheckpointsVirtual_.insert(checkpoints.y);
    136         if(checkpoints.z!=-1)
    137                 nextCheckpointsVirtual_.insert(checkpoints.z);
    138     }
    139 
    140106    void RaceCheckPoint::setNextCheckpointsAsVector3(const Vector3& checkpoints)
    141107    {
     
    148114        if (checkpoints.z > -1)
    149115        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
    150 
    151         this->nextCheckpointsVirtual_=nextCheckpoints_;
    152116    }
    153117
     
    195159        }
    196160        return checkpoints;
    197         //= getVirtualNextCheckpointsAsVector3();
    198         int j[3];
    199         j[0]=changeVirtualToRealCheckPoint(checkpoints.x);
    200         j[1]=changeVirtualToRealCheckPoint(checkpoints.y);
    201         j[2]=changeVirtualToRealCheckPoint(checkpoints.z);
    202 
    203 
    204         return Vector3(j[0],j[1],j[2]);
    205 
    206 
    207161    }
    208162
    209     int RaceCheckPoint::changeVirtualToRealCheckPoint(int checkpointID) {
    210         int temp=checkpointID;
    211         while(temp<-1){
    212             temp = this->virtualToRealCheckPoints_[temp];
    213         }
    214         return temp;
    215     }
    216 
    217 
    218     Vector3 RaceCheckPoint::getVirtualNextCheckpointsAsVector3() const
    219     {
    220         Vector3 checkpoints = Vector3(-1, -1, -1);
    221 
    222         size_t count = 0;
    223         for (std::set<int>::iterator it = this->nextCheckpointsVirtual_.begin(); it != this->nextCheckpointsVirtual_.end(); ++it)
    224         {
    225             switch (count)
    226             {
    227                 case 0: checkpoints.x = static_cast<Ogre::Real>(*it); break;
    228                 case 1: checkpoints.y = static_cast<Ogre::Real>(*it); break;
    229                 case 2: checkpoints.z = static_cast<Ogre::Real>(*it); break;
    230             }
    231             ++count;
    232         }
    233 
    234         return checkpoints;
    235     }
    236163}
  • code/trunk/src/modules/gametypes/RaceCheckPoint.h

    r9963 r9964  
    6161            void setNextCheckpointsAsVector3(const Vector3& checkpoints);
    6262            Vector3 getNextCheckpointsAsVector3();
    63             Vector3 getVirtualNextCheckpointsAsVector3() const;
    64             void setNextVirtualCheckpointsAsVector3(const Vector3& checkpoints);
    65             int changeVirtualToRealCheckPoint(int);
    66 
    67             const std::set<int>& getVirtualNextCheckpoints() const
    68             {
    69                 return this->nextCheckpointsVirtual_;
    70             }
    7163
    7264            std::set<int> getNextCheckpoints()
    7365            {
    7466                return nextCheckpoints_;
    75                 std::set<int> temp;
    76                 std::set<int> temp2=getVirtualNextCheckpoints();
    77                 for (std::set<int>::iterator it = temp2.begin(); it!=temp2.end(); ++it){
    78                     temp.insert(changeVirtualToRealCheckPoint((*it)));
    79                 }
    80                 return temp;
    8167            }
    8268            inline void setLast(bool isLast)
     
    120106            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.
    121107            std::vector<PlayerInfo*> players_; ///< The player that reached the checkpoint
    122             std::set<int>  nextCheckpointsVirtual_;
    123             std::map<int,int> virtualToRealCheckPoints_; // if virtualChepoint was inserted the original can be reconstructed
    124108    };
    125109}
  • code/trunk/src/modules/gametypes/SpaceRaceController.cc

    r9962 r9964  
    188188        {
    189189            int numberOfWays = 0; // counts number of ways from this Point to the last point
    190             for (std::set<int>::iterator it = currentCheckpoint->getVirtualNextCheckpoints().begin(); it!= currentCheckpoint->getVirtualNextCheckpoints().end(); ++it)
     190            for (std::set<int>::iterator it = currentCheckpoint->getNextCheckpoints().begin(); it!= currentCheckpoint->getNextCheckpoints().end(); ++it)
    191191            {
    192192                if(currentCheckpoint == findCheckpoint(*it))
     
    224224        float distances[] = {-1, -1, -1};
    225225        int temp_i = 0;
    226         for (std::set<int>::iterator it =raceCheckpoint->getVirtualNextCheckpoints().begin(); it!= raceCheckpoint->getVirtualNextCheckpoints().end(); ++it)
     226        for (std::set<int>::iterator it =raceCheckpoint->getNextCheckpoints().begin(); it!= raceCheckpoint->getNextCheckpoints().end(); ++it)
    227227        {
    228228            distances[temp_i] = recCalculateDistance(findCheckpoint(*it), this->getControllableEntity()->getPosition());
     
    233233            if (distances[2] < distances[1] && distances[2] >= 0)
    234234            {
    235                 return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().end()); // return checkpoint with ID of raceCheckpoint->getNextCheckpoints() [2]
     235                return findCheckpoint(*raceCheckpoint->getNextCheckpoints().end()); // return checkpoint with ID of raceCheckpoint->getNextCheckpoints() [2]
    236236            }
    237237            else
    238238            {
    239                 std::set<int>::iterator temp = raceCheckpoint->getVirtualNextCheckpoints().begin();
     239                std::set<int>::iterator temp = raceCheckpoint->getNextCheckpoints().begin();
    240240                return findCheckpoint(*(++temp)); // return [1]
    241241            }
     
    245245            if (distances[2] < distances[0] && distances[2] >= 0)
    246246            {
    247                 return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().end()); // return [2]
     247                return findCheckpoint(*raceCheckpoint->getNextCheckpoints().end()); // return [2]
    248248            }
    249249            else
    250250            {
    251                 return findCheckpoint(*raceCheckpoint->getVirtualNextCheckpoints().begin()); // return [0]
     251                return findCheckpoint(*raceCheckpoint->getNextCheckpoints().begin()); // return [0]
    252252            }
    253253        }
     
    268268        {
    269269            float minimum = std::numeric_limits<float>::max();
    270             for (std::set<int>::iterator it = currentCheckPoint->getVirtualNextCheckpoints().begin(); it != currentCheckPoint->getVirtualNextCheckpoints().end(); ++it)
     270            for (std::set<int>::iterator it = currentCheckPoint->getNextCheckpoints().begin(); it != currentCheckPoint->getNextCheckpoints().end(); ++it)
    271271            {
    272272                int dist_currentCheckPoint_currentPosition = static_cast<int> ((currentPosition- currentCheckPoint->getPosition()).length());
     
    289289            return nextRaceCheckpoint_;
    290290        }
    291         if ((currentRaceCheckpoint_->getVirtualNextCheckpoints()).size() == 1) // no Adjust possible
     291        if ((currentRaceCheckpoint_->getNextCheckpoints()).size() == 1) // no Adjust possible
    292292
    293293        {
Note: See TracChangeset for help on using the changeset viewer.