Index: code/branches/input/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/input/src/orxonox/Orxonox.cc	(revision 899)
+++ code/branches/input/src/orxonox/Orxonox.cc	(revision 900)
@@ -44,4 +44,6 @@
 #include <OgreOverlay.h>
 #include <OgreOverlayManager.h>
+#include <OgreTimer.h>
+#include <OgreWindowEventUtilities.h>
 
 //****** OIS *******
@@ -140,4 +142,6 @@
     this->frameListener_ = 0;
     this->root_ = 0;
+    // turn frame smoothing on by setting a value different from 0
+    this->frameSmoothingTime_ = 0.1f;
   }
 
@@ -368,8 +372,4 @@
   }
 
-  /**
-   *
-   * @param
-   */
   void Orxonox::createScene(void)
   {
@@ -386,8 +386,8 @@
 
     Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
-    HUD* orxonoxHud;
-    orxonoxHud = new HUD();
-    orxonoxHud->setEnergyValue(20);
-    orxonoxHud->setEnergyDistr(20,20,60);
+    //HUD* orxonoxHud;
+    orxonoxHUD_ = new HUD();
+    orxonoxHUD_->setEnergyValue(20);
+    orxonoxHUD_->setEnergyDistr(20,20,60);
     hudOverlay->show();
 
@@ -401,7 +401,4 @@
 
 
-  /**
-   *
-   */
   void Orxonox::setupScene()
   {
@@ -454,9 +451,9 @@
   void Orxonox::createFrameListener()
   {
-    TickFrameListener* TickFL = new TickFrameListener();
-    ogre_->getRoot()->addFrameListener(TickFL);
-
-    TimerFrameListener* TimerFL = new TimerFrameListener();
-    ogre_->getRoot()->addFrameListener(TimerFL);
+    //TickFrameListener* TickFL = new TickFrameListener();
+    //ogre_->getRoot()->addFrameListener(TickFL);
+
+    //TimerFrameListener* TimerFL = new TimerFrameListener();
+    //ogre_->getRoot()->addFrameListener(TimerFL);
 
     //if(mode_!=CLIENT) // FIXME just a hack ------- remove this in future
@@ -480,5 +477,150 @@
       ms.height = height;
     }
-    ogre_->getRoot()->startRendering();
+    //ogre_->getRoot()->startRendering();
+    mainLoop();
+  }
+
+  /**
+    Main loop of the orxonox game.
+    This is a new solution, using the ogre engine instead of beeing used by it.
+    An alternative solution would be to simply use the timer of the Root object,
+    but that implies using Ogre in any case. There would be no way to test
+    our code without the help of the root object.
+    There's even a chance that we can dispose of the root object entirely
+    in server mode.
+    About the loop: The design is almost exactly like the one in ogre, so that
+    if any part of ogre registers a framelisteners, it will still behave
+    correctly. Furthermore I have taken over the time smoothing feature from
+    ogre. If turned on (see orxonox constructor), it will calculate the dt_n by
+    means of the recent most dt_n-1, dt_n-2, etc.
+  */
+  void Orxonox::mainLoop()
+  {
+    // use the ogre timer class to measure time.
+    Ogre::Timer *timer = new Ogre::Timer();
+    timer->reset();
+
+    // Contains the times of recently fired events
+    std::deque<unsigned long> eventTimes[3];
+    // Clear event times
+    for (int i = 0; i < 3; ++i)
+      eventTimes[i].clear();
+
+	  while (true)
+	  {
+		  //Pump messages in all registered RenderWindows
+      Ogre::WindowEventUtilities::messagePump();
+
+      // get current time
+      unsigned long now = timer->getMilliseconds();
+
+      // create an event to pass to the frameStarted method in ogre
+      Ogre::FrameEvent evt;
+      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
+      evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]);
+
+      // show the current time in the HUD
+      orxonoxHUD_->setTime((int)now, 0);
+
+      // don't forget to call _fireFrameStarted in ogre to make sure
+      // everything goes smoothly
+      if (!ogre_->getRoot()->_fireFrameStarted(evt))
+        break;
+
+      // Iterate through all Tickables and call their tick(dt) function
+      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
+        (it++)->tick((float)evt.timeSinceLastFrame);
+
+      // Update the timers
+      updateTimers((float)evt.timeSinceLastFrame);
+
+      if (mode_ != SERVER)
+      {
+        // only render in non-server mode
+        ogre_->getRoot()->_updateAllRenderTargets();
+      }
+
+      // get current time
+      now = timer->getMilliseconds();
+
+      // create an event to pass to the frameEnded method in ogre
+      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
+      evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[2]);
+
+      // again, just to be sure ogre works fine
+      if (!ogre_->getRoot()->_fireFrameEnded(evt))
+        break;
+	  }
+  }
+
+  /**
+    Timer updater function.
+    Updates all timers with the current dt.
+    Timers have been tested since their displacement.
+    @param dt The delta time
+  */
+  void Orxonox::updateTimers(float dt)
+  {
+    // Iterate through all Timers
+    for (Iterator<TimerBase> it = ObjectList<TimerBase>::start(); it; )
+    {
+      if (it->isActive())
+      {
+        // If active: Decrease the timer by the duration of the last frame
+        it->time_ -= dt;
+
+        if (it->time_ <= 0)
+        {
+          // It's time to call the function
+          if (it->bLoop_)
+            it->time_ += it->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
+          else
+            it->stopTimer(); // Stop the timer if we don't want to loop
+
+          (it++)->run();
+        }
+        else
+        ++it;
+      }
+      else
+      ++it;
+    }
+
+  }
+  /**
+    Method for calculating the average time between recently fired events.
+    Code directly taken from OgreRoot.cc
+    @param now The current time in ms.
+    @param type The type of event to be considered.
+  */
+  float Orxonox::calculateEventTime(unsigned long now, std::deque<unsigned long> &times)
+  {
+    // Calculate the average time passed between events of the given type
+    // during the last mFrameSmoothingTime seconds.
+
+    times.push_back(now);
+
+    if(times.size() == 1)
+      return 0;
+
+    // Times up to mFrameSmoothingTime seconds old should be kept
+    unsigned long discardThreshold =
+      static_cast<unsigned long>(frameSmoothingTime_ * 1000.0f);
+
+    // Find the oldest time to keep
+    std::deque<unsigned long>::iterator it = times.begin(),
+      end = times.end()-2; // We need at least two times
+    while(it != end)
+    {
+      if (now - *it > discardThreshold)
+        ++it;
+      else
+        break;
+    }
+
+    // Remove old times
+    times.erase(times.begin(), it);
+
+    return (float)(times.back() - times.front()) / ((times.size()-1) * 1000);
   }
 }
Index: code/branches/input/src/orxonox/Orxonox.h
===================================================================
--- code/branches/input/src/orxonox/Orxonox.h	(revision 899)
+++ code/branches/input/src/orxonox/Orxonox.h	(revision 900)
@@ -9,4 +9,5 @@
 
 #include <string>
+#include <deque>
 
 #include <OgrePrerequisites.h>
@@ -65,4 +66,7 @@
       void createFrameListener();
       void startRenderLoop();
+      void mainLoop();
+      void updateTimers(float);
+      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
 
     private:
@@ -78,4 +82,8 @@
       OrxListener*          frameListener_;
       Ogre::Root*           root_;
+      // TODO: make this a config-value by creating a config class for orxonox
+      float                 frameSmoothingTime_;
+      // little hack to actually show something dynamic in the HUD
+      HUD*                  orxonoxHUD_;
 
       // this is used to identify the mode (server/client/...) we're in
Index: code/branches/input/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- code/branches/input/src/orxonox/OrxonoxStableHeaders.h	(revision 899)
+++ code/branches/input/src/orxonox/OrxonoxStableHeaders.h	(revision 900)
@@ -73,8 +73,10 @@
 //#include "audio/AudioManager.h"
 
-//#include "core/CoreIncludes.h"
+#include "core/CoreIncludes.h"
 #include "core/BaseObject.h"
 //#include "core/ArgReader.h"
 #include "core/Error.h"
+#include "core/Loader.h"
+#include "core/XMLPort.h"
 
 #include "network/Synchronisable.h"
Index: code/branches/input/src/orxonox/objects/Tickable.h
===================================================================
--- code/branches/input/src/orxonox/objects/Tickable.h	(revision 899)
+++ code/branches/input/src/orxonox/objects/Tickable.h	(revision 900)
@@ -35,5 +35,5 @@
     Attention:
     Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
-    parent::tick(dt) function explicit in their implementation of tick(dt) because it's a virtual function.
+    parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
 */
 
@@ -48,5 +48,5 @@
 namespace orxonox
 {
-    class TickFrameListener; // Forward declaration
+    //class TickFrameListener; // Forward declaration
 
     //! The Tickable interface provides a tick(dt) function, that gets called every frame.
@@ -64,4 +64,5 @@
     };
 
+#if 0
     //! The TickFrameListener calls the tick(dt) function of all Tickables every frame.
     class _OrxonoxExport TickFrameListener : public Ogre::FrameListener
@@ -78,4 +79,5 @@
             }
     };
+#endif
 }
 
Index: code/branches/input/src/orxonox/tools/Timer.h
===================================================================
--- code/branches/input/src/orxonox/tools/Timer.h	(revision 899)
+++ code/branches/input/src/orxonox/tools/Timer.h	(revision 900)
@@ -66,5 +66,6 @@
     class _OrxonoxExport TimerBase : public OrxonoxClass
     {
-        friend class TimerFrameListener;
+        //friend class TimerFrameListener;
+        friend class Orxonox;
 
         public:
@@ -145,4 +146,5 @@
     };
 
+#if 0
     //! The TimerFrameListener manages all Timers in the game.
     class TimerFrameListener : public Ogre::FrameListener
@@ -180,4 +182,5 @@
             }
     };
+#endif
 }
 
Index: code/branches/input/visual_studio/base_properties.vsprops
===================================================================
--- code/branches/input/visual_studio/base_properties.vsprops	(revision 899)
+++ code/branches/input/visual_studio/base_properties.vsprops	(revision 900)
@@ -33,5 +33,5 @@
 	<UserMacro
 		Name="DependencyDir"
-		Value="$(RootDir)dependencies\"
+		Value="D:\orxonox\dependencies\orxonox\"
 	/>
 	<UserMacro
