Index: /code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- /code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	(revision 6856)
+++ /code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	(revision 6857)
@@ -27,4 +27,9 @@
 */
 
+/**
+    @file DistanceMultiTrigger.cc
+    @brief Implementation of the DistanceMultiTrigger class.
+*/
+
 #include "DistanceMultiTrigger.h"
 
@@ -36,5 +41,9 @@
     
     CreateFactory(DistanceMultiTrigger);
-    
+
+    /**
+    @brief
+        Default Constructor. Registers the object and initializes default values. 
+    */
     DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator)
     {
@@ -43,22 +52,62 @@
         this->distance_ = 100.0f;
     }
-    
+
+    /**
+    @brief
+        Destructor.
+    */
     DistanceMultiTrigger::~DistanceMultiTrigger()
     {
         
     }
-    
+
+    /**
+    @brief
+        Method for creating a DistanceMultiTrigger object through XML.
+    */
     void DistanceMultiTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(DistanceMultiTrigger, XMLPort, xmlelement, mode);
 
-        XMLPortParam(DistanceMultiTrigger, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(100.0f);
+        XMLPortParam(DistanceMultiTrigger, "distance", setDistance, getDistance, xmlelement, mode);
     }
-    
+
+    /**
+    @brief
+        This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
+
+        In this implementation we iterate through all possible objects and check whether the fact that they are in range or not has changed and fire and hand a state ofer to the MultiTrigger if so.
+    */
     std::queue<MultiTriggerState*>* DistanceMultiTrigger::letTrigger(void)
     {
-        ClassTreeMask targetMask = this->getTargetMask();
-        
+        ClassTreeMask& targetMask = this->getTargetMask();
+
         std::queue<MultiTriggerState*>* queue = NULL;
+
+        // Check for objects that were in range but no longer are. Iterate through all objects, that are in range.
+        for(std::set<WorldEntity*>::iterator it = this->range_.begin(); it != this->range_.end(); )
+        {
+            Vector3 distanceVec = (*it)->getWorldPosition() - this->getWorldPosition();
+            // If the object is no longer in range.
+            if (distanceVec.length() > this->distance_)
+            {
+                WorldEntity* temp = *(it++);
+                if(!this->removeFromRange(temp))
+                    continue;
+
+                // If no queue has been created, yet.
+                if(queue == NULL)
+                    queue = new std::queue<MultiTriggerState*>();
+
+                // Create a state and append it to the queue.
+                MultiTriggerState* state = new MultiTriggerState;
+                state->bTriggered = false;
+                state->originator = temp;
+                queue->push(state);
+            }
+            else
+                ++it;
+        }
+
         // Check for new objects that are in range
         for(ClassTreeMaskObjectIterator it = targetMask.begin(); it != targetMask.end(); ++it)
@@ -69,13 +118,16 @@
 
             Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
-            if (distanceVec.length() < this->distance_)
+            // If the object is in range.
+            if (distanceVec.length() <= this->distance_)
             {
+                // Add the object to the objects that are in range.
                 if(!this->addToRange(entity))
                     continue;
-                
+
+                // If no queue has been created, yet.
                 if(queue == NULL)
-                {
                     queue = new std::queue<MultiTriggerState*>();
-                }
+
+                // Create a state and append it to the queue.
                 MultiTriggerState* state = new MultiTriggerState;
                 state->bTriggered = true;
@@ -85,26 +137,4 @@
         }
         
-        for(std::set<WorldEntity*>::iterator it = this->range_.begin(); it != this->range_.end(); )
-        {
-            Vector3 distanceVec = (*it)->getWorldPosition() - this->getWorldPosition();
-            if (distanceVec.length() >= this->distance_)
-            {
-                WorldEntity* temp = *(it++);
-                if(!this->removeFromRange(temp))
-                    continue;
-                
-                if(queue == NULL)
-                {
-                    queue = new std::queue<MultiTriggerState*>();
-                }
-                MultiTriggerState* state = new MultiTriggerState;
-                state->bTriggered = false;
-                state->originator = temp;
-                queue->push(state);
-            }
-            else
-                ++it;
-        }
-        
         return queue;
     }
Index: /code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
===================================================================
--- /code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	(revision 6856)
+++ /code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	(revision 6857)
@@ -27,4 +27,9 @@
 */
 
+/**
+    @file DistanceMultiTrigger.h
+    @brief Definition of the DistanceMultiTrigger class.
+*/
+
 #ifndef _DistanceMultiTrigger_H__
 #define _DistanceMultiTrigger_H__
@@ -40,31 +45,62 @@
 {
 
+    /**
+    @brief
+        The DistanceMultiTrigger is a trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger.
+    @see MultiTrigger.h
+        For more information on MultiTriggers.
+    @author
+        Damian 'Mozork' Frick
+    */
     class _ObjectsExport DistanceMultiTrigger : public MultiTrigger
     {
         
         public:
-            DistanceMultiTrigger(BaseObject* creator);
-            ~DistanceMultiTrigger();
+            DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values.
+            ~DistanceMultiTrigger(); //!< Destructor.
             
-            void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            
+            void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML.
+
+            /**
+            @brief Set the distance at which the DistanceMultiTrigger triggers.
+            @param distance The distance.
+            */
             inline void setDistance(float distance)
-                { this->distance_ = distance; }
+                { if(distance >= 0) this->distance_ = distance; }
+            /**
+            @brief Get the distance at which the DistanceMultiTrigger triggers.
+            @return Returns the distance.
+            */
             inline float getDistance() const
                 { return this->distance_; }
                 
         protected:
-            virtual std::queue<MultiTriggerState*>* letTrigger(void);
-            
+            virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
+
+            /**
+            @brief Check whether a given entity is currently (since the last update) in range of the DistanceMultiTrigger.
+            @param entity A pointer to the entity.
+            @return Returns true if the entity is in the range.
+            */
             inline bool inRange(WorldEntity* entity)
                 { return this->range_.find(entity) != this->range_.end(); }
-            bool addToRange(WorldEntity* entity)
+            /**
+            @brief Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
+            @param entity A pointer to the entity.
+            @return Returns true if successful, false if not.
+            */
+            inline bool addToRange(WorldEntity* entity)
                 { std::pair<std::set<WorldEntity*>::iterator, bool> pair = this->range_.insert(entity); return pair.second; }
-            bool removeFromRange(WorldEntity* entity)
+            /**
+            @brief Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
+            @param entity A pointer ot the entity.
+            @return Returns true if successful.
+            */
+            inline bool removeFromRange(WorldEntity* entity)
                 { return this->range_.erase(entity) > 0; }
                 
         private:
-            float distance_;
-            std::set<WorldEntity*> range_;
+            float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
+            std::set<WorldEntity*> range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
         
     };
Index: /code/trunk/src/modules/objects/triggers/MultiTrigger.cc
===================================================================
--- /code/trunk/src/modules/objects/triggers/MultiTrigger.cc	(revision 6856)
+++ /code/trunk/src/modules/objects/triggers/MultiTrigger.cc	(revision 6857)
@@ -108,5 +108,5 @@
         XMLPortParam(MultiTrigger, "invert", setInvert, getInvert, xmlelement, mode);
         XMLPortParamTemplate(MultiTrigger, "mode", setMode, getModeString, xmlelement, mode, const std::string&);
-        XMLPortParamLoadOnly(MultiTrigger, "target", addTargets, xmlelement, mode).defaultValues("ControllableEntity"); //TODO: Remove load only
+        XMLPortParamLoadOnly(MultiTrigger, "target", addTargets, xmlelement, mode).defaultValues("Pawn"); //TODO: Remove load only
 
         //TODO: Maybe nicer with explicit subgroup, e.g. triggers
Index: /code/trunk/src/modules/objects/triggers/MultiTrigger.h
===================================================================
--- /code/trunk/src/modules/objects/triggers/MultiTrigger.h	(revision 6856)
+++ /code/trunk/src/modules/objects/triggers/MultiTrigger.h	(revision 6857)
@@ -82,5 +82,5 @@
             'simultaniousTriggerers':   The number of simultanious triggerers limits the number of object that are allowed to trigger the MultiTrigger at the same time. Or a little more precisely, the number of distinct objects the MultiTrigger has 'triggered' states for, at each point in time.
             'mode':                     The mode describes how the MultiTrigger acts in relation to all the MultiTriggers, that are appended to it. There are 3 modes: 'and', meaning that the MultiTrigger can only be triggered if all the appended MultiTriggers are active. 'or', meaning that the MultiTrigger can only triggered if at least one of the appendend MultiTriggers is active. And 'xor', meaning that the MultiTrigger can only be triggered if one and only one appended MultiTrigger is active. Notice, that I wrote 'can only be active', that implies, that there is an addtitional condition to the activity of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the activity of a MultiTrigger is still coupled to the object that triggered it. The default is 'and'.
-            'target':                   The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is 'ControllableEntity'.
+            'target':                   The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is 'Pawn'.
             Also there is the possibility of appending MultiTriggers to the MultiTrigger just by adding them as subobjects in the XML description of your MultiTrigger.
 
