Changeset 11065 for code/branches/cpp11_v3/src/orxonox/controllers
- Timestamp:
- Jan 17, 2016, 1:59:00 PM (9 years ago)
- Location:
- code/branches/cpp11_v3/src/orxonox/controllers
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3/src/orxonox/controllers/ActionpointController.cc
r11054 r11065 339 339 inLoop = this->bInLoop_; 340 340 341 Action ::Valuevalue;341 Action value; 342 342 343 343 if ( actionName == "FIGHT" ) … … 371 371 return this->actionpoints_[index]; 372 372 else 373 return 0;373 return nullptr; 374 374 } 375 375 //XML method 376 Action ::ValueActionpointController::getAction ()376 Action ActionpointController::getAction () 377 377 { 378 378 return this->action_; … … 401 401 } 402 402 //XML method 403 void ActionpointController::setAction (Action ::Valueaction)403 void ActionpointController::setAction (Action action) 404 404 { 405 405 this->action_ = action; 406 406 } 407 407 //set action and target/protect 408 void ActionpointController::setAction (Action ::Valueaction, ControllableEntity* target)408 void ActionpointController::setAction (Action action, ControllableEntity* target) 409 409 { 410 410 if (!this || !this->getControllableEntity()) … … 423 423 } 424 424 //set action and target position 425 void ActionpointController::setAction (Action ::Valueaction, const Vector3& target)425 void ActionpointController::setAction (Action action, const Vector3& target) 426 426 { 427 427 if (!this || !this->getControllableEntity()) … … 434 434 } 435 435 //set action and target position and orientation 436 void ActionpointController::setAction (Action ::Valueaction, const Vector3& target, const Quaternion& orient )436 void ActionpointController::setAction (Action action, const Vector3& target, const Quaternion& orient ) 437 437 { 438 438 if (!this || !this->getControllableEntity()) … … 476 476 return; 477 477 478 this->setTarget( 0);478 this->setTarget(nullptr); 479 479 this->setTargetPosition(this->getControllableEntity()->getWorldPosition()); 480 480 this->action_ = Action::NONE; … … 506 506 if (targetName == "") 507 507 break; 508 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)509 { 510 if (!this || !this->getControllableEntity()) 511 return; 512 if (CommonController::getName( *itP) == targetName)508 for (Pawn* pawn : ObjectList<Pawn>()) 509 { 510 if (!this || !this->getControllableEntity()) 511 return; 512 if (CommonController::getName(pawn) == targetName) 513 513 { 514 this->setTarget (static_cast<ControllableEntity*>( *itP));514 this->setTarget (static_cast<ControllableEntity*>(pawn)); 515 515 } 516 516 } … … 541 541 if (protectName == "reservedKeyword:human") 542 542 { 543 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)543 for (Pawn* pawn : ObjectList<Pawn>()) 544 544 { 545 if (orxonox_cast<ControllableEntity*>( *itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController"))545 if (orxonox_cast<ControllableEntity*>(pawn) && (pawn->getController()) && (pawn->getController()->getIdentifier()->getName() == "NewHumanController")) 546 546 { 547 this->setProtect (static_cast<ControllableEntity*>( *itP));547 this->setProtect (static_cast<ControllableEntity*>(pawn)); 548 548 } 549 549 } … … 551 551 else 552 552 { 553 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)553 for (Pawn* pawn : ObjectList<Pawn>()) 554 554 { 555 if (CommonController::getName( *itP) == protectName)555 if (CommonController::getName(pawn) == protectName) 556 556 { 557 this->setProtect (static_cast<ControllableEntity*>( *itP));557 this->setProtect (static_cast<ControllableEntity*>(pawn)); 558 558 } 559 559 } … … 578 578 std::string targetName = p.name; 579 579 580 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)581 { 582 if (CommonController::getName( *itP) == targetName)580 for (Pawn* pawn : ObjectList<Pawn>()) 581 { 582 if (CommonController::getName(pawn) == targetName) 583 583 { 584 584 if (!this || !this->getControllableEntity()) 585 585 return; 586 this->setTarget (static_cast<ControllableEntity*>( *itP));586 this->setTarget (static_cast<ControllableEntity*>(pawn)); 587 587 } 588 588 } … … 702 702 { 703 703 if (!this || !this->getControllableEntity()) 704 return 0;705 706 Pawn* closestTarget = 0;704 return nullptr; 705 706 Pawn* closestTarget = nullptr; 707 707 float minDistance = std::numeric_limits<float>::infinity(); 708 708 Gametype* gt = this->getGametype(); 709 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)709 for (Pawn* pawn : ObjectList<Pawn>()) 710 710 { 711 711 if (!this || !this->getControllableEntity()) 712 return 0;713 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )712 return nullptr; 713 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 714 714 continue; 715 715 716 float distance = CommonController::distance ( *itP, this->getControllableEntity());716 float distance = CommonController::distance (pawn, this->getControllableEntity()); 717 717 if (distance < minDistance) 718 718 { 719 closestTarget = *itP;719 closestTarget = pawn; 720 720 minDistance = distance; 721 721 } … … 725 725 return closestTarget; 726 726 } 727 return 0;727 return nullptr; 728 728 } 729 729 //push action FIGHT to the stack and set target to the closest enemy -
code/branches/cpp11_v3/src/orxonox/controllers/ActionpointController.h
r11052 r11065 65 65 All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. 66 66 */ 67 namespaceAction67 enum class Action 68 68 { 69 enum Value 70 { 71 NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK 72 }; 73 74 } 69 NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK 70 }; 75 71 76 72 struct Point { 77 Action ::Valueaction;73 Action action; 78 74 std::string name; 79 75 Vector3 position; 80 76 bool inLoop; 81 } ; 82 namespace PickupType 83 { 84 enum Value 85 { 86 NONE, DAMAGE, HEALTH, SPEED, PORTAL 87 }; 88 } 77 }; 89 78 90 79 class _OrxonoxExport ActionpointController : public FightingController, public Tickable … … 94 83 ActionpointController(Context* context); 95 84 virtual ~ActionpointController(); 96 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;85 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 97 86 98 87 /** … … 101 90 In tick ship flies and fires. 102 91 */ 103 virtual void tick(float dt) ;92 virtual void tick(float dt) override; 104 93 /** 105 94 @brief … … 186 175 virtual void takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b); 187 176 188 virtual Action ::ValuegetAction ();177 virtual Action getAction (); 189 178 virtual std::string getActionName(); 190 179 191 void setAction (Action ::Valueaction);192 void setAction (Action ::Valueaction, ControllableEntity* target);193 void setAction (Action ::Valueaction, const Vector3& target);194 void setAction (Action ::Valueaction, const Vector3& target, const Quaternion& orient );180 void setAction (Action action); 181 void setAction (Action action, ControllableEntity* target); 182 void setAction (Action action, const Vector3& target); 183 void setAction (Action action, const Vector3& target, const Quaternion& orient ); 195 184 196 185 virtual bool setWingman(ActionpointController* wingman) … … 210 199 WeakPtr<ActionpointController> myDivisionLeader_; 211 200 //----[Actionpoint information]---- 212 Action ::Valueaction_;201 Action action_; 213 202 std::string protectName_; 214 203 std::string targetName_; 215 std::vector<WeakPtr<WorldEntity> 204 std::vector<WeakPtr<WorldEntity>> actionpoints_; 216 205 float squaredaccuracy_; 217 std::vector<Point > parsedActionpoints_;//<! actionpoints as they are stored here after being parsed from XML218 std::vector<Point > loopActionpoints_;//<! actionpoints that are to be looped206 std::vector<Point> parsedActionpoints_; //<! actionpoints as they are stored here after being parsed from XML 207 std::vector<Point> loopActionpoints_; //<! actionpoints that are to be looped 219 208 bool bInLoop_; //<! variable for addActionpoint method 220 209 bool bLoop_; //<! is state machine looping? -
code/branches/cpp11_v3/src/orxonox/controllers/CommonController.cc
r11052 r11065 83 83 int team2 = entity2->getTeam(); 84 84 85 Controller* controller = 0;85 Controller* controller = nullptr; 86 86 if (entity1->getController()) 87 87 controller = entity1->getController(); … … 120 120 } 121 121 122 TeamBaseMatchBase* base = 0;122 TeamBaseMatchBase* base = nullptr; 123 123 base = orxonox_cast<TeamBaseMatchBase*>(entity1); 124 124 if (base) … … 154 154 } 155 155 156 DroneController* droneController = 0;156 DroneController* droneController = nullptr; 157 157 droneController = orxonox_cast<DroneController*>(entity1->getController()); 158 158 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2) -
code/branches/cpp11_v3/src/orxonox/controllers/DivisionController.cc
r11058 r11065 40 40 RegisterObject(DivisionController); 41 41 this->setFormationMode(FormationMode::DIAMOND); 42 this->target_ = 0;43 this->myFollower_ = 0;44 this->myWingman_ = 0;42 this->target_ = nullptr; 43 this->myFollower_ = nullptr; 44 this->myWingman_ = nullptr; 45 45 } 46 46 47 47 DivisionController::~DivisionController() 48 48 { 49 for ( size_t i = 0; i < this->actionpoints_.size(); ++i)49 for (WorldEntity* actionpoint : this->actionpoints_) 50 50 { 51 if (this->actionpoints_[i])52 this->actionpoints_[i]->destroy();51 if (actionpoint) 52 actionpoint->destroy(); 53 53 } 54 54 this->parsedActionpoints_.clear(); -
code/branches/cpp11_v3/src/orxonox/controllers/DivisionController.h
r11058 r11065 51 51 52 52 //----[own functions]---- 53 virtual bool setFollower(ActionpointController* newFollower) ;54 virtual bool setWingman(ActionpointController* newWingman) ;55 virtual bool hasWingman() ;56 virtual bool hasFollower() ;53 virtual bool setFollower(ActionpointController* newFollower) override; 54 virtual bool setWingman(ActionpointController* newWingman) override; 55 virtual bool hasWingman() override; 56 virtual bool hasFollower() override; 57 57 58 58 //----[/own functions]---- 59 virtual void stayNearProtect() ;59 virtual void stayNearProtect() override; 60 60 61 61 protected: 62 62 //----action must only be managed by this---- 63 virtual void action() ; //<! action() is called in regular intervals managing the bot's behaviour.63 virtual void action() override; //<! action() is called in regular intervals managing the bot's behaviour. 64 64 65 65 private: -
code/branches/cpp11_v3/src/orxonox/controllers/FightingController.cc
r11057 r11065 238 238 { 239 239 if (!this || !this->getControllableEntity()) 240 return 0;241 242 Pawn* closestTarget = 0;240 return nullptr; 241 242 Pawn* closestTarget = nullptr; 243 243 float minDistance = std::numeric_limits<float>::infinity(); 244 244 Gametype* gt = this->getGametype(); 245 for ( ObjectList<Pawn>::iterator itP = ObjectList<Pawn>().begin(); itP; ++itP)246 { 247 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>( *itP), gt) )245 for (Pawn* pawn : ObjectList<Pawn>()) 246 { 247 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(pawn), gt) ) 248 248 continue; 249 249 250 float distance = CommonController::distance ( *itP, this->getControllableEntity());250 float distance = CommonController::distance (pawn, this->getControllableEntity()); 251 251 if (distance < minDistance) 252 252 { 253 closestTarget = *itP;253 closestTarget = pawn; 254 254 minDistance = distance; 255 255 } … … 259 259 return closestTarget; 260 260 } 261 return 0;261 return nullptr; 262 262 } 263 263 //I checked it out, rockets DO NOT cause any problems! this->getControllableEntity() is always a SpaceShip … … 335 335 { 336 336 this->weaponModes_.clear(); // reset previous weapon information 337 WeaponSlot* wSlot = 0;337 WeaponSlot* wSlot = nullptr; 338 338 for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++) 339 339 { 340 WeaponMode* wMode = 0;340 WeaponMode* wMode = nullptr; 341 341 for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++) 342 342 { … … 356 356 } 357 357 358 int FightingController::getFiremode( std::stringname)359 { 360 for ( std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)361 { 362 if ( it->first == name)363 return it->second;358 int FightingController::getFiremode(const std::string& name) 359 { 360 for (const auto& mapEntry : this->weaponModes_) 361 { 362 if (mapEntry.first == name) 363 return mapEntry.second; 364 364 } 365 365 return -1; -
code/branches/cpp11_v3/src/orxonox/controllers/FightingController.h
r11057 r11065 72 72 //<! this and target_ plus or minus some amount in difference vector direction, 73 73 //<! depending on whether it is better to close up or survive. 74 void dodgeTowards (Vector3& position); //fly towards position and awoid being hit75 74 void doFire(); //<! choose weapon, set aim at target_ and fire 76 75 WeakPtr<ControllableEntity> target_; … … 97 96 void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed. 98 97 bool bSetupWorked; //<! If false, setupWeapons() is called. 99 int getFiremode( std::stringname);98 int getFiremode(const std::string& name); 100 99 101 100 }; -
code/branches/cpp11_v3/src/orxonox/controllers/FlyingController.cc
r11052 r11065 61 61 } 62 62 63 void FlyingController::setFormationModeXML( std::stringval)63 void FlyingController::setFormationModeXML(const std::string& val) 64 64 { 65 65 const std::string valUpper = getUppercase(val); 66 FormationMode ::Valuevalue;66 FormationMode value; 67 67 68 68 if (valUpper == "WALL") … … 233 233 return; 234 234 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 235 if(ship == NULL) return;235 if(ship == nullptr) return; 236 236 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower()) //upper limit ->boost 237 237 { -
code/branches/cpp11_v3/src/orxonox/controllers/FlyingController.h
r11052 r11065 41 41 42 42 //Formation mode for the divisions 43 namespaceFormationMode43 enum class FormationMode 44 44 { 45 enum Value 46 { 47 FINGER4, DIAMOND, WALL 48 }; 49 } 45 FINGER4, DIAMOND, WALL 46 }; 50 47 51 48 class _OrxonoxExport FlyingController : public CommonController … … 58 55 FlyingController(Context* context); 59 56 virtual ~FlyingController(); 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;57 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 61 58 62 59 void setSpread (int spread) //<! spread is a multiplier for formation flight, should be bigger than 100 … … 65 62 { return this->spread_; } 66 63 67 void setFormationModeXML( std::stringval);64 void setFormationModeXML(const std::string& val); 68 65 std::string getFormationModeXML() const; 69 66 70 void setFormationMode(FormationMode ::Valueval)67 void setFormationMode(FormationMode val) 71 68 { this->formationMode_ = val; } 72 FormationMode ::ValuegetFormationMode() const69 FormationMode getFormationMode() const 73 70 { return this->formationMode_; } 74 71 bool bCopyOrientation_; //<! set to true by default, MasterController sets it in its tick(), … … 91 88 //<! this stays in a certain position relative to leader 92 89 93 FormationMode ::ValueformationMode_;90 FormationMode formationMode_; 94 91 95 92 float rotationProgress_; //<! for slerping -
code/branches/cpp11_v3/src/orxonox/controllers/MasterController.cc
r11054 r11065 58 58 { 59 59 //fill the vector in the first tick 60 for ( ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>().begin(); it; ++it)60 for (ActionpointController* controller : ObjectList<ActionpointController>()) 61 61 { 62 62 //----0ptr?---- 63 if (! it)63 if (!controller) 64 64 continue; 65 this->controllers_.push_back( *it);65 this->controllers_.push_back(controller); 66 66 } 67 67 } -
code/branches/cpp11_v3/src/orxonox/controllers/MasterController.h
r11052 r11065 61 61 62 62 //----[orxonox demanded functions]---- 63 virtual void tick(float dt) ;63 virtual void tick(float dt) override; 64 64 65 65 //----[orxonox demanded functions]---- … … 68 68 69 69 private: 70 std::vector<WeakPtr<ActionpointController> > controllers_;//<! vector of controllers, which action(), canFire() and maneuver() methods are to be called70 std::vector<WeakPtr<ActionpointController>> controllers_;//<! vector of controllers, which action(), canFire() and maneuver() methods are to be called 71 71 size_t indexOfCurrentController_; //<! index of current controller 72 72 unsigned int numberOfTicksPassedSinceLastActionCall_; -
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 -
code/branches/cpp11_v3/src/orxonox/controllers/SectionController.h
r11058 r11065 52 52 ActionpointController* findNewDivisionLeader(); 53 53 54 virtual bool setWingman(ActionpointController* newWingman) ;55 virtual bool hasWingman() ;56 virtual bool hasFollower() 54 virtual bool setWingman(ActionpointController* newWingman) override; 55 virtual bool hasWingman() override; 56 virtual bool hasFollower() override 57 57 { return false; } 58 58 void chooseTarget(); … … 61 61 protected: 62 62 //----action must only be managed by this---- 63 virtual void action() ; //<! action() is called in regular intervals by MasterController managing the bot's behaviour.63 virtual void action() override; //<! action() is called in regular intervals by MasterController managing the bot's behaviour. 64 64 Vector3 getFormationPosition (); 65 65 void keepFormation(); -
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 -
code/branches/cpp11_v3/src/orxonox/controllers/WingmanController.h
r11058 r11065 51 51 52 52 //----[orxonox demanded functions]---- 53 virtual bool hasWingman() 53 virtual bool hasWingman() override 54 54 { return false; } 55 virtual bool hasFollower() 55 virtual bool hasFollower() override 56 56 { return false; } 57 57 //----[/orxonox demanded functions]---- … … 63 63 protected: 64 64 //----action must only be managed by this---- 65 virtual void action() ; //<! action() is called in regular intervals managing the bot's behaviour.65 virtual void action() override; //<! action() is called in regular intervals managing the bot's behaviour. 66 66 Vector3 getFormationPosition (); 67 67 void keepFormation();
Note: See TracChangeset
for help on using the changeset viewer.