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/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;
Note: See TracChangeset for help on using the changeset viewer.