[Orxonox-commit 4950] r9619 - in code/branches/formationupdate/src/orxonox: controllers worldentities/pawns
maxima at orxonox.net
maxima at orxonox.net
Tue Apr 30 15:55:13 CEST 2013
Author: maxima
Date: 2013-04-30 15:55:12 +0200 (Tue, 30 Apr 2013)
New Revision: 9619
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:
New function SetNewMasterWithinFormation(FormationController), but it does not work yet.
Modified: code/branches/formationupdate/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/controllers/FormationController.cc 2013-04-30 13:13:52 UTC (rev 9618)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.cc 2013-04-30 13:55:12 UTC (rev 9619)
@@ -533,7 +533,30 @@
this->state_ = FREE;
}
+ /*
+ void FormationController::setNewMasterWithinFormation(FormationController* newMaster)
+ {
+ if(this->state_ != MASTER) return;
+ if (!this->slaves_.empty())
+ {
+ newMaster->state_ = MASTER;
+ newMaster->slaves_ = this->slaves_;
+ newMaster->myMaster_ = 0;
+
+ for(std::vector<FormationController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)
+ {
+ (*it)->myMaster_ = newMaster;
+ }
+ }
+
+ this->slaves_.clear();
+ 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:13:52 UTC (rev 9618)
+++ code/branches/formationupdate/src/orxonox/controllers/FormationController.h 2013-04-30 13:55:12 UTC (rev 9619)
@@ -58,8 +58,8 @@
static void followme();
static void passivebehaviour(const bool passive);
static void formationsize(const int size);
- void takeLeadOfFormation();
- void loseMasterState();
+ void setNewMasterWithinFormation();
+ //void setNewMasterWithinFormation(FormationController* newMaster);
inline void setFormationFlight(bool formation)
{ this->formationFlight_ = formation; }
@@ -102,6 +102,7 @@
/* Just for testing purposes: report the master. */
FormationController* getMaster( void ) { return myMaster_; }
FormationController* getThis( void ) { return this; }
+ FormationController* getSlave( void ) { return this->slaves_.back(); }
protected:
bool formationFlight_;
@@ -132,7 +133,8 @@
void unregisterSlave();
void searchNewMaster();
void commandSlaves();
- void setNewMasterWithinFormation();
+ void takeLeadOfFormation();
+ void loseMasterState();
void freeSlaves();
void forceFreeSlaves();
Modified: code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc 2013-04-30 13:13:52 UTC (rev 9618)
+++ code/branches/formationupdate/src/orxonox/worldentities/pawns/Pawn.cc 2013-04-30 13:55:12 UTC (rev 9619)
@@ -364,19 +364,18 @@
// set new Master
- orxonox_cast<FormationController*>(this->getController())->loseMasterState();
+ //orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave));
+ orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation();
-
- /* TO DO: - new Master is not set right
- * - The slave still has a AIController
+ /* TO DO: - setNewMasterWithinFormation() with an argument.
+ * - set slave as the new master within the formation
*
*/
// start to control a slave
this->getPlayer()->startControl(entity);
- //orxonox_cast<FormationController*>(this->getController())->takeLeadOfFormation();
}
else
More information about the Orxonox-commit
mailing list