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/objects/triggers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r10769 r10821  
    160160                const std::set<WorldEntity*> attached = entity->getAttachedObjects();
    161161                bool found = false;
    162                 for(std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)
     162                for(const auto & elem : attached)
    163163                {
    164                     if((*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)
     164                    if((elem)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(elem)->getName() == this->targetName_)
    165165                    {
    166166                        found = true;
  • code/branches/cpp11_v2/src/modules/objects/triggers/DistanceTrigger.cc

    r10765 r10821  
    182182                const std::set<WorldEntity*> attached = entity->getAttachedObjects();
    183183                bool found = false;
    184                 for(std::set<WorldEntity*>::const_iterator it = attached.begin(); it != attached.end(); it++)
     184                for(const auto & elem : attached)
    185185                {
    186                     if((*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(*it)->getName() == this->targetName_)
     186                    if((elem)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()) && static_cast<DistanceTriggerBeacon*>(elem)->getName() == this->targetName_)
    187187                    {
    188188                        found = true;
  • code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc

    r10765 r10821  
    504504    bool MultiTrigger::checkAnd(BaseObject* triggerer)
    505505    {
    506         for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    507         {
    508             TriggerBase* trigger = *it;
     506        for(auto trigger : this->children_)
     507        {
     508           
    509509            if(trigger->isMultiTrigger())
    510510            {
     
    531531    bool MultiTrigger::checkOr(BaseObject* triggerer)
    532532    {
    533         for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    534         {
    535             TriggerBase* trigger = *it;
     533        for(auto trigger : this->children_)
     534        {
     535           
    536536            if(trigger->isMultiTrigger())
    537537            {
     
    559559    {
    560560        bool triggered = false;
    561         for(std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    562         {
    563             TriggerBase* trigger = *it;
     561        for(auto trigger : this->children_)
     562        {
     563           
    564564            if(triggered)
    565565            {
  • code/branches/cpp11_v2/src/modules/objects/triggers/Trigger.cc

    r10624 r10821  
    234234    {
    235235        // Iterate over all sub-triggers.
    236         for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    237         {
    238             if (!(*it)->isActive())
     236        for (const auto & elem : this->children_)
     237        {
     238            if (!(elem)->isActive())
    239239                return false;
    240240        }
     
    252252    {
    253253        // Iterate over all sub-triggers.
    254         for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    255         {
    256             if ((*it)->isActive())
     254        for (const auto & elem : this->children_)
     255        {
     256            if ((elem)->isActive())
    257257                return true;
    258258        }
     
    270270    {
    271271        bool test = false;
    272         for (std::set<TriggerBase*>::iterator it = this->children_.begin(); it != this->children_.end(); ++it)
    273         {
    274             if (test && (*it)->isActive())
     272        for (const auto & elem : this->children_)
     273        {
     274            if (test && (elem)->isActive())
    275275                return false;
    276             if ((*it)->isActive())
     276            if ((elem)->isActive())
    277277                test = true;
    278278        }
Note: See TracChangeset for help on using the changeset viewer.