Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10545


Ignore:
Timestamp:
Jul 14, 2015, 11:23:57 PM (6 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

Location:
code/branches/cpp11/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11/src/libraries/core/object/ObjectListBase.h

    r9667 r10545  
    9393            }
    9494
     95            operator T*()
     96            {
     97                return object_;
     98            }
     99
    95100            T* object_;              //!< The object
    96101    };
  • code/branches/cpp11/src/orxonox/chat/ChatManager.cc

    r9667 r10545  
    105105
    106106        // notify all listeners
    107         for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
    108             it->incomingChat(text, name);
     107        for (ChatListener* listener : ObjectList<ChatListener>())
     108                listener->incomingChat(text, name);
    109109    }
    110110
  • 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.