Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (9 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
Location:
code/branches/cpp11_v2/src/modules/overlays
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/overlays/hud/ChatOverlay.cc

    r9667 r10821  
    5858    ChatOverlay::~ChatOverlay()
    5959    {
    60         for (std::set<Timer*>::iterator it = this->timers_.begin(); it != this->timers_.end(); ++it)
    61             delete (*it);
     60        for (const auto & elem : this->timers_)
     61            delete (elem);
    6262    }
    6363
     
    9292        this->text_->setCaption("");
    9393
    94         for (std::list<Ogre::DisplayString>::iterator it = this->messages_.begin(); it != this->messages_.end(); ++it)
     94        for (auto & elem : this->messages_)
    9595        {
    96             this->text_->setCaption(this->text_->getCaption() + "\n" + (*it));
     96            this->text_->setCaption(this->text_->getCaption() + "\n" + (elem));
    9797        }
    9898    }
  • code/branches/cpp11_v2/src/modules/overlays/hud/HUDNavigation.cc

    r10774 r10821  
    131131        }
    132132        this->fontName_ = font;
    133         for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it)
    134         {
    135             if (it->second.text_ != nullptr)
    136                 it->second.text_->setFontName(this->fontName_);
     133        for (auto & elem : this->activeObjectList_)
     134        {
     135            if (elem.second.text_ != nullptr)
     136                elem.second.text_->setFontName(this->fontName_);
    137137        }
    138138    }
     
    151151        }
    152152        this->textSize_ = size;
    153         for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it!=this->activeObjectList_.end(); ++it)
    154         {
    155             if (it->second.text_)
    156                 it->second.text_->setCharHeight(size);
     153        for (auto & elem : this->activeObjectList_)
     154        {
     155            if (elem.second.text_)
     156                elem.second.text_->setCharHeight(size);
    157157        }
    158158    }
     
    186186        const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
    187187
    188         for (std::list<std::pair<RadarViewable*, unsigned int>>::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++listIt)
    189         listIt->second = (int)((listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
     188        for (auto & elem : this->sortedObjectList_)
     189        elem.second = (int)((elem.first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
    190190
    191191        this->sortedObjectList_.sort(compareDistance);
     
    531531        float yScale = this->getActualSize().y;
    532532
    533         for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it)
    534         {
    535             if (it->second.health_ != nullptr)
    536                 it->second.health_->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
    537             if (it->second.healthLevel_ != nullptr)
    538                 it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale);
    539             if (it->second.panel_ != nullptr)
    540                 it->second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
    541             if (it->second.text_ != nullptr)
    542                 it->second.text_->setCharHeight(this->textSize_ * yScale);
    543             if (it->second.target_ != nullptr)
    544                 it->second.target_->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
     533        for (auto & elem : this->activeObjectList_)
     534        {
     535            if (elem.second.health_ != nullptr)
     536                elem.second.health_->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
     537            if (elem.second.healthLevel_ != nullptr)
     538                elem.second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale);
     539            if (elem.second.panel_ != nullptr)
     540                elem.second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
     541            if (elem.second.text_ != nullptr)
     542                elem.second.text_->setCharHeight(this->textSize_ * yScale);
     543            if (elem.second.target_ != nullptr)
     544                elem.second.target_->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
    545545        }
    546546    }
     
    670670    {
    671671        const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects();
    672         for (std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it)
    673         {
    674             if (!(*it)->isHumanShip_)
    675             this->addObject(*it);
     672        for (const auto & respawnObject : respawnObjects)
     673        {
     674            if (!(respawnObject)->isHumanShip_)
     675            this->addObject(respawnObject);
    676676        }
    677677    }
  • code/branches/cpp11_v2/src/modules/overlays/hud/HUDRadar.cc

    r10768 r10821  
    9292            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->map3DBack_);
    9393
    94             for (std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it = this->radarObjects_.begin();
    95                 it != this->radarObjects_.end(); ++it)
    96             {
    97                 Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second);
     94            for (auto & elem : this->radarObjects_)
     95            {
     96                Ogre::OverlayManager::getSingleton().destroyOverlayElement(elem.second);
    9897            }
    9998        }
  • code/branches/cpp11_v2/src/modules/overlays/stats/Scoreboard.cc

    r9667 r10821  
    6060        SUPER(Scoreboard, changedVisibility);
    6161
    62         for (unsigned int i = 0; i < this->lines_.size(); ++i)
    63             this->lines_[i]->changedVisibility();
     62        for (auto & elem : this->lines_)
     63            elem->changedVisibility();
    6464    }
    6565
     
    9494
    9595        unsigned int index = 0;
    96         for (std::map<PlayerInfo*, Player>::const_iterator it = playerList.begin(); it != playerList.end(); ++it)
     96        for (const auto & elem : playerList)
    9797        {
    98             this->lines_[index]->setPlayerName(multi_cast<std::string>(it->first->getName()));
    99             this->lines_[index]->setScore(multi_cast<std::string>(it->second.frags_));
    100             this->lines_[index]->setDeaths(multi_cast<std::string>(it->second.killed_));
     98            this->lines_[index]->setPlayerName(multi_cast<std::string>(elem.first->getName()));
     99            this->lines_[index]->setScore(multi_cast<std::string>(elem.second.frags_));
     100            this->lines_[index]->setDeaths(multi_cast<std::string>(elem.second.killed_));
    101101            index++;
    102102        }
Note: See TracChangeset for help on using the changeset viewer.