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
Files:
9 edited

Legend:

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

    r10768 r10821  
    6161        SUPER(Attacher, changedActivity);
    6262
    63         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    64             (*it)->setActive(this->isActive());
     63        for (auto & elem : this->objects_)
     64            (elem)->setActive(this->isActive());
    6565    }
    6666
     
    6969        SUPER(Attacher, changedVisibility);
    7070
    71         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    72             (*it)->setVisible(this->isVisible());
     71        for (auto & elem : this->objects_)
     72            (elem)->setVisible(this->isVisible());
    7373    }
    7474
     
    8383    {
    8484        unsigned int i = 0;
    85         for (std::list<WorldEntity*>::const_iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
     85        for (const auto & elem : this->objects_)
    8686        {
    8787            if (i == index)
    88                 return (*it);
     88                return (elem);
    8989
    9090            ++i;
  • code/branches/cpp11_v2/src/modules/objects/Script.cc

    r10765 r10821  
    196196            {
    197197                const std::map<unsigned int, PlayerInfo*> clients = PlayerManager::getInstance().getClients();
    198                 for(std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++)
     198                for(const auto & client : clients)
    199199                {
    200                     callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
     200                    callStaticNetworkFunction(&Script::executeHelper, client.first, this->getCode(), this->getMode(), this->getNeedsGraphics());
    201201                    if(this->times_ != Script::INF) // Decrement the number of remaining executions.
    202202                    {
  • code/branches/cpp11_v2/src/modules/objects/SpaceBoundaries.cc

    r10769 r10821  
    5959            this->pawnsIn_.clear();
    6060
    61             for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++)
     61            for(auto & elem : this->billboards_)
    6262            {
    63                 if( current->billy != nullptr)
    64                 {
    65                     delete current->billy;
     63                if( elem.billy != nullptr)
     64                {
     65                    delete elem.billy;
    6666                }
    6767            }
     
    138138    void SpaceBoundaries::removeAllBillboards()
    139139    {
    140         for( std::vector<BillboardAdministration>::iterator current = this->billboards_.begin(); current != this->billboards_.end(); current++ )
    141         {
    142             current->usedYet = false;
    143             current->billy->setVisible(false);
     140        for(auto & elem : this->billboards_)
     141        {
     142            elem.usedYet = false;
     143            elem.billy->setVisible(false);
    144144        }
    145145    }
     
    208208        float distance;
    209209        bool humanItem;
    210         for( std::list<WeakPtr<Pawn>>::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
    211         {
    212             Pawn* currentPawn = *current;
     210        for(auto currentPawn : pawnsIn_)
     211        {
     212           
    213213            if( currentPawn && currentPawn->getNode() )
    214214            {
  • code/branches/cpp11_v2/src/modules/objects/eventsystem/EventDispatcher.cc

    r10768 r10821  
    4545    {
    4646        if (this->isInitialized())
    47             for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    48                 (*it)->destroy();
     47            for (auto & elem : this->targets_)
     48                (elem)->destroy();
    4949    }
    5050
     
    6161    void EventDispatcher::processEvent(Event& event)
    6262    {
    63         for (std::list<BaseObject*>::iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
    64             (*it)->processEvent(event);
     63        for (auto & elem : this->targets_)
     64            (elem)->processEvent(event);
    6565    }
    6666
     
    7373    {
    7474        unsigned int i = 0;
    75         for (std::list<BaseObject*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); ++it)
     75        for (const auto & elem : this->targets_)
    7676        {
    7777            if (i == index)
    78                 return (*it);
     78                return (elem);
    7979            ++i;
    8080        }
  • code/branches/cpp11_v2/src/modules/objects/eventsystem/EventFilter.cc

    r10768 r10821  
    9696    {
    9797        unsigned int i = 0;
    98         for (std::list<BaseObject*>::const_iterator it = this->sources_.begin(); it != this->sources_.end(); ++it)
     98        for (const auto & elem : this->sources_)
    9999        {
    100100            if (i == index)
    101                 return (*it);
     101                return (elem);
    102102            ++i;
    103103        }
     
    113113    {
    114114        unsigned int i = 0;
    115         for (std::list<EventName*>::const_iterator it = this->names_.begin(); it != this->names_.end(); ++it)
     115        for (const auto & elem : this->names_)
    116116        {
    117117            if (i == index)
    118                 return (*it);
     118                return (elem);
    119119            ++i;
    120120        }
  • 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.