Changeset 10916 for code/branches/cpp11_v2/src/orxonox
- Timestamp:
- Dec 2, 2015, 11:22:03 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/orxonox
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/Level.cc
r10821 r10916 106 106 void Level::networkCallbackTemplatesChanged() 107 107 { 108 for(const auto & elem: this->networkTemplateNames_)109 { 110 assert(Template::getTemplate( elem));111 Template::getTemplate( elem)->applyOn(this);108 for(const std::string& name : this->networkTemplateNames_) 109 { 110 assert(Template::getTemplate(name)); 111 Template::getTemplate(name)->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 ( auto & elem: this->plugins_)138 (elem)->destroyLater();137 for (PluginReference* plugin : this->plugins_) 138 plugin->destroyLater(); 139 139 this->plugins_.clear(); 140 140 } … … 173 173 { 174 174 unsigned int i = 0; 175 for ( const auto & elem: this->objects_)175 for (BaseObject* object : this->objects_) 176 176 { 177 177 if (i == index) 178 return (elem);178 return object; 179 179 ++i; 180 180 } -
code/branches/cpp11_v2/src/orxonox/LevelInfo.cc
r10821 r10916 106 106 { 107 107 SubString substr = SubString(tags, ",", " "); // Split the string into tags. 108 const std::vector<std::string>& strings = substr.getAllStrings();109 for (const auto & strings_it : strings)110 this->addTag( strings_it, false);108 const std::vector<std::string>& tokens = substr.getAllStrings(); 109 for (const std::string& token : tokens) 110 this->addTag(token, false); 111 111 112 112 this->tagsUpdated(); … … 121 121 { 122 122 SubString substr = SubString(ships, ",", " "); // Split the string into tags. 123 const std::vector<std::string>& strings = substr.getAllStrings();124 for(const auto & strings_it : strings)125 this->addStartingShip( strings_it, false);123 const std::vector<std::string>& tokens = substr.getAllStrings(); 124 for(const std::string& token : tokens) 125 this->addStartingShip(token, false); 126 126 127 127 this->startingshipsUpdated(); -
code/branches/cpp11_v2/src/orxonox/LevelManager.cc
r10821 r10916 175 175 this->levels_.front()->setActive(true); 176 176 // Make every player enter the newly activated level. 177 for (const auto & elem: PlayerManager::getInstance().getClients())178 this->levels_.front()->playerEntered( elem.second);177 for (const auto& mapEntry : PlayerManager::getInstance().getClients()) 178 this->levels_.front()->playerEntered(mapEntry.second); 179 179 } 180 180 } -
code/branches/cpp11_v2/src/orxonox/Scene.cc
r10821 r10916 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 ( const auto & elem: this->physicalObjects_)222 for (WorldEntity* object : this->physicalObjects_) 223 223 { 224 this->physicalWorld_->removeRigidBody( (elem)->physicalBody_);225 this->physicalObjectQueue_.insert( elem);224 this->physicalWorld_->removeRigidBody(object->physicalBody_); 225 this->physicalObjectQueue_.insert(object); 226 226 } 227 227 this->physicalObjects_.clear(); … … 255 255 { 256 256 // Add all scheduled WorldEntities 257 for ( const auto & elem: this->physicalObjectQueue_)257 for (WorldEntity* object : this->physicalObjectQueue_) 258 258 { 259 this->physicalWorld_->addRigidBody( (elem)->physicalBody_);260 this->physicalObjects_.insert( elem);259 this->physicalWorld_->addRigidBody(object->physicalBody_); 260 this->physicalObjects_.insert(object); 261 261 } 262 262 this->physicalObjectQueue_.clear(); … … 319 319 { 320 320 unsigned int i = 0; 321 for ( const auto & elem: this->objects_)321 for (BaseObject* object : this->objects_) 322 322 { 323 323 if (i == index) 324 return (elem);324 return object; 325 325 ++i; 326 326 } -
code/branches/cpp11_v2/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r10821 r10916 65 65 { 66 66 // Delete all children 67 for (auto & elem: this->attachedShapes_)67 for (auto& mapEntry : this->attachedShapes_) 68 68 { 69 69 // make sure that the child doesn't want to detach itself --> speedup because of the missing update 70 elem.first->notifyDetached();71 elem.first->destroy();72 if (this->collisionShape_ == elem.second)70 mapEntry.first->notifyDetached(); 71 mapEntry.first->destroy(); 72 if (this->collisionShape_ == mapEntry.second) 73 73 this->collisionShape_ = nullptr; // don't destroy it twice 74 74 } … … 246 246 { 247 247 unsigned int i = 0; 248 for (const auto & elem: this->attachedShapes_)248 for (const auto& mapEntry : this->attachedShapes_) 249 249 { 250 250 if (i == index) 251 return elem.first;251 return mapEntry.first; 252 252 ++i; 253 253 } … … 266 266 std::vector<CollisionShape*> shapes; 267 267 // Iterate through all attached CollisionShapes and add them to the list of shapes. 268 for(auto & elem: this->attachedShapes_)269 shapes.push_back( elem.first);268 for(auto& mapEntry : this->attachedShapes_) 269 shapes.push_back(mapEntry.first); 270 270 271 271 // Delete the compound shape and create a new one. … … 274 274 275 275 // Re-attach all CollisionShapes. 276 for(auto shape : shapes) 277 { 278 276 for(CollisionShape* shape : shapes) 277 { 279 278 shape->setScale3D(this->getScale3D()); 280 279 // Only actually attach if we didn't pick a CompoundCollisionShape with no content. -
code/branches/cpp11_v2/src/orxonox/controllers/ArtificialController.cc
r10768 r10916 231 231 int ArtificialController::getFiremode(std::string name) 232 232 { 233 for (auto firemode: this->weaponModes_)234 { 235 if ( firemode.first == name)236 return firemode.second;233 for (auto& mapEntry : this->weaponModes_) 234 { 235 if (mapEntry.first == name) 236 return mapEntry.second; 237 237 } 238 238 return -1; -
code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
r10821 r10916 440 440 if(newMaster->slaves_.size() > this->maxFormationSize_) continue; 441 441 442 for( auto & elem: this->slaves_)442 for(FormationController* slave : this->slaves_) 443 443 { 444 (elem)->myMaster_ = newMaster;445 newMaster->slaves_.push_back( elem);444 slave->myMaster_ = newMaster; 445 newMaster->slaves_.push_back(slave); 446 446 } 447 447 this->slaves_.clear(); … … 486 486 int i = 1; 487 487 488 for( auto & elem: slaves_)488 for(FormationController* slave : slaves_) 489 489 { 490 490 pos = Vector3::ZERO; … … 497 497 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 498 498 } 499 (elem)->setTargetOrientation(orient);500 (elem)->setTargetPosition(pos);499 slave->setTargetOrientation(orient); 500 slave->setTargetPosition(pos); 501 501 left=!left; 502 502 } … … 569 569 if(this->state_ != MASTER) return; 570 570 571 for( auto & elem: slaves_)572 { 573 (elem)->state_ = FREE;574 (elem)->myMaster_ = nullptr;571 for(FormationController* slave : slaves_) 572 { 573 slave->state_ = FREE; 574 slave->myMaster_ = nullptr; 575 575 } 576 576 this->slaves_.clear(); … … 584 584 if(this->state_ != MASTER) return; 585 585 586 for( auto & elem: slaves_)587 { 588 (elem)->state_ = FREE;589 (elem)->forceFreedom();590 (elem)->targetPosition_ = this->targetPosition_;591 (elem)->bShooting_ = true;586 for(FormationController* slave : slaves_) 587 { 588 slave->state_ = FREE; 589 slave->forceFreedom(); 590 slave->targetPosition_ = this->targetPosition_; 591 slave->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( auto & elem: slaves_)653 { 654 (elem)->myMaster_=this;652 for(FormationController* slave : slaves_) 653 { 654 slave->myMaster_=this; 655 655 } 656 656 this->myMaster_=nullptr; … … 694 694 if (this->state_ == MASTER) 695 695 { 696 for( auto & elem: slaves_)697 { 698 (elem)->formationMode_ = val;696 for(FormationController* slave : slaves_) 697 { 698 slave->formationMode_ = val; 699 699 if (val == ATTACK) 700 (elem)->forgetTarget();700 slave->forgetTarget(); 701 701 } 702 702 } -
code/branches/cpp11_v2/src/orxonox/controllers/WaypointController.cc
r10821 r10916 44 44 WaypointController::~WaypointController() 45 45 { 46 for ( auto & elem: this->waypoints_)46 for (WorldEntity* waypoint : this->waypoints_) 47 47 { 48 if( elem)49 elem->destroy();48 if(waypoint) 49 waypoint->destroy(); 50 50 } 51 51 } -
code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc
r10821 r10916 251 251 252 252 // delete states 253 for ( auto &state : states)253 for (GSLevelMementoState* state : states) 254 254 delete state; 255 255 } -
code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc
r10821 r10916 405 405 void Dynamicmatch::rewardPig() 406 406 { 407 for (auto & elem: this->playerParty_) //durch alle Spieler iterieren und alle piggys finden408 { 409 if ( elem.second==piggy)//Spieler mit der Pig-party frags++410 { 411 this->playerScored( elem.first);407 for (auto& mapEntry : this->playerParty_) //durch alle Spieler iterieren und alle piggys finden 408 { 409 if (mapEntry.second==piggy)//Spieler mit der Pig-party frags++ 410 { 411 this->playerScored(mapEntry.first); 412 412 } 413 413 } … … 422 422 423 423 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 424 for ( const auto &pawnAttachment : pawnAttachments)425 { 426 if ( (pawnAttachment)->isA(Class(TeamColourable)))424 for (WorldEntity* pawnAttachment : pawnAttachments) 425 { 426 if (pawnAttachment->isA(Class(TeamColourable))) 427 427 { 428 428 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); … … 441 441 if (tutorial) // Announce selectionphase 442 442 { 443 for (auto & elem: this->playerParty_)444 { 445 if (! elem.first)//in order to catch nullpointer443 for (auto& mapEntry : this->playerParty_) 444 { 445 if (!mapEntry.first)//in order to catch nullpointer 446 446 continue; 447 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)447 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 448 448 continue; 449 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));449 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.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 (auto & elem: this->playerParty_)458 for (auto& mapEntry : this->playerParty_) 459 459 { 460 if (! elem.first)//in order to catch nullpointer460 if (!mapEntry.first)//in order to catch nullpointer 461 461 continue; 462 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)462 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 463 463 continue; 464 else if ( elem.second==chaser)464 else if (mapEntry.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.", elem.first->getClientID(),partyColours_[piggy]);467 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 468 468 else 469 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", elem.first->getClientID(),partyColours_[piggy]);469 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 470 470 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 471 471 } 472 else if ( elem.second==piggy)473 { 474 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", elem.first->getClientID(),partyColours_[chaser]);472 else if (mapEntry.second==piggy) 473 { 474 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[chaser]); 475 475 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 476 476 } 477 else if ( elem.second==killer)478 { 479 this->gtinfo_->sendStaticMessage("Take the chasers down.", elem.first->getClientID(),partyColours_[chaser]);477 else if (mapEntry.second==killer) 478 { 479 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.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 (auto & elem: this->playerParty_)493 { 494 if (! elem.first)//in order to catch nullpointer492 for (auto& mapEntry : this->playerParty_) 493 { 494 if (!mapEntry.first)//in order to catch nullpointer 495 495 continue; 496 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)496 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 497 497 continue; 498 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));498 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.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 (auto & elem: this->playerParty_)507 for (auto& mapEntry : this->playerParty_) 508 508 { 509 if (! elem.first)509 if (!mapEntry.first) 510 510 continue; 511 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)511 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 512 512 continue; 513 else if ( elem.second==chaser)513 else if (mapEntry.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.", elem.first->getClientID(),partyColours_[piggy]);516 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 517 517 else 518 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", elem.first->getClientID(),partyColours_[piggy]);518 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 519 519 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 520 520 } 521 else if ( elem.second==piggy)522 { 523 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", elem.first->getClientID(),partyColours_[piggy]);521 else if (mapEntry.second==piggy) 522 { 523 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[piggy]); 524 524 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 525 525 } 526 else if ( elem.second==killer)527 { 528 this->gtinfo_->sendStaticMessage("Take the chasers down.", elem.first->getClientID(),partyColours_[piggy]);526 else if (mapEntry.second==killer) 527 { 528 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.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 (auto & elem: this->playerParty_)543 { 544 if (! elem.first)//in order to catch nullpointer542 for (auto& mapEntry : this->playerParty_) 543 { 544 if (!mapEntry.first)//in order to catch nullpointer 545 545 continue; 546 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)546 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 547 547 continue; 548 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));548 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.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 (auto & elem: this->playerParty_)557 for (auto& mapEntry : this->playerParty_) 558 558 { 559 if (! elem.first)559 if (!mapEntry.first) 560 560 continue; 561 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)561 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 562 562 continue; 563 else if ( elem.second==chaser)563 else if (mapEntry.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.", elem.first->getClientID(),partyColours_[piggy]);566 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 567 567 else 568 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", elem.first->getClientID(),partyColours_[piggy]);568 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 569 569 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 570 570 } 571 else if ( elem.second==piggy)572 { 573 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", elem.first->getClientID(),partyColours_[chaser]);571 else if (mapEntry.second==piggy) 572 { 573 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[chaser]); 574 574 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 575 575 } 576 else if ( elem.second==killer)577 { 578 this->gtinfo_->sendStaticMessage("Take the chasers down.", elem.first->getClientID(),partyColours_[chaser]);576 else if (mapEntry.second==killer) 577 { 578 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.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 (auto & elem: this->playerParty_)623 { 624 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)622 for (auto& mapEntry : this->playerParty_) 623 { 624 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 625 625 continue; 626 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));626 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.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 ( const auto &teamSpawnPoint : teamSpawnPoints)678 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 679 679 { 680 680 if (index == randomspawn) 681 return (teamSpawnPoint);681 return teamSpawnPoint; 682 682 683 683 ++index; -
code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc
r10821 r10916 139 139 if (!this->gtinfo_->hasStarted()) 140 140 { 141 for (auto & elem: this->players_)141 for (auto& mapEntry : this->players_) 142 142 { 143 143 // Inform the GametypeInfo that the player is ready to spawn. 144 if( elem.first->isHumanPlayer() && elem.first->isReadyToSpawn())145 this->gtinfo_->playerReadyToSpawn( elem.first);144 if(mapEntry.first->isHumanPlayer() && mapEntry.first->isReadyToSpawn()) 145 this->gtinfo_->playerReadyToSpawn(mapEntry.first); 146 146 } 147 147 … … 169 169 } 170 170 171 for (auto & elem: this->players_)172 { 173 if ( elem.first->getControllableEntity())174 { 175 ControllableEntity* oldentity = elem.first->getControllableEntity();171 for (auto& mapEntry : this->players_) 172 { 173 if (mapEntry.first->getControllableEntity()) 174 { 175 ControllableEntity* oldentity = mapEntry.first->getControllableEntity(); 176 176 177 177 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getContext()); … … 186 186 entity->setOrientation(oldentity->getWorldOrientation()); 187 187 } 188 elem.first->startControl(entity);188 mapEntry.first->startControl(entity); 189 189 } 190 190 else 191 this->spawnPlayerAsDefaultPawn( elem.first);191 this->spawnPlayerAsDefaultPawn(mapEntry.first); 192 192 } 193 193 } … … 341 341 unsigned int index = 0; 342 342 std::vector<SpawnPoint*> activeSpawnPoints; 343 for ( const auto & elem: this->spawnpoints_)343 for (SpawnPoint* spawnpoint : this->spawnpoints_) 344 344 { 345 345 if (index == randomspawn) 346 fallbackSpawnPoint = (elem);347 348 if ( elem != nullptr && (elem)->isActive())349 activeSpawnPoints.push_back( elem);346 fallbackSpawnPoint = spawnpoint; 347 348 if (spawnpoint != nullptr && spawnpoint->isActive()) 349 activeSpawnPoints.push_back(spawnpoint); 350 350 351 351 ++index; … … 366 366 void Gametype::assignDefaultPawnsIfNeeded() 367 367 { 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;368 for (auto& mapEntry : this->players_) 369 { 370 if (!mapEntry.first->getControllableEntity()) 371 { 372 mapEntry.second.state_ = PlayerState::Dead; 373 374 if (!mapEntry.first->isReadyToSpawn() || !this->gtinfo_->hasStarted()) 375 { 376 this->spawnPlayerAsDefaultPawn(mapEntry.first); 377 mapEntry.second.state_ = PlayerState::Dead; 378 378 } 379 379 } … … 404 404 bool allplayersready = true; 405 405 bool hashumanplayers = false; 406 for (auto & elem: this->players_)406 for (auto& mapEntry : this->players_) 407 407 { 408 if (! elem.first->isReadyToSpawn())408 if (!mapEntry.first->isReadyToSpawn()) 409 409 allplayersready = false; 410 if ( elem.first->isHumanPlayer())410 if (mapEntry.first->isHumanPlayer()) 411 411 hashumanplayers = true; 412 412 } … … 430 430 void Gametype::spawnPlayersIfRequested() 431 431 { 432 for (auto & elem: this->players_)433 { 434 if ( elem.first->isReadyToSpawn() || this->bForceSpawn_)435 this->spawnPlayer( elem.first);432 for (auto& mapEntry : this->players_) 433 { 434 if (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_) 435 this->spawnPlayer(mapEntry.first); 436 436 } 437 437 } … … 439 439 void Gametype::spawnDeadPlayersIfRequested() 440 440 { 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);441 for (auto& mapEntry : this->players_) 442 if (mapEntry.second.state_ == PlayerState::Dead) 443 if (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_) 444 this->spawnPlayer(mapEntry.first); 445 445 } 446 446 … … 538 538 GSLevelMementoState* Gametype::exportMementoState() 539 539 { 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();540 for (auto& mapEntry : this->players_) 541 { 542 if (mapEntry.first->isHumanPlayer() && mapEntry.first->getControllableEntity() && mapEntry.first->getControllableEntity()->getCamera()) 543 { 544 Camera* camera = mapEntry.first->getControllableEntity()->getCamera(); 545 545 546 546 GametypeMementoState* state = new GametypeMementoState(); … … 559 559 // find correct memento state 560 560 GametypeMementoState* state = nullptr; 561 for ( auto & states_i: states)562 { 563 state = dynamic_cast<GametypeMementoState*>( states_i);561 for (GSLevelMementoState* temp : states) 562 { 563 state = dynamic_cast<GametypeMementoState*>(temp); 564 564 if (state) 565 565 break; … … 587 587 588 588 // find correct player and assign default entity with original position & orientation 589 for (auto & elem: this->players_)590 { 591 if ( elem.first->isHumanPlayer())589 for (auto& mapEntry : this->players_) 590 { 591 if (mapEntry.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 elem.first->startControl(entity);596 mapEntry.first->startControl(entity); 597 597 break; 598 598 } -
code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc
r10821 r10916 56 56 void LastManStanding::spawnDeadPlayersIfRequested() 57 57 { 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);58 for (auto& mapEntry : this->players_) 59 if (mapEntry.second.state_ == PlayerState::Dead) 60 { 61 bool alive = (0<playerLives_[mapEntry.first]&&(inGame_[mapEntry.first])); 62 if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 63 { 64 this->spawnPlayer(mapEntry.first); 65 65 } 66 66 } … … 114 114 { 115 115 int min=lives; 116 for (auto & elem: this->playerLives_)117 { 118 if ( elem.second<=0)116 for (auto& mapEntry : this->playerLives_) 117 { 118 if (mapEntry.second<=0) 119 119 continue; 120 if ( elem.second<lives)121 min= elem.second;120 if (mapEntry.second<lives) 121 min=mapEntry.second; 122 122 } 123 123 return min; … … 128 128 Gametype::end(); 129 129 130 for (auto & elem: this->playerLives_)131 { 132 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)130 for (auto& mapEntry : this->playerLives_) 131 { 132 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 133 133 continue; 134 134 135 if ( elem.second > 0)136 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());135 if (mapEntry.second > 0) 136 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 137 137 else 138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());138 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 139 139 } 140 140 } … … 237 237 this->end(); 238 238 } 239 for (auto & elem: this->timeToAct_)240 { 241 if (playerGetLives( elem.first)<=0)//Players without lives shouldn't be affected by time.239 for (auto& mapEntry : this->timeToAct_) 240 { 241 if (playerGetLives(mapEntry.first)<=0)//Players without lives shouldn't be affected by time. 242 242 continue; 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)243 mapEntry.second-=dt;//Decreases punishment time. 244 if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 245 { 246 playerDelayTime_[mapEntry.first]-=dt; 247 if (playerDelayTime_[mapEntry.first]<=0) 248 this->inGame_[mapEntry.first]=true; 249 250 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 251 251 continue; 252 int output=1+(int)playerDelayTime_[ elem.first];252 int output=1+(int)playerDelayTime_[mapEntry.first]; 253 253 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 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-timer259 if (playerGetLives( elem.first)>0)254 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 255 } 256 else if (mapEntry.second<0.0f) 257 { 258 mapEntry.second=timeRemaining+3.0f;//reset punishment-timer 259 if (playerGetLives(mapEntry.first)>0) 260 260 { 261 this->punishPlayer( elem.first);262 if ( elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)261 this->punishPlayer(mapEntry.first); 262 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 263 263 return; 264 264 const std::string& message = ""; // resets Camper-Warning-message 265 this->gtinfo_->sendFadingMessage(message, elem.first->getClientID());265 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 266 266 } 267 267 } 268 else if ( elem.second<timeRemaining/5)//Warning message269 { 270 if ( elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)268 else if (mapEntry.second<timeRemaining/5)//Warning message 269 { 270 if (mapEntry.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, elem.first->getClientID());273 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 274 274 } 275 275 } -
code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc
r10821 r10916 145 145 void LastTeamStanding::spawnDeadPlayersIfRequested() 146 146 { 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);147 for (auto& mapEntry : this->players_) 148 if (mapEntry.second.state_ == PlayerState::Dead) 149 { 150 bool alive = (0 < playerLives_[mapEntry.first]&&(inGame_[mapEntry.first])); 151 if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 152 { 153 this->spawnPlayer(mapEntry.first); 154 154 } 155 155 } … … 184 184 this->end(); 185 185 } 186 for (auto & elem: this->timeToAct_)187 { 188 if (playerGetLives( elem.first) <= 0)//Players without lives shouldn't be affected by time.186 for (auto& mapEntry : this->timeToAct_) 187 { 188 if (playerGetLives(mapEntry.first) <= 0)//Players without lives shouldn't be affected by time. 189 189 continue; 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)190 mapEntry.second -= dt;//Decreases punishment time. 191 if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 192 { 193 playerDelayTime_[mapEntry.first] -= dt; 194 if (playerDelayTime_[mapEntry.first] <= 0) 195 this->inGame_[mapEntry.first] = true; 196 197 if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN) 198 198 continue; 199 int output = 1 + (int)playerDelayTime_[ elem.first];199 int output = 1 + (int)playerDelayTime_[mapEntry.first]; 200 200 const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown 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-timer206 if (playerGetLives( elem.first) > 0)201 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 202 } 203 else if (mapEntry.second < 0.0f) 204 { 205 mapEntry.second = timeRemaining + 3.0f;//reset punishment-timer 206 if (playerGetLives(mapEntry.first) > 0) 207 207 { 208 this->punishPlayer( elem.first);209 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)208 this->punishPlayer(mapEntry.first); 209 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 210 210 return; 211 211 const std::string& message = ""; // resets Camper-Warning-message 212 this->gtinfo_->sendFadingMessage(message, elem.first->getClientID());212 this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID()); 213 213 } 214 214 } 215 else if ( elem.second < timeRemaining/5)//Warning message216 { 217 if ( elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)215 else if (mapEntry.second < timeRemaining/5)//Warning message 216 { 217 if (mapEntry.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, elem.first->getClientID());220 this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID()); 221 221 } 222 222 } … … 229 229 int party = -1; 230 230 //find a player who survived 231 for (auto & elem: this->playerLives_)232 { 233 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)231 for (auto& mapEntry : this->playerLives_) 232 { 233 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 234 234 continue; 235 235 236 if ( elem.second > 0)//a player that is alive236 if (mapEntry.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( elem.first);239 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(mapEntry.first); 240 240 if (it2 != this->teamnumbers_.end()) 241 241 { … … 255 255 { 256 256 int min = lives; 257 for (auto & elem: this->playerLives_)258 { 259 if ( elem.second <= 0)257 for (auto& mapEntry : this->playerLives_) 258 { 259 if (mapEntry.second <= 0) 260 260 continue; 261 if ( elem.second < lives)262 min = elem.second;261 if (mapEntry.second < lives) 262 min = mapEntry.second; 263 263 } 264 264 return min; -
code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc
r10821 r10916 152 152 int amountControlled2 = 0; 153 153 154 for ( const auto & elem: this->bases_)155 { 156 if( (elem)->getState() == BaseState::ControlTeam1)154 for (TeamBaseMatchBase* base : this->bases_) 155 { 156 if(base->getState() == BaseState::ControlTeam1) 157 157 { 158 158 amountControlled++; 159 159 } 160 if( (elem)->getState() == BaseState::ControlTeam2)160 if(base->getState() == BaseState::ControlTeam2) 161 161 { 162 162 amountControlled2++; … … 187 187 } 188 188 189 for (auto & elem: this->teamnumbers_)190 { 191 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)189 for (auto& mapEntry : this->teamnumbers_) 190 { 191 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 192 192 continue; 193 193 194 if ( elem.second == winningteam)195 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());194 if (mapEntry.second == winningteam) 195 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 196 196 else 197 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());197 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 198 198 } 199 199 … … 238 238 int count = 0; 239 239 240 for ( const auto & elem: this->bases_)241 { 242 if ( (elem)->getState() == BaseState::ControlTeam1 && team == 0)240 for (TeamBaseMatchBase* base : this->bases_) 241 { 242 if (base->getState() == BaseState::ControlTeam1 && team == 0) 243 243 count++; 244 if ( (elem)->getState() == BaseState::ControlTeam2 && team == 1)244 if (base->getState() == BaseState::ControlTeam2 && team == 1) 245 245 count++; 246 246 } … … 258 258 { 259 259 unsigned int i = 0; 260 for ( const auto & elem: this->bases_)260 for (TeamBaseMatchBase* base : this->bases_) 261 261 { 262 262 i++; 263 263 if (i > index) 264 return (elem);264 return base; 265 265 } 266 266 return nullptr; -
code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc
r10821 r10916 69 69 int winnerTeam = 0; 70 70 int highestScore = 0; 71 for (auto & elem: this->players_)71 for (auto& mapEntry : this->players_) 72 72 { 73 if ( this->getTeamScore( elem.first) > highestScore )73 if ( this->getTeamScore(mapEntry.first) > highestScore ) 74 74 { 75 winnerTeam = this->getTeam( elem.first);76 highestScore = this->getTeamScore( elem.first);75 winnerTeam = this->getTeam(mapEntry.first); 76 highestScore = this->getTeamScore(mapEntry.first); 77 77 } 78 78 } -
code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc
r10821 r10916 99 99 std::vector<unsigned int> playersperteam(this->teams_, 0); 100 100 101 for (auto & elem: this->teamnumbers_)102 if ( elem.second < static_cast<int>(this->teams_) && elem.second >= 0)103 playersperteam[ elem.second]++;101 for (auto& mapEntry : this->teamnumbers_) 102 if (mapEntry.second < static_cast<int>(this->teams_) && mapEntry.second >= 0) 103 playersperteam[mapEntry.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 (auto & elem: this->allowedInGame_)126 { 127 if( elem.second == false) // waiting player found128 { elem.second = true; break;} // allow player to enter125 for (auto& mapEntry : this->allowedInGame_) 126 { 127 if(mapEntry.second == false) // waiting player found 128 {mapEntry.second = true; break;} // allow player to enter 129 129 } 130 130 } … … 141 141 void TeamGametype::spawnDeadPlayersIfRequested() 142 142 { 143 for (auto & elem: this->players_)\144 { 145 if(allowedInGame_[ elem.first] == false)//check if dead player is allowed to enter143 for (auto& mapEntry : this->players_)\ 144 { 145 if(allowedInGame_[mapEntry.first] == false)//check if dead player is allowed to enter 146 146 { 147 147 continue; 148 148 } 149 if ( elem.second.state_ == PlayerState::Dead)150 { 151 if (( elem.first->isReadyToSpawn() || this->bForceSpawn_))149 if (mapEntry.second.state_ == PlayerState::Dead) 150 { 151 if ((mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 152 152 { 153 this->spawnPlayer( elem.first);153 this->spawnPlayer(mapEntry.first); 154 154 } 155 155 } … … 178 178 if(!player || this->getTeam(player) == -1) 179 179 return 0; 180 for (auto & elem: this->players_)181 { 182 if ( this->getTeam( elem.first) == this->getTeam(player) )183 { 184 teamscore += elem.second.frags_;180 for (auto& mapEntry : this->players_) 181 { 182 if ( this->getTeam(mapEntry.first) == this->getTeam(player) ) 183 { 184 teamscore += mapEntry.second.frags_; 185 185 } 186 186 } … … 191 191 { 192 192 int teamSize = 0; 193 for (auto & elem: this->teamnumbers_)194 { 195 if ( elem.second == team)193 for (auto& mapEntry : this->teamnumbers_) 194 { 195 if (mapEntry.second == team) 196 196 teamSize++; 197 197 } … … 202 202 { 203 203 int teamSize = 0; 204 for (auto & elem: this->teamnumbers_)205 { 206 if ( elem.second == team && elem.first->isHumanPlayer())204 for (auto& mapEntry : this->teamnumbers_) 205 { 206 if (mapEntry.second == team && mapEntry.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 ( const auto &teamSpawnPoint : teamSpawnPoints)243 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 244 244 { 245 245 if (index == randomspawn) 246 246 { 247 fallbackSpawnPoint = (teamSpawnPoint);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 ( const auto &teamSpawnPoint : teamSpawnPoints)268 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 269 269 { 270 270 if (index == randomspawn) 271 return (teamSpawnPoint);271 return teamSpawnPoint; 272 272 273 273 ++index; … … 364 364 365 365 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 366 for ( const auto &pawnAttachment : pawnAttachments)367 { 368 if ( (pawnAttachment)->isA(Class(TeamColourable)))366 for (WorldEntity* pawnAttachment : pawnAttachments) 367 { 368 if (pawnAttachment->isA(Class(TeamColourable))) 369 369 { 370 370 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); … … 376 376 void TeamGametype::announceTeamWin(int winnerTeam) 377 377 { 378 for (auto & elem: this->teamnumbers_)379 { 380 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)378 for (auto& mapEntry : this->teamnumbers_) 379 { 380 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 381 381 continue; 382 if ( elem.second == winnerTeam)383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", elem.first->getClientID());382 if (mapEntry.second == winnerTeam) 383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", mapEntry.first->getClientID()); 385 385 } 386 386 else 387 387 { 388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", elem.first->getClientID());388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", mapEntry.first->getClientID()); 389 389 } 390 390 } -
code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc
r10821 r10916 74 74 this->gameEnded_ = true; 75 75 76 for (auto & elem: this->teamnumbers_)77 { 78 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)76 for (auto& mapEntry : this->teamnumbers_) 77 { 78 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 79 79 continue; 80 80 81 if ( elem.second == attacker_)82 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());81 if (mapEntry.second == attacker_) 82 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 83 83 else 84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());84 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 85 85 } 86 86 } … … 155 155 ChatManager::message(message); 156 156 157 for (auto & elem: this->teamnumbers_)158 { 159 if ( elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)157 for (auto& mapEntry : this->teamnumbers_) 158 { 159 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 160 160 continue; 161 161 162 if ( elem.second == 1)163 this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.first->getClientID());162 if (mapEntry.second == 1) 163 this->gtinfo_->sendAnnounceMessage("You have won the match!", mapEntry.first->getClientID()); 164 164 else 165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", elem.first->getClientID());165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 166 166 } 167 167 } -
code/branches/cpp11_v2/src/orxonox/interfaces/PickupCarrier.cc
r10821 r10916 135 135 // Go recursively through all children to check whether they are the target. 136 136 std::vector<PickupCarrier*>* children = this->getCarrierChildren(); 137 for( auto & elem: *children)137 for(PickupCarrier* child : *children) 138 138 { 139 if(pickup->isTarget( elem))139 if(pickup->isTarget(child)) 140 140 { 141 target = elem;141 target = child; 142 142 break; 143 143 } -
code/branches/cpp11_v2/src/orxonox/interfaces/Pickupable.cc
r10821 r10916 160 160 { 161 161 // Iterate through all targets of this Pickupable. 162 for( const auto & elem: this->targets_)162 for(Identifier* target : this->targets_) 163 163 { 164 if(identifier->isA( elem))164 if(identifier->isA(target)) 165 165 return true; 166 166 } -
code/branches/cpp11_v2/src/orxonox/items/MultiStateEngine.cc
r10821 r10916 219 219 { 220 220 unsigned int i = 0; 221 for ( const auto & elem: this->effectContainers_)221 for (EffectContainer* effectContainer : this->effectContainers_) 222 222 { 223 223 if (i == index) 224 return (elem);224 return effectContainer; 225 225 i++; 226 226 } -
code/branches/cpp11_v2/src/orxonox/items/ShipPart.cc
r10821 r10916 143 143 @brief 144 144 Check whether the ShipPart has a particular Entity. 145 @param engine145 @param search 146 146 A pointer to the Entity to be checked. 147 147 */ 148 bool ShipPart::hasEntity(StaticEntity* entity) const149 { 150 for( auto & elem: this->entityList_)151 { 152 if(e lem == entity)148 bool ShipPart::hasEntity(StaticEntity* search) const 149 { 150 for(StaticEntity* entity : this->entityList_) 151 { 152 if(entity == search) 153 153 return true; 154 154 } -
code/branches/cpp11_v2/src/orxonox/overlays/OverlayGroup.cc
r10821 r10916 62 62 OverlayGroup::~OverlayGroup() 63 63 { 64 for ( const auto & elem: hudElements_)65 (elem)->destroy();64 for (OrxonoxOverlay* hudElement : hudElements_) 65 hudElement->destroy(); 66 66 this->hudElements_.clear(); 67 67 } … … 86 86 void OverlayGroup::setScale(const Vector2& scale) 87 87 { 88 for ( const auto & elem: hudElements_)89 (elem)->scale(scale / this->scale_);88 for (OrxonoxOverlay* hudElement : hudElements_) 89 hudElement->scale(scale / this->scale_); 90 90 this->scale_ = scale; 91 91 } … … 94 94 void OverlayGroup::setScroll(const Vector2& scroll) 95 95 { 96 for ( const auto & elem: hudElements_)97 (elem)->scroll(scroll - this->scroll_);96 for (OrxonoxOverlay* hudElement : hudElements_) 97 hudElement->scroll(scroll - this->scroll_); 98 98 this->scroll_ = scroll; 99 99 } … … 147 147 SUPER( OverlayGroup, changedVisibility ); 148 148 149 for ( const auto & elem: hudElements_)150 (elem)->changedVisibility(); //inform all Child Overlays that our visibility has changed149 for (OrxonoxOverlay* hudElement : hudElements_) 150 hudElement->changedVisibility(); //inform all Child Overlays that our visibility has changed 151 151 } 152 152 … … 155 155 this->owner_ = owner; 156 156 157 for ( const auto & elem: hudElements_)158 (elem)->setOwner(owner);157 for (OrxonoxOverlay* hudElement : hudElements_) 158 hudElement->setOwner(owner); 159 159 } 160 160 -
code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc
r10821 r10916 407 407 if (ambient != nullptr) 408 408 { 409 for ( auto & elem: this->ambientSounds_)410 { 411 if ( elem.first == ambient)409 for (std::pair<AmbientSound*, bool>& pair : this->ambientSounds_) 410 { 411 if (pair.first == ambient) 412 412 { 413 elem.second = true;414 this->fadeOut( elem.first);413 pair.second = true; 414 this->fadeOut(pair.first); 415 415 return; 416 416 } -
code/branches/cpp11_v2/src/orxonox/sound/SoundStreamer.cc
r10821 r10916 68 68 int current_section; 69 69 70 for( auto& initbuffer : initbuffers)70 for(ALuint& initbuffer : initbuffers) 71 71 { 72 72 long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section); -
code/branches/cpp11_v2/src/orxonox/weaponsystem/Munition.cc
r10821 r10916 55 55 Munition::~Munition() 56 56 { 57 for (auto & elem: this->currentMagazines_)58 delete elem.second;57 for (auto& mapEntry : this->currentMagazines_) 58 delete mapEntry.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 (const auto & elem: this->currentMagazines_)271 if ( elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)270 for (const auto& mapEntry : this->currentMagazines_) 271 if (mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_) 272 272 return true; 273 273 } … … 316 316 { 317 317 bool change = false; 318 for (auto & elem: this->currentMagazines_)318 for (auto& mapEntry : this->currentMagazines_) 319 319 { 320 320 // Add munition if the magazine isn't full (but only to loaded magazines) 321 if (amount > 0 && elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)321 if (amount > 0 && mapEntry.second->munition_ < this->maxMunitionPerMagazine_ && mapEntry.second->bLoaded_) 322 322 { 323 elem.second->munition_++;323 mapEntry.second->munition_++; 324 324 amount--; 325 325 change = true; -
code/branches/cpp11_v2/src/orxonox/weaponsystem/Weapon.cc
r10821 r10916 61 61 this->weaponPack_->removeWeapon(this); 62 62 63 for (auto & elem: this->weaponmodes_)64 elem.second->destroy();63 for (auto& mapEntry : this->weaponmodes_) 64 mapEntry.second->destroy(); 65 65 } 66 66 } … … 85 85 { 86 86 unsigned int i = 0; 87 for (const auto & elem: this->weaponmodes_)87 for (const auto& mapEntry : this->weaponmodes_) 88 88 { 89 89 if (i == index) 90 return elem.second;90 return mapEntry.second; 91 91 92 92 ++i; … … 136 136 void Weapon::reload() 137 137 { 138 for (auto & elem: this->weaponmodes_)139 elem.second->reload();138 for (auto& mapEntry : this->weaponmodes_) 139 mapEntry.second->reload(); 140 140 } 141 141 … … 148 148 void Weapon::notifyWeaponModes() 149 149 { 150 for (auto & elem: this->weaponmodes_)151 elem.second->setWeapon(this);150 for (auto& mapEntry : this->weaponmodes_) 151 mapEntry.second->setWeapon(this); 152 152 } 153 153 } -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc
r10821 r10916 76 76 void WeaponPack::fire(unsigned int weaponmode) 77 77 { 78 for ( auto & elem: this->weapons_)79 (elem)->fire(weaponmode);78 for (Weapon* weapon : this->weapons_) 79 weapon->fire(weaponmode); 80 80 } 81 81 … … 86 86 void WeaponPack::reload() 87 87 { 88 for ( auto & elem: this->weapons_)89 (elem)->reload();88 for (Weapon* weapon : this->weapons_) 89 weapon->reload(); 90 90 } 91 91 … … 114 114 unsigned int i = 0; 115 115 116 for ( const auto & elem: this->weapons_)116 for (Weapon* weapon : this->weapons_) 117 117 { 118 118 if (i == index) 119 return (elem);119 return weapon; 120 120 ++i; 121 121 } … … 132 132 { 133 133 unsigned int i = 0; 134 for ( const auto & elem: this->links_)134 for (DefaultWeaponmodeLink* link : this->links_) 135 135 { 136 136 if (i == index) 137 return (elem);137 return link; 138 138 139 139 ++i; … … 144 144 unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const 145 145 { 146 for ( const auto & elem: this->links_)147 if ( (elem)->getFiremode() == firemode)148 return (elem)->getWeaponmode();146 for (DefaultWeaponmodeLink* link : this->links_) 147 if (link->getFiremode() == firemode) 148 return link->getWeaponmode(); 149 149 150 150 return WeaponSystem::WEAPON_MODE_UNASSIGNED; -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSet.cc
r10821 r10916 63 63 { 64 64 // Fire all WeaponPacks with their defined weaponmode 65 for (auto & elem: this->weaponpacks_)66 if ( elem.second != WeaponSystem::WEAPON_MODE_UNASSIGNED)67 elem.first->fire(elem.second);65 for (auto& mapEntry : this->weaponpacks_) 66 if (mapEntry.second != WeaponSystem::WEAPON_MODE_UNASSIGNED) 67 mapEntry.first->fire(mapEntry.second); 68 68 } 69 69 … … 71 71 { 72 72 // Reload all WeaponPacks with their defined weaponmode 73 for (auto & elem: this->weaponpacks_)74 elem.first->reload();73 for (auto& mapEntry : this->weaponpacks_) 74 mapEntry.first->reload(); 75 75 } 76 76 -
code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponSystem.cc
r10821 r10916 106 106 { 107 107 unsigned int i = 0; 108 for ( const auto & elem: this->weaponSlots_)108 for (WeaponSlot* weaponSlot : this->weaponSlots_) 109 109 { 110 110 ++i; 111 111 if (i > index) 112 return (elem);112 return weaponSlot; 113 113 } 114 114 return nullptr; … … 153 153 { 154 154 unsigned int i = 0; 155 for (const auto & elem: this->weaponSets_)155 for (const auto& mapEntry : this->weaponSets_) 156 156 { 157 157 ++i; 158 158 if (i > index) 159 return elem.second;159 return mapEntry.second; 160 160 } 161 161 return nullptr; … … 168 168 169 169 unsigned int freeSlots = 0; 170 for ( auto & elem: this->weaponSlots_)171 { 172 if (! (elem)->isOccupied())170 for (WeaponSlot* weaponSlot : this->weaponSlots_) 171 { 172 if (!weaponSlot->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 ( auto & elem: this->weaponSlots_)187 { 188 if (! (elem)->isOccupied() && i < wPack->getNumWeapons())186 for (WeaponSlot* weaponSlot : this->weaponSlots_) 187 { 188 if (!weaponSlot->isOccupied() && i < wPack->getNumWeapons()) 189 189 { 190 190 Weapon* weapon = wPack->getWeapon(i); 191 (elem)->attachWeapon(weapon);191 weaponSlot->attachWeapon(weapon); 192 192 this->getPawn()->attach(weapon); 193 193 ++i; … … 196 196 197 197 // Assign the desired weaponmode to the firemodes 198 for (auto & elem: this->weaponSets_)199 { 200 unsigned int weaponmode = wPack->getDesiredWeaponmode( elem.first);198 for (auto& mapEntry : this->weaponSets_) 199 { 200 unsigned int weaponmode = wPack->getDesiredWeaponmode(mapEntry.first); 201 201 if (weaponmode != WeaponSystem::WEAPON_MODE_UNASSIGNED) 202 elem.second->setWeaponmodeLink(wPack, weaponmode);202 mapEntry.second->setWeaponmodeLink(wPack, weaponmode); 203 203 } 204 204 … … 219 219 220 220 // Remove all added links from the WeaponSets 221 for (auto & elem: this->weaponSets_)222 elem.second->removeWeaponmodeLink(wPack);221 for (auto& mapEntry : this->weaponSets_) 222 mapEntry.second->removeWeaponmodeLink(wPack); 223 223 224 224 // Remove the WeaponPack from the WeaponSystem … … 231 231 { 232 232 unsigned int i = 0; 233 for ( const auto & elem: this->weaponPacks_)233 for (WeaponPack* weaponPack : this->weaponPacks_) 234 234 { 235 235 ++i; 236 236 if (i > index) 237 return (elem);237 return weaponPack; 238 238 } 239 239 return nullptr; … … 268 268 // Check if the WeaponSet belongs to this WeaponSystem 269 269 bool foundWeaponSet = false; 270 for (auto & elem: this->weaponSets_)271 { 272 if ( elem.second == wSet)270 for (auto& mapEntry : this->weaponSets_) 271 { 272 if (mapEntry.second == wSet) 273 273 { 274 274 foundWeaponSet = true; … … 296 296 void WeaponSystem::reload() 297 297 { 298 for (auto & elem: this->weaponSets_)299 elem.second->reload();298 for (auto& mapEntry : this->weaponSets_) 299 mapEntry.second->reload(); 300 300 } 301 301 -
code/branches/cpp11_v2/src/orxonox/worldentities/ControllableEntity.cc
r10821 r10916 165 165 { 166 166 unsigned int i = 0; 167 for ( const auto & elem: this->cameraPositions_)167 for (CameraPosition* cameraPosition : this->cameraPositions_) 168 168 { 169 169 if (i == index) 170 return (elem);170 return cameraPosition; 171 171 ++i; 172 172 } … … 180 180 181 181 unsigned int counter = 0; 182 for ( const auto & elem: this->cameraPositions_)183 { 184 if ( (elem)== this->currentCameraPosition_)182 for (CameraPosition* cameraPosition : this->cameraPositions_) 183 { 184 if (cameraPosition == this->currentCameraPosition_) 185 185 break; 186 186 counter++; … … 477 477 if (parent) 478 478 { 479 for ( auto & elem: this->cameraPositions_)480 if ( (elem)->getIsAbsolute())481 parent->attach( (elem));479 for (CameraPosition* cameraPosition : this->cameraPositions_) 480 if (cameraPosition->getIsAbsolute()) 481 parent->attach(cameraPosition); 482 482 } 483 483 } -
code/branches/cpp11_v2/src/orxonox/worldentities/EffectContainer.cc
r10821 r10916 89 89 { 90 90 unsigned int i = 0; 91 for ( const auto & elem: this->effects_)91 for (WorldEntity* effect : this->effects_) 92 92 if (i == index) 93 return (elem);93 return effect; 94 94 return nullptr; 95 95 } -
code/branches/cpp11_v2/src/orxonox/worldentities/WorldEntity.cc
r10821 r10916 233 233 234 234 // iterate over all children and change their activity as well 235 for ( const auto & elem: this->getAttachedObjects())235 for (WorldEntity* object : this->getAttachedObjects()) 236 236 { 237 237 if(!this->isActive()) 238 238 { 239 (elem)->bActiveMem_ = (elem)->isActive();240 (elem)->setActive(this->isActive());239 object->bActiveMem_ = object->isActive(); 240 object->setActive(this->isActive()); 241 241 } 242 242 else 243 243 { 244 (elem)->setActive((elem)->bActiveMem_);244 object->setActive(object->bActiveMem_); 245 245 } 246 246 } … … 259 259 { 260 260 // iterate over all children and change their visibility as well 261 for ( const auto & elem: this->getAttachedObjects())261 for (WorldEntity* object : this->getAttachedObjects()) 262 262 { 263 263 if(!this->isVisible()) 264 264 { 265 (elem)->bVisibleMem_ = (elem)->isVisible();266 (elem)->setVisible(this->isVisible());265 object->bVisibleMem_ = object->isVisible(); 266 object->setVisible(this->isVisible()); 267 267 } 268 268 else 269 269 { 270 (elem)->setVisible((elem)->bVisibleMem_);270 object->setVisible(object->bVisibleMem_); 271 271 } 272 272 } … … 518 518 { 519 519 unsigned int i = 0; 520 for ( const auto & elem: this->children_)520 for (WorldEntity* child : this->children_) 521 521 { 522 522 if (i == index) 523 return (elem);523 return child; 524 524 ++i; 525 525 } … … 938 938 // Recalculate mass 939 939 this->childrenMass_ = 0.0f; 940 for ( const auto & elem: this->children_)941 this->childrenMass_ += (elem)->getMass();940 for (WorldEntity* child : this->children_) 941 this->childrenMass_ += child->getMass(); 942 942 recalculateMassProps(); 943 943 // Notify parent WE -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10821 r10916 99 99 } 100 100 // iterate through all attached parts 101 for( auto & elem: this->partList_)101 for(ShipPart* part : 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(( elem->getName() == this->getAttachedObject(i)->getName()) && !elem->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))104 if((part->getName() == this->getAttachedObject(i)->getName()) && !part->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)))) 105 105 { 106 106 // The Entity is added to the part's entityList_ 107 elem->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));107 part->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)), elem);109 this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), part); 110 110 } 111 111 } … … 146 146 ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const 147 147 { 148 for (const auto & elem: this->partMap_)149 { 150 if ( elem.first == entity)151 return elem.second;148 for (const auto& mapEntry : this->partMap_) 149 { 150 if (mapEntry.first == entity) 151 return mapEntry.second; 152 152 } 153 153 return nullptr; … … 242 242 ShipPart* ModularSpaceShip::getShipPartByName(std::string name) 243 243 { 244 for( auto & elem: this->partList_)245 { 246 if(orxonox_cast<ShipPart*>( elem)->getName() == name)247 { 248 return orxonox_cast<ShipPart*>( elem);244 for(ShipPart* part : this->partList_) 245 { 246 if(orxonox_cast<ShipPart*>(part)->getName() == name) 247 { 248 return orxonox_cast<ShipPart*>(part); 249 249 } 250 250 } … … 256 256 @brief 257 257 Check whether the SpaceShip has a particular Engine. 258 @param engine258 @param search 259 259 A pointer to the Engine to be checked. 260 260 */ 261 bool ModularSpaceShip::hasShipPart(ShipPart* part) const262 { 263 for( auto & elem: this->partList_)264 { 265 if( elem == part)261 bool ModularSpaceShip::hasShipPart(ShipPart* search) const 262 { 263 for(ShipPart* part : this->partList_) 264 { 265 if(part == search) 266 266 return true; 267 267 } -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/SpaceShip.cc
r10821 r10916 158 158 159 159 // Run the engines 160 for( auto & elem: this->engineList_)161 (elem)->run(dt);160 for(Engine* engine : this->engineList_) 161 engine->run(dt); 162 162 163 163 if (this->hasLocalController()) … … 313 313 @brief 314 314 Check whether the SpaceShip has a particular Engine. 315 @param engine315 @param search 316 316 A pointer to the Engine to be checked. 317 317 */ 318 bool SpaceShip::hasEngine(Engine* engine) const319 { 320 for( auto & elem: this->engineList_)321 { 322 if(e lem == engine)318 bool SpaceShip::hasEngine(Engine* search) const 319 { 320 for(Engine* engine : this->engineList_) 321 { 322 if(engine == search) 323 323 return true; 324 324 } … … 350 350 Engine* SpaceShip::getEngineByName(const std::string& name) 351 351 { 352 for( auto & elem: this->engineList_)353 if(e lem->getName() == name)354 return e lem;352 for(Engine* engine : this->engineList_) 353 if(engine->getName() == name) 354 return engine; 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( auto & elem: this->engineList_)399 e lem->addSpeedMultiply(factor);398 for(Engine* engine : this->engineList_) 399 engine->addSpeedMultiply(factor); 400 400 } 401 401 … … 408 408 void SpaceShip::addSpeed(float speed) 409 409 { 410 for( auto & elem: this->engineList_)411 e lem->addSpeedAdd(speed);410 for(Engine* engine : this->engineList_) 411 engine->addSpeedAdd(speed); 412 412 } 413 413 … … 436 436 { 437 437 float speed=0; 438 for( auto & elem: this->engineList_)439 { 440 if(e lem->getMaxSpeedFront() > speed)441 speed = e lem->getMaxSpeedFront();438 for(Engine* engine : this->engineList_) 439 { 440 if(engine->getMaxSpeedFront() > speed) 441 speed = engine->getMaxSpeedFront(); 442 442 } 443 443 return speed; -
code/branches/cpp11_v2/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
r10821 r10916 80 80 81 81 std::set<WorldEntity*> attachments = this->getAttachedObjects(); 82 for ( const auto &attachment : attachments)82 for (WorldEntity* attachment : attachments) 83 83 { 84 if ( (attachment)->isA(Class(TeamColourable)))84 if (attachment->isA(Class(TeamColourable))) 85 85 { 86 86 TeamColourable* tc = orxonox_cast<TeamColourable*>(attachment);
Note: See TracChangeset
for help on using the changeset viewer.