Index: code/trunk/src/modules/objects/ForceField.cc
===================================================================
--- code/trunk/src/modules/objects/ForceField.cc	(revision 9945)
+++ code/trunk/src/modules/objects/ForceField.cc	(revision 11071)
@@ -67,5 +67,5 @@
         this->setMassDiameter(0);   //! We allow point-masses
         this->setLength(2000);
-        this->mode_ = forceFieldMode::tube;
+        this->mode_ = ForceFieldMode::tube;
         
         this->registerVariables();
@@ -115,8 +115,8 @@
     void ForceField::tick(float dt)
     {
-        if(this->mode_ == forceFieldMode::tube)
-        {
-            // Iterate over all objects that could possibly be affected by the ForceField.
-            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
+        if(this->mode_ == ForceFieldMode::tube)
+        {
+            // Iterate over all objects that could possibly be affected by the ForceField.
+            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
             {
                 // The direction of the orientation of the force field.
@@ -125,5 +125,5 @@
 
                 // Vector from the center of the force field to the object its acting on.
-                Vector3 distanceVector = it->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction));
+                Vector3 distanceVector = mobileEntity->getWorldPosition() - (this->getWorldPosition() + (this->halfLength_ * direction));
 
                 // The object is outside a ball around the center with radius length/2 of the ForceField.
@@ -132,5 +132,5 @@
 
                 // The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector)
-                float distanceFromDirectionVector = ((it->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();
+                float distanceFromDirectionVector = ((mobileEntity->getWorldPosition() - this->getWorldPosition()).crossProduct(direction)).length();
 
                 // If the object in a tube of radius 'radius' around the direction of orientation.
@@ -140,13 +140,13 @@
                 // Apply a force to the object in the direction of the orientation.
                 // The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius.
-                it->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);
-            }
-        }
-        else if(this->mode_ == forceFieldMode::sphere)
-        {
-            // Iterate over all objects that could possibly be affected by the ForceField.
-            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
-            {
-                Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
+                mobileEntity->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);
+            }
+        }
+        else if(this->mode_ == ForceFieldMode::sphere)
+        {
+            // Iterate over all objects that could possibly be affected by the ForceField.
+            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
+            {
+                Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition();
                 float distance = distanceVector.length();
                 // If the object is within 'radius' distance.
@@ -155,14 +155,14 @@
                     distanceVector.normalise();
                     // Apply a force proportional to the velocity, with highest force at the origin of the sphere, linear decreasing until reaching a distance of 'radius' from the origin, where the force reaches zero. 
-                    it->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector);
-                }
-            }
-        }
-        else if(this->mode_ == forceFieldMode::invertedSphere)
-        {
-            // Iterate over all objects that could possibly be affected by the ForceField.
-            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
-            {
-                Vector3 distanceVector = this->getWorldPosition() - it->getWorldPosition();
+                    mobileEntity->applyCentralForce((this->radius_ - distance)/this->radius_ * this->velocity_ * distanceVector);
+                }
+            }
+        }
+        else if(this->mode_ == ForceFieldMode::invertedSphere)
+        {
+            // Iterate over all objects that could possibly be affected by the ForceField.
+            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
+            {
+                Vector3 distanceVector = this->getWorldPosition() - mobileEntity->getWorldPosition();
                 float distance = distanceVector.length();
                 // If the object is within 'radius' distance and no more than 'length' away from the boundary of the sphere.
@@ -172,14 +172,14 @@
                     distanceVector.normalise();
                     // Apply a force proportional to the velocity, with highest force at the boundary of the sphere, linear decreasing until reaching a distance of 'radius-length' from the origin, where the force reaches zero.
-                    it->applyCentralForce((distance-range)/range * this->velocity_ * distanceVector);
-                }
-            }
-        }
-        else if(this->mode_ == forceFieldMode::newtonianGravity)
-        {
-            // Iterate over all objects that could possibly be affected by the ForceField.
-            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
-            {
-                Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
+                    mobileEntity->applyCentralForce((distance-range)/range * this->velocity_ * distanceVector);
+                }
+            }
+        }
+        else if(this->mode_ == ForceFieldMode::newtonianGravity)
+        {
+            // Iterate over all objects that could possibly be affected by the ForceField.
+            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
+            {
+                Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition();
                 float distance = distanceVector.length();
                 // If the object is within 'radius' distance and especially further away than massRadius_
@@ -197,14 +197,14 @@
                     
                     // Note: this so called force is actually an acceleration!
-                    it->applyCentralForce((-1) * (ForceField::attenFactor_ * ForceField::gravConstant_ * this->getMass()) / (distance * distance) * distanceVector);
-                }
-            }
-        }
-        else if(this->mode_ == forceFieldMode::homogen)
-        {
-            // Iterate over all objects that could possibly be affected by the ForceField.
-            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
-            {
-                Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
+                    mobileEntity->applyCentralForce((-1) * (ForceField::attenFactor_ * ForceField::gravConstant_ * this->getMass()) / (distance * distance) * distanceVector);
+                }
+            }
+        }
+        else if(this->mode_ == ForceFieldMode::homogen)
+        {
+            // Iterate over all objects that could possibly be affected by the ForceField.
+            for (MobileEntity* mobileEntity : ObjectList<MobileEntity>())
+            {
+                Vector3 distanceVector = mobileEntity->getWorldPosition() - this->getWorldPosition();
                 float distance = distanceVector.length();
                 if (distance < this->radius_ && distance > this->massRadius_)
@@ -212,5 +212,5 @@
                     // Add a Acceleration in forceDirection_.
                     // Vector3(0,0,0) is the direction, where the force should work.
-                    it->addAcceleration(forceDirection_ , Vector3(0,0,0));
+                    mobileEntity->addAcceleration(forceDirection_ , Vector3(0,0,0));
                 }
             }
@@ -227,19 +227,19 @@
     {
         if(mode == ForceField::modeTube_s)
-            this->mode_ = forceFieldMode::tube;
+            this->mode_ = ForceFieldMode::tube;
         else if(mode == ForceField::modeSphere_s)
-            this->mode_ = forceFieldMode::sphere;
+            this->mode_ = ForceFieldMode::sphere;
         else if(mode == ForceField::modeInvertedSphere_s)
-            this->mode_ = forceFieldMode::invertedSphere;
+            this->mode_ = ForceFieldMode::invertedSphere;
         else if(mode == ForceField::modeNewtonianGravity_s)
-            this->mode_ = forceFieldMode::newtonianGravity;
+            this->mode_ = ForceFieldMode::newtonianGravity;
 
         else if(mode == ForceField::modeHomogen_s)
-            this->mode_ = forceFieldMode::homogen;
+            this->mode_ = ForceFieldMode::homogen;
 
         else
         {
             orxout(internal_warning) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << endl;
-            this->mode_ = forceFieldMode::tube;
+            this->mode_ = ForceFieldMode::tube;
         }
     }
@@ -255,14 +255,14 @@
         switch(this->mode_)
         {
-            case forceFieldMode::tube:
+            case ForceFieldMode::tube:
                 return ForceField::modeTube_s;
-            case forceFieldMode::sphere:
+            case ForceFieldMode::sphere:
                 return ForceField::modeSphere_s;
-            case forceFieldMode::invertedSphere:
+            case ForceFieldMode::invertedSphere:
                 return ForceField::modeInvertedSphere_s;
-            case forceFieldMode::newtonianGravity:
+            case ForceFieldMode::newtonianGravity:
                 return ForceField::modeNewtonianGravity_s;
 
-            case forceFieldMode::homogen:
+            case ForceFieldMode::homogen:
                 return ForceField::modeHomogen_s;
 
