- Timestamp:
- Nov 21, 2015, 7:05:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/controllers/FormationController.cc
r10768 r10821 440 440 if(newMaster->slaves_.size() > this->maxFormationSize_) continue; 441 441 442 for( std::vector<FormationController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)442 for(auto & elem : this->slaves_) 443 443 { 444 ( *itSlave)->myMaster_ = newMaster;445 newMaster->slaves_.push_back( *itSlave);444 (elem)->myMaster_ = newMaster; 445 newMaster->slaves_.push_back(elem); 446 446 } 447 447 this->slaves_.clear(); … … 486 486 int i = 1; 487 487 488 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)488 for(auto & elem : slaves_) 489 489 { 490 490 pos = Vector3::ZERO; … … 497 497 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 498 498 } 499 ( *it)->setTargetOrientation(orient);500 ( *it)->setTargetPosition(pos);499 (elem)->setTargetOrientation(orient); 500 (elem)->setTargetPosition(pos); 501 501 left=!left; 502 502 } … … 569 569 if(this->state_ != MASTER) return; 570 570 571 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)572 { 573 ( *it)->state_ = FREE;574 ( *it)->myMaster_ = nullptr;571 for(auto & elem : slaves_) 572 { 573 (elem)->state_ = FREE; 574 (elem)->myMaster_ = nullptr; 575 575 } 576 576 this->slaves_.clear(); … … 584 584 if(this->state_ != MASTER) return; 585 585 586 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)587 { 588 ( *it)->state_ = FREE;589 ( *it)->forceFreedom();590 ( *it)->targetPosition_ = this->targetPosition_;591 ( *it)->bShooting_ = true;586 for(auto & elem : slaves_) 587 { 588 (elem)->state_ = FREE; 589 (elem)->forceFreedom(); 590 (elem)->targetPosition_ = this->targetPosition_; 591 (elem)->bShooting_ = true; 592 592 // (*it)->getControllableEntity()->fire(0);// fire once for fun 593 593 } … … 650 650 this->slaves_.push_back(this->myMaster_); 651 651 //set this as new master 652 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)653 { 654 ( *it)->myMaster_=this;652 for(auto & elem : slaves_) 653 { 654 (elem)->myMaster_=this; 655 655 } 656 656 this->myMaster_=nullptr; … … 694 694 if (this->state_ == MASTER) 695 695 { 696 for( std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)697 { 698 ( *it)->formationMode_ = val;696 for(auto & elem : slaves_) 697 { 698 (elem)->formationMode_ = val; 699 699 if (val == ATTACK) 700 ( *it)->forgetTarget();700 (elem)->forgetTarget(); 701 701 } 702 702 }
Note: See TracChangeset
for help on using the changeset viewer.