Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 1:59:00 PM (8 years ago)
Author:
landauf
Message:

added c++11 features to code that was added in presentationHS15

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc

    r11058 r11065  
    3939    {
    4040        RegisterObject(WingmanController);
    41         this->myLeader_ = 0;
     41        this->myLeader_ = nullptr;
    4242        this->bFirstAction_ = true;
    4343
     
    4646    WingmanController::~WingmanController()
    4747    {
    48         for (size_t i = 0; i < this->actionpoints_.size(); ++i)
    49         {
    50             if(this->actionpoints_[i])
    51                 this->actionpoints_[i]->destroy();
     48        for (WorldEntity* actionpoint : this->actionpoints_)
     49        {
     50            if (actionpoint)
     51                actionpoint->destroy();
    5252        }
    5353        this->parsedActionpoints_.clear();
     
    170170
    171171        if (!this->getControllableEntity())
    172             return 0;
     172            return nullptr;
    173173
    174174        //----vars for finding the closest leader----
    175         ActionpointController* closestLeader = 0;
     175        ActionpointController* closestLeader = nullptr;
    176176        float minDistance =  std::numeric_limits<float>::infinity();
    177177        Gametype* gt = this->getGametype();
    178178
    179         for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)
     179        for (ActionpointController* controller : ObjectList<ActionpointController>())
    180180        {
    181181            //----0ptr or not a leader or dead?----
    182             if (!it ||
    183                 (it->getIdentifier()->getName() != "SectionController" && it->getIdentifier()->getName() != "DivisionController") ||
    184                 !(it->getControllableEntity()))
     182            if (!controller ||
     183                (controller->getIdentifier()->getName() != "SectionController" && controller->getIdentifier()->getName() != "DivisionController") ||
     184                !(controller->getControllableEntity()))
    185185                continue;
    186186           
    187187            //----same team?----
    188             if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity(), gt) )
     188            if ( !CommonController::sameTeam (this->getControllableEntity(), controller->getControllableEntity(), gt) )
    189189                continue;
    190190           
    191191            //----check distance----
    192             float distance = CommonController::distance (it->getControllableEntity(), this->getControllableEntity());
    193             if (distance < minDistance && !(it->hasWingman()))
    194             {
    195                 closestLeader = *it;
     192            float distance = CommonController::distance (controller->getControllableEntity(), this->getControllableEntity());
     193            if (distance < minDistance && !(controller->hasWingman()))
     194            {
     195                closestLeader = controller;
    196196                minDistance = distance;
    197197            }
     
    207207            }
    208208        }
    209         return 0;
     209        return nullptr;
    210210    }
    211211
Note: See TracChangeset for help on using the changeset viewer.