Index: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10946)
@@ -9,5 +9,5 @@
  *   modify it under the terms of the GNU General Public License
  *   as published by the Free Software Foundation; either version 2
- *   of the License, or ( at your option )any later version.
+ *   of the License, or (at your option)any later version.
  *
  *   This program is distributed in the hope that it will be useful,
@@ -28,5 +28,5 @@
 #include "controllers/CommonController.h"
 
-//stuff for sameTeam function
+//here starts stuff for sameTeam function copied from FormationController
 #include "gametypes/TeamDeathmatch.h"
 #include "gametypes/Gametype.h"
@@ -39,30 +39,45 @@
 {
 
-    RegisterClass( CommonController );
-
-    CommonController::CommonController( Context* context ): Controller( context )
-    {
-        RegisterObject( CommonController );
+    RegisterClass(CommonController);
+
+    CommonController::CommonController(Context* context): Controller(context)
+    {
+        RegisterObject(CommonController);
     }
     CommonController::~CommonController() 
     {
-        
-    }
-
-    float CommonController::randomInRange( float a, float b )
+        //no member variables - nothing to destroy
+    }
+    /**
+    @brief
+      PRE: a < b.
+      returns random float between a and b.
+    */
+    float CommonController::randomInRange(float a, float b)
     {
         return a + rnd(1.0f) * (b - a);
     }
-    float CommonController::distance (ControllableEntity* entity1, ControllableEntity* entity2)
+    /**
+    @brief
+      returns distance between two entities, if either is zero pointer, returns infinity
+    */    
+    float CommonController::distance (const ControllableEntity* entity1, const ControllableEntity* entity2)
     {
         if (!entity1 || !entity2)
             return std::numeric_limits<float>::infinity();
-        return ( entity1->getPosition() - entity2->getPosition() ).length();
-    }
+        return (entity1->getPosition() - entity2->getPosition()).length();
+    }
+    /**
+    @brief
+      bad function from FormationController that returns true if both entities have same team
+    */    
     bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     {
+        //uncomment following code if functions stops working due to being a hack
         /*if (!entity1 || !entity2)
             return false;
         return entity1->getTeam() == entity2->getTeam();*/
+        if (!entity1 || !entity2)
+            return false;
         if (entity1 == entity2)
             return true;
@@ -161,5 +176,5 @@
                 team2 = dynamic->getParty(entity2->getPlayer());
 
-            if (team1 ==-1 ||team2 ==-1 ) {return false;}
+            if (team1 ==-1 ||team2 ==-1) {return false;}
             else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;}
             else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;}
@@ -170,13 +185,21 @@
         return (team1 == team2 && team1 != -1);
     }
-    bool CommonController::isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle )
-    {
-        if ( !entityThatLooks || !entityBeingLookedAt )
+    /**
+    @brief
+      returns true if entityThatLooks does look at entityBeingLookeAt with a tolerance of angle.
+    */    
+    bool CommonController::isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle)
+    {
+        if (!entityThatLooks || !entityBeingLookedAt)
             return false;
-        return ( getAngle( entityThatLooks ->getPosition() , 
+        return (getAngle(entityThatLooks ->getPosition() , 
             entityThatLooks->getOrientation()  * WorldEntity::FRONT, 
-            entityBeingLookedAt->getWorldPosition() ) < angle );
-    }
-    std::string CommonController::getName(Pawn* entity)
+            entityBeingLookedAt->getWorldPosition()) < angle);
+    }
+    /**
+    @brief
+      returns a name of a Pawn entity, if no name set, returns string representing address of the Pawn.
+    */    
+    std::string CommonController::getName(const Pawn* entity)
     {
         std::string name = entity->getName();
