Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (9 years ago)
Author:
muemart
Message:

Run clang-modernize -loop-convert

  • Again, not all possible loops were converted
  • It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
Location:
code/branches/cpp11_v2/src/orxonox/gametypes
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/orxonox/gametypes/Dynamicmatch.cc

    r10768 r10821  
    405405    void Dynamicmatch::rewardPig()
    406406    {
    407         for (std::map< PlayerInfo*, int >::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it) //durch alle Spieler iterieren und alle piggys finden
    408         {
    409             if (it->second==piggy)//Spieler mit der Pig-party frags++
    410             {
    411                  this->playerScored(it->first);
     407        for (auto & elem : this->playerParty_) //durch alle Spieler iterieren und alle piggys finden
     408        {
     409            if (elem.second==piggy)//Spieler mit der Pig-party frags++
     410            {
     411                 this->playerScored(elem.first);
    412412            }
    413413        }
     
    422422
    423423                std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
    424                 for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
    425                 {
    426                     if ((*it)->isA(Class(TeamColourable)))
     424                for (const auto & pawnAttachment : pawnAttachments)
     425                {
     426                    if ((pawnAttachment)->isA(Class(TeamColourable)))
    427427                    {
    428                         TeamColourable* tc = orxonox_cast<TeamColourable*>(*it);
     428                        TeamColourable* tc = orxonox_cast<TeamColourable*>(pawnAttachment);
    429429                        tc->setTeamColour(this->partyColours_[it_player->second]);
    430430                    }
     
    441441            if (tutorial) // Announce selectionphase
    442442            {
    443              for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
    444                 {
    445                     if (!it->first)//in order to catch nullpointer
     443             for (auto & elem : this->playerParty_)
     444                {
     445                    if (!elem.first)//in order to catch nullpointer
    446446                        continue;
    447                     if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     447                    if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    448448                        continue;
    449                     this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
     449                    this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    450450                }
    451451            }
     
    456456             if(tutorial&&(!notEnoughKillers)&&(!notEnoughChasers)) //Selection phase over
    457457             {
    458                   for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     458                  for (auto & elem : this->playerParty_)
    459459                  {
    460                        if (!it->first)//in order to catch nullpointer
     460                       if (!elem.first)//in order to catch nullpointer
    461461                           continue;
    462                        if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     462                       if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    463463                           continue;
    464                        else if (it->second==chaser)
     464                       else if (elem.second==chaser)
    465465                       {
    466466                           if (numberOf[killer]>0)
    467                                this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID(),partyColours_[piggy]);
     467                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]);
    468468                           else
    469                                this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID(),partyColours_[piggy]);
     469                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]);
    470470                           //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
    471471                       }
    472                        else if (it->second==piggy)
    473                        {
    474                            this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID(),partyColours_[chaser]);
     472                       else if (elem.second==piggy)
     473                       {
     474                           this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[chaser]);
    475475                           //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
    476476                       }
    477                        else if (it->second==killer)
    478                        {
    479                            this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID(),partyColours_[chaser]);
     477                       else if (elem.second==killer)
     478                       {
     479                           this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[chaser]);
    480480                           //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
    481481                       }
     
    490490            if (tutorial) // Announce selectionphase
    491491            {
    492              for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
    493                 {
    494                     if (!it->first)//in order to catch nullpointer
     492             for (auto & elem : this->playerParty_)
     493                {
     494                    if (!elem.first)//in order to catch nullpointer
    495495                        continue;
    496                     if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     496                    if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    497497                        continue;
    498                     this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
     498                    this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    499499                }
    500500            }
     
    505505            if(tutorial&&(!notEnoughPigs)&&(!notEnoughChasers)) //Selection phase over
    506506             {
    507                   for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     507                  for (auto & elem : this->playerParty_)
    508508                  {
    509                        if (!it->first)
     509                       if (!elem.first)
    510510                           continue;
    511                        if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     511                       if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    512512                           continue;
    513                        else if (it->second==chaser)
     513                       else if (elem.second==chaser)
    514514                       {
    515515                           if (numberOf[killer]>0)
    516                                this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID(),partyColours_[piggy]);
     516                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]);
    517517                           else
    518                                this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID(),partyColours_[piggy]);
     518                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]);
    519519                           //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
    520520                       }
    521                        else if (it->second==piggy)
    522                        {
    523                            this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID(),partyColours_[piggy]);
     521                       else if (elem.second==piggy)
     522                       {
     523                           this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[piggy]);
    524524                           //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
    525525                       }
    526                        else if (it->second==killer)
    527                        {
    528                            this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID(),partyColours_[piggy]);
     526                       else if (elem.second==killer)
     527                       {
     528                           this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[piggy]);
    529529                           //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
    530530                       }
     
    540540            if (tutorial) // Announce selectionphase
    541541            {
    542              for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
    543                 {
    544                     if (!it->first)//in order to catch nullpointer
     542             for (auto & elem : this->playerParty_)
     543                {
     544                    if (!elem.first)//in order to catch nullpointer
    545545                        continue;
    546                     if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     546                    if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    547547                        continue;
    548                     this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
     548                    this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    549549                }
    550550            }
     
    555555             if(tutorial&&(!notEnoughPigs)&&(!notEnoughKillers)) //Selection phase over
    556556             {
    557                   for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
     557                  for (auto & elem : this->playerParty_)
    558558                  {
    559                        if (!it->first)
     559                       if (!elem.first)
    560560                           continue;
    561                        if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     561                       if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    562562                           continue;
    563                        else if (it->second==chaser)
     563                       else if (elem.second==chaser)
    564564                       {
    565565                           if (numberOf[killer]>0)
    566                                this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",it->first->getClientID(),partyColours_[piggy]);
     566                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible. Defend yourself against the killers.",elem.first->getClientID(),partyColours_[piggy]);
    567567                           else
    568                                this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",it->first->getClientID(),partyColours_[piggy]);
     568                               this->gtinfo_->sendStaticMessage("Shoot at the victim as often as possible.",elem.first->getClientID(),partyColours_[piggy]);
    569569                           //this->gtinfo_->sendFadingMessage("You're now a chaser.",it->first->getClientID());
    570570                       }
    571                        else if (it->second==piggy)
    572                        {
    573                            this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",it->first->getClientID(),partyColours_[chaser]);
     571                       else if (elem.second==piggy)
     572                       {
     573                           this->gtinfo_->sendStaticMessage("Either hide or shoot a chaser.",elem.first->getClientID(),partyColours_[chaser]);
    574574                           //this->gtinfo_->sendFadingMessage("You're now a victim.",it->first->getClientID());
    575575                       }
    576                        else if (it->second==killer)
    577                        {
    578                            this->gtinfo_->sendStaticMessage("Take the chasers down.",it->first->getClientID(),partyColours_[chaser]);
     576                       else if (elem.second==killer)
     577                       {
     578                           this->gtinfo_->sendStaticMessage("Take the chasers down.",elem.first->getClientID(),partyColours_[chaser]);
    579579                           //this->gtinfo_->sendFadingMessage("You're now a killer.",it->first->getClientID());
    580580                       }
     
    620620        else if(tutorial) // Announce selectionphase
    621621        {
    622             for (std::map<PlayerInfo*, int>::iterator it = this->playerParty_.begin(); it != this->playerParty_.end(); ++it)
    623             {
    624                 if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     622            for (auto & elem : this->playerParty_)
     623            {
     624                if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    625625                    continue;
    626                 this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",it->first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
     626                this->gtinfo_->sendStaticMessage("Selection phase: Shoot at everything that moves.",elem.first->getClientID(),ColourValue(1.0f, 1.0f, 0.5f));
    627627            }
    628628        }
     
    676676            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(teamSpawnPoints.size())));
    677677            unsigned int index = 0;
    678             for (std::set<SpawnPoint*>::const_iterator it = teamSpawnPoints.begin(); it != teamSpawnPoints.end(); ++it)
     678            for (const auto & teamSpawnPoint : teamSpawnPoints)
    679679            {
    680680                if (index == randomspawn)
    681                     return (*it);
     681                    return (teamSpawnPoint);
    682682
    683683                ++index;
  • code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc

    r10768 r10821  
    139139        if (!this->gtinfo_->hasStarted())
    140140        {
    141             for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     141            for (auto & elem : 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(elem.first->isHumanPlayer() && elem.first->isReadyToSpawn())
     145                    this->gtinfo_->playerReadyToSpawn(elem.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 (auto & elem : this->players_)
     172        {
     173            if (elem.first->getControllableEntity())
     174            {
     175                ControllableEntity* oldentity = elem.first->getControllableEntity();
    176176
    177177                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getContext());
     
    186186                    entity->setOrientation(oldentity->getWorldOrientation());
    187187                }
    188                 it->first->startControl(entity);
     188                elem.first->startControl(entity);
    189189            }
    190190            else
    191                 this->spawnPlayerAsDefaultPawn(it->first);
     191                this->spawnPlayerAsDefaultPawn(elem.first);
    192192        }
    193193    }
     
    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 (const auto & elem : this->spawnpoints_)
    344344            {
    345345                if (index == randomspawn)
    346                     fallbackSpawnPoint = (*it);
    347 
    348                 if (*it != nullptr && (*it)->isActive())
    349                     activeSpawnPoints.push_back(*it);
     346                    fallbackSpawnPoint = (elem);
     347
     348                if (elem != nullptr && (elem)->isActive())
     349                    activeSpawnPoints.push_back(elem);
    350350
    351351                ++index;
     
    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 & elem : this->players_)
     369        {
     370            if (!elem.first->getControllableEntity())
     371            {
     372                elem.second.state_ = PlayerState::Dead;
     373
     374                if (!elem.first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
     375                {
     376                    this->spawnPlayerAsDefaultPawn(elem.first);
     377                    elem.second.state_ = PlayerState::Dead;
    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 (auto & elem : this->players_)
    407407                    {
    408                         if (!it->first->isReadyToSpawn())
     408                        if (!elem.first->isReadyToSpawn())
    409409                            allplayersready = false;
    410                         if (it->first->isHumanPlayer())
     410                        if (elem.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 (auto & elem : this->players_)
     433        {
     434            if (elem.first->isReadyToSpawn() || this->bForceSpawn_)
     435                this->spawnPlayer(elem.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 (auto & elem : this->players_)
     442            if (elem.second.state_ == PlayerState::Dead)
     443                if (elem.first->isReadyToSpawn() || this->bForceSpawn_)
     444                    this->spawnPlayer(elem.first);
    445445    }
    446446
     
    538538    GSLevelMementoState* Gametype::exportMementoState()
    539539    {
    540         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    541         {
    542             if (it->first->isHumanPlayer() && it->first->getControllableEntity() && it->first->getControllableEntity()->getCamera())
    543             {
    544                 Camera* camera = it->first->getControllableEntity()->getCamera();
     540        for (auto & elem : this->players_)
     541        {
     542            if (elem.first->isHumanPlayer() && elem.first->getControllableEntity() && elem.first->getControllableEntity()->getCamera())
     543            {
     544                Camera* camera = elem.first->getControllableEntity()->getCamera();
    545545
    546546                GametypeMementoState* state = new GametypeMementoState();
     
    559559        // find correct memento state
    560560        GametypeMementoState* state = nullptr;
    561         for (size_t i = 0; i < states.size(); ++i)
    562         {
    563             state = dynamic_cast<GametypeMementoState*>(states[i]);
     561        for (auto & states_i : states)
     562        {
     563            state = dynamic_cast<GametypeMementoState*>(states_i);
    564564            if (state)
    565565                break;
     
    587587
    588588        // find correct player and assign default entity with original position & orientation
    589         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    590         {
    591             if (it->first->isHumanPlayer())
     589        for (auto & elem : this->players_)
     590        {
     591            if (elem.first->isHumanPlayer())
    592592            {
    593593                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(scene->getContext());
    594594                entity->setPosition(state->cameraPosition_);
    595595                entity->setOrientation(state->cameraOrientation_);
    596                 it->first->startControl(entity);
     596                elem.first->startControl(entity);
    597597                break;
    598598            }
  • code/branches/cpp11_v2/src/orxonox/gametypes/LastManStanding.cc

    r9667 r10821  
    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 (auto & elem : this->players_)
     59            if (elem.second.state_ == PlayerState::Dead)
     60            {
     61                bool alive = (0<playerLives_[elem.first]&&(inGame_[elem.first]));
     62                if (alive&&(elem.first->isReadyToSpawn() || this->bForceSpawn_))
     63                {
     64                    this->spawnPlayer(elem.first);
    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 (auto & elem : this->playerLives_)
     117        {
     118            if (elem.second<=0)
    119119                continue;
    120             if (it->second<lives)
    121                 min=it->second;
     120            if (elem.second<lives)
     121                min=elem.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 (auto & elem : this->playerLives_)
     131        {
     132            if (elem.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 (elem.second > 0)
     136                this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.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!", elem.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 & elem : this->timeToAct_)
     240            {
     241                if (playerGetLives(elem.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                elem.second-=dt;//Decreases punishment time.
     244                if (!inGame_[elem.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
     245                {
     246                    playerDelayTime_[elem.first]-=dt;
     247                    if (playerDelayTime_[elem.first]<=0)
     248                    this->inGame_[elem.first]=true;
     249
     250                    if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
    251251                        continue;
    252                     int output=1+(int)playerDelayTime_[it->first];
     252                    int output=1+(int)playerDelayTime_[elem.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,elem.first->getClientID());
     255                }
     256                else if (elem.second<0.0f)
     257                {
     258                    elem.second=timeRemaining+3.0f;//reset punishment-timer
     259                    if (playerGetLives(elem.first)>0)
    260260                    {
    261                         this->punishPlayer(it->first);
    262                         if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
     261                        this->punishPlayer(elem.first);
     262                        if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
    263263                            return;
    264264                        const std::string& message = ""; // resets Camper-Warning-message
    265                         this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
     265                        this->gtinfo_->sendFadingMessage(message,elem.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 (elem.second<timeRemaining/5)//Warning message
     269                {
     270                    if (elem.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,elem.first->getClientID());
    274274                }
    275275            }
  • code/branches/cpp11_v2/src/orxonox/gametypes/LastTeamStanding.cc

    r9941 r10821  
    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 (auto & elem : this->players_)
     148            if (elem.second.state_ == PlayerState::Dead)
     149            {
     150                bool alive = (0 < playerLives_[elem.first]&&(inGame_[elem.first]));
     151                if (alive&&(elem.first->isReadyToSpawn() || this->bForceSpawn_))
     152                {
     153                    this->spawnPlayer(elem.first);
    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 & elem : this->timeToAct_)
     187            {
     188                if (playerGetLives(elem.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                elem.second -= dt;//Decreases punishment time.
     191                if (!inGame_[elem.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
     192                {
     193                    playerDelayTime_[elem.first] -= dt;
     194                    if (playerDelayTime_[elem.first] <= 0)
     195                    this->inGame_[elem.first] = true;
     196
     197                    if (elem.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
    198198                        continue;
    199                     int output = 1 + (int)playerDelayTime_[it->first];
     199                    int output = 1 + (int)playerDelayTime_[elem.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,elem.first->getClientID());
     202                }
     203                else if (elem.second < 0.0f)
     204                {
     205                    elem.second = timeRemaining + 3.0f;//reset punishment-timer
     206                    if (playerGetLives(elem.first) > 0)
    207207                    {
    208                         this->punishPlayer(it->first);
    209                         if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     208                        this->punishPlayer(elem.first);
     209                        if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    210210                            return;
    211211                        const std::string& message = ""; // resets Camper-Warning-message
    212                         this->gtinfo_->sendFadingMessage(message, it->first->getClientID());
     212                        this->gtinfo_->sendFadingMessage(message, elem.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 (elem.second < timeRemaining/5)//Warning message
     216                {
     217                  if (elem.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, elem.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 (auto & elem : this->playerLives_)
     232        {
     233          if (elem.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    234234                continue;
    235235
    236             if (it->second > 0)//a player that is alive
     236            if (elem.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(elem.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 (auto & elem : this->playerLives_)
     258        {
     259            if (elem.second <= 0)
    260260                continue;
    261             if (it->second < lives)
    262                 min = it->second;
     261            if (elem.second < lives)
     262                min = elem.second;
    263263        }
    264264        return min;
  • code/branches/cpp11_v2/src/orxonox/gametypes/TeamBaseMatch.cc

    r10768 r10821  
    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 (const auto & elem : this->bases_)
     155        {
     156            if((elem)->getState() == BaseState::ControlTeam1)
    157157            {
    158158                amountControlled++;
    159159            }
    160             if((*it)->getState() == BaseState::ControlTeam2)
     160            if((elem)->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 (auto & elem : this->teamnumbers_)
     190            {
     191                if (elem.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 (elem.second == winningteam)
     195                    this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.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!", elem.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 (const auto & elem : this->bases_)
     241        {
     242            if ((elem)->getState() == BaseState::ControlTeam1 && team == 0)
    243243                count++;
    244             if ((*it)->getState() == BaseState::ControlTeam2 && team == 1)
     244            if ((elem)->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 (const auto & elem : this->bases_)
    261261        {
    262262            i++;
    263263            if (i > index)
    264                 return (*it);
     264                return (elem);
    265265        }
    266266        return nullptr;
  • code/branches/cpp11_v2/src/orxonox/gametypes/TeamDeathmatch.cc

    r9941 r10821  
    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 (auto & elem : this->players_)
    7272        {
    73             if ( this->getTeamScore(it->first) > highestScore )
     73            if ( this->getTeamScore(elem.first) > highestScore )
    7474            {
    75                 winnerTeam = this->getTeam(it->first);
    76                 highestScore = this->getTeamScore(it->first);
     75                winnerTeam = this->getTeam(elem.first);
     76                highestScore = this->getTeamScore(elem.first);
    7777            }
    7878        }
  • code/branches/cpp11_v2/src/orxonox/gametypes/TeamGametype.cc

    r10768 r10821  
    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 (auto & elem : this->teamnumbers_)
     102            if (elem.second < static_cast<int>(this->teams_) && elem.second >= 0)
     103                playersperteam[elem.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 & elem : this->allowedInGame_)
     126            {
     127                 if(elem.second == false) // waiting player found
     128                 {elem.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 (auto & elem : this->players_)\
     144        {
     145            if(allowedInGame_[elem.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 (elem.second.state_ == PlayerState::Dead)
     150            {
     151                if ((elem.first->isReadyToSpawn() || this->bForceSpawn_))
    152152                {
    153                    this->spawnPlayer(it->first);
     153                   this->spawnPlayer(elem.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 (auto & elem : this->players_)
     181        {
     182            if ( this->getTeam(elem.first) ==  this->getTeam(player) )
     183            {
     184                teamscore += elem.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 (auto & elem : this->teamnumbers_)
     194        {
     195            if (elem.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 (auto & elem : this->teamnumbers_)
     205        {
     206            if (elem.second == team  && elem.first->isHumanPlayer())
    207207                teamSize++;
    208208        }
     
    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 (const auto & 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 (const auto & teamSpawnPoint : teamSpawnPoints)
    269269            {
    270270                if (index == randomspawn)
    271                     return (*it);
     271                    return (teamSpawnPoint);
    272272
    273273                ++index;
     
    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 (const auto & 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 (auto & elem : this->teamnumbers_)
     379        {
     380            if (elem.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 (elem.second == winnerTeam)
     383            {
     384                this->gtinfo_->sendAnnounceMessage("Your team has won the match!", elem.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!", elem.first->getClientID());
    389389            }
    390390        }   
  • code/branches/cpp11_v2/src/orxonox/gametypes/UnderAttack.cc

    r10768 r10821  
    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 (auto & elem : this->teamnumbers_)
     77        {
     78            if (elem.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 (elem.second == attacker_)
     82                this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.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!", elem.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 (auto & elem : this->teamnumbers_)
     158                {
     159                    if (elem.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 (elem.second == 1)
     163                        this->gtinfo_->sendAnnounceMessage("You have won the match!", elem.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!", elem.first->getClientID());
    166166                }
    167167            }
Note: See TracChangeset for help on using the changeset viewer.