Index: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 10624)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 11071)
@@ -65,8 +65,8 @@
     GSLevel::GSLevel(const GameStateInfo& info)
         : GameState(info)
-        , gameInputState_(0)
-        , guiMouseOnlyInputState_(0)
-        , guiKeysOnlyInputState_(0)
-        , startFile_(0)
+        , gameInputState_(nullptr)
+        , guiMouseOnlyInputState_(nullptr)
+        , guiKeysOnlyInputState_(nullptr)
+        , startFile_(nullptr)
         , bShowIngameGUI_(false)
     {
@@ -143,7 +143,7 @@
 #endif
 
-            gameInputState_->setHandler(0);
-            guiMouseOnlyInputState_->setHandler(0);
-            guiKeysOnlyInputState_->setHandler(0);
+            gameInputState_->setHandler(nullptr);
+            guiMouseOnlyInputState_->setHandler(nullptr);
+            guiKeysOnlyInputState_->setHandler(nullptr);
             InputManager::getInstance().destroyState("game");
             InputManager::getInstance().destroyState("guiKeysOnly");
@@ -156,5 +156,5 @@
         {
             ModifyConsoleCommand(__CC_changeGame_name).deactivate();
-            ModifyConsoleCommand(__CC_reloadLevel_name).setObject(NULL).deactivate();
+            ModifyConsoleCommand(__CC_reloadLevel_name).setObject(nullptr).deactivate();
         }
     }
@@ -164,12 +164,12 @@
         // Note: Temporarily moved to GSRoot.
         //// Call the scene objects
-        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
-        //    it->tick(time.getDeltaTime() * this->timeFactor_);
+        //for (Tickable* tickable : ObjectList<Tickable>())
+        //    tickable->tick(time.getDeltaTime() * this->timeFactor_);
     }
 
     void GSLevel::prepareObjectTracking()
     {
-        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
-            this->staticObjects_.insert(*it);
+        for (BaseObject* baseObject : ObjectList<BaseObject>())
+            this->staticObjects_.insert(baseObject);
     }
 
@@ -178,10 +178,10 @@
         orxout(internal_info) << "Remaining objects:" << endl;
         unsigned int i = 0;
-        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
-        {
-            std::set<BaseObject*>::const_iterator find = this->staticObjects_.find(*it);
+        for (BaseObject* baseObject : ObjectList<BaseObject>())
+        {
+            std::set<BaseObject*>::const_iterator find = this->staticObjects_.find(baseObject);
             if (find == this->staticObjects_.end())
             {
-                orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
+                orxout(internal_warning) << ++i << ": " << baseObject->getIdentifier()->getName() << " (" << baseObject << "), references: " << baseObject->getReferenceCount() << endl;
             }
         }
@@ -215,12 +215,15 @@
     void GSLevel::unloadLevelAsClient()
     {
-        for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); )
+        ObjectList<Level> listLevel;
+        for (ObjectList<Level>::iterator it = listLevel.begin(); it != listLevel.end(); )
         {
             StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it
-            for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); )
+            ObjectList<BaseObject> listBaseObject(level);
+            for (ObjectList<BaseObject>::iterator it = listBaseObject.begin(); it != listBaseObject.end(); )
                 (it++)->destroy();
         }
 
-        for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); )
+        ObjectList<Synchronisable> listSynchronisable;
+        for (ObjectList<Synchronisable>::iterator it = listSynchronisable.begin(); it != listSynchronisable.end(); )
         {
             if (it->getSyncMode() != 0x0)
@@ -235,7 +238,7 @@
         // export all states
         std::vector<GSLevelMementoState*> states;
-        for (ObjectList<GSLevelMemento>::iterator it = ObjectList<GSLevelMemento>::begin(); it != ObjectList<GSLevelMemento>::end(); ++it)
-        {
-            GSLevelMementoState* state = it->exportMementoState();
+        for (GSLevelMemento* memento : ObjectList<GSLevelMemento>())
+        {
+            GSLevelMementoState* state = memento->exportMementoState();
             if (state)
                 states.push_back(state);
@@ -247,10 +250,10 @@
 
         // import all states
-        for (ObjectList<GSLevelMemento>::iterator it = ObjectList<GSLevelMemento>::begin(); it != ObjectList<GSLevelMemento>::end(); ++it)
-            it->importMementoState(states);
+        for (GSLevelMemento* memento : ObjectList<GSLevelMemento>())
+            memento->importMementoState(states);
 
         // delete states
-        for (size_t i = 0; i < states.size(); ++i)
-            delete states[i];
+        for (GSLevelMementoState* state : states)
+            delete state;
     }
 
