Changeset 11071 for code/trunk/src/orxonox/gametypes
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/gametypes/Asteroids.h
r9667 r11071 41 41 virtual ~Asteroids() {} 42 42 43 virtual void tick(float dt) ;43 virtual void tick(float dt) override; 44 44 45 virtual void start() ;46 virtual void end() ;45 virtual void start() override; 46 virtual void end() override; 47 47 48 48 inline void firstCheckpointReached(bool reached) … … 50 50 51 51 protected: 52 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);52 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 53 53 54 54 private: -
code/trunk/src/orxonox/gametypes/Deathmatch.h
r9667 r11071 41 41 virtual ~Deathmatch() {} 42 42 43 virtual void start() ;44 virtual void end() ;45 virtual void playerEntered(PlayerInfo* player) ;46 virtual bool playerLeft(PlayerInfo* player) ;47 virtual bool playerChangedName(PlayerInfo* player) ;43 virtual void start() override; 44 virtual void end() override; 45 virtual void playerEntered(PlayerInfo* player) override; 46 virtual bool playerLeft(PlayerInfo* player) override; 47 virtual bool playerChangedName(PlayerInfo* player) override; 48 48 49 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);50 virtual void playerScored(PlayerInfo* player, int score = 1) ;49 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 50 virtual void playerScored(PlayerInfo* player, int score = 1) override; 51 51 }; 52 52 } -
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r11052 r11071 88 88 Dynamicmatch::~Dynamicmatch() 89 89 { 90 for ( std::set<Timer*>::iterator it = this->piggyTimers_.begin(); it != this->piggyTimers_.end(); ++it)91 delete (*it);90 for (Timer* timer : this->piggyTimers_) 91 delete timer; 92 92 } 93 93 … … 413 413 void Dynamicmatch::rewardPig() 414 414 { 415 for ( std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden416 { 417 if ( it->second==piggy)//Spieler mit der Pig-party frags++418 { 419 this->playerScored( it->first);415 for (const auto& mapEntry : this->playerParty_) //durch alle Spieler iterieren und alle piggys finden 416 { 417 if (mapEntry.second==piggy)//Spieler mit der Pig-party frags++ 418 { 419 this->playerScored(mapEntry.first); 420 420 } 421 421 } … … 430 430 431 431 std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects(); 432 for ( std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)433 { 434 if ( (*it)->isA(Class(TeamColourable)))432 for (WorldEntity* pawnAttachment : pawnAttachments) 433 { 434 if (pawnAttachment->isA(Class(TeamColourable))) 435 435 { 436 TeamColourable* tc = orxonox_cast<TeamColourable*>( *it);436 TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment); 437 437 tc->setTeamColour(this->partyColours_[it_player->second]); 438 438 } … … 449 449 if (tutorial) // Announce selectionphase 450 450 { 451 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)452 { 453 if (! it->first)//in order to catch nullpointer451 for (const auto& mapEntry : this->playerParty_) 452 { 453 if (!mapEntry.first)//in order to catch nullpointer 454 454 continue; 455 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)455 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 456 456 continue; 457 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));457 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 458 458 } 459 459 } … … 464 464 if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over 465 465 { 466 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)466 for (const auto& mapEntry : this->playerParty_) 467 467 { 468 if (! it->first)//in order to catch nullpointer468 if (!mapEntry.first)//in order to catch nullpointer 469 469 continue; 470 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)470 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 471 471 continue; 472 else if ( it->second==chaser)472 else if (mapEntry.second==chaser) 473 473 { 474 474 if (numberOf[killer]>0) 475 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);475 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 476 476 else 477 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);477 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 478 478 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 479 479 } 480 else if ( it->second==piggy)481 { 482 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[chaser]);480 else if (mapEntry.second==piggy) 481 { 482 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[chaser]); 483 483 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 484 484 } 485 else if ( it->second==killer)486 { 487 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[chaser]);485 else if (mapEntry.second==killer) 486 { 487 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.first->getClientID(),partyColours_[chaser]); 488 488 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 489 489 } … … 498 498 if (tutorial) // Announce selectionphase 499 499 { 500 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)501 { 502 if (! it->first)//in order to catch nullpointer500 for (const auto& mapEntry : this->playerParty_) 501 { 502 if (!mapEntry.first)//in order to catch nullpointer 503 503 continue; 504 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)504 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 505 505 continue; 506 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));506 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 507 507 } 508 508 } … … 513 513 if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over 514 514 { 515 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)515 for (const auto& mapEntry : this->playerParty_) 516 516 { 517 if (! it->first)517 if (!mapEntry.first) 518 518 continue; 519 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)519 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 520 520 continue; 521 else if ( it->second==chaser)521 else if (mapEntry.second==chaser) 522 522 { 523 523 if (numberOf[killer]>0) 524 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);524 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 525 525 else 526 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);526 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 527 527 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 528 528 } 529 else if ( it->second==piggy)530 { 531 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[piggy]);529 else if (mapEntry.second==piggy) 530 { 531 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[piggy]); 532 532 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 533 533 } 534 else if ( it->second==killer)535 { 536 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[piggy]);534 else if (mapEntry.second==killer) 535 { 536 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.first->getClientID(),partyColours_[piggy]); 537 537 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 538 538 } … … 548 548 if (tutorial) // Announce selectionphase 549 549 { 550 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)551 { 552 if (! it->first)//in order to catch nullpointer550 for (const auto& mapEntry : this->playerParty_) 551 { 552 if (!mapEntry.first)//in order to catch nullpointer 553 553 continue; 554 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)554 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 555 555 continue; 556 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));556 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 557 557 } 558 558 } … … 563 563 if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over 564 564 { 565 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)565 for (const auto& mapEntry : this->playerParty_) 566 566 { 567 if (! it->first)567 if (!mapEntry.first) 568 568 continue; 569 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)569 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 570 570 continue; 571 else if ( it->second==chaser)571 else if (mapEntry.second==chaser) 572 572 { 573 573 if (numberOf[killer]>0) 574 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.", it->first->getClientID(),partyColours_[piggy]);574 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",mapEntry.first->getClientID(),partyColours_[piggy]); 575 575 else 576 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.", it->first->getClientID(),partyColours_[piggy]);576 this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",mapEntry.first->getClientID(),partyColours_[piggy]); 577 577 //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID()); 578 578 } 579 else if ( it->second==piggy)580 { 581 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.", it->first->getClientID(),partyColours_[chaser]);579 else if (mapEntry.second==piggy) 580 { 581 this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",mapEntry.first->getClientID(),partyColours_[chaser]); 582 582 //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID()); 583 583 } 584 else if ( it->second==killer)585 { 586 this->gtinfo_->sendStaticMessage("Take the chasers down.", it->first->getClientID(),partyColours_[chaser]);584 else if (mapEntry.second==killer) 585 { 586 this->gtinfo_->sendStaticMessage("Take the chasers down.",mapEntry.first->getClientID(),partyColours_[chaser]); 587 587 //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID()); 588 588 } … … 631 631 else if(tutorial) // Announce selectionphase 632 632 { 633 for ( std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)634 { 635 if ( it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)633 for (const auto& mapEntry : this->playerParty_) 634 { 635 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 636 636 continue; 637 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.", it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));637 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",mapEntry.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f)); 638 638 } 639 639 } … … 687 687 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size()))); 688 688 unsigned int index = 0; 689 for ( std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)689 for (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 690 690 { 691 691 if (index == randomspawn) 692 return (*it);692 return teamSpawnPoint; 693 693 694 694 ++index; … … 696 696 } 697 697 698 return 0;698 return nullptr; 699 699 } 700 700 -
code/trunk/src/orxonox/gametypes/Dynamicmatch.h
r11052 r11071 65 65 bool tutorial; //goal: new players receive messages how the new gametype works - later it can be switched off. 66 66 67 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //ok - score function and management of parties68 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //ok - simple69 virtual void start() ;70 virtual void end() ; //Wie geht das mit der Punkteausgabe aendern? Z.B: Persoenliche Nachricht?71 virtual void playerEntered(PlayerInfo* player) ;72 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ;//is used to initialize the player's party and colour73 virtual bool playerLeft(PlayerInfo* player) ;74 virtual bool playerChangedName(PlayerInfo* player) ;//unchanged67 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; //ok - score function and management of parties 68 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; //ok - simple 69 virtual void start() override; 70 virtual void end() override; //Wie geht das mit der Punkteausgabe aendern? Z.B: Persoenliche Nachricht? 71 virtual void playerEntered(PlayerInfo* player) override; 72 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override;//is used to initialize the player's party and colour 73 virtual bool playerLeft(PlayerInfo* player) override; 74 virtual bool playerChangedName(PlayerInfo* player) override;//unchanged 75 75 76 76 /*virtual void instructions(); … … 79 79 void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost. 80 80 void resetSpeedFactor(SpaceShip* spaceship, Timer* timer); 81 v oid tick (float dt);// used to end the game82 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;81 virtual void tick (float dt) override;// used to end the game 82 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const override; 83 83 84 84 -
code/trunk/src/orxonox/gametypes/Gametype.cc
r10624 r11071 66 66 67 67 this->defaultControllableEntity_ = Class(Spectator); 68 this->scoreboard_ = 0;68 this->scoreboard_ = nullptr; 69 69 70 70 this->bAutoStart_ = false; … … 92 92 this->gtinfo_->destroy(); 93 93 94 ModifyConsoleCommand(__CC_addBots_name).setObject( NULL);95 ModifyConsoleCommand(__CC_killBots_name).setObject( NULL);94 ModifyConsoleCommand(__CC_addBots_name).setObject(nullptr); 95 ModifyConsoleCommand(__CC_killBots_name).setObject(nullptr); 96 96 } 97 97 } … … 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 (const auto& mapEntry : 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(mapEntry.first->isHumanPlayer() && mapEntry.first->isReadyToSpawn()) 145 this->gtinfo_->playerReadyToSpawn(mapEntry.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 (const 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 it->first->startControl(entity);188 mapEntry.first->startControl(entity); 189 189 } 190 190 else 191 this->spawnPlayerAsDefaultPawn( it->first);191 this->spawnPlayerAsDefaultPawn(mapEntry.first); 192 192 } 193 193 } … … 337 337 { 338 338 // Fallback spawn point if there is no active one, choose a random one. 339 SpawnPoint* fallbackSpawnPoint = NULL;339 SpawnPoint* fallbackSpawnPoint = nullptr; 340 340 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 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 (SpawnPoint* spawnpoint : this->spawnpoints_) 344 344 { 345 345 if (index == randomspawn) 346 fallbackSpawnPoint = (*it);347 348 if ( *it != NULL && (*it)->isActive())349 activeSpawnPoints.push_back( *it);346 fallbackSpawnPoint = spawnpoint; 347 348 if (spawnpoint != nullptr && spawnpoint->isActive()) 349 activeSpawnPoints.push_back(spawnpoint); 350 350 351 351 ++index; … … 361 361 return fallbackSpawnPoint; 362 362 } 363 return 0;363 return nullptr; 364 364 } 365 365 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& 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 ( std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)406 for (const auto& mapEntry : this->players_) 407 407 { 408 if (! it->first->isReadyToSpawn())408 if (!mapEntry.first->isReadyToSpawn()) 409 409 allplayersready = false; 410 if ( it->first->isHumanPlayer())410 if (mapEntry.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 (const 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 ( 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 (const 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 … … 492 492 { 493 493 unsigned int i = 0; 494 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 494 ObjectList<Bot> list; 495 for (ObjectList<Bot>::iterator it = list.begin(); (it != list.end()) && ((amount == 0) || (i < amount)); ) 495 496 { 496 497 if (it->getGametype() == this) … … 538 539 GSLevelMementoState* Gametype::exportMementoState() 539 540 { 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();541 for (const auto& mapEntry : this->players_) 542 { 543 if (mapEntry.first->isHumanPlayer() && mapEntry.first->getControllableEntity() && mapEntry.first->getControllableEntity()->getCamera()) 544 { 545 Camera* camera = mapEntry.first->getControllableEntity()->getCamera(); 545 546 546 547 GametypeMementoState* state = new GametypeMementoState(); … … 552 553 } 553 554 554 return NULL;555 return nullptr; 555 556 } 556 557 … … 558 559 { 559 560 // find correct memento state 560 GametypeMementoState* state = NULL;561 for ( size_t i = 0; i < states.size(); ++i)562 { 563 state = dynamic_cast<GametypeMementoState*>( states[i]);561 GametypeMementoState* state = nullptr; 562 for (GSLevelMementoState* temp : states) 563 { 564 state = dynamic_cast<GametypeMementoState*>(temp); 564 565 if (state) 565 566 break; … … 570 571 571 572 // find correct scene 572 Scene* scene = NULL;573 for ( ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); it != ObjectList<Scene>::end(); ++it)574 { 575 if ( it->getName() == state->sceneName_)576 { 577 scene = *it;573 Scene* scene = nullptr; 574 for (Scene* someScene : ObjectList<Scene>()) 575 { 576 if (someScene->getName() == state->sceneName_) 577 { 578 scene = someScene; 578 579 break; 579 580 } … … 587 588 588 589 // 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())590 for (const auto& mapEntry : this->players_) 591 { 592 if (mapEntry.first->isHumanPlayer()) 592 593 { 593 594 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(scene->getContext()); 594 595 entity->setPosition(state->cameraPosition_); 595 596 entity->setOrientation(state->cameraOrientation_); 596 it->first->startControl(entity);597 mapEntry.first->startControl(entity); 597 598 break; 598 599 } -
code/trunk/src/orxonox/gametypes/Gametype.h
r10624 r11071 45 45 namespace orxonox 46 46 { 47 namespace PlayerState 48 { 49 enum Value 50 { 51 Uninitialized, 52 Joined, 53 Alive, 54 Dead 55 }; 56 } 47 enum class PlayerState 48 { 49 Uninitialized, 50 Joined, 51 Alive, 52 Dead 53 }; 57 54 58 55 struct Player 59 56 { 60 57 PlayerInfo* info_; 61 PlayerState ::Valuestate_;58 PlayerState state_; 62 59 int frags_; 63 60 int killed_; … … 76 73 void setConfigValues(); 77 74 78 virtual void tick(float dt) ;75 virtual void tick(float dt) override; 79 76 80 77 inline const GametypeInfo* getGametypeInfo() const … … 96 93 virtual void playerScored(PlayerInfo* player, int score = 1); 97 94 98 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);99 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);100 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);101 102 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);95 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr); 96 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr); 97 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr); 98 99 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr); 103 100 virtual void pawnPreSpawn(Pawn* pawn); 104 101 virtual void pawnPostSpawn(Pawn* pawn); … … 175 172 virtual void spawnDeadPlayersIfRequested(); 176 173 177 virtual GSLevelMementoState* exportMementoState() ;178 virtual void importMementoState(const std::vector<GSLevelMementoState*>& states) ;174 virtual GSLevelMementoState* exportMementoState() override; 175 virtual void importMementoState(const std::vector<GSLevelMementoState*>& states) override; 179 176 180 177 WeakPtr<GametypeInfo> gtinfo_; -
code/trunk/src/orxonox/gametypes/LastManStanding.cc
r9667 r11071 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 (const 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 ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)117 { 118 if ( it->second<=0)116 for (const auto& mapEntry : this->playerLives_) 117 { 118 if (mapEntry.second<=0) 119 119 continue; 120 if ( it->second<lives)121 min= it->second;120 if (mapEntry.second<lives) 121 min=mapEntry.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 (const auto& mapEntry : this->playerLives_) 131 { 132 if (mapEntry.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 (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!", it->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 ( 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& mapEntry : this->timeToAct_) 240 { 241 if (playerGetLives(mapEntry.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 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_[ it->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, 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,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( it->first);262 if ( it->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, it->first->getClientID());265 this->gtinfo_->sendFadingMessage(message,mapEntry.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 (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, it->first->getClientID());273 this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID()); 274 274 } 275 275 } -
code/trunk/src/orxonox/gametypes/LastManStanding.h
r9667 r11071 61 61 bool bHardPunishment; //!< Switches between damage and death as punishment. 62 62 float punishDamageRate; //!< Makes Damage adjustable. 63 virtual void spawnDeadPlayersIfRequested() ; //!< Prevents dead players to respawn.63 virtual void spawnDeadPlayersIfRequested() override; //!< Prevents dead players to respawn. 64 64 virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped; 65 65 … … 69 69 void setConfigValues(); //!< Makes values configurable. 70 70 71 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponent, his punishment countdown will be resetted.72 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives.71 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; //!< If a player shoot's an opponent, his punishment countdown will be resetted. 72 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; //!< Manages each players lives. 73 73 74 virtual void end() ; //!< Sends an end message.74 virtual void end() override; //!< Sends an end message. 75 75 int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_". 76 76 int getNumPlayersAlive() const; //!< Returns the number of players that are still alive. 77 virtual void playerEntered(PlayerInfo* player) ; //!< Initializes values.78 virtual bool playerLeft(PlayerInfo* player) ; //!< Manages all local variables.79 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ; //!< Resets punishment time and respawn delay.77 virtual void playerEntered(PlayerInfo* player) override; //!< Initializes values. 78 virtual bool playerLeft(PlayerInfo* player) override; //!< Manages all local variables. 79 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override; //!< Resets punishment time and respawn delay. 80 80 81 81 void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining". 82 v oid tick (float dt); //!< used to end the game82 virtual void tick (float dt) override; //!< used to end the game 83 83 }; 84 84 } -
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
r9941 r11071 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 (const 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 ( 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& mapEntry : this->timeToAct_) 187 { 188 if (playerGetLives(mapEntry.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 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_[ it->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, 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,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( it->first);209 if ( it->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, it->first->getClientID());212 this->gtinfo_->sendFadingMessage(message, mapEntry.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 (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, it->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 ( 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 (const auto& mapEntry : this->playerLives_) 232 { 233 if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 234 234 continue; 235 235 236 if ( it->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( it->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 ( std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)258 { 259 if ( it->second <= 0)257 for (const auto& mapEntry : this->playerLives_) 258 { 259 if (mapEntry.second <= 0) 260 260 continue; 261 if ( it->second < lives)262 min = it->second;261 if (mapEntry.second < lives) 262 min = mapEntry.second; 263 263 } 264 264 return min; -
code/trunk/src/orxonox/gametypes/LastTeamStanding.h
r9667 r11071 67 67 std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state. 68 68 69 virtual void spawnDeadPlayersIfRequested() ; //!< Prevents dead players to respawn.69 virtual void spawnDeadPlayersIfRequested() override; //!< Prevents dead players to respawn. 70 70 virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped; 71 71 … … 74 74 virtual ~LastTeamStanding(); //!< Default Destructor. 75 75 76 virtual void playerEntered(PlayerInfo* player) ; //!< Initializes values.77 virtual bool playerLeft(PlayerInfo* player) ; //!< Manages all local variables.76 virtual void playerEntered(PlayerInfo* player) override; //!< Initializes values. 77 virtual bool playerLeft(PlayerInfo* player) override; //!< Manages all local variables. 78 78 79 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each player's lost lives.80 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //!< If a player shoot's an opponent, his punishment countdown will be resetted.81 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ; //!< Resets punishment time and respawn delay.82 v oid tick (float dt); //!< used to end the game83 virtual void end() ; //!< Sends an end message.79 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; //!< Manages each player's lost lives. 80 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; //!< If a player shoot's an opponent, his punishment countdown will be resetted. 81 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override; //!< Resets punishment time and respawn delay. 82 virtual void tick (float dt) override; //!< used to end the game 83 virtual void end() override; //!< Sends an end message. 84 84 void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining". 85 85 int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_". -
code/trunk/src/orxonox/gametypes/Mission.cc
r10624 r11071 101 101 void Mission::setTeams() 102 102 { //Set pawn-colours 103 for ( ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)103 for (Pawn* pawn : ObjectList<Pawn>()) 104 104 { 105 Pawn* pawn = static_cast<Pawn*>(*it);106 105 if (!pawn) 107 106 continue; … … 111 110 void Mission::endMission(bool accomplished) 112 111 { 113 for ( ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)112 for (Mission* mission : ObjectList<Mission>()) 114 113 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions! 115 it->setMissionAccomplished(accomplished);116 it->end();114 mission->setMissionAccomplished(accomplished); 115 mission->end(); 117 116 } 118 117 } … … 120 119 void Mission::setLivesWrapper(unsigned int amount) 121 120 { 122 for ( ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)121 for (Mission* mission : ObjectList<Mission>()) 123 122 { //TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would affect ALL missions! 124 it->setLives(amount);123 mission->setLives(amount); 125 124 } 126 125 } -
code/trunk/src/orxonox/gametypes/Mission.h
r9729 r11071 42 42 virtual ~Mission() {} 43 43 44 virtual void tick(float dt) ;44 virtual void tick(float dt) override; 45 45 46 virtual void start() ;47 virtual void end() ;46 virtual void start() override; 47 virtual void end() override; 48 48 virtual void setTeams(); 49 virtual void addBots(unsigned int amount) {} //<! overwrite function in order to bypass the addbots command49 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command 50 50 inline void setLives(unsigned int amount) 51 51 {this->lives_ = amount;} … … 58 58 59 59 protected: 60 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);60 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 61 61 bool missionAccomplished_; //<! indicates if player successfully finsihed the mission; 62 62 int lives_; //<! amount of player's lives <-> nr. of retries -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
r9667 r11071 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 (TeamBaseMatchBase* base : this->bases_) 155 { 156 if(base->getState() == BaseState::ControlTeam1) 157 157 { 158 158 amountControlled++; 159 159 } 160 if( (*it)->getState() == BaseState::ControlTeam2)160 if(base->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 (const auto& mapEntry : this->teamnumbers_) 190 { 191 if (mapEntry.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 (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!", it->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 ( 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 (TeamBaseMatchBase* base : this->bases_) 241 { 242 if (base->getState() == BaseState::ControlTeam1 && team == 0) 243 243 count++; 244 if ( (*it)->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 ( std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)260 for (TeamBaseMatchBase* base : this->bases_) 261 261 { 262 262 i++; 263 263 if (i > index) 264 return (*it);265 } 266 return 0;264 return base; 265 } 266 return nullptr; 267 267 } 268 268 -
code/trunk/src/orxonox/gametypes/TeamBaseMatch.h
r9667 r11071 44 44 virtual ~TeamBaseMatch() {} 45 45 46 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);47 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) ;46 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; 47 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator) override; 48 48 49 virtual void playerScored(PlayerInfo* player, int score = 1) ;49 virtual void playerScored(PlayerInfo* player, int score = 1) override; 50 50 virtual void showPoints(); 51 51 virtual void endGame(); -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc
r9941 r11071 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 (const auto& mapEntry : this->players_) 72 72 { 73 if ( this->getTeamScore( it->first) > highestScore )73 if ( this->getTeamScore(mapEntry.first) > highestScore ) 74 74 { 75 winnerTeam = this->getTeam( it->first);76 highestScore = this->getTeamScore( it->first);75 winnerTeam = this->getTeam(mapEntry.first); 76 highestScore = this->getTeamScore(mapEntry.first); 77 77 } 78 78 } -
code/trunk/src/orxonox/gametypes/TeamDeathmatch.h
r9941 r11071 42 42 43 43 void setConfigValues(); 44 virtual void start() ;45 virtual void end() ;46 virtual void playerEntered(PlayerInfo* player) ;47 virtual bool playerLeft(PlayerInfo* player) ;48 virtual bool playerChangedName(PlayerInfo* player) ;44 virtual void start() override; 45 virtual void end() override; 46 virtual void playerEntered(PlayerInfo* player) override; 47 virtual bool playerLeft(PlayerInfo* player) override; 48 virtual bool playerChangedName(PlayerInfo* player) override; 49 49 50 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);51 virtual void playerScored(PlayerInfo* player, int score = 1) ;50 virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override; 51 virtual void playerScored(PlayerInfo* player, int score = 1) override; 52 52 protected: 53 53 int maxScore_; -
code/trunk/src/orxonox/gametypes/TeamGametype.cc
r9941 r11071 75 75 void TeamGametype::playerEntered(PlayerInfo* player) 76 76 { 77 if(player == NULL) return; // catch null pointers77 if(player == nullptr) return; // catch null pointers 78 78 Gametype::playerEntered(player); 79 79 this->findAndSetTeam(player); … … 96 96 void TeamGametype::findAndSetTeam(PlayerInfo* player) 97 97 { 98 if(player == NULL) return; // catch null pointers98 if(player == nullptr) return; // catch null pointers 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 (const 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 ( 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& 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 ( 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 (const 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 ( it->second.state_ == PlayerState::Dead)150 { 151 if (( it->first->isReadyToSpawn() || this->bForceSpawn_))149 if (mapEntry.second.state_ == PlayerState::Dead) 150 { 151 if ((mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) 152 152 { 153 this->spawnPlayer( it->first);153 this->spawnPlayer(mapEntry.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 (const 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 ( std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)194 { 195 if ( it->second == team)193 for (const auto& mapEntry : this->teamnumbers_) 194 { 195 if (mapEntry.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 (const auto& mapEntry : this->teamnumbers_) 205 { 206 if (mapEntry.second == team && mapEntry.first->isHumanPlayer()) 207 207 teamSize++; 208 208 } … … 235 235 } 236 236 237 SpawnPoint* fallbackSpawnPoint = NULL;237 SpawnPoint* fallbackSpawnPoint = nullptr; 238 238 if (teamSpawnPoints.size() > 0) 239 239 { … … 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 (SpawnPoint* 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 (SpawnPoint* teamSpawnPoint : teamSpawnPoints) 269 269 { 270 270 if (index == randomspawn) 271 return (*it);271 return teamSpawnPoint; 272 272 273 273 ++index; … … 277 277 } 278 278 279 return 0;279 return nullptr; 280 280 } 281 281 … … 328 328 void TeamGametype::setDefaultObjectColour(Pawn* pawn) 329 329 { 330 if(pawn == NULL)330 if(pawn == nullptr) 331 331 return; 332 332 … … 340 340 ControllableEntity* entity = orxonox_cast<ControllableEntity*>(pawn); 341 341 342 Controller* controller = 0;342 Controller* controller = nullptr; 343 343 if (entity->getController()) 344 344 controller = entity->getController(); … … 350 350 ArtificialController* artificial = orxonox_cast<ArtificialController*>(controller); 351 351 //get Teamnumber - get the data 352 if(artificial == NULL)352 if(artificial == nullptr) 353 353 return; 354 354 teamnumber= artificial->getTeam(); … … 360 360 void TeamGametype::colourPawn(Pawn* pawn, int teamNr) 361 361 {// catch: no-colouring-case and wrong input 362 if(teamNr < 0 || teamNr+1 > int(this->teamcolours_.size()) ||pawn == NULL) return;362 if(teamNr < 0 || teamNr+1 > int(this->teamcolours_.size()) ||pawn == nullptr) return; 363 363 pawn->setRadarObjectColour(this->teamcolours_[teamNr]); 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 (WorldEntity* 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 (const auto& mapEntry : this->teamnumbers_) 379 { 380 if (mapEntry.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 (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!", it3->first->getClientID());388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", mapEntry.first->getClientID()); 389 389 } 390 390 } -
code/trunk/src/orxonox/gametypes/TeamGametype.h
r9941 r11071 46 46 void setConfigValues(); 47 47 48 virtual void playerEntered(PlayerInfo* player) ;48 virtual void playerEntered(PlayerInfo* player) override; 49 49 virtual void findAndSetTeam(PlayerInfo* player); 50 virtual bool playerLeft(PlayerInfo* player) ;51 virtual void spawnDeadPlayersIfRequested() ; //!< Prevents players to respawn.50 virtual bool playerLeft(PlayerInfo* player) override; 51 virtual void spawnDeadPlayersIfRequested() override; //!< Prevents players to respawn. 52 52 53 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);54 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);55 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);53 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr) override; 54 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; 55 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; 56 56 57 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) ;57 virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override; 58 58 59 59 … … 67 67 68 68 protected: 69 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const ;69 virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const override; 70 70 bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2); 71 71 -
code/trunk/src/orxonox/gametypes/UnderAttack.cc
r9941 r11071 48 48 this->gameTime_ = 180; 49 49 this->teams_ = 2; 50 this->destroyer_ = 0;50 this->destroyer_ = nullptr; 51 51 this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this)); 52 52 this->gameEnded_ = false; … … 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 (const auto& mapEntry : this->teamnumbers_) 77 { 78 if (mapEntry.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 (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!", it->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 ( 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 (const auto& mapEntry : this->teamnumbers_) 158 { 159 if (mapEntry.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 (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!", it->first->getClientID());165 this->gtinfo_->sendAnnounceMessage("You have lost the match!", mapEntry.first->getClientID()); 166 166 } 167 167 } … … 202 202 void UnderAttack::setTransporterHealth() 203 203 { 204 if (this->destroyer_ != 0)204 if (this->destroyer_ != nullptr) 205 205 { 206 206 //Calculation: Each attacker deals about 3500 damage. A human attacker deals 1500 damage additionally. -
code/trunk/src/orxonox/gametypes/UnderAttack.h
r9941 r11071 43 43 44 44 void setConfigValues(); 45 v oid tick (float dt);45 virtual void tick (float dt) override; 46 46 void addDestroyer(Destroyer* destroyer); 47 47 inline Destroyer* getDestroyer() const 48 48 { return this->destroyer_; } 49 49 50 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);51 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);52 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);53 virtual void playerEntered(PlayerInfo* player) ;50 virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr) override; 51 virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr) override; 52 virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr) override; 53 virtual void playerEntered(PlayerInfo* player) override; 54 54 55 55 protected:
Note: See TracChangeset
for help on using the changeset viewer.