- 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/Gametype.cc
r10768 r10821 139 139 if (!this->gtinfo_->hasStarted()) 140 140 { 141 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)141 for (auto & elem : this->players_) 142 142 { 143 143 // Inform the GametypeInfo that the player is ready to spawn. 144 if( it->first->isHumanPlayer() && it->first->isReadyToSpawn())145 this->gtinfo_->playerReadyToSpawn( it->first);144 if(elem.first->isHumanPlayer() && elem.first->isReadyToSpawn()) 145 this->gtinfo_->playerReadyToSpawn(elem.first); 146 146 } 147 147 … … 169 169 } 170 170 171 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)172 { 173 if ( it->first->getControllableEntity())174 { 175 ControllableEntity* oldentity = it->first->getControllableEntity();171 for (auto & elem : this->players_) 172 { 173 if (elem.first->getControllableEntity()) 174 { 175 ControllableEntity* oldentity = elem.first->getControllableEntity(); 176 176 177 177 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getContext()); … … 186 186 entity->setOrientation(oldentity->getWorldOrientation()); 187 187 } 188 it->first->startControl(entity);188 elem.first->startControl(entity); 189 189 } 190 190 else 191 this->spawnPlayerAsDefaultPawn( it->first);191 this->spawnPlayerAsDefaultPawn(elem.first); 192 192 } 193 193 } … … 341 341 unsigned int index = 0; 342 342 std::vector<SpawnPoint*> activeSpawnPoints; 343 for ( std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)343 for (const auto & elem : this->spawnpoints_) 344 344 { 345 345 if (index == randomspawn) 346 fallbackSpawnPoint = ( *it);347 348 if ( *it != nullptr && (*it)->isActive())349 activeSpawnPoints.push_back( *it);346 fallbackSpawnPoint = (elem); 347 348 if (elem != nullptr && (elem)->isActive()) 349 activeSpawnPoints.push_back(elem); 350 350 351 351 ++index; … … 366 366 void Gametype::assignDefaultPawnsIfNeeded() 367 367 { 368 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)369 { 370 if (! it->first->getControllableEntity())371 { 372 it->second.state_ = PlayerState::Dead;373 374 if (! it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())375 { 376 this->spawnPlayerAsDefaultPawn( it->first);377 it->second.state_ = PlayerState::Dead;368 for (auto & elem : this->players_) 369 { 370 if (!elem.first->getControllableEntity()) 371 { 372 elem.second.state_ = PlayerState::Dead; 373 374 if (!elem.first->isReadyToSpawn() || !this->gtinfo_->hasStarted()) 375 { 376 this->spawnPlayerAsDefaultPawn(elem.first); 377 elem.second.state_ = PlayerState::Dead; 378 378 } 379 379 } … … 404 404 bool allplayersready = true; 405 405 bool hashumanplayers = false; 406 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)406 for (auto & elem : this->players_) 407 407 { 408 if (! it->first->isReadyToSpawn())408 if (!elem.first->isReadyToSpawn()) 409 409 allplayersready = false; 410 if ( it->first->isHumanPlayer())410 if (elem.first->isHumanPlayer()) 411 411 hashumanplayers = true; 412 412 } … … 430 430 void Gametype::spawnPlayersIfRequested() 431 431 { 432 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)433 { 434 if ( it->first->isReadyToSpawn() || this->bForceSpawn_)435 this->spawnPlayer( it->first);432 for (auto & elem : this->players_) 433 { 434 if (elem.first->isReadyToSpawn() || this->bForceSpawn_) 435 this->spawnPlayer(elem.first); 436 436 } 437 437 } … … 439 439 void Gametype::spawnDeadPlayersIfRequested() 440 440 { 441 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)442 if ( it->second.state_ == PlayerState::Dead)443 if ( it->first->isReadyToSpawn() || this->bForceSpawn_)444 this->spawnPlayer( it->first);441 for (auto & elem : this->players_) 442 if (elem.second.state_ == PlayerState::Dead) 443 if (elem.first->isReadyToSpawn() || this->bForceSpawn_) 444 this->spawnPlayer(elem.first); 445 445 } 446 446 … … 538 538 GSLevelMementoState* Gametype::exportMementoState() 539 539 { 540 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)541 { 542 if ( it->first->isHumanPlayer() && it->first->getControllableEntity() && it->first->getControllableEntity()->getCamera())543 { 544 Camera* camera = it->first->getControllableEntity()->getCamera();540 for (auto & elem : this->players_) 541 { 542 if (elem.first->isHumanPlayer() && elem.first->getControllableEntity() && elem.first->getControllableEntity()->getCamera()) 543 { 544 Camera* camera = elem.first->getControllableEntity()->getCamera(); 545 545 546 546 GametypeMementoState* state = new GametypeMementoState(); … … 559 559 // find correct memento state 560 560 GametypeMementoState* state = nullptr; 561 for ( size_t i = 0; i < states.size(); ++i)562 { 563 state = dynamic_cast<GametypeMementoState*>(states [i]);561 for (auto & states_i : states) 562 { 563 state = dynamic_cast<GametypeMementoState*>(states_i); 564 564 if (state) 565 565 break; … … 587 587 588 588 // find correct player and assign default entity with original position & orientation 589 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)590 { 591 if ( it->first->isHumanPlayer())589 for (auto & elem : this->players_) 590 { 591 if (elem.first->isHumanPlayer()) 592 592 { 593 593 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(scene->getContext()); 594 594 entity->setPosition(state->cameraPosition_); 595 595 entity->setOrientation(state->cameraOrientation_); 596 it->first->startControl(entity);596 elem.first->startControl(entity); 597 597 break; 598 598 }
Note: See TracChangeset
for help on using the changeset viewer.