[Orxonox-commit 4951] r9620 - in code/branches/formationupdate/src/orxonox: controllers worldentities/pawns

maxima at orxonox.net maxima at orxonox.net
Tue Apr 30 16:04:27 CEST 2013


Author: maxima
Date: 2013-04-30 16:04:26 +0200 (Tue, 30 Apr 2013)
New Revision: 9620

Modified:
   code/branches/formationupdate/src/orxonox/controllers/FormationController.cc
   code/branches/formationupdate/src/orxonox/controllers/FormationController.h
   code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
Log:
setNewMasterWithInFormation works!


Modified: code/branches/formationupdate/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/controllers/FormationController.cc	2013-04-30 13:55:12 UTC (rev 9619)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.cc	2013-04-30 14:04:26 UTC (rev 9620)
@@ -533,13 +533,19 @@
         this->state_ = FREE;
     }
 
-    /*
+
     void FormationController::setNewMasterWithinFormation(FormationController* newMaster)
         {
-            if(this->state_ != MASTER) return;
+            if(this->state_ != MASTER || newMaster->myMaster_ != this) return;
 
             if (!this->slaves_.empty())
             {
+				std::vector<FormationController*>::iterator it2 = std::find(this->slaves_.begin(), this->slaves_.end(), newMaster);
+				if (it2 != this->slaves_.end())
+				{
+					 this->slaves_.erase(it2);
+				}
+
                 newMaster->state_ = MASTER;
                 newMaster->slaves_ = this->slaves_;
                 newMaster->myMaster_ = 0;
@@ -554,9 +560,9 @@
             this->specificMasterAction_ = NONE;
             this->state_ = FREE;
         }
-     */
 
 
+
   /**
         @brief Frees all slaves form a master. Initiated by a master.
     */

Modified: code/branches/formationupdate/src/orxonox/controllers/FormationController.h
===================================================================
--- code/branches/formationupdate/src/orxonox/controllers/FormationController.h	2013-04-30 13:55:12 UTC (rev 9619)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.h	2013-04-30 14:04:26 UTC (rev 9620)
@@ -59,7 +59,7 @@
       static void passivebehaviour(const bool passive);
       static void formationsize(const int size);
       void setNewMasterWithinFormation();
-      //void setNewMasterWithinFormation(FormationController* newMaster);
+      void setNewMasterWithinFormation(FormationController* newMaster);
 
       inline void setFormationFlight(bool formation)
            { this->formationFlight_ = formation; }

Modified: code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc	2013-04-30 13:55:12 UTC (rev 9619)
+++ code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc	2013-04-30 14:04:26 UTC (rev 9620)
@@ -364,8 +364,8 @@
 
 
             		// set new Master
-					//orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave));
-            		orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation();
+					orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave));
+            		//orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation();
 
 
             		/* TO DO: - setNewMasterWithinFormation() with an argument.




More information about the Orxonox-commit mailing list