Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gametypes/Asteroids.h

    r9667 r11071  
    4141            virtual ~Asteroids() {}
    4242
    43             virtual void tick(float dt);
     43            virtual void tick(float dt) override;
    4444
    45             virtual void start();
    46             virtual void end();
     45            virtual void start() override;
     46            virtual void end() override;
    4747
    4848            inline void firstCheckpointReached(bool reached)
     
    5050
    5151        protected:
    52             virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     52            virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override;
    5353
    5454        private:
  • code/trunk/src/orxonox/gametypes/Deathmatch.h

    r9667 r11071  
    4141            virtual ~Deathmatch() {}
    4242
    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;
    4848
    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;
    5151    };
    5252}
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r11052 r11071  
    8888    Dynamicmatch::~Dynamicmatch()
    8989    {
    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;
    9292    }
    9393
     
    413413    void Dynamicmatch::rewardPig()
    414414    {
    415         for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden
    416         {
    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);
    420420            }
    421421        }
     
    430430
    431431                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)))
    435435                    {
    436                         TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
     436                        TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment);
    437437                        tc->setTeamColour(this->partyColours_[it_player->second]);
    438438                    }
     
    449449            if (tutorial) // Announce selectionphase
    450450            {
    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 nullpointer
     451             for (const auto& mapEntry : this->playerParty_)
     452                {
     453                    if (!mapEntry.first)//in order to catch nullpointer
    454454                        continue;
    455                     if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     455                    if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    456456                        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));
    458458                }
    459459            }
     
    464464             if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over
    465465             {
    466                   for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     466                  for (const auto& mapEntry : this->playerParty_)
    467467                  {
    468                        if (!it->first)//in order to catch nullpointer
     468                       if (!mapEntry.first)//in order to catch nullpointer
    469469                           continue;
    470                        if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     470                       if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    471471                           continue;
    472                        else if (it->second==chaser)
     472                       else if (mapEntry.second==chaser)
    473473                       {
    474474                           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]);
    476476                           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]);
    478478                           //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
    479479                       }
    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]);
    483483                           //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
    484484                       }
    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]);
    488488                           //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
    489489                       }
     
    498498            if (tutorial) // Announce selectionphase
    499499            {
    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 nullpointer
     500             for (const auto& mapEntry : this->playerParty_)
     501                {
     502                    if (!mapEntry.first)//in order to catch nullpointer
    503503                        continue;
    504                     if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     504                    if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    505505                        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));
    507507                }
    508508            }
     
    513513            if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over
    514514             {
    515                   for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     515                  for (const auto& mapEntry : this->playerParty_)
    516516                  {
    517                        if (!it->first)
     517                       if (!mapEntry.first)
    518518                           continue;
    519                        if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     519                       if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    520520                           continue;
    521                        else if (it->second==chaser)
     521                       else if (mapEntry.second==chaser)
    522522                       {
    523523                           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]);
    525525                           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]);
    527527                           //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
    528528                       }
    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]);
    532532                           //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
    533533                       }
    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]);
    537537                           //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
    538538                       }
     
    548548            if (tutorial) // Announce selectionphase
    549549            {
    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 nullpointer
     550             for (const auto& mapEntry : this->playerParty_)
     551                {
     552                    if (!mapEntry.first)//in order to catch nullpointer
    553553                        continue;
    554                     if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     554                    if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    555555                        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));
    557557                }
    558558            }
     
    563563             if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over
    564564             {
    565                   for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     565                  for (const auto& mapEntry : this->playerParty_)
    566566                  {
    567                        if (!it->first)
     567                       if (!mapEntry.first)
    568568                           continue;
    569                        if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     569                       if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    570570                           continue;
    571                        else if (it->second==chaser)
     571                       else if (mapEntry.second==chaser)
    572572                       {
    573573                           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]);
    575575                           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]);
    577577                           //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
    578578                       }
    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]);
    582582                           //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
    583583                       }
    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]);
    587587                           //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
    588588                       }
     
    631631        else if(tutorial) // Announce selectionphase
    632632        {
    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)
    636636                    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));
    638638            }
    639639        }
     
    687687            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
    688688            unsigned int index = 0;
    689             for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
     689            for (SpawnPoint* teamSpawnPoint : teamSpawnPoints)
    690690            {
    691691                if (index == randomspawn)
    692                     return (*it);
     692                    return teamSpawnPoint;
    693693
    694694                ++index;
     
    696696        }
    697697
    698         return 0;
     698        return nullptr;
    699699    }
    700700
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.h

    r11052 r11071  
    6565            bool tutorial; //goal: new players receive messages how the new gametype works - later it can be switched off.
    6666
    67             virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0); //ok - score function and management of parties
    68             virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //ok - simple
    69             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 colour
    73             virtual bool playerLeft(PlayerInfo* player);
    74             virtual bool playerChangedName(PlayerInfo* player);//unchanged
     67            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
    7575
    7676            /*virtual void instructions();
     
    7979            void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost.
    8080            void resetSpeedFactor(SpaceShip* spaceship, Timer* timer);
    81             void tick (float dt);// used to end the game
    82             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;
    8383
    8484
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r10624 r11071  
    6666
    6767        this->defaultControllableEntity_ = Class(Spectator);
    68         this->scoreboard_ = 0;
     68        this->scoreboard_ = nullptr;
    6969
    7070        this->bAutoStart_ = false;
     
    9292                this->gtinfo_->destroy();
    9393
    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);
    9696        }
    9797    }
     
    139139        if (!this->gtinfo_->hasStarted())
    140140        {
    141             for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     141            for (const auto& mapEntry : this->players_)
    142142            {
    143143                // 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);
    146146            }
    147147
     
    169169        }
    170170
    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();
    176176
    177177                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getContext());
     
    186186                    entity->setOrientation(oldentity->getWorldOrientation());
    187187                }
    188                 it->first->startControl(entity);
     188                mapEntry.first->startControl(entity);
    189189            }
    190190            else
    191                 this->spawnPlayerAsDefaultPawn(it->first);
     191                this->spawnPlayerAsDefaultPawn(mapEntry.first);
    192192        }
    193193    }
     
    337337        {
    338338            // Fallback spawn point if there is no active one, choose a random one.
    339             SpawnPoint* fallbackSpawnPoint = NULL;
     339            SpawnPoint* fallbackSpawnPoint = nullptr;
    340340            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    341341            unsigned int index = 0;
    342342            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_)
    344344            {
    345345                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);
    350350
    351351                ++index;
     
    361361            return fallbackSpawnPoint;
    362362        }
    363         return 0;
     363        return nullptr;
    364364    }
    365365
    366366    void Gametype::assignDefaultPawnsIfNeeded()
    367367    {
    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;
    378378                }
    379379            }
     
    404404                    bool allplayersready = true;
    405405                    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_)
    407407                    {
    408                         if (!it->first->isReadyToSpawn())
     408                        if (!mapEntry.first->isReadyToSpawn())
    409409                            allplayersready = false;
    410                         if (it->first->isHumanPlayer())
     410                        if (mapEntry.first->isHumanPlayer())
    411411                            hashumanplayers = true;
    412412                    }
     
    430430    void Gametype::spawnPlayersIfRequested()
    431431    {
    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);
    436436        }
    437437    }
     
    439439    void Gametype::spawnDeadPlayersIfRequested()
    440440    {
    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);
    445445    }
    446446
     
    492492    {
    493493        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)); )
    495496        {
    496497            if (it->getGametype() == this)
     
    538539    GSLevelMementoState* Gametype::exportMementoState()
    539540    {
    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();
    545546
    546547                GametypeMementoState* state = new GametypeMementoState();
     
    552553        }
    553554
    554         return NULL;
     555        return nullptr;
    555556    }
    556557
     
    558559    {
    559560        // 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);
    564565            if (state)
    565566                break;
     
    570571
    571572        // 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;
    578579                break;
    579580            }
     
    587588
    588589        // 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())
    592593            {
    593594                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(scene->getContext());
    594595                entity->setPosition(state->cameraPosition_);
    595596                entity->setOrientation(state->cameraOrientation_);
    596                 it->first->startControl(entity);
     597                mapEntry.first->startControl(entity);
    597598                break;
    598599            }
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r10624 r11071  
    4545namespace orxonox
    4646{
    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    };
    5754
    5855    struct Player
    5956    {
    6057        PlayerInfo* info_;
    61         PlayerState::Value state_;
     58        PlayerState state_;
    6259        int frags_;
    6360        int killed_;
     
    7673            void setConfigValues();
    7774
    78             virtual void tick(float dt);
     75            virtual void tick(float dt) override;
    7976
    8077            inline const GametypeInfo* getGametypeInfo() const
     
    9693            virtual void playerScored(PlayerInfo* player, int score = 1);
    9794
    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);
    103100            virtual void pawnPreSpawn(Pawn* pawn);
    104101            virtual void pawnPostSpawn(Pawn* pawn);
     
    175172            virtual void spawnDeadPlayersIfRequested();
    176173
    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;
    179176
    180177            WeakPtr<GametypeInfo> gtinfo_;
  • code/trunk/src/orxonox/gametypes/LastManStanding.cc

    r9667 r11071  
    5656    void LastManStanding::spawnDeadPlayersIfRequested()
    5757    {
    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);
    6565                }
    6666            }
     
    114114    {
    115115        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)
    119119                continue;
    120             if (it->second<lives)
    121                 min=it->second;
     120            if (mapEntry.second<lives)
     121                min=mapEntry.second;
    122122        }
    123123        return min;
     
    128128        Gametype::end();
    129129
    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)
    133133                continue;
    134134
    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());
    137137            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());
    139139        }
    140140    }
     
    237237                this->end();
    238238            }
    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.
    242242                    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)
    251251                        continue;
    252                     int output=1+(int)playerDelayTime_[it->first];
     252                    int output=1+(int)playerDelayTime_[mapEntry.first];
    253253                    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-timer
    259                     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)
    260260                    {
    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)
    263263                            return;
    264264                        const std::string& message = ""; // resets Camper-Warning-message
    265                         this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
     265                        this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID());
    266266                    }
    267267                }
    268                 else if (it->second<timeRemaining/5)//Warning message
    269                 {
    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)
    271271                        continue;
    272272                    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());
    274274                }
    275275            }
  • code/trunk/src/orxonox/gametypes/LastManStanding.h

    r9667 r11071  
    6161            bool bHardPunishment; //!< Switches between damage and death as punishment.
    6262            float punishDamageRate; //!< Makes Damage adjustable.
    63             virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn.
     63            virtual void spawnDeadPlayersIfRequested() override; //!< Prevents dead players to respawn.
    6464            virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped;
    6565
     
    6969            void setConfigValues(); //!< Makes values configurable.
    7070
    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.
    7373
    74             virtual void end(); //!< Sends an end message.
     74            virtual void end() override; //!< Sends an end message.
    7575            int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
    7676            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.
    8080
    8181            void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
    82             void tick (float dt); //!< used to end the game
     82            virtual void tick (float dt) override; //!< used to end the game
    8383    };
    8484}
  • code/trunk/src/orxonox/gametypes/LastTeamStanding.cc

    r9941 r11071  
    145145    void LastTeamStanding::spawnDeadPlayersIfRequested()
    146146    {
    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);
    154154                }
    155155            }
     
    184184                this->end();
    185185            }
    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.
    189189                    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)
    198198                        continue;
    199                     int output = 1 + (int)playerDelayTime_[it->first];
     199                    int output = 1 + (int)playerDelayTime_[mapEntry.first];
    200200                    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-timer
    206                     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)
    207207                    {
    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)
    210210                            return;
    211211                        const std::string& message = ""; // resets Camper-Warning-message
    212                         this->gtinfo_->sendFadingMessage(message, it->first->getClientID());
     212                        this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID());
    213213                    }
    214214                }
    215                 else if (it->second < timeRemaining/5)//Warning message
    216                 {
    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)
    218218                        continue;
    219219                    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());
    221221                }
    222222            }
     
    229229        int party = -1;
    230230        //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)
    234234                continue;
    235235
    236             if (it->second > 0)//a player that is alive
     236            if (mapEntry.second > 0)//a player that is alive
    237237            {
    238238                //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);
    240240                if (it2 != this->teamnumbers_.end())
    241241                {
     
    255255    {
    256256        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)
    260260                continue;
    261             if (it->second < lives)
    262                 min = it->second;
     261            if (mapEntry.second < lives)
     262                min = mapEntry.second;
    263263        }
    264264        return min;
  • code/trunk/src/orxonox/gametypes/LastTeamStanding.h

    r9667 r11071  
    6767            std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state.
    6868
    69             virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn.
     69            virtual void spawnDeadPlayersIfRequested() override; //!< Prevents dead players to respawn.
    7070            virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped;
    7171
     
    7474            virtual ~LastTeamStanding(); //!< Default Destructor.
    7575
    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.
    7878
    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             void tick (float dt); //!< used to end the game
    83             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.
    8484            void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
    8585            int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
  • code/trunk/src/orxonox/gametypes/Mission.cc

    r10624 r11071  
    101101    void Mission::setTeams()
    102102    { //Set pawn-colours
    103         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     103        for (Pawn* pawn : ObjectList<Pawn>())
    104104        {
    105             Pawn* pawn = static_cast<Pawn*>(*it);
    106105            if (!pawn)
    107106                continue;
     
    111110    void Mission::endMission(bool accomplished)
    112111    {
    113         for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
     112        for (Mission* mission : ObjectList<Mission>())
    114113        { //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();
    117116        }
    118117    }
     
    120119    void Mission::setLivesWrapper(unsigned int amount)
    121120    {
    122         for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
     121        for (Mission* mission : ObjectList<Mission>())
    123122        { //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);
    125124        }
    126125    }
  • code/trunk/src/orxonox/gametypes/Mission.h

    r9729 r11071  
    4242            virtual ~Mission() {}
    4343
    44             virtual void tick(float dt);
     44            virtual void tick(float dt) override;
    4545
    46             virtual void start();
    47             virtual void end();
     46            virtual void start() override;
     47            virtual void end() override;
    4848            virtual void setTeams();
    49             virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command
     49            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
    5050            inline void setLives(unsigned int amount)
    5151                {this->lives_ = amount;}
     
    5858
    5959        protected:
    60             virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     60            virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr) override;
    6161            bool missionAccomplished_; //<! indicates if player successfully finsihed the mission;
    6262            int lives_; //<! amount of player's lives <-> nr. of retries
  • code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc

    r9667 r11071  
    152152        int amountControlled2 = 0;
    153153
    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)
    157157            {
    158158                amountControlled++;
    159159            }
    160             if((*it)->getState() == BaseState::ControlTeam2)
     160            if(base->getState() == BaseState::ControlTeam2)
    161161            {
    162162                amountControlled2++;
     
    187187            }
    188188
    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)
    192192                    continue;
    193193
    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());
    196196                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());
    198198            }
    199199
     
    238238        int count = 0;
    239239
    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)
    243243                count++;
    244             if ((*it)->getState() == BaseState::ControlTeam2 && team == 1)
     244            if (base->getState() == BaseState::ControlTeam2 && team == 1)
    245245                count++;
    246246        }
     
    258258    {
    259259        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_)
    261261        {
    262262            i++;
    263263            if (i > index)
    264                 return (*it);
    265         }
    266         return 0;
     264                return base;
     265        }
     266        return nullptr;
    267267    }
    268268
  • code/trunk/src/orxonox/gametypes/TeamBaseMatch.h

    r9667 r11071  
    4444            virtual ~TeamBaseMatch() {}
    4545
    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;
    4848
    49             virtual void playerScored(PlayerInfo* player, int score = 1);
     49            virtual void playerScored(PlayerInfo* player, int score = 1) override;
    5050            virtual void showPoints();
    5151            virtual void endGame();
  • code/trunk/src/orxonox/gametypes/TeamDeathmatch.cc

    r9941 r11071  
    6969        int winnerTeam = 0;
    7070        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_)
    7272        {
    73             if ( this->getTeamScore(it->first) > highestScore )
     73            if ( this->getTeamScore(mapEntry.first) > highestScore )
    7474            {
    75                 winnerTeam = this->getTeam(it->first);
    76                 highestScore = this->getTeamScore(it->first);
     75                winnerTeam = this->getTeam(mapEntry.first);
     76                highestScore = this->getTeamScore(mapEntry.first);
    7777            }
    7878        }
  • code/trunk/src/orxonox/gametypes/TeamDeathmatch.h

    r9941 r11071  
    4242
    4343            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;
    4949
    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;
    5252       protected:
    5353            int maxScore_;
  • code/trunk/src/orxonox/gametypes/TeamGametype.cc

    r9941 r11071  
    7575    void TeamGametype::playerEntered(PlayerInfo* player)
    7676    {
    77         if(player == NULL) return; // catch null pointers
     77        if(player == nullptr) return; // catch null pointers
    7878        Gametype::playerEntered(player);
    7979        this->findAndSetTeam(player);
     
    9696    void TeamGametype::findAndSetTeam(PlayerInfo* player)
    9797    {
    98         if(player == NULL) return; // catch null pointers
     98        if(player == nullptr) return; // catch null pointers
    9999        std::vector<unsigned int> playersperteam(this->teams_, 0);
    100100
    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]++;
    104104
    105105        unsigned int minplayers = static_cast<unsigned int>(-1);
     
    123123        if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list"
    124124        {
    125             for (std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it)
    126             {
    127                  if(it->second == false) // waiting player found
    128                  {it->second = true; break;} // allow player to enter
     125            for (auto& mapEntry : this->allowedInGame_)
     126            {
     127                 if(mapEntry.second == false) // waiting player found
     128                 {mapEntry.second = true; break;} // allow player to enter
    129129            }
    130130        }
     
    141141    void TeamGametype::spawnDeadPlayersIfRequested()
    142142    {
    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 enter
     143        for (const auto& mapEntry : this->players_)\
     144        {
     145            if(allowedInGame_[mapEntry.first] == false)//check if dead player is allowed to enter
    146146            {
    147147                continue;
    148148            }
    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_))
    152152                {
    153                    this->spawnPlayer(it->first);
     153                   this->spawnPlayer(mapEntry.first);
    154154                }
    155155            }
     
    178178        if(!player || this->getTeam(player) == -1)
    179179            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_;
    185185            }
    186186        }
     
    191191    {
    192192        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)
    196196                teamSize++;
    197197        }
     
    202202    {
    203203        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())
    207207                teamSize++;
    208208        }
     
    235235        }
    236236
    237         SpawnPoint* fallbackSpawnPoint = NULL;
     237        SpawnPoint* fallbackSpawnPoint = nullptr;
    238238        if (teamSpawnPoints.size() > 0)
    239239        {
     
    241241            unsigned int index = 0;
    242242            // 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)
    244244            {
    245245                if (index == randomspawn)
    246246                {
    247                     fallbackSpawnPoint = (*it);
     247                    fallbackSpawnPoint = teamSpawnPoint;
    248248                    break;
    249249                }
     
    266266            randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
    267267            index = 0;
    268             for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
     268            for (SpawnPoint* teamSpawnPoint : teamSpawnPoints)
    269269            {
    270270                if (index == randomspawn)
    271                     return (*it);
     271                    return teamSpawnPoint;
    272272
    273273                ++index;
     
    277277        }
    278278
    279         return 0;
     279        return nullptr;
    280280    }
    281281
     
    328328    void TeamGametype::setDefaultObjectColour(Pawn* pawn)
    329329    {
    330         if(pawn == NULL)
     330        if(pawn == nullptr)
    331331            return;
    332332
     
    340340        ControllableEntity* entity = orxonox_cast<ControllableEntity*>(pawn);
    341341
    342         Controller* controller = 0;
     342        Controller* controller = nullptr;
    343343        if (entity->getController())
    344344            controller = entity->getController();
     
    350350        ArtificialController* artificial =  orxonox_cast<ArtificialController*>(controller);
    351351        //get Teamnumber - get the data
    352         if(artificial == NULL)
     352        if(artificial == nullptr)
    353353            return;
    354354        teamnumber= artificial->getTeam();
     
    360360    void TeamGametype::colourPawn(Pawn* pawn, int teamNr)
    361361    {// 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;
    363363        pawn->setRadarObjectColour(this->teamcolours_[teamNr]);
    364364
    365365        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);
    371371                tc->setTeamColour(this->teamcolours_[teamNr]);
    372372            }
     
    376376    void TeamGametype::announceTeamWin(int winnerTeam)
    377377    {
    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)
    381381                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());
    385385            }
    386386            else
    387387            {
    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());
    389389            }
    390390        }   
  • code/trunk/src/orxonox/gametypes/TeamGametype.h

    r9941 r11071  
    4646            void setConfigValues();
    4747
    48             virtual void playerEntered(PlayerInfo* player);
     48            virtual void playerEntered(PlayerInfo* player) override;
    4949            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.
    5252
    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;
    5656
    57             virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
     57            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) override;
    5858
    5959
     
    6767
    6868        protected:
    69             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
     69            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const override;
    7070            bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
    7171
  • code/trunk/src/orxonox/gametypes/UnderAttack.cc

    r9941 r11071  
    4848        this->gameTime_ = 180;
    4949        this->teams_ = 2;
    50         this->destroyer_ = 0;
     50        this->destroyer_ = nullptr;
    5151        this->destroyer_.setCallback(createFunctor(&UnderAttack::killedDestroyer, this));
    5252        this->gameEnded_ = false;
     
    7474        this->gameEnded_ = true;
    7575
    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)
    7979                continue;
    8080
    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());
    8383            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());
    8585        }
    8686    }
     
    155155                ChatManager::message(message);
    156156
    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)
    160160                        continue;
    161161
    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());
    164164                    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());
    166166                }
    167167            }
     
    202202    void UnderAttack::setTransporterHealth()
    203203    {
    204         if (this->destroyer_ != 0)
     204        if (this->destroyer_ != nullptr)
    205205        {
    206206            //Calculation: Each attacker deals about 3500 damage. A human attacker deals 1500 damage additionally.
  • code/trunk/src/orxonox/gametypes/UnderAttack.h

    r9941 r11071  
    4343
    4444            void setConfigValues();
    45             void tick (float dt);
     45            virtual void tick (float dt) override;
    4646            void addDestroyer(Destroyer* destroyer);
    4747            inline Destroyer* getDestroyer() const
    4848                { return this->destroyer_; }
    4949
    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;
    5454
    5555        protected:
Note: See TracChangeset for help on using the changeset viewer.