Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 14, 2015, 11:23:57 PM (9 years ago)
Author:
bknecht
Message:

rewrote a couple of for loops to use C++11 notation. Also made small change in ObjectList so it can almost be used like a normal list with C++11 notation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11/src/orxonox/controllers/ArtificialController.cc

    r10294 r10545  
    205205    void ArtificialController::setAllBotLevel(float level)
    206206    {
    207         for (ObjectList<ArtificialController>::iterator it = ObjectList<ArtificialController>::begin(); it != ObjectList<ArtificialController>::end(); ++it)
    208             it->setBotLevel(level);
     207        for (ArtificialController* controller : ObjectList<ArtificialController>())
     208            controller->setBotLevel(level);
    209209    }
    210210
     
    229229    int ArtificialController::getFiremode(std::string name)
    230230    {
    231         for (std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)
    232         {
    233             if (it->first == name)
    234                 return it->second;
     231        for (auto firemode : this->weaponModes_)
     232        {
     233            if (firemode.first == name)
     234                return firemode.second;
    235235        }
    236236        return -1;
     
    257257    {
    258258        WorldEntity* waypoint = NULL;
    259         for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
    260         {
    261             if((*it)->getIdentifier() == ClassByString(name))
     259        for (WorldEntity* we : ObjectList<WorldEntity>())
     260        {
     261            if(we->getIdentifier() == ClassByString(name))
    262262            {
    263263                ControllableEntity* controllable = this->getControllableEntity();
    264264                if(!controllable) continue;
    265                 float actualDistance = ( (*it)->getPosition() - controllable->getPosition() ).length();
     265                float actualDistance = ( we->getPosition() - controllable->getPosition() ).length();
    266266                if(actualDistance > searchDistance || actualDistance < 5.0f) continue;
    267267                    // TODO: PickupSpawner: adjust waypoint accuracy to PickupSpawner's triggerdistance
     
    269269                else
    270270                {
    271                     waypoint = *it;
     271                    waypoint = we;
    272272                    break;
    273273                }
Note: See TracChangeset for help on using the changeset viewer.