[Orxonox-commit 6212] r10869 - code/branches/campaignHS15/src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Fri Nov 27 08:39:47 CET 2015


Author: gania
Date: 2015-11-27 08:39:46 +0100 (Fri, 27 Nov 2015)
New Revision: 10869

Modified:
   code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
   code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
   code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
   code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
   code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
   code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
Log:
fixed a bug and got rid of unnecessary Rank enumeration, used getIdentifire instead

Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	2015-11-27 07:39:46 UTC (rev 10869)
@@ -130,14 +130,6 @@
     { 
         return this->formationMode_; 
     }
-    void CommonController::setRank(Rank::Value val)
-    { 
-        this->rank_ = val; 
-    }
-    Rank::Value CommonController::getRank() const
-    { 
-        return this->rank_; 
-    }
     
     //------------------------------------------------------------------------------
     //-------------------------------World interaction------------------------------

Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	2015-11-27 07:39:46 UTC (rev 10869)
@@ -52,15 +52,7 @@
             FINGER4, DIAMOND, WALL
         };
     }
-    namespace Rank
-    {
-        enum Value 
-        { 
-            NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN 
-        };
 
-    }
-   
 
     
  
@@ -85,9 +77,7 @@
                 void setFormationMode(FormationMode::Value val);
                 FormationMode::Value getFormationMode() const;
 
-                void setRank(Rank::Value val);
-                Rank::Value getRank() const;
-           
+               
 
             //----[/XML methods]----
 
@@ -171,7 +161,6 @@
 
             //----["Private" variables]----
                 FormationMode::Value formationMode_;
-                Rank::Value rank_;
 
                 int attackRange_;
                 bool bLookAtTarget_;        

Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-27 07:39:46 UTC (rev 10869)
@@ -44,7 +44,6 @@
         this->myFollower_ = 0;
         this->myWingman_ = 0;
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
-        this->rank_ = Rank::DIVISIONLEADER;
     }
 
     DivisionController::~DivisionController()
@@ -106,12 +105,13 @@
         }
         
     }
+    //I wanted to do it different here, but at this point I think nothing will change if I delete that method
     void DivisionController::stayNearProtect()
     {
         ActionpointController::stayNearProtect();
     }
     
-    bool DivisionController::setWingman(ActionpointController* cwingman)
+    bool DivisionController::setWingman(CommonController* cwingman)
     {
 
         WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);

Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h	2015-11-27 07:39:46 UTC (rev 10869)
@@ -52,7 +52,7 @@
 
             //----[own functions]----
                 virtual bool setFollower(LeaderController* myFollower);
-                virtual bool setWingman(ActionpointController* cwingman);
+                virtual bool setWingman(CommonController* cwingman);
                 virtual bool hasWingman();
                 virtual bool hasFollower();
                 

Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-27 07:39:46 UTC (rev 10869)
@@ -46,7 +46,6 @@
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
         this->myWingman_ = 0;
         this->myDivisionLeader_ = 0;
-        this->rank_ = Rank::SECTIONLEADER;
         this->bFirstAction_ = true;
         //orxout(internal_error) << this << "Was created" << endl;
 
@@ -284,7 +283,7 @@
         for (ObjectList<LeaderController>::iterator it = ObjectList<LeaderController>::begin(); it; ++it)
         {
             //0ptr or not DivisionController?
-            if (!(it) || !((it)->getRank() == Rank::DIVISIONLEADER) || !(it->getControllableEntity()))
+            if (!(it) || !((it)->getIdentifier()->getName() == "DivisionController") || !(it->getControllableEntity()))
                 continue;
             //same team?
             if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()))
@@ -310,7 +309,7 @@
         }
         return 0;
     }
-    bool SectionController::setWingman(ActionpointController* cwingman)
+    bool SectionController::setWingman(CommonController* cwingman)
     {
         WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
 

Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h	2015-11-27 07:39:46 UTC (rev 10869)
@@ -52,7 +52,7 @@
             //----[own functions]----
                 LeaderController* findNewDivisionLeader();
 
-                virtual bool setWingman(ActionpointController* cwingman);
+                virtual bool setWingman(CommonController* cwingman);
                 virtual bool hasWingman();
 
                 void chooseTarget();

Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	2015-11-27 07:39:46 UTC (rev 10869)
@@ -40,7 +40,6 @@
         RegisterObject(WingmanController);
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
         this->myLeader_ = 0;
-        this->rank_ = Rank::WINGMAN;
         this->bFirstAction_ = true;
 
     }
@@ -80,7 +79,7 @@
         //----If no leader, find one----
         if (!this->myLeader_)
         {
-            ActionpointController* newLeader = findNewLeader();
+            ActionpointController* newLeader = orxonox_cast<ActionpointController*> (findNewLeader());
             this->myLeader_ = newLeader;
            
         }
@@ -171,7 +170,7 @@
         this->setFormationMode( this->myLeader_->getFormationMode() );
         Vector3* targetRelativePosition;
 
-        if (this->myLeader_->getRank() == Rank::DIVISIONLEADER)
+        if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
         {
             switch (this->formationMode_){
                 case FormationMode::WALL:
@@ -216,21 +215,21 @@
         return *targetRelativePosition;
     }
     //----POST: closest leader that is ready to take a new wingman is returned----
-    ActionpointController* WingmanController::findNewLeader()
+    CommonController* WingmanController::findNewLeader()
     {
 
         if (!this->getControllableEntity())
             return 0;
 
         //----vars for finding the closest leader----
-        ActionpointController* closestLeader = 0;
+        CommonController* closestLeader = 0;
         float minDistance =  std::numeric_limits<float>::infinity();
         Gametype* gt = this->getGametype();
-        for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
+        for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
         {
             //----0ptr or not a leader or dead?----
             if (!it || 
-                (it->getRank() != Rank::SECTIONLEADER && it->getRank() != Rank::DIVISIONLEADER) || 
+                (it->getIdentifier()->getName() != "SectionController" && it->getIdentifier()->getName() != "DivisionController") || 
                 !(it->getControllableEntity()))
                 continue;
             
@@ -250,7 +249,7 @@
         if (closestLeader)
         {
             //----Racing conditions----
-            if (closestLeader->setWingman(this))
+            if (closestLeader->setWingman(orxonox_cast<CommonController*>(this)))
                 return closestLeader;
         }
         return 0;

Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h	2015-11-26 21:40:59 UTC (rev 10868)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h	2015-11-27 07:39:46 UTC (rev 10869)
@@ -51,7 +51,7 @@
             //----[/orxonox demanded functions]----
 
             //----[own functions]----
-               ActionpointController* findNewLeader();
+               CommonController* findNewLeader();
             //----[/own functions]----
 
         protected:




More information about the Orxonox-commit mailing list