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/weaponsystem/Munition.cc

    r10768 r10821  
    5555    Munition::~Munition()
    5656    {
    57         for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
    58             delete it->second;
     57        for (auto & elem : this->currentMagazines_)
     58            delete elem.second;
    5959    }
    6060
     
    268268        {
    269269            // Return true if any of the current magazines is not full (loading counts as full although it returns 0 munition)
    270             for (std::map<WeaponMode*, Magazine*>::const_iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
    271                 if (it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
     270            for (const auto & elem : this->currentMagazines_)
     271                if (elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)
    272272                    return true;
    273273        }
     
    316316            {
    317317                bool change = false;
    318                 for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
     318                for (auto & elem : this->currentMagazines_)
    319319                {
    320320                    // Add munition if the magazine isn't full (but only to loaded magazines)
    321                     if (amount > 0 && it->second->munition_ < this->maxMunitionPerMagazine_ && it->second->bLoaded_)
     321                    if (amount > 0 && elem.second->munition_ < this->maxMunitionPerMagazine_ && elem.second->bLoaded_)
    322322                    {
    323                         it->second->munition_++;
     323                        elem.second->munition_++;
    324324                        amount--;
    325325                        change = true;
Note: See TracChangeset for help on using the changeset viewer.