Changeset 11071 for code/trunk/src/modules/gametypes/SpaceRaceManager.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/gametypes/SpaceRaceManager.cc
r10624 r11071 54 54 SpaceRaceManager::~SpaceRaceManager() 55 55 { 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(); 58 58 } 59 59 … … 71 71 this->players_ = this->race_->getPlayers(); 72 72 73 if (this->checkpoints_[0] != NULL&& !this->firstcheckpointvisible_)73 if (this->checkpoints_[0] != nullptr && !this->firstcheckpointvisible_) 74 74 { 75 75 this->checkpoints_[0]->setRadarVisibility(true); … … 77 77 } 78 78 79 for ( std::map< PlayerInfo*, Player>::iterator it = players_.begin(); it != players_.end(); ++it)79 for (const auto& mapEntry : players_) 80 80 { 81 81 82 for ( size_t i = 0; i < this->checkpoints_.size(); ++i)82 for (RaceCheckPoint* checkpoint : this->checkpoints_) 83 83 { 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()*/); 86 86 } 87 87 } … … 100 100 return this->checkpoints_[index]; 101 101 else 102 return 0;102 return nullptr; 103 103 } 104 104 … … 113 113 RaceCheckPoint* SpaceRaceManager::findCheckpoint(int index) const 114 114 { 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; 119 119 } 120 120 121 121 bool SpaceRaceManager::reachedValidCheckpoint(RaceCheckPoint* oldCheckpoint, RaceCheckPoint* newCheckpoint, PlayerInfo* player) const 122 122 { 123 if (oldCheckpoint != NULL)123 if (oldCheckpoint != nullptr) 124 124 { 125 125 // the player already visited an old checkpoint; see which checkpoints are possible now 126 126 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) 129 129 return true; 130 130 return false; … … 179 179 { 180 180 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); 183 183 } 184 184 … … 188 188 189 189 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); 192 192 } 193 193 }
Note: See TracChangeset
for help on using the changeset viewer.