Index: code/trunk/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/WingmanController.cc	(revision 11052)
+++ code/trunk/src/orxonox/controllers/WingmanController.cc	(revision 11071)
@@ -39,5 +39,5 @@
     {
         RegisterObject(WingmanController);
-        this->myLeader_ = 0;
+        this->myLeader_ = nullptr;
         this->bFirstAction_ = true;
 
@@ -46,26 +46,11 @@
     WingmanController::~WingmanController()
     {
-        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
+        for (WorldEntity* actionpoint : this->actionpoints_)
         {
-            if(this->actionpoints_[i])
-                this->actionpoints_[i]->destroy();
+            if (actionpoint)
+                actionpoint->destroy();
         }
         this->parsedActionpoints_.clear();
         this->actionpoints_.clear();
-    }
-  
-    void WingmanController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(WingmanController, XMLPort, xmlelement, mode);
-    }
-    
-    //----in tick, move (or look) and shoot----
-    void WingmanController::tick(float dt)
-    {   
-        if (!this->isActive())
-            return; 
-        
-        SUPER(WingmanController, tick, dt);
-
     }
     
@@ -122,8 +107,5 @@
     Vector3 WingmanController::getFormationPosition ()
     {
-
-
         this->setFormationMode( this->myLeader_->getFormationMode() );
-        Vector3* targetRelativePosition;
         this->spread_ = this->myLeader_->getSpread();
         if (this->myLeader_->getIdentifier()->getName() == "DivisionController")
@@ -131,18 +113,11 @@
             switch (this->formationMode_){
                 case FormationMode::WALL:
-                {
-                    targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
-                    break;
-                }
+                    return Vector3 (2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
                 case FormationMode::FINGER4: 
-                {
-                    targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
-                    break;
-                }
+                    return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
                 case FormationMode::DIAMOND: 
-                {
-                    targetRelativePosition = new Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
-                    break;
-                }
+                    return Vector3 (2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
+                default:
+                    return Vector3::ZERO;
             }
         }
@@ -151,23 +126,13 @@
             switch (this->formationMode_){
                 case FormationMode::WALL:
-                {
-                    targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
-                    break;
-                }
+                    return Vector3 (-2.0f*this->spread_, 0, 0 - 1.0f*this->tolerance_);
                 case FormationMode::FINGER4: 
-                {
-                    targetRelativePosition = new Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
-                    break;
-                }
+                    return Vector3 (-2.0f*this->spread_, 0, this->spread_ - 1.0f*this->tolerance_);
                 case FormationMode::DIAMOND: 
-                {
-                    targetRelativePosition = new Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_);
-                    break;
-                }
+                    return Vector3 (2.0f*this->spread_, -1.0f*this->spread_, 0 - 1.0f*this->tolerance_);
+                default:
+                    return Vector3::ZERO;
             }
         }
-        Vector3 result = *targetRelativePosition;
-        delete targetRelativePosition;
-        return result;
     }
     void WingmanController::keepFormation()
@@ -185,28 +150,28 @@
 
         if (!this->getControllableEntity())
-            return 0;
+            return nullptr;
 
         //----vars for finding the closest leader----
-        ActionpointController* closestLeader = 0;
+        ActionpointController* closestLeader = nullptr;
         float minDistance =  std::numeric_limits<float>::infinity();
         Gametype* gt = this->getGametype();
 
-        for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
+        for (ActionpointController* controller : ObjectList<ActionpointController>())
         {
             //----0ptr or not a leader or dead?----
-            if (!it || 
-                (it->getIdentifier()->getName() != "SectionController" && it->getIdentifier()->getName() != "DivisionController") || 
-                !(it->getControllableEntity()))
+            if (!controller ||
+                (controller->getIdentifier()->getName() != "SectionController" && controller->getIdentifier()->getName() != "DivisionController") ||
+                !(controller->getControllableEntity()))
                 continue;
             
             //----same team?----
-            if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity(), gt) )
+            if ( !CommonController::sameTeam (this->getControllableEntity(), controller->getControllableEntity(), gt) )
                 continue;
             
             //----check distance----
-            float distance = CommonController::distance (it->getControllableEntity(), this->getControllableEntity());
-            if (distance < minDistance && !(it->hasWingman()))
+            float distance = CommonController::distance (controller->getControllableEntity(), this->getControllableEntity());
+            if (distance < minDistance && !(controller->hasWingman()))
             {
-                closestLeader = *it;
+                closestLeader = controller;
                 minDistance = distance;
             }
@@ -222,5 +187,5 @@
             }
         }
-        return 0;
+        return nullptr;
     }
 
