[Orxonox-commit 4277] r8948 - code/branches/formation/src/orxonox/controllers

willis at orxonox.net willis at orxonox.net
Wed Nov 23 16:06:18 CET 2011


Author: willis
Date: 2011-11-23 16:06:18 +0100 (Wed, 23 Nov 2011)
New Revision: 8948

Modified:
   code/branches/formation/src/orxonox/controllers/HumanController.cc
   code/branches/formation/src/orxonox/controllers/HumanController.h
   code/branches/formation/src/orxonox/controllers/Masterable.cc
Log:
debugging

Modified: code/branches/formation/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/HumanController.cc	2011-11-23 14:55:17 UTC (rev 8947)
+++ code/branches/formation/src/orxonox/controllers/HumanController.cc	2011-11-23 15:06:18 UTC (rev 8948)
@@ -76,18 +76,20 @@
         this->controlPaused_ = false;
         this->boosting_ = false;
         this->boosting_ = false;
-
+        this->tempMaster=NULL;
         HumanController::localController_s = this;
         this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));
         this->boostingTimeout_.stopTimer();
-        this->state_=MASTER;
+        this->state_=FREE;
     }
 
     HumanController::~HumanController()
     {
+        if (HumanController::localController_s) 
+        {
+            HumanController::localController_s->removeFromFormation();
+        }
         HumanController::localController_s = 0;
-        if (this->state_==MASTER)
-            removeFromFormation();
     }
 
     void HumanController::tick(float dt)
@@ -100,9 +102,9 @@
         }
 
         // commandslaves when Master of a formation
-        if (this->state_==MASTER)
+        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
         {
-            this->commandSlaves();
+            HumanController::localController_s->commandSlaves();
         }
     }
 
@@ -273,16 +275,20 @@
 
     void HumanController::toggleFormationFlight()
     {
+        
         if (HumanController::localController_s)
         {
             if (HumanController::localController_s->state_==MASTER)
             {
                 HumanController::localController_s->freeSlaves();
                 HumanController::localController_s->state_=FREE;
+                orxout(message) <<"FormationFlight disabled "<< endl;
             } else //SLAVE or FREE
             {
                 HumanController::localController_s->takeLeadOfFormation();
+                orxout(message) <<"FormationFlight enabled "<< endl;
             }
+            
         }
 
     }

Modified: code/branches/formation/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/formation/src/orxonox/controllers/HumanController.h	2011-11-23 14:55:17 UTC (rev 8947)
+++ code/branches/formation/src/orxonox/controllers/HumanController.h	2011-11-23 15:06:18 UTC (rev 8948)
@@ -108,6 +108,7 @@
             bool boosting_; // Whether the HumanController is in boosting mode or not.
             Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.
             static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.
+            Masterable* tempMaster;
 
     }; // tolua_export
 } // tolua_export

Modified: code/branches/formation/src/orxonox/controllers/Masterable.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/Masterable.cc	2011-11-23 14:55:17 UTC (rev 8947)
+++ code/branches/formation/src/orxonox/controllers/Masterable.cc	2011-11-23 15:06:18 UTC (rev 8948)
@@ -58,7 +58,7 @@
 
   static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
   static const int RADIUS_TO_SEARCH_FOR_MASTERS = 20000;
-  static const int FORMATION_LENGTH =  130;
+  static const int FORMATION_LENGTH =  110;
   static const int FORMATION_WIDTH =  110;
   static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
   static const float SPEED_MASTER = 0.6f;
@@ -85,7 +85,7 @@
 	this->bHasTargetOrientation_=false;
         this->speedCounter_ = 0.2f;
         this->targetPosition_ = Vector3::ZERO;
-
+        //this->team_=-1;
         this->target_.setCallback(createFunctor(&Masterable::targetDied, this));
   }
 
@@ -318,7 +318,7 @@
 		    }
                 if (distance < 40)
                 {
-                    this->getControllableEntity()->moveFrontBack(0.8f*SPEED_MASTER);
+                    this->getControllableEntity()->moveFrontBack(0.2f*SPEED_MASTER);
 		   
                 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
 
@@ -443,6 +443,7 @@
         {
             this->state_ = MASTER;
             this->myMaster_ = 0;
+            orxout(debug_output) << "search new master: no master found, but teammates"<< endl;
         }
     }
  /**
@@ -587,7 +588,8 @@
         //search new Master, then take lead
         if (this->state_==FREE)
         {
-            float minDistance=RADIUS_TO_SEARCH_FOR_MASTERS;
+          /*
+            float minDistance=(float)RADIUS_TO_SEARCH_FOR_MASTERS;
             Masterable* bestMaster=NULL;
 
             //search nearest Master, store in bestMaster
@@ -638,12 +640,15 @@
               this->state_=MASTER;
               this->slaves_.clear();
               this->myMaster_=0;
+              orxout(debug_output) << this << "no formation found!, empty formation"<< endl;
               return;
             }
+         */
+          searchNewMaster();
         }
 
-        if (this->state_==SLAVE)
-        {
+        if (this->state_==SLAVE)  //become master of this formation
+        {   
             this->slaves_=myMaster_->slaves_;
             this->myMaster_->slaves_.clear();
             this->myMaster_->state_=SLAVE;




More information about the Orxonox-commit mailing list