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/controllers/FormationController.cc

    r10768 r10821  
    440440                if(newMaster->slaves_.size() > this->maxFormationSize_) continue;
    441441
    442                 for(std::vector<FormationController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)
     442                for(auto & elem : this->slaves_)
    443443                {
    444                     (*itSlave)->myMaster_ = newMaster;
    445                     newMaster->slaves_.push_back(*itSlave);
     444                    (elem)->myMaster_ = newMaster;
     445                    newMaster->slaves_.push_back(elem);
    446446                }
    447447                this->slaves_.clear();
     
    486486            int i = 1;
    487487
    488             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
     488            for(auto & elem : slaves_)
    489489            {
    490490                pos = Vector3::ZERO;
     
    497497                    dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK);
    498498                }
    499                 (*it)->setTargetOrientation(orient);
    500                 (*it)->setTargetPosition(pos);
     499                (elem)->setTargetOrientation(orient);
     500                (elem)->setTargetPosition(pos);
    501501                left=!left;
    502502            }
     
    569569        if(this->state_ != MASTER) return;
    570570
    571         for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    572         {
    573             (*it)->state_ = FREE;
    574             (*it)->myMaster_ = nullptr;
     571        for(auto & elem : slaves_)
     572        {
     573            (elem)->state_ = FREE;
     574            (elem)->myMaster_ = nullptr;
    575575        }
    576576        this->slaves_.clear();
     
    584584        if(this->state_ != MASTER) return;
    585585
    586         for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    587         {
    588             (*it)->state_ = FREE;
    589             (*it)->forceFreedom();
    590             (*it)->targetPosition_ = this->targetPosition_;
    591             (*it)->bShooting_ = true;
     586        for(auto & elem : slaves_)
     587        {
     588            (elem)->state_ = FREE;
     589            (elem)->forceFreedom();
     590            (elem)->targetPosition_ = this->targetPosition_;
     591            (elem)->bShooting_ = true;
    592592//             (*it)->getControllableEntity()->fire(0);// fire once for fun
    593593        }
     
    650650            this->slaves_.push_back(this->myMaster_);
    651651            //set this as new master
    652             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    653             {
    654                  (*it)->myMaster_=this;
     652            for(auto & elem : slaves_)
     653            {
     654                 (elem)->myMaster_=this;
    655655            }
    656656            this->myMaster_=nullptr;
     
    694694        if (this->state_ == MASTER)
    695695        {
    696             for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
    697             {
    698                  (*it)->formationMode_ = val;
     696            for(auto & elem : slaves_)
     697            {
     698                 (elem)->formationMode_ = val;
    699699                 if (val == ATTACK)
    700                      (*it)->forgetTarget();
     700                     (elem)->forgetTarget();
    701701            }
    702702        }
Note: See TracChangeset for help on using the changeset viewer.