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/questsystem
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/questsystem/GlobalQuest.cc

    r10765 r10821  
    9494
    9595        // Iterate through all players possessing this Quest.
    96         for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    97             QuestEffect::invokeEffects(*it, this->getFailEffectList());
     96        for(const auto & elem : players_)
     97            QuestEffect::invokeEffects(elem, this->getFailEffectList());
    9898
    9999        return true;
     
    119119
    120120        // Iterate through all players possessing the Quest.
    121         for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    122             QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
     121        for(const auto & elem : players_)
     122            QuestEffect::invokeEffects(elem, this->getCompleteEffectList());
    123123
    124124        Quest::complete(player);
     
    242242    {
    243243        int i = index;
    244         for (std::list<QuestEffect*>::const_iterator effect = this->rewards_.begin(); effect != this->rewards_.end(); ++effect)
     244        for (const auto & elem : this->rewards_)
    245245        {
    246246            if(i == 0)
    247                return *effect;
     247               return elem;
    248248
    249249            i--;
  • code/branches/cpp11_v2/src/modules/questsystem/Quest.cc

    r10765 r10821  
    190190
    191191        // Iterate through all subquests.
    192         for (std::list<Quest*>::const_iterator subQuest = this->subQuests_.begin(); subQuest != this->subQuests_.end(); ++subQuest)
     192        for (const auto & elem : this->subQuests_)
    193193        {
    194194            if(i == 0) // We're counting down...
    195                return *subQuest;
     195               return elem;
    196196
    197197            i--;
     
    214214
    215215        // Iterate through all QuestHints.
    216         for (std::list<QuestHint*>::const_iterator hint = this->hints_.begin(); hint != this->hints_.end(); ++hint)
     216        for (const auto & elem : this->hints_)
    217217        {
    218218            if(i == 0) // We're counting down...
    219                return *hint;
     219               return elem;
    220220
    221221            i--;
     
    237237
    238238        // Iterate through all fail QuestEffects.
    239         for (std::list<QuestEffect*>::const_iterator effect = this->failEffects_.begin(); effect != this->failEffects_.end(); ++effect)
     239        for (const auto & elem : this->failEffects_)
    240240        {
    241241            if(i == 0) // We're counting down...
    242                return *effect;
     242               return elem;
    243243
    244244            i--;
     
    260260
    261261        // Iterate through all complete QuestEffects.
    262         for (std::list<QuestEffect*>::const_iterator effect = this->completeEffects_.begin(); effect != this->completeEffects_.end(); ++effect)
     262        for (const auto & elem : this->completeEffects_)
    263263        {
    264264            if(i == 0) // We're counting down...
    265                return *effect;
     265               return elem;
    266266
    267267            i--;
  • code/branches/cpp11_v2/src/modules/questsystem/QuestEffect.cc

    r10624 r10821  
    7474        orxout(verbose, context::quests) << "Invoking QuestEffects on player: " << player << " ."  << endl;
    7575
    76         for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
    77             temp = temp && (*effect)->invoke(player);
     76        for (auto & effects_effect : effects)
     77            temp = temp && (effects_effect)->invoke(player);
    7878
    7979        return temp;
  • code/branches/cpp11_v2/src/modules/questsystem/QuestEffectBeacon.cc

    r10765 r10821  
    236236    {
    237237        int i = index;
    238         for (std::list<QuestEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
     238        for (const auto & elem : this->effects_)
    239239        {
    240240            if(i == 0)
    241                return *effect;
     241               return elem;
    242242
    243243            i--;
  • code/branches/cpp11_v2/src/modules/questsystem/QuestListener.cc

    r10765 r10821  
    9797    /* static */ void QuestListener::advertiseStatusChange(std::list<QuestListener*> & listeners, const std::string & status)
    9898    {
    99         for (std::list<QuestListener*>::iterator it = listeners.begin(); it != listeners.end(); ++it) // Iterate through all QuestListeners
    100         {
    101             QuestListener* listener = *it;
     99        for (auto listener : listeners) // Iterate through all QuestListeners
     100        {
     101           
    102102            if(listener->getMode() == status || listener->getMode() == QuestListener::ALL) // Check whether the status change affects the give QuestListener.
    103103                listener->execute();
  • 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;
  • code/branches/cpp11_v2/src/modules/questsystem/effects/AddReward.cc

    r10765 r10821  
    8484    {
    8585        int i = index;
    86         for (std::list<Rewardable*>::const_iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward)
     86        for (const auto & elem : this->rewards_)
    8787        {
    8888            if(i == 0)
    89                return *reward;
     89               return elem;
    9090            i--;
    9191        }
     
    106106
    107107        bool temp = true;
    108         for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
    109             temp = temp && (*reward)->reward(player);
     108        for (auto & elem : this->rewards_)
     109            temp = temp && (elem)->reward(player);
    110110
    111111        orxout(verbose, context::quests) << "Rewardable successfully added to player." << player << " ." << endl;
Note: See TracChangeset for help on using the changeset viewer.