Index: code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc	(revision 9271)
+++ code/branches/presentation2012merge/src/orxonox/controllers/FormationController.cc	(revision 9272)
@@ -50,25 +50,25 @@
 {
 
-  SetConsoleCommand("FormationController", "formationflight",  &FormationController::formationflight);
-  SetConsoleCommand("FormationController", "masteraction",     &FormationController::masteraction);
-  SetConsoleCommand("FormationController", "followme",         &FormationController::followme);
-  SetConsoleCommand("FormationController", "passivebehaviour", &FormationController::passivebehaviour);
-  SetConsoleCommand("FormationController", "formationsize",    &FormationController::formationsize);
-
-
-
-
-  static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
-  static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
-  static const float FORMATION_LENGTH =  110;
-  static const float 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;
-  static const float ROTATEFACTOR_MASTER = 0.2f;
-  static const float SPEED_FREE = 0.8f;
-  static const float ROTATEFACTOR_FREE = 0.8f;
-
-  FormationController::FormationController(BaseObject* creator) : Controller(creator)
-  {
+    SetConsoleCommand("FormationController", "formationflight",  &FormationController::formationflight);
+    SetConsoleCommand("FormationController", "masteraction",     &FormationController::masteraction);
+    SetConsoleCommand("FormationController", "followme",         &FormationController::followme);
+    SetConsoleCommand("FormationController", "passivebehaviour", &FormationController::passivebehaviour);
+    SetConsoleCommand("FormationController", "formationsize",    &FormationController::formationsize);
+
+
+
+
+    static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
+    static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
+    static const float FORMATION_LENGTH =  110;
+    static const float 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;
+    static const float ROTATEFACTOR_MASTER = 0.2f;
+    static const float SPEED_FREE = 0.8f;
+    static const float ROTATEFACTOR_FREE = 0.8f;
+
+    FormationController::FormationController(BaseObject* creator) : Controller(creator)
+    {
         RegisterObject(FormationController);
 
@@ -91,9 +91,9 @@
         this->team_=-1;
         this->target_.setCallback(createFunctor(&FormationController::targetDied, this));
-  }
-
-  FormationController::~FormationController()
-  {
-    if (this->isInitialized())
+    }
+
+    FormationController::~FormationController()
+    {
+        if (this->isInitialized())
         {
             this->removeFromFormation();
@@ -123,7 +123,7 @@
             }
         }
-  }
-
-  void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    }
+
+    void FormationController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(FormationController, XMLPort, xmlelement, mode);
@@ -137,9 +137,9 @@
 
 
-  /**
+    /**
         @brief Activates / deactivates formationflight behaviour
         @param form activate formflight if form is true
     */
-  void FormationController::formationflight(const bool form)
+    void FormationController::formationflight(const bool form)
     {
         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
@@ -168,5 +168,5 @@
     }
 
-  /**
+    /**
         @brief Get all masters to do a "specific master action"
         @param action which action to perform (integer, so it can be called with a console command (tmp solution))
@@ -198,5 +198,5 @@
     }
 
-  /**
+    /**
         @brief Sets shooting behaviour of pawns.
         @param passive if true, bots won't shoot.
@@ -225,5 +225,5 @@
     }
 
-  /**
+    /**
         @brief Sets maximal formation size
         @param size maximal formation size.
@@ -282,11 +282,11 @@
         Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
         float distance = (target - this->getControllableEntity()->getPosition()).length();
-		if(coord.x < 0.0001 && coord.y < 0.0001)
-		{
-			// if the ship reaches a direction very close to the direct one, set it to the direct one
-			Vector3 v_temp = this->getControllableEntity()->getPosition();
-			Quaternion quat = v_temp.getRotationTo(target);
-			this->getControllableEntity()->rotate(quat);
-		}
+        if(coord.x < 0.0001 && coord.y < 0.0001)
+        {
+            // if the ship reaches a direction very close to the direct one, set it to the direct one
+            Vector3 v_temp = this->getControllableEntity()->getPosition();
+            Quaternion quat = v_temp.getRotationTo(target);
+            this->getControllableEntity()->rotate(quat);
+        }
 
         if(this->state_ == FREE)
@@ -324,42 +324,42 @@
 
         if(this->state_ == SLAVE)
-		{
-
-			this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
-			this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
-
-			if (distance < 300)
-			{
-				if (bHasTargetOrientation_)
-				{
-					copyTargetOrientation();
-				}
-				if (distance < 100)
-				{ //linear speed reduction
-					this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
-
-				} else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
-
-			} else {
-				this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
-			}
-		}
+        {
+
+            this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * coord.x * 2);
+            this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * coord.y * 2);
+
+            if (distance < 300)
+            {
+                if (bHasTargetOrientation_)
+                {
+                    copyTargetOrientation();
+                }
+                if (distance < 100)
+                { //linear speed reduction
+                    this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER);
+                }
+                else
+                    this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
+            }
+            else
+                this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
+        }
 
         if (distance < 10)
         {
             this->positionReached();
-	    bHasTargetOrientation_=false;
-        }
-    }
-
-
-
-  void FormationController::moveToTargetPosition()
+            bHasTargetOrientation_=false;
+        }
+    }
+
+
+
+    void FormationController::moveToTargetPosition()
     {
         this->moveToPosition(this->targetPosition_);
     }
 
-  //copy the Roll orientation of given Quaternion.
-  void FormationController::copyOrientation(const Quaternion& orient)
+    //copy the Roll orientation of given Quaternion.
+    void FormationController::copyOrientation(const Quaternion& orient)
     {
         //roll angle difference in radian
@@ -379,5 +379,5 @@
 
 
-   /**
+    /**
         @brief Unregisters a slave from its master. Initiated by a slave.
     */
@@ -469,9 +469,9 @@
         }
     }
- /**
+
+    /**
         @brief Commands the slaves of a master into a formation. Sufficiently fast not to be called within tick. Initiated by a master.
     */
-
-void FormationController::commandSlaves()
+    void FormationController::commandSlaves()
     {
         if(this->state_ != MASTER) return;
@@ -487,9 +487,9 @@
         }
         else
-	// formation:
+        // formation:
         {
             dest += 1.0f*orient*WorldEntity::BACK;
             Vector3 pos = Vector3::ZERO;
-	         bool left=true;
+            bool left=true;
             int i = 1;
 
@@ -689,9 +689,10 @@
 
         if (specificMasterActionHoldCount_ == 0)
-         {
+        {
             this->specificMasterAction_ = NONE;
             this->searchNewTarget();
-         }
-        else specificMasterActionHoldCount_--;
+        }
+        else
+            specificMasterActionHoldCount_--;
     }
 
@@ -717,10 +718,10 @@
     void FormationController::turn180()
     {
-            Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
-
-            this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
-            this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
-
-            this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
+        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
+
+        this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
+        this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
+
+        this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
     }
 
@@ -740,6 +741,6 @@
     void FormationController::spin()
     {
-            this->moveToTargetPosition();
-            this->getControllableEntity()->rotateRoll(0.8f);
+        this->moveToTargetPosition();
+        this->getControllableEntity()->rotateRoll(0.8f);
     }
 
@@ -779,24 +780,19 @@
         if((humanPawn != NULL) && (allMasters.size() != 0))
         {
-                float posHuman = humanPawn->getPosition().length();
-                float distance = 0.0f;
-                float minDistance = FLT_MAX;
-                int index = 0;
-                int i = 0;
-
-                for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
-                    {
-                        if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
-                        distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
-                        if(distance < minDistance) index = i;
-                    }
-                allMasters[index]->followInit(humanPawn);
-            }
-
-    }
-
-
-
-
+            float posHuman = humanPawn->getPosition().length();
+            float distance = 0.0f;
+            float minDistance = FLT_MAX;
+            int index = 0;
+            int i = 0;
+
+            for(std::vector<FormationController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++, i++)
+            {
+                if (!FormationController::sameTeam((*it)->getControllableEntity(), humanPawn, (*it)->getGametype())) continue;
+                distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
+                if(distance < minDistance) index = i;
+            }
+            allMasters[index]->followInit(humanPawn);
+        }
+    }
 
     /**
@@ -820,5 +816,5 @@
     }
 
-   /**
+    /**
         @brief Master begins to follow a randomly chosen human player of the same team. Is a "specific master action".
     */
@@ -848,5 +844,5 @@
 
 
-  /**
+    /**
         @brief Master follows target with adjusted speed. Called within tick.
     */
@@ -860,5 +856,5 @@
 
 
-  void FormationController::setTargetPosition(const Vector3& target)
+    void FormationController::setTargetPosition(const Vector3& target)
     {
         this->targetPosition_ = target;
@@ -924,5 +920,5 @@
     }
 
-  void FormationController::forgetTarget()
+    void FormationController::forgetTarget()
     {
         this->target_ = 0;
@@ -930,5 +926,5 @@
     }
 
-   void FormationController::targetDied()
+    void FormationController::targetDied()
     {
         this->forgetTarget();
@@ -936,5 +932,5 @@
     }
 
-  bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
+    bool FormationController::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     {
         if (entity1 == entity2)
