- 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/SectionController.cc
r11058 r11065 40 40 this->setFormationMode(FormationMode::FINGER4); 41 41 42 this->myWingman_ = 0;43 this->myDivisionLeader_ = 0;42 this->myWingman_ = nullptr; 43 this->myDivisionLeader_ = nullptr; 44 44 this->bFirstAction_ = true; 45 45 … … 48 48 SectionController::~SectionController() 49 49 { 50 for (size_t i = 0; i < this->actionpoints_.size(); ++i)51 { 52 if (this->actionpoints_[i])53 this->actionpoints_[i]->destroy();50 for (WorldEntity* actionpoint : this->actionpoints_) 51 { 52 if (actionpoint) 53 actionpoint->destroy(); 54 54 } 55 55 this->parsedActionpoints_.clear(); … … 117 117 { 118 118 //----If division leader fights, cover him by fighting emenies close to his target---- 119 Action ::Valueaction = this->myDivisionLeader_->getAction();119 Action action = this->myDivisionLeader_->getAction(); 120 120 121 121 if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK) … … 133 133 Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition(); 134 134 Gametype* gt = this->getGametype(); 135 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)135 for (Pawn* pawn : ObjectList<Pawn>()) 136 136 { 137 137 //----is enemy?---- 138 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )138 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 139 139 continue; 140 140 //----in range?---- 141 if (( (*itP)->getWorldPosition() - divisionTargetPosition).length() < 3000 &&142 (*itP)!= this->myDivisionLeader_->getTarget())141 if ((pawn->getWorldPosition() - divisionTargetPosition).length() < 3000 && 142 pawn != this->myDivisionLeader_->getTarget()) 143 143 { 144 144 foundTarget = true; 145 target = (*itP);145 target = pawn; 146 146 break; 147 147 } … … 212 212 213 213 if (!this->getControllableEntity()) 214 return 0;215 216 ActionpointController* closestLeader = 0;214 return nullptr; 215 216 ActionpointController* closestLeader = nullptr; 217 217 float minDistance = std::numeric_limits<float>::infinity(); 218 218 //go through all pawns 219 for ( ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)219 for (ActionpointController* controller : ObjectList<ActionpointController>()) 220 220 { 221 221 //0ptr or not DivisionController? 222 if (! (it) || !((it)->getIdentifier()->getName() == "DivisionController") || !(it->getControllableEntity()))222 if (!controller || !(controller->getIdentifier()->getName() == "DivisionController") || !(controller->getControllableEntity())) 223 223 continue; 224 224 //same team? 225 if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()))225 if ((this->getControllableEntity()->getTeam() != controller->getControllableEntity()->getTeam())) 226 226 continue; 227 227 228 228 //is equal to this? 229 if (orxonox_cast<ControllableEntity*>( *it) == this->getControllableEntity())229 if (orxonox_cast<ControllableEntity*>(controller) == this->getControllableEntity()) 230 230 continue; 231 231 232 float distance = CommonController::distance ( it->getControllableEntity(), this->getControllableEntity());232 float distance = CommonController::distance (controller->getControllableEntity(), this->getControllableEntity()); 233 233 234 if (distance < minDistance && !( it->hasFollower()))235 { 236 closestLeader = *it;234 if (distance < minDistance && !(controller->hasFollower())) 235 { 236 closestLeader = controller; 237 237 minDistance = distance; 238 238 } … … 244 244 return closestLeader; 245 245 } 246 return 0;246 return nullptr; 247 247 } 248 248
Note: See TracChangeset
for help on using the changeset viewer.