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/worldentities/pawns/ModularSpaceShip.cc

    r10768 r10821  
    9999            }
    100100            // iterate through all attached parts
    101             for(unsigned int j = 0; j < this->partList_.size(); j++)
     101            for(auto & elem : this->partList_)
    102102            {
    103103                // if the name of the part matches the name of the object, add the object to that parts entitylist (unless it was already done).
    104                 if((this->partList_[j]->getName() == this->getAttachedObject(i)->getName()) && !this->partList_[j]->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))
     104                if((elem->getName() == this->getAttachedObject(i)->getName()) && !elem->hasEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i))))
    105105                {
    106106                    // The Entity is added to the part's entityList_
    107                     this->partList_[j]->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));
     107                    elem->addEntity(orxonox_cast<StaticEntity*>(this->getAttachedObject(i)));
    108108                    // An entry in the partMap_ is created, assigning the part to the entity.
    109                     this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), this->partList_[j]);
     109                    this->addPartEntityAssignment((StaticEntity*)(this->getAttachedObject(i)), elem);
    110110                }
    111111            }
     
    146146    ShipPart* ModularSpaceShip::getPartOfEntity(StaticEntity* entity) const
    147147    {
    148         for (std::map<StaticEntity*, ShipPart*>::const_iterator it = this->partMap_.begin(); it != this->partMap_.end(); ++it)
    149         {
    150             if (it->first == entity)
    151                 return it->second;
     148        for (const auto & elem : this->partMap_)
     149        {
     150            if (elem.first == entity)
     151                return elem.second;
    152152        }
    153153        return nullptr;
     
    242242    ShipPart* ModularSpaceShip::getShipPartByName(std::string name)
    243243    {
    244         for(std::vector<ShipPart*>::iterator it = this->partList_.begin(); it != this->partList_.end(); ++it)
    245         {
    246             if(orxonox_cast<ShipPart*>(*it)->getName() == name)
    247             {
    248                 return orxonox_cast<ShipPart*>(*it);
     244        for(auto & elem : this->partList_)
     245        {
     246            if(orxonox_cast<ShipPart*>(elem)->getName() == name)
     247            {
     248                return orxonox_cast<ShipPart*>(elem);
    249249            }
    250250        }
     
    261261    bool ModularSpaceShip::hasShipPart(ShipPart* part) const
    262262    {
    263         for(unsigned int i = 0; i < this->partList_.size(); i++)
    264         {
    265             if(this->partList_[i] == part)
     263        for(auto & elem : this->partList_)
     264        {
     265            if(elem == part)
    266266                return true;
    267267        }
Note: See TracChangeset for help on using the changeset viewer.