Changeset 10821 for code/branches/cpp11_v2/src/orxonox
- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/orxonox
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/Level.cc
r10818 r10821 106 106 void Level::networkCallbackTemplatesChanged() 107 107 { 108 for( std::set<std::string>::iterator it = this->networkTemplateNames_.begin(); it!=this->networkTemplateNames_.end(); ++it)109 { 110 assert(Template::getTemplate( *it));111 Template::getTemplate( *it)->applyOn(this);108 for(const auto & elem : this->networkTemplateNames_) 109 { 110 assert(Template::getTemplate(elem)); 111 Template::getTemplate(elem)->applyOn(this); 112 112 } 113 113 } … … 135 135 // objects alive when ~Level is called. This is the reason why we cannot directly destroy() the Plugins - instead we need 136 136 // to call destroyLater() to ensure that no instances from this plugin exist anymore. 137 for ( std::list<PluginReference*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)138 ( *it)->destroyLater();137 for (auto & elem : this->plugins_) 138 (elem)->destroyLater(); 139 139 this->plugins_.clear(); 140 140 } … … 173 173 { 174 174 unsigned int i = 0; 175 for ( std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)175 for (const auto & elem : this->objects_) 176 176 { 177 177 if (i == index) 178 return ( *it);178 return (elem); 179 179 ++i; 180 180 } -
code/branches/cpp11_v2/src/orxonox/LevelInfo.cc
r9667 r10821 107 107 SubString substr = SubString(tags, ",", " "); // Split the string into tags. 108 108 const std::vector<std::string>& strings = substr.getAllStrings(); 109 for ( std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)110 this->addTag( *it, false);109 for (const auto & strings_it : strings) 110 this->addTag(strings_it, false); 111 111 112 112 this->tagsUpdated(); … … 122 122 SubString substr = SubString(ships, ",", " "); // Split the string into tags. 123 123 const std::vector<std::string>& strings = substr.getAllStrings(); 124 for( std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)125 this->addStartingShip( *it, false);124 for(const auto & strings_it : strings) 125 this->addStartingShip(strings_it, false); 126 126 127 127 this->startingshipsUpdated(); -
code/branches/cpp11_v2/src/orxonox/LevelManager.cc
r10768 r10821 175 175 this->levels_.front()->setActive(true); 176 176 // Make every player enter the newly activated level. 177 for ( std::map<unsigned int, PlayerInfo*>::const_iterator it = PlayerManager::getInstance().getClients().begin(); it != PlayerManager::getInstance().getClients().end(); ++it)178 this->levels_.front()->playerEntered( it->second);177 for (const auto & elem : PlayerManager::getInstance().getClients()) 178 this->levels_.front()->playerEntered(elem.second); 179 179 } 180 180 } -
code/branches/cpp11_v2/src/orxonox/Scene.cc
r10768 r10821 220 220 { 221 221 // Remove all WorldEntities and shove them to the queue since they would still like to be in a physical world. 222 for (std::set<WorldEntity*>::const_iterator it = this->physicalObjects_.begin(); 223 it != this->physicalObjects_.end(); ++it) 222 for (const auto & elem : this->physicalObjects_) 224 223 { 225 this->physicalWorld_->removeRigidBody(( *it)->physicalBody_);226 this->physicalObjectQueue_.insert( *it);224 this->physicalWorld_->removeRigidBody((elem)->physicalBody_); 225 this->physicalObjectQueue_.insert(elem); 227 226 } 228 227 this->physicalObjects_.clear(); … … 256 255 { 257 256 // Add all scheduled WorldEntities 258 for (std::set<WorldEntity*>::const_iterator it = this->physicalObjectQueue_.begin(); 259 it != this->physicalObjectQueue_.end(); ++it) 257 for (const auto & elem : this->physicalObjectQueue_) 260 258 { 261 this->physicalWorld_->addRigidBody(( *it)->physicalBody_);262 this->physicalObjects_.insert( *it);259 this->physicalWorld_->addRigidBody((elem)->physicalBody_); 260 this->physicalObjects_.insert(elem); 263 261 } 264 262 this->physicalObjectQueue_.clear(); … … 321 319 { 322 320 unsigned int i = 0; 323 for ( std::list<BaseObject*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)321 for (const auto & elem : this->objects_) 324 322 { 325 323 if (i == index) 326 return ( *it);324 return (elem); 327 325 ++i; 328 326 } -
code/branches/cpp11_v2/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r10768 r10821 65 65 { 66 66 // Delete all children 67 for (std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); 68 it != this->attachedShapes_.end(); ++it) 67 for (auto & elem : this->attachedShapes_) 69 68 { 70 69 // make sure that the child doesn't want to detach itself --> speedup because of the missing update 71 it->first->notifyDetached();72 it->first->destroy();73 if (this->collisionShape_ == it->second)70 elem.first->notifyDetached(); 71 elem.first->destroy(); 72 if (this->collisionShape_ == elem.second) 74 73 this->collisionShape_ = nullptr; // don't destroy it twice 75 74 } … … 247 246 { 248 247 unsigned int i = 0; 249 for ( std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)248 for (const auto & elem : this->attachedShapes_) 250 249 { 251 250 if (i == index) 252 return it->first;251 return elem.first; 253 252 ++i; 254 253 } … … 267 266 std::vector<CollisionShape*> shapes; 268 267 // Iterate through all attached CollisionShapes and add them to the list of shapes. 269 for( std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)270 shapes.push_back( it->first);268 for(auto & elem : this->attachedShapes_) 269 shapes.push_back(elem.first); 271 270 272 271 // Delete the compound shape and create a new one. … … 275 274 276 275 // Re-attach all CollisionShapes. 277 for( std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++)278 { 279 CollisionShape* shape = *it;276 for(auto shape : shapes) 277 { 278 280 279 shape->setScale3D(this->getScale3D()); 281 280 // Only actually attach if we didn't pick a CompoundCollisionShape with no content. -
code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
r10768 r10821 440 440 if(newMaster->slaves_.size() > this->maxFormationSize_) continue; 441 441 442 for( std::vector<FormationController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)442 for(auto & elem : this->slaves_) 443 443 { 444 ( *itSlave)->myMaster_ = newMaster;445 newMaster->slaves_.push_back( *itSlave);444 (elem)->myMaster_ = newMaster; 445 newMaster->slaves_.push_back(elem); 446 446 } 447 447 this->slaves_.clear(); … … 486 486 int i = 1; 487 487 488 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)488 for(auto & elem : slaves_) 489 489 { 490 490 pos = Vector3::ZERO; … … 497 497 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 498 498 } 499 ( *it)->setTargetOrientation(orient);500 ( *it)->setTargetPosition(pos);499 (elem)->setTargetOrientation(orient); 500 (elem)->setTargetPosition(pos); 501 501 left=!left; 502 502 } … … 569 569 if(this->state_ != MASTER) return; 570 570 571 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)572 { 573 ( *it)->state_ = FREE;574 ( *it)->myMaster_ = nullptr;571 for(auto & elem : slaves_) 572 { 573 (elem)->state_ = FREE; 574 (elem)->myMaster_ = nullptr; 575 575 } 576 576 this->slaves_.clear(); … … 584 584 if(this->state_ != MASTER) return; 585 585 586 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)587 { 588 ( *it)->state_ = FREE;589 ( *it)->forceFreedom();590 ( *it)->targetPosition_ = this->targetPosition_;591 ( *it)->bShooting_ = true;586 for(auto & elem : slaves_) 587 { 588 (elem)->state_ = FREE; 589 (elem)->forceFreedom(); 590 (elem)->targetPosition_ = this->targetPosition_; 591 (elem)->bShooting_ = true; 592 592 // (*it)->getControllableEntity()->fire(0);// fire once for fun 593 593 } … … 650 650 this->slaves_.push_back(this->myMaster_); 651 651 //set this as new master 652 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)653 { 654 ( *it)->myMaster_=this;652 for(auto & elem : slaves_) 653 { 654 (elem)->myMaster_=this; 655 655 } 656 656 this->myMaster_=nullptr; … … 694 694 if (this->state_ == MASTER) 695 695 { 696 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)697 { 698 ( *it)->formationMode_ = val;696 for(auto & elem : slaves_) 697 { 698 (elem)->formationMode_ = val; 699 699 if (val == ATTACK) 700 ( *it)->forgetTarget();700 (elem)->forgetTarget(); 701 701 } 702 702 } -
code/branches/cpp11_v2/src/orxonox/controllers/WaypointController.cc
r9667 r10821 44 44 WaypointController::~WaypointController() 45 45 { 46 for ( size_t i = 0; i < this->waypoints_.size(); ++i)46 for (auto & elem : this->waypoints_) 47 47 { 48 if( this->waypoints_[i])49 this->waypoints_[i]->destroy();48 if(elem) 49 elem->destroy(); 50 50 } 51 51 } -
code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc
r10768 r10821 251 251 252 252 // delete states 253 for ( size_t i = 0; i < states.size(); ++i)254 delete state s[i];253 for (auto & state : states) 254 delete state; 255 255 } 256 256 -
code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc
r10768 r10821 405 405 void Dynamicmatch::rewardPig() 406 406 { 407 for ( std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden408 { 409 if ( it->second==piggy)//Spieler mit der Pig-party frags++410 { 411 this->playerScored( it->first);407 for (auto & elem : this->playerParty_) //durch alle Spieler iterieren und alle piggys finden 408 { 409 if (elem.second==piggy)//Spieler mit der Pig-party frags++ 410 { 411 this->playerScored(elem.first); 412 412 } 413 413 } … … 422 422 423 423 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 424 for ( std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)425 { 426 if (( *it)->isA(Class(TeamColourable)))424 for (const auto & pawnAttachment : pawnAttachments) 425 { 426 if ((pawnAttachment)->isA(Class(TeamColourable))) 427 427 { 428 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);428 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); 429 429 tc->setTeamColour(this->partyColours_[it_player->second]); 430 430 } … … 441 441 if (tutorial) // Announce selectionphase 442 442 { 443 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)444 { 445 if (! it->first)//in order to catch nullpointer443 for (auto & elem : this->playerParty_) 444 { 445 if (!elem.first)//in order to catch nullpointer 446 446 continue; 447 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)447 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 448 448 continue; 449 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));449 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 450 450 } 451 451 } … … 456 456 if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over 457 457 { 458 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)458 for (auto & elem : this->playerParty_) 459 459 { 460 if (! it->first)//in order to catch nullpointer460 if (!elem.first)//in order to catch nullpointer 461 461 continue; 462 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)462 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 463 463 continue; 464 else if ( it->second==chaser)464 else if (elem.second==chaser) 465 465 { 466 466 if (numberOf[killer]>0) 467 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);467 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]); 468 468 else 469 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);469 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]); 470 470 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 471 471 } 472 else if ( it->second==piggy)473 { 474 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[chaser]);472 else if (elem.second==piggy) 473 { 474 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[chaser]); 475 475 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 476 476 } 477 else if ( it->second==killer)478 { 479 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[chaser]);477 else if (elem.second==killer) 478 { 479 this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[chaser]); 480 480 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 481 481 } … … 490 490 if (tutorial) // Announce selectionphase 491 491 { 492 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)493 { 494 if (! it->first)//in order to catch nullpointer492 for (auto & elem : this->playerParty_) 493 { 494 if (!elem.first)//in order to catch nullpointer 495 495 continue; 496 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)496 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 497 497 continue; 498 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));498 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 499 499 } 500 500 } … … 505 505 if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over 506 506 { 507 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)507 for (auto & elem : this->playerParty_) 508 508 { 509 if (! it->first)509 if (!elem.first) 510 510 continue; 511 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)511 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 512 512 continue; 513 else if ( it->second==chaser)513 else if (elem.second==chaser) 514 514 { 515 515 if (numberOf[killer]>0) 516 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);516 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]); 517 517 else 518 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);518 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]); 519 519 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 520 520 } 521 else if ( it->second==piggy)522 { 523 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[piggy]);521 else if (elem.second==piggy) 522 { 523 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[piggy]); 524 524 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 525 525 } 526 else if ( it->second==killer)527 { 528 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[piggy]);526 else if (elem.second==killer) 527 { 528 this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[piggy]); 529 529 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 530 530 } … … 540 540 if (tutorial) // Announce selectionphase 541 541 { 542 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)543 { 544 if (! it->first)//in order to catch nullpointer542 for (auto & elem : this->playerParty_) 543 { 544 if (!elem.first)//in order to catch nullpointer 545 545 continue; 546 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)546 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 547 547 continue; 548 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));548 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 549 549 } 550 550 } … … 555 555 if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over 556 556 { 557 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)557 for (auto & elem : this->playerParty_) 558 558 { 559 if (! it->first)559 if (!elem.first) 560 560 continue; 561 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)561 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 562 562 continue; 563 else if ( it->second==chaser)563 else if (elem.second==chaser) 564 564 { 565 565 if (numberOf[killer]>0) 566 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);566 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]); 567 567 else 568 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);568 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]); 569 569 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 570 570 } 571 else if ( it->second==piggy)572 { 573 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[chaser]);571 else if (elem.second==piggy) 572 { 573 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[chaser]); 574 574 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 575 575 } 576 else if ( it->second==killer)577 { 578 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[chaser]);576 else if (elem.second==killer) 577 { 578 this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[chaser]); 579 579 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 580 580 } … … 620 620 else if(tutorial) // Announce selectionphase 621 621 { 622 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)623 { 624 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)622 for (auto & elem : this->playerParty_) 623 { 624 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 625 625 continue; 626 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));626 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 627 627 } 628 628 } … … 676 676 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 677 677 unsigned int index = 0; 678 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)678 for (const auto & teamSpawnPoint : teamSpawnPoints) 679 679 { 680 680 if (index == randomspawn) 681 return ( *it);681 return (teamSpawnPoint); 682 682 683 683 ++index; -
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 } -
code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc
r9667 r10821 56 56 void LastManStanding::spawnDeadPlayersIfRequested() 57 57 { 58 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)59 if ( it->second.state_ == PlayerState::Dead)60 { 61 bool alive = (0<playerLives_[ it->first]&&(inGame_[it->first]));62 if (alive&&( it->first->isReadyToSpawn() || this->bForceSpawn_))63 { 64 this->spawnPlayer( it->first);58 for (auto & elem : this->players_) 59 if (elem.second.state_ == PlayerState::Dead) 60 { 61 bool alive = (0<playerLives_[elem.first]&&(inGame_[elem.first])); 62 if (alive&&(elem.first->isReadyToSpawn() || this->bForceSpawn_)) 63 { 64 this->spawnPlayer(elem.first); 65 65 } 66 66 } … … 114 114 { 115 115 int min=lives; 116 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)117 { 118 if ( it->second<=0)116 for (auto & elem : this->playerLives_) 117 { 118 if (elem.second<=0) 119 119 continue; 120 if ( it->second<lives)121 min= it->second;120 if (elem.second<lives) 121 min=elem.second; 122 122 } 123 123 return min; … … 128 128 Gametype::end(); 129 129 130 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)131 { 132 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)130 for (auto & elem : this->playerLives_) 131 { 132 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 133 133 continue; 134 134 135 if ( it->second > 0)136 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());135 if (elem.second > 0) 136 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID()); 137 137 else 138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID()); 139 139 } 140 140 } … … 237 237 this->end(); 238 238 } 239 for ( std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)240 { 241 if (playerGetLives( it->first)<=0)//Players without lives shouldn't be affected by time.239 for (auto & elem : this->timeToAct_) 240 { 241 if (playerGetLives(elem.first)<=0)//Players without lives shouldn't be affected by time. 242 242 continue; 243 it->second-=dt;//Decreases punishment time.244 if (!inGame_[ it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.245 { 246 playerDelayTime_[ it->first]-=dt;247 if (playerDelayTime_[ it->first]<=0)248 this->inGame_[ it->first]=true;249 250 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)243 elem.second-=dt;//Decreases punishment time. 244 if (!inGame_[elem.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 245 { 246 playerDelayTime_[elem.first]-=dt; 247 if (playerDelayTime_[elem.first]<=0) 248 this->inGame_[elem.first]=true; 249 250 if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 251 251 continue; 252 int output=1+(int)playerDelayTime_[ it->first];252 int output=1+(int)playerDelayTime_[elem.first]; 253 253 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 254 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());255 } 256 else if ( it->second<0.0f)257 { 258 it->second=timeRemaining+3.0f;//reset punishment-timer259 if (playerGetLives( it->first)>0)254 this->gtinfo_->sendFadingMessage(message,elem.first->getClientID()); 255 } 256 else if (elem.second<0.0f) 257 { 258 elem.second=timeRemaining+3.0f;//reset punishment-timer 259 if (playerGetLives(elem.first)>0) 260 260 { 261 this->punishPlayer( it->first);262 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)261 this->punishPlayer(elem.first); 262 if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 263 263 return; 264 264 const std::string& message = ""; // resets Camper-Warning-message 265 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());265 this->gtinfo_->sendFadingMessage(message,elem.first->getClientID()); 266 266 } 267 267 } 268 else if ( it->second<timeRemaining/5)//Warning message269 { 270 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)268 else if (elem.second<timeRemaining/5)//Warning message 269 { 270 if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 271 271 continue; 272 272 const std::string& message = "Camper Warning! Don't forget to shoot."; 273 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());273 this->gtinfo_->sendFadingMessage(message,elem.first->getClientID()); 274 274 } 275 275 } -
code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc
r9941 r10821 145 145 void LastTeamStanding::spawnDeadPlayersIfRequested() 146 146 { 147 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)148 if ( it->second.state_ == PlayerState::Dead)149 { 150 bool alive = (0 < playerLives_[ it->first]&&(inGame_[it->first]));151 if (alive&&( it->first->isReadyToSpawn() || this->bForceSpawn_))152 { 153 this->spawnPlayer( it->first);147 for (auto & elem : this->players_) 148 if (elem.second.state_ == PlayerState::Dead) 149 { 150 bool alive = (0 < playerLives_[elem.first]&&(inGame_[elem.first])); 151 if (alive&&(elem.first->isReadyToSpawn() || this->bForceSpawn_)) 152 { 153 this->spawnPlayer(elem.first); 154 154 } 155 155 } … … 184 184 this->end(); 185 185 } 186 for ( std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)187 { 188 if (playerGetLives( it->first) <= 0)//Players without lives shouldn't be affected by time.186 for (auto & elem : this->timeToAct_) 187 { 188 if (playerGetLives(elem.first) <= 0)//Players without lives shouldn't be affected by time. 189 189 continue; 190 it->second -= dt;//Decreases punishment time.191 if (!inGame_[ it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.192 { 193 playerDelayTime_[ it->first] -= dt;194 if (playerDelayTime_[ it->first] <= 0)195 this->inGame_[ it->first] = true;196 197 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)190 elem.second -= dt;//Decreases punishment time. 191 if (!inGame_[elem.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 192 { 193 playerDelayTime_[elem.first] -= dt; 194 if (playerDelayTime_[elem.first] <= 0) 195 this->inGame_[elem.first] = true; 196 197 if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 198 198 continue; 199 int output = 1 + (int)playerDelayTime_[ it->first];199 int output = 1 + (int)playerDelayTime_[elem.first]; 200 200 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 201 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());202 } 203 else if ( it->second < 0.0f)204 { 205 it->second = timeRemaining + 3.0f;//reset punishment-timer206 if (playerGetLives( it->first) > 0)201 this->gtinfo_->sendFadingMessage(message,elem.first->getClientID()); 202 } 203 else if (elem.second < 0.0f) 204 { 205 elem.second = timeRemaining + 3.0f;//reset punishment-timer 206 if (playerGetLives(elem.first) > 0) 207 207 { 208 this->punishPlayer( it->first);209 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)208 this->punishPlayer(elem.first); 209 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 210 210 return; 211 211 const std::string& message = ""; // resets Camper-Warning-message 212 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());212 this->gtinfo_->sendFadingMessage(message, elem.first->getClientID()); 213 213 } 214 214 } 215 else if ( it->second < timeRemaining/5)//Warning message216 { 217 if ( it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)215 else if (elem.second < timeRemaining/5)//Warning message 216 { 217 if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 218 218 continue; 219 219 const std::string& message = "Camper Warning! Don't forget to shoot."; 220 this->gtinfo_->sendFadingMessage(message, it->first->getClientID());220 this->gtinfo_->sendFadingMessage(message, elem.first->getClientID()); 221 221 } 222 222 } … … 229 229 int party = -1; 230 230 //find a player who survived 231 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)232 { 233 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)231 for (auto & elem : this->playerLives_) 232 { 233 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 234 234 continue; 235 235 236 if ( it->second > 0)//a player that is alive236 if (elem.second > 0)//a player that is alive 237 237 { 238 238 //which party has survived? 239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find( it->first);239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(elem.first); 240 240 if (it2 != this->teamnumbers_.end()) 241 241 { … … 255 255 { 256 256 int min = lives; 257 for ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)258 { 259 if ( it->second <= 0)257 for (auto & elem : this->playerLives_) 258 { 259 if (elem.second <= 0) 260 260 continue; 261 if ( it->second < lives)262 min = it->second;261 if (elem.second < lives) 262 min = elem.second; 263 263 } 264 264 return min; -
code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc
r10768 r10821 152 152 int amountControlled2 = 0; 153 153 154 for ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)155 { 156 if(( *it)->getState() == BaseState::ControlTeam1)154 for (const auto & elem : this->bases_) 155 { 156 if((elem)->getState() == BaseState::ControlTeam1) 157 157 { 158 158 amountControlled++; 159 159 } 160 if(( *it)->getState() == BaseState::ControlTeam2)160 if((elem)->getState() == BaseState::ControlTeam2) 161 161 { 162 162 amountControlled2++; … … 187 187 } 188 188 189 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)190 { 191 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)189 for (auto & elem : this->teamnumbers_) 190 { 191 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 192 192 continue; 193 193 194 if ( it->second == winningteam)195 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());194 if (elem.second == winningteam) 195 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID()); 196 196 else 197 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());197 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID()); 198 198 } 199 199 … … 238 238 int count = 0; 239 239 240 for ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)241 { 242 if (( *it)->getState() == BaseState::ControlTeam1 && team == 0)240 for (const auto & elem : this->bases_) 241 { 242 if ((elem)->getState() == BaseState::ControlTeam1 && team == 0) 243 243 count++; 244 if (( *it)->getState() == BaseState::ControlTeam2 && team == 1)244 if ((elem)->getState() == BaseState::ControlTeam2 && team == 1) 245 245 count++; 246 246 } … … 258 258 { 259 259 unsigned int i = 0; 260 for ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)260 for (const auto & elem : this->bases_) 261 261 { 262 262 i++; 263 263 if (i > index) 264 return ( *it);264 return (elem); 265 265 } 266 266 return nullptr; -
code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc
r9941 r10821 69 69 int winnerTeam = 0; 70 70 int highestScore = 0; 71 for ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)71 for (auto & elem : this->players_) 72 72 { 73 if ( this->getTeamScore( it->first) > highestScore )73 if ( this->getTeamScore(elem.first) > highestScore ) 74 74 { 75 winnerTeam = this->getTeam( it->first);76 highestScore = this->getTeamScore( it->first);75 winnerTeam = this->getTeam(elem.first); 76 highestScore = this->getTeamScore(elem.first); 77 77 } 78 78 } -
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 } -
code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc
r10768 r10821 74 74 this->gameEnded_ = true; 75 75 76 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)77 { 78 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)76 for (auto & elem : this->teamnumbers_) 77 { 78 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 79 79 continue; 80 80 81 if ( it->second == attacker_)82 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());81 if (elem.second == attacker_) 82 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID()); 83 83 else 84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID()); 85 85 } 86 86 } … … 155 155 ChatManager::message(message); 156 156 157 for ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)158 { 159 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)157 for (auto & elem : this->teamnumbers_) 158 { 159 if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 160 160 continue; 161 161 162 if ( it->second == 1)163 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());162 if (elem.second == 1) 163 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID()); 164 164 else 165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID()); 166 166 } 167 167 } -
code/branches/cpp11_v2/src/orxonox/interfaces/PickupCarrier.cc
r10765 r10821 135 135 // Go recursively through all children to check whether they are the target. 136 136 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 137 for( std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)137 for(auto & elem : *children) 138 138 { 139 if(pickup->isTarget( *it))139 if(pickup->isTarget(elem)) 140 140 { 141 target = *it;141 target = elem; 142 142 break; 143 143 } -
code/branches/cpp11_v2/src/orxonox/interfaces/Pickupable.cc
r10765 r10821 160 160 { 161 161 // Iterate through all targets of this Pickupable. 162 for( std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)162 for(const auto & elem : this->targets_) 163 163 { 164 if(identifier->isA( *it))164 if(identifier->isA(elem)) 165 165 return true; 166 166 } -
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc
r10768 r10821 219 219 { 220 220 unsigned int i = 0; 221 for ( std::vector<EffectContainer*>::const_iterator it = this->effectContainers_.begin(); it != this->effectContainers_.end(); ++it)221 for (const auto & elem : this->effectContainers_) 222 222 { 223 223 if (i == index) 224 return (*it); 224 return (elem); 225 i++; 225 226 } 226 227 return nullptr; -
code/branches/cpp11_v2/src/orxonox/items/ShipPart.cc
r10765 r10821 148 148 bool ShipPart::hasEntity(StaticEntity* entity) const 149 149 { 150 for( unsigned int i = 0; i < this->entityList_.size(); i++)151 { 152 if( this->entityList_[i]== entity)150 for(auto & elem : this->entityList_) 151 { 152 if(elem == entity) 153 153 return true; 154 154 } -
code/branches/cpp11_v2/src/orxonox/overlays/OverlayGroup.cc
r10769 r10821 62 62 OverlayGroup::~OverlayGroup() 63 63 { 64 for ( std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)65 ( *it)->destroy();64 for (const auto & elem : hudElements_) 65 (elem)->destroy(); 66 66 this->hudElements_.clear(); 67 67 } … … 86 86 void OverlayGroup::setScale(const Vector2& scale) 87 87 { 88 for ( std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)89 ( *it)->scale(scale / this->scale_);88 for (const auto & elem : hudElements_) 89 (elem)->scale(scale / this->scale_); 90 90 this->scale_ = scale; 91 91 } … … 94 94 void OverlayGroup::setScroll(const Vector2& scroll) 95 95 { 96 for ( std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)97 ( *it)->scroll(scroll - this->scroll_);96 for (const auto & elem : hudElements_) 97 (elem)->scroll(scroll - this->scroll_); 98 98 this->scroll_ = scroll; 99 99 } … … 147 147 SUPER( OverlayGroup, changedVisibility ); 148 148 149 for ( std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)150 ( *it)->changedVisibility(); //inform all Child Overlays that our visibility has changed149 for (const auto & elem : hudElements_) 150 (elem)->changedVisibility(); //inform all Child Overlays that our visibility has changed 151 151 } 152 152 … … 155 155 this->owner_ = owner; 156 156 157 for ( std::set<StrongPtr<OrxonoxOverlay>>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)158 ( *it)->setOwner(owner);157 for (const auto & elem : hudElements_) 158 (elem)->setOwner(owner); 159 159 } 160 160 -
code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc
r10771 r10821 407 407 if (ambient != nullptr) 408 408 { 409 for ( AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)410 { 411 if ( it->first == ambient)409 for (auto & elem : this->ambientSounds_) 410 { 411 if (elem.first == ambient) 412 412 { 413 it->second = true;414 this->fadeOut( it->first);413 elem.second = true; 414 this->fadeOut(elem.first); 415 415 return; 416 416 } -
code/branches/cpp11_v2/src/orxonox/sound/SoundStreamer.cc
r10765 r10821 68 68 int current_section; 69 69 70 for( int i = 0; i < 4; i++)70 for(auto & initbuffer : initbuffers) 71 71 { 72 72 long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section); … … 82 82 } 83 83 84 alBufferData(initbuffer s[i], format, &inbuffer, ret, vorbisInfo->rate);84 alBufferData(initbuffer, format, &inbuffer, ret, vorbisInfo->rate); 85 85 } 86 86 alSourceQueueBuffers(audioSource, 4, initbuffers); -
code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc
r10768 r10821 55 55 Munition::~Munition() 56 56 { 57 for ( std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)58 delete it->second;57 for (auto & elem : this->currentMagazines_) 58 delete elem.second; 59 59 } 60 60 … … 268 268 { 269 269 // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition) 270 for ( std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)271 if ( it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)270 for (const auto & elem : this->currentMagazines_) 271 if (elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_) 272 272 return true; 273 273 } … … 316 316 { 317 317 bool change = false; 318 for ( std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)318 for (auto & elem : this->currentMagazines_) 319 319 { 320 320 // Add munition if the magazine isn't full (but only to loaded magazines) 321 if (amount > 0 && it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)321 if (amount > 0 && elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_) 322 322 { 323 it->second->munition_++;323 elem.second->munition_++; 324 324 amount--; 325 325 change = true; -
code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc
r10768 r10821 61 61 this->weaponPack_->removeWeapon(this); 62 62 63 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)64 it->second->destroy();63 for (auto & elem : this->weaponmodes_) 64 elem.second->destroy(); 65 65 } 66 66 } … … 85 85 { 86 86 unsigned int i = 0; 87 for ( std::multimap<unsigned int, WeaponMode*>::const_iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)87 for (const auto & elem : this->weaponmodes_) 88 88 { 89 89 if (i == index) 90 return it->second;90 return elem.second; 91 91 92 92 ++i; … … 136 136 void Weapon::reload() 137 137 { 138 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)139 it->second->reload();138 for (auto & elem : this->weaponmodes_) 139 elem.second->reload(); 140 140 } 141 141 … … 148 148 void Weapon::notifyWeaponModes() 149 149 { 150 for ( std::multimap<unsigned int, WeaponMode*>::iterator it = this->weaponmodes_.begin(); it != this->weaponmodes_.end(); ++it)151 it->second->setWeapon(this);150 for (auto & elem : this->weaponmodes_) 151 elem.second->setWeapon(this); 152 152 } 153 153 } -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc
r10768 r10821 76 76 void WeaponPack::fire(unsigned int weaponmode) 77 77 { 78 for ( std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)79 ( *it)->fire(weaponmode);78 for (auto & elem : this->weapons_) 79 (elem)->fire(weaponmode); 80 80 } 81 81 … … 86 86 void WeaponPack::reload() 87 87 { 88 for ( std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)89 ( *it)->reload();88 for (auto & elem : this->weapons_) 89 (elem)->reload(); 90 90 } 91 91 … … 114 114 unsigned int i = 0; 115 115 116 for ( std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)116 for (const auto & elem : this->weapons_) 117 117 { 118 118 if (i == index) 119 return ( *it);119 return (elem); 120 120 ++i; 121 121 } … … 132 132 { 133 133 unsigned int i = 0; 134 for ( std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)134 for (const auto & elem : this->links_) 135 135 { 136 136 if (i == index) 137 return ( *it);137 return (elem); 138 138 139 139 ++i; … … 144 144 unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const 145 145 { 146 for ( std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)147 if (( *it)->getFiremode() == firemode)148 return ( *it)->getWeaponmode();146 for (const auto & elem : this->links_) 147 if ((elem)->getFiremode() == firemode) 148 return (elem)->getWeaponmode(); 149 149 150 150 return WeaponSystem::WEAPON_MODE_UNASSIGNED; -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc
r10768 r10821 63 63 { 64 64 // Fire all WeaponPacks with their defined weaponmode 65 for ( std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)66 if ( it->second != WeaponSystem::WEAPON_MODE_UNASSIGNED)67 it->first->fire(it->second);65 for (auto & elem : this->weaponpacks_) 66 if (elem.second != WeaponSystem::WEAPON_MODE_UNASSIGNED) 67 elem.first->fire(elem.second); 68 68 } 69 69 … … 71 71 { 72 72 // Reload all WeaponPacks with their defined weaponmode 73 for ( std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)74 it->first->reload();73 for (auto & elem : this->weaponpacks_) 74 elem.first->reload(); 75 75 } 76 76 -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc
r10768 r10821 106 106 { 107 107 unsigned int i = 0; 108 for ( std::vector<WeaponSlot*>::const_iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)108 for (const auto & elem : this->weaponSlots_) 109 109 { 110 110 ++i; 111 111 if (i > index) 112 return ( *it);112 return (elem); 113 113 } 114 114 return nullptr; … … 153 153 { 154 154 unsigned int i = 0; 155 for ( std::map<unsigned int, WeaponSet*>::const_iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)155 for (const auto & elem : this->weaponSets_) 156 156 { 157 157 ++i; 158 158 if (i > index) 159 return it->second;159 return elem.second; 160 160 } 161 161 return nullptr; … … 168 168 169 169 unsigned int freeSlots = 0; 170 for ( std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)171 { 172 if (!( *it)->isOccupied())170 for (auto & elem : this->weaponSlots_) 171 { 172 if (!(elem)->isOccupied()) 173 173 ++freeSlots; 174 174 } … … 184 184 // Attach all weapons to the first free slots (and to the Pawn) 185 185 unsigned int i = 0; 186 for ( std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)187 { 188 if (!( *it)->isOccupied() && i < wPack->getNumWeapons())186 for (auto & elem : this->weaponSlots_) 187 { 188 if (!(elem)->isOccupied() && i < wPack->getNumWeapons()) 189 189 { 190 190 Weapon* weapon = wPack->getWeapon(i); 191 ( *it)->attachWeapon(weapon);191 (elem)->attachWeapon(weapon); 192 192 this->getPawn()->attach(weapon); 193 193 ++i; … … 196 196 197 197 // Assign the desired weaponmode to the firemodes 198 for ( std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)199 { 200 unsigned int weaponmode = wPack->getDesiredWeaponmode( it->first);198 for (auto & elem : this->weaponSets_) 199 { 200 unsigned int weaponmode = wPack->getDesiredWeaponmode(elem.first); 201 201 if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED) 202 it->second->setWeaponmodeLink(wPack, weaponmode);202 elem.second->setWeaponmodeLink(wPack, weaponmode); 203 203 } 204 204 … … 219 219 220 220 // Remove all added links from the WeaponSets 221 for ( std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)222 it->second->removeWeaponmodeLink(wPack);221 for (auto & elem : this->weaponSets_) 222 elem.second->removeWeaponmodeLink(wPack); 223 223 224 224 // Remove the WeaponPack from the WeaponSystem … … 231 231 { 232 232 unsigned int i = 0; 233 for ( std::vector<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)233 for (const auto & elem : this->weaponPacks_) 234 234 { 235 235 ++i; 236 236 if (i > index) 237 return ( *it);237 return (elem); 238 238 } 239 239 return nullptr; … … 268 268 // Check if the WeaponSet belongs to this WeaponSystem 269 269 bool foundWeaponSet = false; 270 for ( std::map<unsigned int, WeaponSet *>::iterator it2 = this->weaponSets_.begin(); it2 != this->weaponSets_.end(); ++it2)271 { 272 if ( it2->second == wSet)270 for (auto & elem : this->weaponSets_) 271 { 272 if (elem.second == wSet) 273 273 { 274 274 foundWeaponSet = true; … … 296 296 void WeaponSystem::reload() 297 297 { 298 for ( std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it)299 it->second->reload();298 for (auto & elem : this->weaponSets_) 299 elem.second->reload(); 300 300 } 301 301 -
code/branches/cpp11_v2/src/orxonox/worldentities/ControllableEntity.cc
r10769 r10821 165 165 { 166 166 unsigned int i = 0; 167 for ( std::list<StrongPtr<CameraPosition>>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)167 for (const auto & elem : this->cameraPositions_) 168 168 { 169 169 if (i == index) 170 return ( *it);170 return (elem); 171 171 ++i; 172 172 } … … 180 180 181 181 unsigned int counter = 0; 182 for ( std::list<StrongPtr<CameraPosition>>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)183 { 184 if (( *it) == this->currentCameraPosition_)182 for (const auto & elem : this->cameraPositions_) 183 { 184 if ((elem) == this->currentCameraPosition_) 185 185 break; 186 186 counter++; … … 477 477 if (parent) 478 478 { 479 for ( std::list<StrongPtr<CameraPosition>>::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)480 if (( *it)->getIsAbsolute())481 parent->attach(( *it));479 for (auto & elem : this->cameraPositions_) 480 if ((elem)->getIsAbsolute()) 481 parent->attach((elem)); 482 482 } 483 483 } -
code/branches/cpp11_v2/src/orxonox/worldentities/EffectContainer.cc
r10765 r10821 89 89 { 90 90 unsigned int i = 0; 91 for ( std::vector<WorldEntity*>::const_iterator it = this->effects_.begin(); it != this->effects_.end(); ++it)91 for (const auto & elem : this->effects_) 92 92 if (i == index) 93 return ( *it);93 return (elem); 94 94 return nullptr; 95 95 } -
code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc
r10774 r10821 233 233 234 234 // iterate over all children and change their activity as well 235 for ( std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)235 for (const auto & elem : this->getAttachedObjects()) 236 236 { 237 237 if(!this->isActive()) 238 238 { 239 ( *it)->bActiveMem_ = (*it)->isActive();240 ( *it)->setActive(this->isActive());239 (elem)->bActiveMem_ = (elem)->isActive(); 240 (elem)->setActive(this->isActive()); 241 241 } 242 242 else 243 243 { 244 ( *it)->setActive((*it)->bActiveMem_);244 (elem)->setActive((elem)->bActiveMem_); 245 245 } 246 246 } … … 259 259 { 260 260 // iterate over all children and change their visibility as well 261 for ( std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)261 for (const auto & elem : this->getAttachedObjects()) 262 262 { 263 263 if(!this->isVisible()) 264 264 { 265 ( *it)->bVisibleMem_ = (*it)->isVisible();266 ( *it)->setVisible(this->isVisible());265 (elem)->bVisibleMem_ = (elem)->isVisible(); 266 (elem)->setVisible(this->isVisible()); 267 267 } 268 268 else 269 269 { 270 ( *it)->setVisible((*it)->bVisibleMem_);270 (elem)->setVisible((elem)->bVisibleMem_); 271 271 } 272 272 } … … 518 518 { 519 519 unsigned int i = 0; 520 for ( std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)520 for (const auto & elem : this->children_) 521 521 { 522 522 if (i == index) 523 return ( *it);523 return (elem); 524 524 ++i; 525 525 } … … 938 938 // Recalculate mass 939 939 this->childrenMass_ = 0.0f; 940 for ( std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)941 this->childrenMass_ += ( *it)->getMass();940 for (const auto & elem : this->children_) 941 this->childrenMass_ += (elem)->getMass(); 942 942 recalculateMassProps(); 943 943 // Notify parent WE -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10768 r10821 99 99 } 100 100 // iterate through all attached parts 101 for( unsigned int j = 0; j < this->partList_.size(); j++)101 for(auto & elem : this->partList_) 102 102 { 103 103 // if the name of the part matches the name of the object, add the object to that parts entitylist (unless it was already done). 104 if(( this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))104 if((elem->getName() == this->getAttachedObject(i)->getName()) && !elem->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 105 105 { 106 106 // The Entity is added to the part's entityList_ 107 this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));107 elem->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))); 108 108 // An entry in the partMap_ is created, assigning the part to the entity. 109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), elem); 110 110 } 111 111 } … … 146 146 ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const 147 147 { 148 for ( std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)149 { 150 if ( it->first == entity)151 return it->second;148 for (const auto & elem : this->partMap_) 149 { 150 if (elem.first == entity) 151 return elem.second; 152 152 } 153 153 return nullptr; … … 242 242 ShipPart* ModularSpaceShip::getShipPartByName(std::string name) 243 243 { 244 for( std::vector<ShipPart*>::iterator it = this->partList_.begin(); it != this->partList_.end(); ++it)245 { 246 if(orxonox_cast<ShipPart*>( *it)->getName() == name)247 { 248 return orxonox_cast<ShipPart*>( *it);244 for(auto & elem : this->partList_) 245 { 246 if(orxonox_cast<ShipPart*>(elem)->getName() == name) 247 { 248 return orxonox_cast<ShipPart*>(elem); 249 249 } 250 250 } … … 261 261 bool ModularSpaceShip::hasShipPart(ShipPart* part) const 262 262 { 263 for( unsigned int i = 0; i < this->partList_.size(); i++)264 { 265 if( this->partList_[i]== part)263 for(auto & elem : this->partList_) 264 { 265 if(elem == part) 266 266 return true; 267 267 } -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc
r10768 r10821 158 158 159 159 // Run the engines 160 for( std::vector<Engine*>::iterator it = this->engineList_.begin(); it != this->engineList_.end(); it++)161 ( *it)->run(dt);160 for(auto & elem : this->engineList_) 161 (elem)->run(dt); 162 162 163 163 if (this->hasLocalController()) … … 318 318 bool SpaceShip::hasEngine(Engine* engine) const 319 319 { 320 for( unsigned int i = 0; i < this->engineList_.size(); i++)321 { 322 if( this->engineList_[i]== engine)320 for(auto & elem : this->engineList_) 321 { 322 if(elem == engine) 323 323 return true; 324 324 } … … 350 350 Engine* SpaceShip::getEngineByName(const std::string& name) 351 351 { 352 for( size_t i = 0; i < this->engineList_.size(); ++i)353 if( this->engineList_[i]->getName() == name)354 return this->engineList_[i];352 for(auto & elem : this->engineList_) 353 if(elem->getName() == name) 354 return elem; 355 355 356 356 orxout(internal_warning) << "Couldn't find Engine with name \"" << name << "\"." << endl; … … 396 396 void SpaceShip::addSpeedFactor(float factor) 397 397 { 398 for( unsigned int i=0; i<this->engineList_.size(); i++)399 this->engineList_[i]->addSpeedMultiply(factor);398 for(auto & elem : this->engineList_) 399 elem->addSpeedMultiply(factor); 400 400 } 401 401 … … 408 408 void SpaceShip::addSpeed(float speed) 409 409 { 410 for( unsigned int i=0; i<this->engineList_.size(); i++)411 this->engineList_[i]->addSpeedAdd(speed);410 for(auto & elem : this->engineList_) 411 elem->addSpeedAdd(speed); 412 412 } 413 413 … … 436 436 { 437 437 float speed=0; 438 for( unsigned int i=0; i<this->engineList_.size(); i++)439 { 440 if( this->engineList_[i]->getMaxSpeedFront() > speed)441 speed = this->engineList_[i]->getMaxSpeedFront();438 for(auto & elem : this->engineList_) 439 { 440 if(elem->getMaxSpeedFront() > speed) 441 speed = elem->getMaxSpeedFront(); 442 442 } 443 443 return speed; -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r10624 r10821 80 80 81 81 std::set<WorldEntity*> attachments = this->getAttachedObjects(); 82 for ( std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it)82 for (const auto & attachment : attachments) 83 83 { 84 if (( *it)->isA(Class(TeamColourable)))84 if ((attachment)->isA(Class(TeamColourable))) 85 85 { 86 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);86 TeamColourable* tc = orxonox_cast<TeamColourable*>(attachment); 87 87 tc->setTeamColour(colour); 88 88 }
Note: See TracChangeset
for help on using the changeset viewer.