Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2013, 3:12:21 PM (11 years ago)
Author:
smerkli
Message:

Merged Maxim's Branch back into trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/controllers/FormationController.cc

    r9348 r9625  
    535535
    536536
     537    // Sets newMaster as the new master within the formation. Called by the master.
     538    void FormationController::setNewMasterWithinFormation(FormationController* newMaster)
     539        {
     540            if(this->state_ != MASTER || newMaster->myMaster_ != this) return;
     541
     542            if (!this->slaves_.empty())
     543            {
     544                                std::vector<FormationController*>::iterator it2 = std::find(this->slaves_.begin(), this->slaves_.end(), newMaster);
     545                                if (it2 != this->slaves_.end())
     546                                {
     547                                         this->slaves_.erase(it2);
     548                                }
     549
     550                newMaster->state_ = MASTER;
     551                newMaster->slaves_ = this->slaves_;
     552                newMaster->myMaster_ = 0;
     553
     554                for(std::vector<FormationController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)
     555                {
     556                    (*it)->myMaster_ = newMaster;
     557                }
     558            }
     559
     560            this->slaves_.clear();
     561            this->specificMasterAction_ = NONE;
     562            this->state_ = FREE;
     563        }
     564
     565
     566
    537567  /**
    538         @brief Frees all slaves form a master. Initiated by a master.
     568        @brief Frees all slaves from a master. Initiated by a master.
    539569    */
    540570    void FormationController::freeSlaves()
Note: See TracChangeset for help on using the changeset viewer.