Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (8 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
File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.