- Timestamp:
- Jan 17, 2016, 1:59:00 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.cc
r11058 r11065 39 39 { 40 40 RegisterObject(WingmanController); 41 this->myLeader_ = 0;41 this->myLeader_ = nullptr; 42 42 this->bFirstAction_ = true; 43 43 … … 46 46 WingmanController::~WingmanController() 47 47 { 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(); 52 52 } 53 53 this->parsedActionpoints_.clear(); … … 170 170 171 171 if (!this->getControllableEntity()) 172 return 0;172 return nullptr; 173 173 174 174 //----vars for finding the closest leader---- 175 ActionpointController* closestLeader = 0;175 ActionpointController* closestLeader = nullptr; 176 176 float minDistance = std::numeric_limits<float>::infinity(); 177 177 Gametype* gt = this->getGametype(); 178 178 179 for ( ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)179 for (ActionpointController* controller : ObjectList<ActionpointController>()) 180 180 { 181 181 //----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())) 185 185 continue; 186 186 187 187 //----same team?---- 188 if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity(), gt) )188 if ( !CommonController::sameTeam (this->getControllableEntity(), controller->getControllableEntity(), gt) ) 189 189 continue; 190 190 191 191 //----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; 196 196 minDistance = distance; 197 197 } … … 207 207 } 208 208 } 209 return 0;209 return nullptr; 210 210 } 211 211
Note: See TracChangeset
for help on using the changeset viewer.