Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 2, 2012, 11:08:21 PM (12 years ago)
Author:
landauf
Message:

fixed bug in SpaceRaceManager - it used the wrong index to identify Checkpoints (the order in which they appear in the XML file instead of RaceCheckPoint::getCheckpointIndex())
+ some more cleanup

File:
1 edited

Legend:

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

    r9260 r9262  
    9494    }
    9595
    96     int SpaceRaceManager::getIndex(RaceCheckPoint* checkpoint)
     96    /**
     97        @brief Returns the checkpoint with the given checkpoint-index (@see RaceCheckPoint::getCheckpointIndex).
     98    */
     99    RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const
    97100    {
    98101        for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    99             if (this->checkpoints_[i] == checkpoint)
    100                 return i;
    101 
    102         return -1;
     102            if (this->checkpoints_[i]->getCheckpointIndex() == index)
     103                return this->checkpoints_[i];
     104        return 0;
    103105    }
    104106
     
    113115        if (index > -1)
    114116        {
    115             Vector3 v = this->getCheckpoint(index)->getNextcheckpoint();
     117            Vector3 v = this->findCheckpoint(index)->getNextcheckpoint();
    116118
    117             if (this->getCheckpoint(v.x) == check)
     119            if (this->findCheckpoint(v.x) == check)
    118120            {
    119121                reachedValidCheckpoint = true;
    120122            }
    121             if (this->getCheckpoint(v.y) == check)
     123            if (this->findCheckpoint(v.y) == check)
    122124            {
    123125                reachedValidCheckpoint = true;
    124126            }
    125             if (this->getCheckpoint(v.z) == check)
     127            if (this->findCheckpoint(v.z) == check)
    126128            {
    127129                reachedValidCheckpoint = true;
     
    130132        else
    131133        {
    132             reachedValidCheckpoint = (this->getIndex(check) == 0);
     134            reachedValidCheckpoint = (check->getCheckpointIndex() == 0);
    133135        }
    134136
     
    147149                        {
    148150                if (index > -1)
    149                     this->setRadVis(player, false);
     151                    this->setRadarVisibility(player, false);
    150152                else
    151                     this->getCheckpoint(0)->setRadarVisibility(false);
     153                    this->findCheckpoint(0)->setRadarVisibility(false);
    152154
    153155                gametype->newCheckpointReached(check, player);
    154                 this->setRadVis(player, true);
     156                this->setRadarVisibility(player, true);
    155157            }
    156158        }
     
    159161    }
    160162
    161     void SpaceRaceManager::setRadVis(PlayerInfo* player, bool bVisible)
     163    void SpaceRaceManager::setRadarVisibility(PlayerInfo* player, bool bVisible)
    162164    {
    163165        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    164166        assert(gametype);
    165167        int index = gametype->getCheckpointReached(player);
    166         Vector3 v = this->getCheckpoint(index)->getNextcheckpoint();
     168        Vector3 v = this->findCheckpoint(index)->getNextcheckpoint();
    167169
    168170        if (v.x > -1)
    169171        {
    170             this->getCheckpoint(v.x)->setRadarVisibility(bVisible);
    171             this->getCheckpoint(v.x)->settingsChanged();
     172            this->findCheckpoint(v.x)->setRadarVisibility(bVisible);
     173            this->findCheckpoint(v.x)->settingsChanged();
    172174        }
    173175        if (v.y > -1)
    174176        {
    175             this->getCheckpoint(v.y)->setRadarVisibility(bVisible);
    176             this->getCheckpoint(v.y)->settingsChanged();
     177            this->findCheckpoint(v.y)->setRadarVisibility(bVisible);
     178            this->findCheckpoint(v.y)->settingsChanged();
    177179        }
    178180        if (v.z > -1)
    179181        {
    180             this->getCheckpoint(v.z)->setRadarVisibility(bVisible);
    181             this->getCheckpoint(v.z)->settingsChanged();
     182            this->findCheckpoint(v.z)->setRadarVisibility(bVisible);
     183            this->findCheckpoint(v.z)->settingsChanged();
    182184        }
    183185    }
Note: See TracChangeset for help on using the changeset viewer.