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/modules/questsystem/QuestManager.cc

    r10765 r10821  
    235235    {
    236236        int numQuests = 0;
    237         for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
    238         {
    239             if(it->second->getParentQuest() == nullptr && !it->second->isInactive(player))
     237        for(auto & elem : this->questMap_)
     238        {
     239            if(elem.second->getParentQuest() == nullptr && !elem.second->isInactive(player))
    240240                numQuests++;
    241241        }
     
    255255    Quest* QuestManager::getRootQuest(PlayerInfo* player, int index)
    256256    {
    257         for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
    258         {
    259             if(it->second->getParentQuest() == nullptr && !it->second->isInactive(player) && index-- == 0)
    260                 return it->second;
     257        for(auto & elem : this->questMap_)
     258        {
     259            if(elem.second->getParentQuest() == nullptr && !elem.second->isInactive(player) && index-- == 0)
     260                return elem.second;
    261261        }
    262262        return nullptr;
     
    280280        std::list<Quest*> quests = quest->getSubQuestList();
    281281        int numQuests = 0;
    282         for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
    283         {
    284             if(!(*it)->isInactive(player))
     282        for(auto & quest : quests)
     283        {
     284            if(!(quest)->isInactive(player))
    285285                numQuests++;
    286286        }
     
    304304
    305305        std::list<Quest*> quests = quest->getSubQuestList();
    306         for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
    307         {
    308             if(!(*it)->isInactive(player) && index-- == 0)
    309                 return *it;
     306        for(auto & quest : quests)
     307        {
     308            if(!(quest)->isInactive(player) && index-- == 0)
     309                return quest;
    310310        }
    311311        return nullptr;
     
    326326        std::list<QuestHint*> hints = quest->getHintsList();
    327327        int numHints = 0;
    328         for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
    329         {
    330             if((*it)->isActive(player))
     328        for(auto & hint : hints)
     329        {
     330            if((hint)->isActive(player))
    331331                numHints++;
    332332        }
     
    349349    {
    350350        std::list<QuestHint*> hints = quest->getHintsList();
    351         for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
    352         {
    353             if((*it)->isActive(player) && index-- == 0)
    354                 return *it;
     351        for(auto & hint : hints)
     352        {
     353            if((hint)->isActive(player) && index-- == 0)
     354                return hint;
    355355        }
    356356        return nullptr;
Note: See TracChangeset for help on using the changeset viewer.