Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/gametypes/SpaceRaceManager.cc

    r10624 r11071  
    5454    SpaceRaceManager::~SpaceRaceManager()
    5555    {
    56         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    57         this->checkpoints_[i]->destroy();
     56        for (RaceCheckPoint* checkpoint : this->checkpoints_)
     57        checkpoint->destroy();
    5858    }
    5959
     
    7171        this->players_ = this->race_->getPlayers();
    7272
    73         if (this->checkpoints_[0] != NULL && !this->firstcheckpointvisible_)
     73        if (this->checkpoints_[0] != nullptr && !this->firstcheckpointvisible_)
    7474        {
    7575            this->checkpoints_[0]->setRadarVisibility(true);
     
    7777        }
    7878
    79         for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)
     79        for (const auto& mapEntry : players_)
    8080        {
    8181
    82             for (size_t i = 0; i < this->checkpoints_.size(); ++i)
     82            for (RaceCheckPoint* checkpoint : this->checkpoints_)
    8383            {
    84                 if (this->checkpoints_[i]->playerWasHere(it->first)){
    85                 this->checkpointReached(this->checkpoints_[i], it->first /*this->checkpoints_[i]->getPlayer()*/);
     84                if (checkpoint->playerWasHere(mapEntry.first)){
     85                this->checkpointReached(checkpoint, mapEntry.first /*this->checkpoints_[i]->getPlayer()*/);
    8686                }
    8787            }
     
    100100        return this->checkpoints_[index];
    101101        else
    102         return 0;
     102        return nullptr;
    103103    }
    104104
     
    113113    RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const
    114114    {
    115         for (size_t i = 0; i < this->checkpoints_.size(); ++i)
    116         if (this->checkpoints_[i]->getCheckpointIndex() == index)
    117         return this->checkpoints_[i];
    118         return 0;
     115        for (RaceCheckPoint* checkpoint : this->checkpoints_)
     116        if (checkpoint->getCheckpointIndex() == index)
     117        return checkpoint;
     118        return nullptr;
    119119    }
    120120
    121121    bool SpaceRaceManager::reachedValidCheckpoint(RaceCheckPoint* oldCheckpoint, RaceCheckPoint* newCheckpoint, PlayerInfo* player) const
    122122    {
    123         if (oldCheckpoint != NULL)
     123        if (oldCheckpoint != nullptr)
    124124        {
    125125            // the player already visited an old checkpoint; see which checkpoints are possible now
    126126            const std::set<int>& possibleCheckpoints = oldCheckpoint->getNextCheckpoints();
    127             for (std::set<int>::const_iterator it = possibleCheckpoints.begin(); it != possibleCheckpoints.end(); ++it)
    128             if (this->findCheckpoint(*it) == newCheckpoint)
     127            for (int possibleCheckpoint : possibleCheckpoints)
     128            if (this->findCheckpoint(possibleCheckpoint) == newCheckpoint)
    129129            return true;
    130130            return false;
     
    179179        {
    180180            const std::set<int>& oldVisible = oldCheckpoint->getNextCheckpoints();
    181             for (std::set<int>::const_iterator it = oldVisible.begin(); it != oldVisible.end(); ++it)
    182             this->findCheckpoint(*it)->setRadarVisibility(false);
     181            for (int checkpointIndex : oldVisible)
     182            this->findCheckpoint(checkpointIndex)->setRadarVisibility(false);
    183183        }
    184184
     
    188188
    189189            const std::set<int>& newVisible = newCheckpoint->getNextCheckpoints();
    190             for (std::set<int>::const_iterator it = newVisible.begin(); it != newVisible.end(); ++it)
    191             this->findCheckpoint(*it)->setRadarVisibility(true);
     190            for (int checkpointIndex : newVisible)
     191            this->findCheckpoint(checkpointIndex)->setRadarVisibility(true);
    192192        }
    193193    }
Note: See TracChangeset for help on using the changeset viewer.