Index: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10851)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10854)
@@ -50,4 +50,15 @@
     DivisionController::~DivisionController()
     {
+        if (this->myFollower_)
+        {
+            this->myFollower_->takeActionpoints(this->parsedActionpoints_);
+        }
+        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
+        {
+            if(this->actionpoints_[i])
+                this->actionpoints_[i]->destroy();
+        }
+        this->parsedActionpoints_.clear();
+        this->actionpoints_.clear();
     } 
 
@@ -65,202 +76,12 @@
     }
     void DivisionController::action()
-    {        
-        if (this->startAttackingEnemiesThatAreClose())
-        {
-            Point p = { Action::FIGHT, "", Vector3::ZERO };
-            
-            if (this->myWingman_)
-            {
-                this->myWingman_->parsedActionpoints_.push_back(p);
-            }
-            if (this->myFollower_)
-            {
-                this->myFollower_->parsedActionpoints_.push_back(p);
-            }
-        }
-
-        if (this->action_ == Action::NONE)
-        {
-            this->executeActionpoint();
-        }
-        if (this->action_ == Action::FIGHT || this->action_ == Action::FIGHTALL)
-        {
-            if (!this->hasTarget())
-            {
-                //----find a target----
-                ControllableEntity* newTarget = this->closestTarget();
-                if (this->action_ == Action::FIGHT)
-                {
-                    if (newTarget && 
-                            CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
-                    {
-                        this->setAction (Action::FIGHT, newTarget);
-                    }
-                    else
-                    {
-                        this->nextActionpoint();
-                        if (this->myWingman_)
-                        {
-                            this->myWingman_->nextActionpoint();
-                        }
-                        if (this->myFollower_)
-                        {
-                            this->myFollower_->nextActionpoint();
-                        }
-                        return;
-                    }
-                }
-                else if (this->action_ == Action::FIGHTALL)
-                {
-                    if (newTarget && newTarget->getController())
-                    {
-                        this->setAction (Action::FIGHTALL, newTarget);
-                    }
-                    else
-                    {
-                        this->nextActionpoint();
-                        if (this->myWingman_)
-                        {
-                            this->myWingman_->nextActionpoint();
-                        }
-                        if (this->myFollower_)
-                        {
-                            this->myFollower_->nextActionpoint();
-                        }
-                        return;
-                    }
-                }
-
-            }
-            else if (this->hasTarget())
-            {
-                //----fly in formation if far enough----
-                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
-                    
-                if (diffVector.length() > this->attackRange_)
-                {
-                    if (this->action_ == Action::FIGHT)
-                    {
-                        this->nextActionpoint();
-                        if (this->myWingman_)
-                        {
-                            this->myWingman_->nextActionpoint();
-                        }
-                        if (this->myFollower_)
-                        {
-                            this->myFollower_->nextActionpoint();
-                        }
-                        return;
-                    }
-                    else
-                    {
-                        this->setTargetPositionOfWingman();
-                        this->setTargetPositionOfFollower();                    
-                    }
-                }
-                else
-                {
-                    //----wingmans shall support the fire of their leaders----
-                    if (this->myWingman_)
-                    {
-                        this->myWingman_->setAction (Action::FIGHT, this->target_);     
-                    }
-                    if (this->myFollower_)
-                    {
-                        this->myFollower_->setAction (Action::FIGHT);                                    
-                    }
-                }
-            }
-        }
-        else if (this->action_ == Action::FLY)
-        {
-            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
-            {
-                this->nextActionpoint();
-                if (this->myWingman_)
-                {
-                    this->myWingman_->nextActionpoint();
-                }
-                if (this->myFollower_)
-                {
-                    this->myFollower_->nextActionpoint();
-                }
-                return;
-            }
-            this->setTargetPositionOfWingman();
-            this->setTargetPositionOfFollower();
-        }
-        else if (this->action_ == Action::PROTECT)
-        {
-            if (!this->getProtect())
-            {
-                this->nextActionpoint();
-                if (this->myWingman_)
-                {
-                    this->myWingman_->nextActionpoint();
-                }
-                if (this->myFollower_)
-                {
-                    this->myFollower_->nextActionpoint();
-                }
-                return;
-            }
-
-            Vector3* targetRelativePosition;
-                
-            targetRelativePosition = new Vector3 (0, 300, 300);  
- 
-            Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
-                (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
-            this->setTargetPosition(targetAbsolutePosition);
-            
-            this->setTargetPositionOfWingman();
-            this->setTargetPositionOfFollower();
-
-        }
-        else if (this->action_ == Action::ATTACK)
-        {   
-            if (!this->hasTarget())
-            {
-                this->nextActionpoint();
-                if (this->myWingman_)
-                {
-                    this->myWingman_->nextActionpoint();
-                }
-                if (this->myFollower_)
-                {
-                    this->myFollower_->nextActionpoint();
-                }
-                return;
-            }
-            //----fly in formation if far enough----
-            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
-            if (diffVector.length() > this->attackRange_)
-            {
-                this->setTargetPositionOfWingman();
-                this->setTargetPositionOfFollower();                    
-            }
-            else
-            {
-                //----wingmans shall support the fire of their leaders----
-                if (this->myWingman_)
-                {
-                    this->myWingman_->setAction (Action::FIGHT, this->target_);     
-                }
-                if (this->myFollower_)
-                {
-                    this->myFollower_->setAction (Action::FIGHT);                                    
-                }
-            }          
-        }
-        if (this->hasTarget())
-        {
-            //----choose where to go----
-            this->maneuver();
-            //----fire if you can----
-            this->bShooting_ = this->canFire();                
-        }
+    {   
+        CommonController::action();
+        
     }
-    
+    void DivisionController::stayNearProtect()
+    {
+        CommonController::stayNearProtect();
+    }
     void DivisionController::setTargetPositionOfWingman()
     {
@@ -294,36 +115,5 @@
        
     }
-    void DivisionController::setTargetPositionOfFollower()
-    {
-        if (!this->myFollower_)
-            return;
-        this->myFollower_->setFormationMode(this->formationMode_);
-
-        Vector3* targetRelativePositionOfFollower;
-        switch (this->formationMode_){
-            case FormationMode::WALL:
-            {
-                targetRelativePositionOfFollower = new Vector3 (-400, 0, 0);   
-                break;
-            }
-            case FormationMode::FINGER4: 
-            {
-                targetRelativePositionOfFollower = new Vector3 (-400, 0, 200);   
-                break;
-            }
-            
-            case FormationMode::DIAMOND: 
-            {
-                targetRelativePositionOfFollower = new Vector3 (-400, 0, 200);                   
-                break;
-            }
-        }
-        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
-        
-        Vector3 targetAbsolutePositionOfFollower = ((this->getControllableEntity()->getWorldPosition()) + 
-        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower)));
-        
-        myFollower_->setAction ( Action::FLY, targetAbsolutePositionOfFollower, orient );       
-    }
+    
     bool DivisionController::setWingman(CommonController* cwingman)
     {
