Changeset 10821 for code/branches/cpp11_v2/src/orxonox/gametypes
- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/orxonox/gametypes
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.