- Timestamp:
- Nov 21, 2015, 7:05:53 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc
r10768 r10821 99 99 std::vector<unsigned int> playersperteam(this->teams_, 0); 100 100 101 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)102 if ( it->second < static_cast<int>(this->teams_) && it->second >= 0)103 playersperteam[ it->second]++;101 for (auto & elem : this->teamnumbers_) 102 if (elem.second < static_cast<int>(this->teams_) && elem.second >= 0) 103 playersperteam[elem.second]++; 104 104 105 105 unsigned int minplayers = static_cast<unsigned int>(-1); … … 123 123 if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list" 124 124 { 125 for ( std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it)126 { 127 if( it->second == false) // waiting player found128 { it->second = true; break;} // allow player to enter125 for (auto & elem : this->allowedInGame_) 126 { 127 if(elem.second == false) // waiting player found 128 {elem.second = true; break;} // allow player to enter 129 129 } 130 130 } … … 141 141 void TeamGametype::spawnDeadPlayersIfRequested() 142 142 { 143 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\144 { 145 if(allowedInGame_[ it->first] == false)//check if dead player is allowed to enter143 for (auto & elem : this->players_)\ 144 { 145 if(allowedInGame_[elem.first] == false)//check if dead player is allowed to enter 146 146 { 147 147 continue; 148 148 } 149 if ( it->second.state_ == PlayerState::Dead)150 { 151 if (( it->first->isReadyToSpawn() || this->bForceSpawn_))149 if (elem.second.state_ == PlayerState::Dead) 150 { 151 if ((elem.first->isReadyToSpawn() || this->bForceSpawn_)) 152 152 { 153 this->spawnPlayer( it->first);153 this->spawnPlayer(elem.first); 154 154 } 155 155 } … … 178 178 if(!player || this->getTeam(player) == -1) 179 179 return 0; 180 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)181 { 182 if ( this->getTeam( it->first) == this->getTeam(player) )183 { 184 teamscore += it->second.frags_;180 for (auto & elem : this->players_) 181 { 182 if ( this->getTeam(elem.first) == this->getTeam(player) ) 183 { 184 teamscore += elem.second.frags_; 185 185 } 186 186 } … … 191 191 { 192 192 int teamSize = 0; 193 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)194 { 195 if ( it->second == team)193 for (auto & elem : this->teamnumbers_) 194 { 195 if (elem.second == team) 196 196 teamSize++; 197 197 } … … 202 202 { 203 203 int teamSize = 0; 204 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)205 { 206 if ( it->second == team && it->first->isHumanPlayer())204 for (auto & elem : this->teamnumbers_) 205 { 206 if (elem.second == team && elem.first->isHumanPlayer()) 207 207 teamSize++; 208 208 } … … 241 241 unsigned int index = 0; 242 242 // Get random fallback spawnpoint in case there is no active SpawnPoint. 243 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)243 for (const auto & teamSpawnPoint : teamSpawnPoints) 244 244 { 245 245 if (index == randomspawn) 246 246 { 247 fallbackSpawnPoint = ( *it);247 fallbackSpawnPoint = (teamSpawnPoint); 248 248 break; 249 249 } … … 266 266 randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 267 267 index = 0; 268 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)268 for (const auto & teamSpawnPoint : teamSpawnPoints) 269 269 { 270 270 if (index == randomspawn) 271 return ( *it);271 return (teamSpawnPoint); 272 272 273 273 ++index; … … 364 364 365 365 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 366 for ( std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)367 { 368 if (( *it)->isA(Class(TeamColourable)))369 { 370 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);366 for (const auto & pawnAttachment : pawnAttachments) 367 { 368 if ((pawnAttachment)->isA(Class(TeamColourable))) 369 { 370 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); 371 371 tc->setTeamColour(this->teamcolours_[teamNr]); 372 372 } … … 376 376 void TeamGametype::announceTeamWin(int winnerTeam) 377 377 { 378 for ( std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3)379 { 380 if ( it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)378 for (auto & elem : this->teamnumbers_) 379 { 380 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 381 381 continue; 382 if ( it3->second == winnerTeam)383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID());382 if (elem.second == winnerTeam) 383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", elem.first->getClientID()); 385 385 } 386 386 else 387 387 { 388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID());388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", elem.first->getClientID()); 389 389 } 390 390 }
Note: See TracChangeset
for help on using the changeset viewer.