Index: code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc	(revision 2344)
+++ code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc	(revision 2400)
@@ -32,4 +32,5 @@
 #include "util/Exception.h"
 #include "util/Debug.h"
+#include "core/Core.h"
 #include "core/Factory.h"
 #include "core/ConfigValueIncludes.h"
@@ -43,4 +44,6 @@
 #include "tools/Timer.h"
 #include "objects/Tickable.h"
+#include "objects/worldentities/Backlight.h"
+#include "tools/ParticleInterface.h"
 #include "Settings.h"
 
@@ -67,4 +70,5 @@
     GSRoot::GSRoot()
         : RootGameState("root")
+        , timeFactor_(1.0f)
         , settings_(0)
         , tclBind_(0)
@@ -74,4 +78,6 @@
         RegisterRootObject(GSRoot);
         setConfigValues();
+
+        this->ccSetTimeFactor_ = 0;
     }
 
@@ -88,4 +94,7 @@
         // creates the class hierarchy for all classes with factories
         Factory::createClassHierarchy();
+
+        // reset game speed to normal
+        timeFactor_ = 1.0f;
 
         // Create the lua interface
@@ -129,4 +138,10 @@
         ccSelectGameState_ = createConsoleCommand(functor2, "selectGameState");
         CommandExecutor::addConsoleCommandShortcut(ccSelectGameState_);
+
+        // time factor console command
+        FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor);
+        functor->setObject(this);
+        ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor");
+        CommandExecutor::addConsoleCommandShortcut(ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
     }
 
@@ -143,4 +158,10 @@
         delete this->settings_;
         delete this->luaBind_;
+
+        if (this->ccSetTimeFactor_)
+        {
+            delete this->ccSetTimeFactor_;
+            this->ccSetTimeFactor_ = 0;
+        }
     }
 
@@ -155,5 +176,5 @@
         // Call the Tickable objects
         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
-            it->tick(time.getDeltaTime());
+            it->tick(time.getDeltaTime() * this->timeFactor_);
         /*** HACK *** HACK ***/
 
@@ -168,5 +189,5 @@
 
         Copyright (c) 2000-2008 Torus Knot Software Ltd
-        
+
         OGRE is licensed under the LGPL. For more info, see OGRE license.
     */
@@ -175,16 +196,16 @@
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
         // Get the current process core mask
-	    DWORD procMask;
-	    DWORD sysMask;
+        DWORD procMask;
+        DWORD sysMask;
 #  if _MSC_VER >= 1400 && defined (_M_X64)
-	    GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
+        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
 #  else
-	    GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
-#  endif
-
-	    // If procMask is 0, consider there is only one core available
-	    // (using 0 as procMask will cause an infinite loop below)
-	    if (procMask == 0)
-		    procMask = 1;
+        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
+#  endif
+
+        // If procMask is 0, consider there is only one core available
+        // (using 0 as procMask will cause an infinite loop below)
+        if (procMask == 0)
+            procMask = 1;
 
         // if the core specified with limitToCPU is not available, take the lowest one
@@ -192,12 +213,33 @@
             limitToCPU = 0;
 
-	    // Find the lowest core that this process uses and limitToCPU suggests
+        // Find the lowest core that this process uses and limitToCPU suggests
         DWORD threadMask = 1;
-	    while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
-		    threadMask <<= 1;
-
-	    // Set affinity to the first core
-	    SetThreadAffinityMask(GetCurrentThread(), threadMask);
+        while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
+            threadMask <<= 1;
+
+        // Set affinity to the first core
+        SetThreadAffinityMask(GetCurrentThread(), threadMask);
 #endif
     }
+
+    /**
+    @brief
+        Changes the speed of Orxonox
+    */
+    void GSRoot::setTimeFactor(float factor)
+    {
+        if (Core::isMaster())
+        {
+            float change = factor / this->timeFactor_;
+
+            this->timeFactor_ = factor;
+/*
+            for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it != ObjectList<ParticleInterface>::end(); ++it)
+                it->setSpeedFactor(it->getSpeedFactor() * change);
+
+            for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it != ObjectList<Backlight>::end(); ++it)
+                it->setTimeFactor(timeFactor_);
+*/
+        }
+    }
 }
