Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10869 for code/branches


Ignore:
Timestamp:
Nov 27, 2015, 8:39:46 AM (9 years ago)
Author:
gania
Message:

fixed a bug and got rid of unnecessary Rank enumeration, used getIdentifire instead

Location:
code/branches/campaignHS15/src/orxonox/controllers
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc

    r10864 r10869  
    130130    {
    131131        return this->formationMode_;
    132     }
    133     void CommonController::setRank(Rank::Value val)
    134     {
    135         this->rank_ = val;
    136     }
    137     Rank::Value CommonController::getRank() const
    138     {
    139         return this->rank_;
    140132    }
    141133   
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.h

    r10864 r10869  
    5353        };
    5454    }
    55     namespace Rank
    56     {
    57         enum Value
    58         {
    59             NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN
    60         };
    6155
    62     }
    63    
    6456
    6557   
     
    8678                FormationMode::Value getFormationMode() const;
    8779
    88                 void setRank(Rank::Value val);
    89                 Rank::Value getRank() const;
    90            
     80               
    9181
    9282            //----[/XML methods]----
     
    172162            //----["Private" variables]----
    173163                FormationMode::Value formationMode_;
    174                 Rank::Value rank_;
    175164
    176165                int attackRange_;
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc

    r10864 r10869  
    4545        this->myWingman_ = 0;
    4646        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
    47         this->rank_ = Rank::DIVISIONLEADER;
    4847    }
    4948
     
    107106       
    108107    }
     108    //I wanted to do it different here, but at this point I think nothing will change if I delete that method
    109109    void DivisionController::stayNearProtect()
    110110    {
     
    112112    }
    113113   
    114     bool DivisionController::setWingman(ActionpointController* cwingman)
     114    bool DivisionController::setWingman(CommonController* cwingman)
    115115    {
    116116
  • code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h

    r10864 r10869  
    5353            //----[own functions]----
    5454                virtual bool setFollower(LeaderController* myFollower);
    55                 virtual bool setWingman(ActionpointController* cwingman);
     55                virtual bool setWingman(CommonController* cwingman);
    5656                virtual bool hasWingman();
    5757                virtual bool hasFollower();
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc

    r10866 r10869  
    4747        this->myWingman_ = 0;
    4848        this->myDivisionLeader_ = 0;
    49         this->rank_ = Rank::SECTIONLEADER;
    5049        this->bFirstAction_ = true;
    5150        //orxout(internal_error) << this << "Was created" << endl;
     
    285284        {
    286285            //0ptr or not DivisionController?
    287             if (!(it) || !((it)->getRank() == Rank::DIVISIONLEADER) || !(it->getControllableEntity()))
     286            if (!(it) || !((it)->getIdentifier()->getName() == "DivisionController") || !(it->getControllableEntity()))
    288287                continue;
    289288            //same team?
     
    311310        return 0;
    312311    }
    313     bool SectionController::setWingman(ActionpointController* cwingman)
     312    bool SectionController::setWingman(CommonController* cwingman)
    314313    {
    315314        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
  • code/branches/campaignHS15/src/orxonox/controllers/SectionController.h

    r10864 r10869  
    5353                LeaderController* findNewDivisionLeader();
    5454
    55                 virtual bool setWingman(ActionpointController* cwingman);
     55                virtual bool setWingman(CommonController* cwingman);
    5656                virtual bool hasWingman();
    5757
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10864 r10869  
    4141        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
    4242        this->myLeader_ = 0;
    43         this->rank_ = Rank::WINGMAN;
    4443        this->bFirstAction_ = true;
    4544
     
    8180        if (!this->myLeader_)
    8281        {
    83             ActionpointController* newLeader = findNewLeader();
     82            ActionpointController* newLeader = orxonox_cast<ActionpointController*> (findNewLeader());
    8483            this->myLeader_ = newLeader;
    8584           
     
    172171        Vector3* targetRelativePosition;
    173172
    174         if (this->myLeader_->getRank() == Rank::DIVISIONLEADER)
     173        if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
    175174        {
    176175            switch (this->formationMode_){
     
    217216    }
    218217    //----POST: closest leader that is ready to take a new wingman is returned----
    219     ActionpointController* WingmanController::findNewLeader()
     218    CommonController* WingmanController::findNewLeader()
    220219    {
    221220
     
    224223
    225224        //----vars for finding the closest leader----
    226         ActionpointController* closestLeader = 0;
     225        CommonController* closestLeader = 0;
    227226        float minDistance =  std::numeric_limits<float>::infinity();
    228227        Gametype* gt = this->getGametype();
    229         for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
     228        for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
    230229        {
    231230            //----0ptr or not a leader or dead?----
    232231            if (!it ||
    233                 (it->getRank() != Rank::SECTIONLEADER && it->getRank() != Rank::DIVISIONLEADER) ||
     232                (it->getIdentifier()->getName() != "SectionController" && it->getIdentifier()->getName() != "DivisionController") ||
    234233                !(it->getControllableEntity()))
    235234                continue;
     
    251250        {
    252251            //----Racing conditions----
    253             if (closestLeader->setWingman(this))
     252            if (closestLeader->setWingman(orxonox_cast<CommonController*>(this)))
    254253                return closestLeader;
    255254        }
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h

    r10864 r10869  
    5252
    5353            //----[own functions]----
    54                ActionpointController* findNewLeader();
     54               CommonController* findNewLeader();
    5555            //----[/own functions]----
    5656
Note: See TracChangeset for help on using the changeset viewer.