Index: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	(revision 978)
+++ code/trunk/src/orxonox/CMakeLists.txt	(revision 1021)
@@ -1,8 +1,9 @@
 SET( ORXONOX_SRC_FILES
   GraphicsEngine.cc
+  InputEventListener.cc
+  InputHandler.cc
   Main.cc
   Orxonox.cc
-  objects/Tickable.cc
-  SpaceshipSteering.cc
+#  SpaceshipSteering.cc
   hud/HUD.cc
   particle/ParticleInterface.cc
Index: code/trunk/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/trunk/src/orxonox/GraphicsEngine.cc	(revision 978)
+++ code/trunk/src/orxonox/GraphicsEngine.cc	(revision 1021)
@@ -33,7 +33,10 @@
 
 #include <OgreRoot.h>
+#include <OgreException.h>
 #include <OgreConfigFile.h>
 #include <OgreTextureManager.h>
+#include <OgreRenderWindow.h>
 
+#include "core/CoreIncludes.h"
 #include "core/Debug.h"
 #include "GraphicsEngine.h"
@@ -46,8 +49,12 @@
   GraphicsEngine::GraphicsEngine()
   {
+    RegisterObject(GraphicsEngine);
+    //this->bOverwritePath_ = false;
+    this->setConfigValues();
     // set to standard values
     this->configPath_ = "";
-    this->dataPath_ = "";
-    scene_ = NULL;
+    this->root_ = 0;
+    this->scene_ = 0;
+    this->renderWindow_ = 0;
   }
 
@@ -55,4 +62,12 @@
   GraphicsEngine::~GraphicsEngine()
   {
+    if (!this->root_)
+      delete this->root_;
+  }
+
+  void GraphicsEngine::setConfigValues()
+  {
+    SetConfigValue(dataPath_, dataPath_).description("relative path to media data");
+
   }
 
@@ -66,5 +81,5 @@
     root_ = new Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
 #endif*/
-#if defined(_DEBUG) && defined(WIN32)
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(_DEBUG)
     std::string plugin_filename = "plugins_d.cfg";
 #else
@@ -87,6 +102,9 @@
   }
 
-  bool GraphicsEngine::load()
+  bool GraphicsEngine::load(std::string dataPath)
   {
+    // temporary overwrite of dataPath, change ini file for permanent change
+    if( dataPath != "" )
+      dataPath_ = dataPath;
     loadRessourceLocations(this->dataPath_);
     if (!root_->restoreConfig() && !root_->showConfigDialog())
@@ -95,8 +113,9 @@
   }
 
-  void GraphicsEngine::startRender()
+  void GraphicsEngine::initialise()
   {
-    root_->initialise(true, "OrxonoxV2");
+    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
     TextureManager::getSingleton().setDefaultNumMipmaps(5);
+    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
     ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
   }
@@ -131,4 +150,49 @@
   }
 
+  /**
+    Returns the window handle of the render window.
+    At least the InputHandler uses this to create the OIS::InputManager
+    @return The window handle of the render window
+  */
+  size_t GraphicsEngine::getWindowHandle()
+  {
+    if (this->renderWindow_)
+    {
+      Ogre::RenderWindow *renderWindow = this->root_->getAutoCreatedWindow();
+      size_t windowHnd = 0;
+      renderWindow->getCustomAttribute("WINDOW", &windowHnd);
+      return windowHnd;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    Get the width of the current render window
+    @return The width of the current render window
+  */
+  int GraphicsEngine::getWindowWidth() const
+  {
+    if (this->renderWindow_)
+    {
+      return this->renderWindow_->getWidth();
+    }
+    else
+      return 0;
+  }
+
+  /**
+    Get the height of the current render window
+    @return The height of the current render window
+  */
+  int GraphicsEngine::getWindowHeight() const
+  {
+    if (this->renderWindow_)
+    {
+      return this->renderWindow_->getHeight();
+    }
+    else
+      return 0;
+  }
 
 }
Index: code/trunk/src/orxonox/GraphicsEngine.h
===================================================================
--- code/trunk/src/orxonox/GraphicsEngine.h	(revision 978)
+++ code/trunk/src/orxonox/GraphicsEngine.h	(revision 1021)
@@ -10,8 +10,10 @@
 #include <string>
 
+#include <OgrePrerequisites.h>
 #include <OgreRoot.h>
 #include <OgreSceneManager.h>
 
 #include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
 
 
@@ -21,17 +23,34 @@
    * graphics engine manager class
  */
-  class _OrxonoxExport GraphicsEngine {
+  class _OrxonoxExport GraphicsEngine : public OrxonoxClass
+  {
     public:
       GraphicsEngine();
       inline void setConfigPath(std::string path) { this->configPath_ = path; };
       // find a better way for this
-      inline Ogre::Root* getRoot() { return root_; };
+      //inline Ogre::Root* getRoot() { return root_; };
+      void setConfigValues();
       void setup();
-      bool load();
+      bool load(std::string path);
       void loadRessourceLocations(std::string path);
       Ogre::SceneManager* getSceneManager();
-      void startRender();
+      void initialise();
+
+      // several window properties
+      Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
+      size_t getWindowHandle();
+      int getWindowWidth() const;
+      int getWindowHeight() const;
+
+      // Ogre Root access for Orxonox
+      void frameStarted(Ogre::FrameEvent &evt)
+      { if (root_) root_->_fireFrameStarted(evt); }
+      void frameEnded  (Ogre::FrameEvent &evt)
+      { if (root_) root_->_fireFrameEnded(evt);   }
+      void renderOneFrame()
+      { if (root_) root_->_updateAllRenderTargets(); }
 
       virtual ~GraphicsEngine();
+
     private:
       Ogre::Root*         root_;        //!< Ogre's root
@@ -39,4 +58,6 @@
       std::string         dataPath_;    //!< path to data file
       Ogre::SceneManager* scene_;       //!< scene manager of the game
+      Ogre::RenderWindow* renderWindow_;//!< the current render window
+      //bool               bOverwritePath_; //!< overwrites path
 
   };
Index: code/trunk/src/orxonox/InputEvent.h
===================================================================
--- code/trunk/src/orxonox/InputEvent.h	(revision 1021)
+++ code/trunk/src/orxonox/InputEvent.h	(revision 1021)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief InputEvent Structure declaration
+ */
+
+#ifndef _InputEvent_H__
+#define _InputEvent_H__
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+  /**
+    @brief Interface that any class can use to get key independent input.
+  */
+  struct InputEvent
+  {
+    unsigned char id;      //!< Event ID
+    bool bStarted;         //!< Tells whether the Event started or ended (e.g. firing started)
+    int data1, data2;      //!< Two additional integer datafields, for instance for the mouse moved event
+    void* dataRef;         //!< Additional pointer to any further data
+  };
+}
+
+#endif /* _InputEvent_H__ */
Index: code/trunk/src/orxonox/InputEventListener.cc
===================================================================
--- code/trunk/src/orxonox/InputEventListener.cc	(revision 1021)
+++ code/trunk/src/orxonox/InputEventListener.cc	(revision 1021)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Some guy writing the example code from Ogre
+ *
+ */
+
+/**
+ @file
+ @brief Core relevant parts of InputEventListener
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "core/CoreIncludes.h"
+#include "InputEventListener.h"
+
+namespace orxonox
+{
+  /**
+    @brief standard constructor
+  */
+  InputEventListener::InputEventListener()
+  {
+    RegisterRootObject(InputEventListener);
+    this->bActive_ = true;
+  }
+
+  InputEventListener::~InputEventListener()
+  {
+  }
+
+}
Index: code/trunk/src/orxonox/InputEventListener.h
===================================================================
--- code/trunk/src/orxonox/InputEventListener.h	(revision 1021)
+++ code/trunk/src/orxonox/InputEventListener.h	(revision 1021)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief InputEventListener Interface declaration
+ */
+
+#ifndef _InputEventListener_H__
+#define _InputEventListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+#include "InputEvent.h"
+
+namespace orxonox
+{
+  /**
+    @brief Interface that any class can use to get key independent input.
+  */
+  class _OrxonoxExport InputEventListener : virtual public OrxonoxClass
+  {
+    friend class InputHandler;
+  public:
+    InputEventListener();
+    virtual ~InputEventListener();
+    /** Method is called every time an Input event occurs && bActive */
+    virtual void eventOccured(InputEvent &evt) = 0;
+
+  private:
+    bool bActive_;
+  };
+}
+
+#endif /* _InputEventListener_H__ */
Index: code/trunk/src/orxonox/InputHandler.cc
===================================================================
--- code/trunk/src/orxonox/InputHandler.cc	(revision 1021)
+++ code/trunk/src/orxonox/InputHandler.cc	(revision 1021)
@@ -0,0 +1,272 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of a little Input handler that distributes everything
+        coming from OIS.
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Debug.h"
+#include "Orxonox.h"
+#include "InputEventListener.h"
+#include "InputHandler.h"
+
+namespace orxonox
+{
+  /**
+    @brief The reference to the singleton
+  */
+  InputHandler* InputHandler::singletonRef_s = 0;
+
+  /**
+    @brief Constructor only resets the pointer values to 0.
+  */
+  InputHandler::InputHandler() :
+      mouse_(0), keyboard_(0), inputSystem_(0)
+  {
+    //RegisterObject(InputHandler);
+  }
+
+  /**
+    @brief Destructor only called at the end of the program
+  */
+  InputHandler::~InputHandler()
+  {
+  }
+
+  /**
+    @brief The one instance of the InputHandler is stored in this function.
+    @return The pointer to the only instance of the InputHandler
+  */
+  InputHandler *InputHandler::getSingleton()
+  {
+    if (!singletonRef_s)
+      singletonRef_s = new InputHandler();
+    return singletonRef_s;
+    //static InputHandler theOnlyInstance;
+    //return &theOnlyInstance;
+  }
+
+  /**
+    @brief Creates the OIS::InputMananger, the keyboard and the mouse and
+           assigns the key bindings.
+    @param windowHnd The window handle of the render window
+    @param windowWidth The width of the render window
+    @param windowHeight The height of the render window
+  */
+  bool InputHandler::initialise(size_t windowHnd, int windowWidth, int windowHeight)
+  {
+    if (!this->inputSystem_)
+    {
+      // Setup basic variables
+      OIS::ParamList paramList;
+      std::ostringstream windowHndStr;
+
+      // Fill parameter list
+      windowHndStr << (unsigned int)windowHnd;
+      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+
+#if defined OIS_LINUX_PLATFORM
+      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+#endif
+
+      try
+      {
+        // Create inputsystem
+        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+        //if (getSoftDebugLevel() >= ORX_DEBUG)
+        //  orxonox::OutputHandler::getOutStream().setOutputLevel(4) << "asdfblah" << std::endl;
+        COUT(ORX_DEBUG) << "*** InputHandler: Created OIS input system" << std::endl;
+
+        // If possible create a buffered keyboard
+        /*if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+        {*/
+          keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true));
+          keyboard_->setEventCallback(this);
+          COUT(ORX_DEBUG) << "*** InputHandler: Created OIS mouse" << std::endl;
+        //}
+
+        // If possible create a buffered mouse
+        /*if (inputSystem_->numMice() > 0 )
+        {*/
+          mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
+          mouse_->setEventCallback(this);
+          COUT(ORX_DEBUG) << "*** InputHandler: Created OIS keyboard" << std::endl;
+
+          // Set mouse region
+          this->setWindowExtents(windowWidth, windowHeight);
+        //}
+      }
+      catch (OIS::Exception ex)
+      {
+        // something went wrong with the initialisation
+        COUT(ORX_ERROR) << "Error: Failed creating an input system. Message: \"" << ex.eText << "\"" << std::endl;
+        this->inputSystem_ = 0;
+        return false;
+      }
+    }
+
+    COUT(ORX_DEBUG) << "*** InputHandler: Loading key bindings..." << std::endl;
+    // temporary solution: create event list
+    //InputEvent[] list = this->createEventList();
+    // load the key bindings
+    InputEvent empty = {0, false, 0, 0, 0};
+    for (int i = 0; i < this->numberOfKeys_; i++)
+      this->bindingsKeyPressed_[i] = empty;
+
+    //assign 'abort' to the escape key
+    this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1;
+    COUT(ORX_DEBUG) << "*** InputHandler: Loading done." << std::endl;
+
+    return true;
+  }
+
+  /**
+    @brief Destroys all the created input devices.
+  */
+  void InputHandler::destroyDevices()
+  {
+    COUT(ORX_DEBUG) << "*** InputHandler: Destroying InputHandler..." << std::endl;
+    if (this->mouse_)
+      this->inputSystem_->destroyInputObject(mouse_);
+    if (this->keyboard_)
+      this->inputSystem_->destroyInputObject(keyboard_);
+    if (this->inputSystem_)
+      OIS::InputManager::destroyInputSystem(this->inputSystem_);
+
+    this->mouse_         = 0;
+    this->keyboard_      = 0;
+    this->inputSystem_   = 0;
+    COUT(ORX_DEBUG) << "*** InputHandler: Destroying done." << std::endl;
+  }
+
+  /**
+    @brief Destroys the singleton.
+  */
+  void InputHandler::destroy()
+  {
+    if (singletonRef_s)
+      delete singletonRef_s;
+    singletonRef_s = 0;
+  }
+
+  /**
+    @brief Updates the InputHandler
+    @param dt Delta time
+  */
+  void InputHandler::tick(float dt)
+  {
+    // capture all the input. That calls the event handlers.
+    if (mouse_)
+      mouse_->capture();
+
+    if (keyboard_)
+      keyboard_->capture();
+  }
+
+  /**
+    @brief Adjusts the mouse window metrics.
+    This method has to be called every time the size of the window changes.
+    @param width The new width of the render window
+    @param height the new height of the render window
+  */
+  void InputHandler::setWindowExtents(int width, int height)
+  {
+    // Set mouse region (if window resizes, we should alter this to reflect as well)
+    const OIS::MouseState &mouseState = mouse_->getMouseState();
+    mouseState.width  = width;
+    mouseState.height = height;
+  }
+
+  /**
+    @brief Calls all the objects from classes that derive from InputEventListener.
+    @param evt The input event that occured.
+  */
+  inline void InputHandler::callListeners(orxonox::InputEvent &evt)
+  {
+    for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; )
+    {
+      if (it->bActive_)
+        (it++)->eventOccured(evt);
+      else
+        it++;
+    }
+  }
+
+  /**
+    @brief Event handler for the keyPressed Event.
+    @param e Event information
+  */
+  bool InputHandler::keyPressed(const OIS::KeyEvent &e)
+  {
+    callListeners(this->bindingsKeyPressed_[(int)e.key]);
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyReleased Event.
+    @param e Event information
+  */
+  bool InputHandler::keyReleased(const OIS::KeyEvent &e)
+  {
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Event information
+  */
+  bool InputHandler::mouseMoved(const OIS::MouseEvent &e)
+  {
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mousePressed Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseReleased Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    return true;
+  }
+
+}
Index: code/trunk/src/orxonox/InputHandler.h
===================================================================
--- code/trunk/src/orxonox/InputHandler.h	(revision 1021)
+++ code/trunk/src/orxonox/InputHandler.h	(revision 1021)
@@ -0,0 +1,108 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of a little Input handler that distributes everything
+        coming from OIS.
+ */
+
+#ifndef _InputHandler_H__
+#define _InputHandler_H__
+
+#include <OIS/OIS.h>
+
+#include "OrxonoxPrereqs.h"
+#include "core/Tickable.h"
+#include "InputEvent.h"
+
+namespace orxonox
+{
+  /**
+    @brief Captures and distributes mouse and keyboard input.
+    It resolves the key bindings to InputEvents which can be heard by
+    implementing the InputEventListener interface.
+  */
+  class _OrxonoxExport InputHandler
+        : public Tickable, public OIS::KeyListener, public OIS::MouseListener
+  {
+    //friend class ClassIdentifier<InputHandler>;
+  public:
+    bool initialise(size_t windowHnd, int windowWidth, int windowHeight);
+    void destroyDevices();
+    void tick(float dt);
+    void setWindowExtents(int width, int height);
+
+    // Temporary solutions. Will be removed soon!
+    OIS::Mouse    *getMouse()    { return this->mouse_   ; }
+    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
+
+    static InputHandler* getSingleton();
+    static void destroy();
+
+  private:
+    // don't mess with a Singleton
+    InputHandler ();
+    InputHandler (const InputHandler&);
+    InputHandler& operator=(const InputHandler& instance);
+    ~InputHandler();
+
+    void callListeners(InputEvent &evt);
+
+    // input events
+		bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+    bool mouseMoved   (const OIS::MouseEvent &arg);
+		bool keyPressed   (const OIS::KeyEvent   &arg);
+		bool keyReleased  (const OIS::KeyEvent   &arg);
+
+    OIS::InputManager *inputSystem_;    //!< OIS input manager
+    OIS::Keyboard     *keyboard_;       //!< OIS mouse
+    OIS::Mouse        *mouse_;          //!< OIS keyboard
+
+    /** denotes the maximum number of different keys there are in OIS.
+        256 should be ok since the highest number in the enum is 237. */
+    static const int numberOfKeys_ = 256;
+    //! Array of input events for every pressed key
+    InputEvent bindingsKeyPressed_[numberOfKeys_];
+    //! Array of input events for every released key
+    InputEvent bindingsKeyReleased_[numberOfKeys_];
+
+    /** denotes the maximum number of different buttons there are in OIS.
+        16 should be ok since the highest number in the enum is 7. */
+    static const int numberOfButtons_ = 16;
+    //! Array of input events for every pressed key
+    InputEvent bindingsButtonPressed_[numberOfButtons_];
+    //! Array of input events for every released key
+    InputEvent bindingsButtonReleased_[numberOfButtons_];
+
+    //! Pointer to the instance of the singleton
+    static InputHandler *singletonRef_s;
+  };
+}
+
+#endif /* _InputHandler_H__ */
Index: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc	(revision 978)
+++ code/trunk/src/orxonox/Main.cc	(revision 1021)
@@ -27,19 +27,18 @@
 
  /**
- @file  Main.cc
- @brief main file handling most of the machine specific code
+ @file
+ @brief Entry point of the program. Platform specific code.
   */
 
 #include "OrxonoxStableHeaders.h"
 
-#include <OgrePlatform.h>
-#include <OgreException.h>
+#include <exception>
 
-
+#include "OrxonoxPlatform.h"
 #include "core/SignalHandler.h"
 #include "Orxonox.h"
 
 using namespace orxonox;
-#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
 #include <CoreFoundation/CoreFoundation.h>
 
@@ -72,133 +71,23 @@
 #endif
 
-#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 && !defined( __MINGW32__ )
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include "windows.h"
-  INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)
-  {
-    // something like this would be less hacky
-    // maybe one can work with trailing '\0'
-    // or maybe use string based functions
-    // I was unable to test it without working windows version
-    char* cmd = strCmdLine;
-    int argc = 2;
-    int i;
-    int j;
-    for(i = 0; cmd[i] != NULL; i++)
-    {
-      if(cmd[i] == ' ') argc++;
-    }
-    char **argv = new char*[argc];
-    for (j = 0; j < argc; j++)
-    {
-      argv[j] = new char[i];
-    }
-    j = 1;
-    int k = 0;
-    for(int i = 0; cmd[i] != NULL; i++)
-    {
-      if(cmd[i] != ' ') {
-        argv[j][k] = cmd[i];
-        k++;
-      }
-      else {
-        argv[j][k] = '\0';
-        k = 0;
-        j++;
-      }
-    }
-    argv[j][k] = '\0';
-    argv[0] = "BeniXonox.exe";
-    //char *argv[2];
-    //argv[0] = "asdfProgram";
-    //argv[1] =  strCmdLine;
-    //int argc = 2;
+int main(int argc, char **argv)
+{
+  try {
+    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
+    Orxonox* orx = Orxonox::getSingleton();
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+    orx->init(argc, argv, macBundlePath());
 #else
-  int main(int argc, char **argv)
-  {
-#endif
-    try {
-      srand(time(0));  //initaialize RNG; TODO check if it works on win
-      SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
-      Orxonox* orx = Orxonox::getSingleton();
-#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
-      orx->init(argc, argv, macBundlePath());
-      orx->start();
-#else
-/*
-for (int i = 0; i < 500; i++)
-{
-int x = rand() % 40000 - 20000;
-int y = rand() % 40000 - 20000;
-int z = rand() % 40000 - 20000;
-
-int scale = rand() % 100 + 20;
-
-int version = rand() % 6 + 1;
-
-float rotx = float(rand()) / RAND_MAX;
-float roty = float(rand()) / RAND_MAX;
-float rotz = float(rand()) / RAND_MAX;
-
-int axis = rand() % 3 + 1;
-
-if (axis == 1)
-  rotx = 0;
-if (axis == 2)
-  roty = 0;
-if (axis == 3)
-  rotz = 0;
-
-int rotation = rand() % 40 + 10;
-
-//    <Model position="1000,1500,0" scale="50" mesh="ast1.mesh" rotationAxis="0,1.25,0" rotationRate="70" />
-std::cout << "    <Model position=\"" << x << "," << y << "," << z << "\" scale=\"" << scale << "\" mesh=\"ast" << version << ".mesh\" rotationAxis=\"" << rotx << "," << roty << "," << rotz << "\" rotationRate=\"" << rotation << "\" />" << std::endl;
-
-
-}
-*/
-      orx->init(argc, argv, "");
-      orx->start();
-#endif
-    }
-    catch (Ogre::Exception& e) {
-#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 && !defined( __MINGW32__ )
-      MessageBoxA(NULL, e.getFullDescription().c_str(),
-            "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
-#else
-      std::cerr << "Exception:\n";
-      std::cerr << e.getFullDescription().c_str() << "\n";
-#endif
-      return 1;
-    }
-    return 0;
-  }
-
-#ifdef __cplusplus
-}
+    orx->init(argc, argv, "");
 #endif
 
-
-/*int main(int argc, char **argv)
-{
-  try
+    orx->start();
+    orx->destroy();
+  }
+  catch (std::exception &ex)
   {
-    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
-    Orxonox* orx = Orxonox::getSingleton();
-#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
-    orx->init(argc, argv, macBundlePath());
-    orx->start();
-#else
-    orx->init(argc, argv, "");
-    orx->start();
-#endif
-
-  }
-  catch(Ogre::Exception& e)
-  {
-    fprintf(stderr, "An exception has occurred: %s\n",
-            e.getFullDescription().c_str());
+    std::cerr << "Exception:\n";
+    std::cerr << ex.what() << "\n";
     return 1;
   }
@@ -207,3 +96,5 @@
 }
 
-*/
+#ifdef __cplusplus
+}
+#endif
Index: code/trunk/src/orxonox/Orxonox.cc
===================================================================
--- code/trunk/src/orxonox/Orxonox.cc	(revision 978)
+++ code/trunk/src/orxonox/Orxonox.cc	(revision 1021)
@@ -35,27 +35,21 @@
 
 //****** OGRE ******
-#include <OgreException.h>
-#include <OgreRoot.h>
+//#include <OgreException.h>
 #include <OgreFrameListener.h>
-#include <OgreRenderWindow.h>
-#include <OgreTextureManager.h>
-#include <OgreResourceGroupManager.h>
-#include <OgreConfigFile.h>
 #include <OgreOverlay.h>
 #include <OgreOverlayManager.h>
-
-//****** OIS *******
-#include <OIS/OIS.h>
+#include <OgreTimer.h>
+#include <OgreWindowEventUtilities.h>
 
 //****** STD *******
-#include <iostream>
-#include <exception>
+//#include <iostream>
+//#include <exception>
+#include <deque>
 
 //***** ORXONOX ****
 //misc
-#include "util/Sleep.h"
-
-// loader and audio
-//#include "loader/LevelLoader.h"
+//#include "util/Sleep.h"
+
+// audio
 #include "audio/AudioManager.h"
 
@@ -63,17 +57,18 @@
 #include "network/Server.h"
 #include "network/Client.h"
-#include "network/NetworkFrameListener.h"
+network::Client *client_g;
+network::Server *server_g;
 
 // objects
-#include "objects/Tickable.h"
+#include "core/ArgReader.h"
+#include "core/Debug.h"
+#include "core/Factory.h"
+#include "core/Loader.h"
+#include "core/Tickable.h"
+#include "hud/HUD.h"
 #include "tools/Timer.h"
-#include "objects/NPC.h"
-#include "core/ArgReader.h"
-#include "core/Factory.h"
-#include "core/Debug.h"
-#include "core/Loader.h"
-#include "hud/HUD.h"
 #include "objects/weapon/BulletManager.h"
-#include "GraphicsEngine.h"
+
+#include "InputHandler.h"
 
 #include "Orxonox.h"
@@ -81,47 +76,8 @@
 namespace orxonox
 {
-   // put this in a seperate Class or solve the problem in another fashion
-  class OrxListener : public Ogre::FrameListener
-  {
-    public:
-      OrxListener(OIS::Keyboard *keyboard, audio::AudioManager*  auMan, gameMode mode)
-      {
-        mKeyboard = keyboard;
-        mode_=mode;
-        auMan_ = auMan;
-      }
-
-      bool frameStarted(const Ogre::FrameEvent& evt)
-      {
-        auMan_->update();
-        updateAI();
-
-        if(mode_ == PRESENTATION)
-          server_g->tick(evt.timeSinceLastFrame);
-        else if(mode_ == CLIENT)
-          client_g->tick(evt.timeSinceLastFrame);
-
-        usleep(10);
-
-        mKeyboard->capture();
-        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
-      }
-
-      void updateAI()
-      {
-        for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it)
-        {
-          it->update();
-        }
-      }
-
-    private:
-      gameMode mode_;
-      OIS::Keyboard *mKeyboard;
-      audio::AudioManager*  auMan_;
-  };
-
-  // init static singleton reference of Orxonox
-  Orxonox* Orxonox::singletonRef_ = NULL;
+  /**
+    @brief Reference to the only instance of the class.
+  */
+  Orxonox *Orxonox::singletonRef_s = 0;
 
   /**
@@ -131,13 +87,12 @@
   {
     this->ogre_ = new GraphicsEngine();
+    this->timer_ = 0;
     this->dataPath_ = "";
-//    this->loader_ = 0;
     this->auMan_ = 0;
-    this->singletonRef_ = 0;
-    this->keyboard_ = 0;
-    this->mouse_ = 0;
-    this->inputManager_ = 0;
-    this->frameListener_ = 0;
-    this->root_ = 0;
+    this->inputHandler_ = 0;
+    //this->root_ = 0;
+    // turn on frame smoothing by setting a value different from 0
+    this->frameSmoothingTime_ = 0.0f;
+    this->bAbort_ = false;
   }
 
@@ -147,5 +102,61 @@
   Orxonox::~Orxonox()
   {
-    // nothing to delete as for now
+    // keep in mind: the order of deletion is very important!
+    if (this->bulletMgr_)
+      delete this->bulletMgr_;
+    if (this->orxonoxHUD_)
+      delete this->orxonoxHUD_;
+    Loader::close();
+    InputHandler::destroy();
+    if (this->auMan_)
+      delete this->auMan_;
+    if (this->timer_)
+      delete this->timer_;
+    if (this->ogre_)
+      delete this->ogre_;
+
+    if (client_g)
+      delete client_g;
+    if (server_g)
+      delete server_g;
+  }
+
+  /**
+   * error kills orxonox
+   */
+  void Orxonox::abortImmediate(/* some error code */)
+  {
+    //TODO: destroy and destruct everything and print nice error msg
+    delete this;
+  }
+
+  /**
+    Asks the mainloop nicely to abort.
+  */
+  void Orxonox::abortRequest()
+  {
+    bAbort_ = true;
+  }
+
+  /**
+   * @return singleton object
+   */
+  Orxonox* Orxonox::getSingleton()
+  {
+    if (!singletonRef_s)
+      singletonRef_s = new Orxonox();
+    return singletonRef_s;
+    //static Orxonox theOnlyInstance;
+    //return &theOnlyInstance;
+  }
+
+  /**
+    @brief Destroys the Orxonox singleton.
+  */
+  void Orxonox::destroy()
+  {
+    if (singletonRef_s)
+      delete singletonRef_s;
+    singletonRef_s = 0;
   }
 
@@ -153,5 +164,5 @@
    * initialization of Orxonox object
    * @param argc argument counter
-   * @param argv list of arguments
+   * @param argv list of argumenst
    * @param path path to config (in home dir or something)
    */
@@ -162,154 +173,41 @@
     //TODO: give config file to Ogre
     std::string mode;
-//     if(argc>=2)
-//       mode = std::string(argv[1]);
-//     else
-//       mode = "";
+
     ArgReader ar = ArgReader(argc, argv);
     ar.checkArgument("mode", mode, false);
     ar.checkArgument("data", this->dataPath_, false);
     ar.checkArgument("ip", serverIp_, false);
-    //mode = "presentation";
-    if(ar.errorHandling()) die();
-    if(mode == std::string("server"))
+    if(ar.errorHandling()) abortImmediate();
+    if(mode == std::string("client"))
     {
+      mode_ = CLIENT;
+      clientInit(path);
+    }
+    else if(mode== std::string("server")){
+      mode_ = SERVER;
       serverInit(path);
-      mode_ = SERVER;
-    }
-    else if(mode == std::string("client"))
-    {
-      clientInit(path);
-      mode_ = CLIENT;
-    }
-    else if(mode == std::string("presentation"))
-    {
-      serverInit(path);
-      mode_ = PRESENTATION;
     }
     else{
+      mode_ = STANDALONE;
       standaloneInit(path);
-      mode_ = STANDALONE;
     }
   }
 
-  /**
-   * start modules
-   */
-  void Orxonox::start()
-  {
-    //TODO: start modules
-    ogre_->startRender();
-    //TODO: run engine
-    Factory::createClassHierarchy();
-    createScene();
-    setupScene();
-    setupInputSystem();
-    if(mode_!=CLIENT){ // remove this in future ---- presentation hack
-    }
-    else
-      std::cout << "client here" << std::endl;
-    createFrameListener();
-    switch(mode_){
-    case PRESENTATION:
-      //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener());
-      //std::cout << "could not add framelistener" << std::endl;
-      server_g->open();
-      break;
-    case CLIENT:
-      client_g->establishConnection();
-      break;
-    case SERVER:
-    case STANDALONE:
-    default:
-      break;
-    }
-    startRenderLoop();
-  }
-
-  /**
-   * @return singleton object
-   */
-  Orxonox* Orxonox::getSingleton()
-  {
-    if (!singletonRef_)
-      singletonRef_ = new Orxonox();
-    return singletonRef_;
-  }
-
-  /**
-   * error kills orxonox
-   */
-  void Orxonox::die(/* some error code */)
-  {
-    //TODO: destroy and destruct everything and print nice error msg
-    delete this;
-  }
-
-  void Orxonox::standaloneInit(std::string path)
-  {
+  void Orxonox::serverInit(std::string path)
+  {
+    COUT(2) << "initialising server" << std::endl;
+    
     ogre_->setConfigPath(path);
     ogre_->setup();
-    root_ = ogre_->getRoot();
-    if(!ogre_->load()) die(/* unable to load */);
-
-    //defineResources();
-    //setupRenderSystem();
-    //createRenderWindow();
-    //initializeResourceGroups();
-    /*createScene();
-    setupScene();
-    setupInputSystem();
-    createFrameListener();
-    Factory::createClassHierarchy();
-    startRenderLoop();*/
-  }
-
-  void Orxonox::playableServer(std::string path)
-  {
-    ogre_->setConfigPath(path);
-    ogre_->setup();
-    root_ = ogre_->getRoot();
-    defineResources();
-    setupRenderSystem();
-    createRenderWindow();
-    initializeResourceGroups();
-    setupInputSystem();
-    Factory::createClassHierarchy();
-    createScene();
-    setupScene();
-    createFrameListener();
-    try{
-      server_g = new network::Server(); //!< add port and bindadress
-      server_g->open(); //!< open server and create listener thread
-      if(ogre_ && ogre_->getRoot())
-        ogre_->getRoot()->addFrameListener(new network::ServerFrameListener()); // adds a framelistener for the server
-      COUT(3) << "Info: network framelistener added" << std::endl;
-    }
-    catch(...)
-    {
-      COUT(1) << "Error: There was a problem initialising the server :(" << std::endl;
-    }
-    startRenderLoop();
-  }
-
-  void Orxonox::standalone(){
-
-
-
-  }
-
-  void Orxonox::serverInit(std::string path)
-  {
-    COUT(2) << "initialising server" << std::endl;
-    ogre_->setConfigPath(path);
-    ogre_->setup();
-    server_g = new network::Server(); // FIXME add some settings if wanted
-    if(!ogre_->load()) die(/* unable to load */);
-    // FIXME add network framelistener
+    //root_ = ogre_->getRoot();
+    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
+    
+    server_g = new network::Server();
   }
 
   void Orxonox::clientInit(std::string path)
   {
-    COUT(2) << "initialising client" << std::endl;
+    COUT(2) << "initialising client" << std::endl;\
+    
     ogre_->setConfigPath(path);
     ogre_->setup();
@@ -317,72 +215,44 @@
       client_g = new network::Client();
     else
-      client_g = new network::Client(serverIp_, 55556);
-    if(!ogre_->load()) die(/* unable to load */);
-    ogre_->getRoot()->addFrameListener(new network::ClientFrameListener());
-  }
-
-  void Orxonox::defineResources()
-  {
-    std::string secName, typeName, archName;
-    Ogre::ConfigFile cf;
-#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
-    cf.load(macBundlePath() + "/Contents/Resources/resources.cfg");
-#else
-    cf.load(dataPath_ + "resources.cfg");
-#endif
-
-    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-    while (seci.hasMoreElements())
-    {
-      secName = seci.peekNextKey();
-      Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-      Ogre::ConfigFile::SettingsMultiMap::iterator i;
-      for (i = settings->begin(); i != settings->end(); ++i)
-      {
-        typeName = i->first;
-        archName = i->second;
-#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
-        Ogre::ResourceGroupManager::getSingleton().addResourceLocation( std::string(macBundlePath() + "/" + archName), typeName, secName);
-#else
-        Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName);
-#endif
-      }
+      client_g = new network::Client(serverIp_, NETWORK_PORT);
+    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
+  }
+  
+  void Orxonox::standaloneInit(std::string path)
+  {
+    COUT(2) << "initialising standalone mode" << std::endl;
+    
+    ogre_->setConfigPath(path);
+    ogre_->setup();
+    //root_ = ogre_->getRoot();
+    if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */);
+  }
+  
+  /**
+   * start modules
+   */
+  void Orxonox::start()
+  {
+    switch(mode_){
+    case CLIENT:
+      clientStart();
+      break;
+    case SERVER:
+      serverStart();
+      break;
+    default:
+      standaloneStart();
     }
   }
-
-  void Orxonox::setupRenderSystem()
-  {
-    if (!root_->restoreConfig() && !root_->showConfigDialog())
-      throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()");
-  }
-
-  void Orxonox::createRenderWindow()
-  {
-    root_->initialise(true, "OrxonoxV2");
-  }
-
-  void Orxonox::initializeResourceGroups()
-  {
-    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
-    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
-  }
-
-  /**
-   *
-   * @param
-   */
-  void Orxonox::createScene(void)
-  {
-	// Init audio
+  
+  void Orxonox::clientStart(){
+    ogre_->initialise();
+    Factory::createClassHierarchy();
+    
+    
     auMan_ = new audio::AudioManager();
 
     bulletMgr_ = new BulletManager();
-
-    // load this file from config
-//    loader_ = new loader::LevelLoader("sample.oxw");
-//    loader_->loadLevel();
-    Level* startlevel = new Level("levels/sample.oxw");
-    Loader::open(startlevel);
-
+    
     Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
     HUD* orxonoxHud;
@@ -391,4 +261,54 @@
     orxonoxHud->setEnergyDistr(20,20,60);
     hudOverlay->show();
+    
+    client_g->establishConnection();
+    client_g->tick(0);
+    
+    
+    //setupInputSystem();
+    
+    startRenderLoop();
+  }
+  
+  void Orxonox::serverStart(){
+    //TODO: start modules
+    ogre_->initialise();
+    //TODO: run engine
+    Factory::createClassHierarchy();
+    createScene();
+    setupInputSystem();
+    
+    server_g->open();
+    
+    startRenderLoop();
+  }
+  
+  void Orxonox::standaloneStart(){
+    //TODO: start modules
+    ogre_->initialise();
+    //TODO: run engine
+    Factory::createClassHierarchy();
+    createScene();
+    setupInputSystem();
+    
+    startRenderLoop();
+  }
+
+  void Orxonox::createScene(void)
+  {
+	  // Init audio
+    auMan_ = new audio::AudioManager();
+
+    bulletMgr_ = new BulletManager();
+
+    // load this file from config
+    Level* startlevel = new Level("levels/sample.oxw");
+    Loader::open(startlevel);
+
+    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
+    orxonoxHUD_ = new HUD();
+    orxonoxHUD_->setEnergyValue(20);
+    orxonoxHUD_->setEnergyDistr(20,20,60);
+    hudOverlay->show();
 
 	/*
@@ -396,89 +316,132 @@
     auMan_->ambientAdd("a2");
     auMan_->ambientAdd("a3");
-                                //auMan->ambientAdd("ambient1");
-    auMan_->ambientStart();*/
-  }
-
-
-  /**
-   *
-   */
-  void Orxonox::setupScene()
-  {
-//    SceneManager *mgr = ogre_->getSceneManager();
-
-
-//    SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");
-//     SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));
-
-
-/*
-    particle::ParticleInterface *e = new particle::ParticleInterface(mgr,"engine","Orxonox/strahl");
-    e->particleSystem_->setParameter("local_space","true");
-    e->setPositionOfEmitter(0, Vector3(0,-10,0));
-    e->setDirection(Vector3(0,0,-1));
-    e->addToSceneNode(node);
-*/
-  }
-
-
+    //auMan->ambientAdd("ambient1");
+    auMan_->ambientStart();
+  */
+  }
+
+  /**
+    @brief Calls the InputHandler which sets up the input devices.
+    The render window width and height are used to set up the mouse movement.
+  */
   void Orxonox::setupInputSystem()
   {
-    size_t windowHnd = 0;
-    std::ostringstream windowHndStr;
-    OIS::ParamList pl;
-
-    // fixes auto repeat problem
-    #if defined OIS_LINUX_PLATFORM
-      pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
-    #endif
-
-      Ogre::RenderWindow *win = ogre_->getRoot()->getAutoCreatedWindow();
-    win->getCustomAttribute("WINDOW", &windowHnd);
-    windowHndStr << windowHnd;
-    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
-    inputManager_ = OIS::InputManager::createInputSystem(pl);
-
-    try
+    inputHandler_ = InputHandler::getSingleton();
+    if (!inputHandler_->initialise(ogre_->getWindowHandle(),
+          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
+      abortImmediate();
+  }
+
+  /**
+    Main loop of the orxonox game.
+    This is a new solution, using the ogre engine instead of being 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::startRenderLoop()
+  {
+    // use the ogre timer class to measure time.
+    if (!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 (!bAbort_)
+	  {
+		  // 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);
+
+      // Iterate through all Tickables and call their tick(dt) function
+      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
+        (it++)->tick((float)evt.timeSinceLastFrame);
+
+      // don't forget to call _fireFrameStarted in ogre to make sure
+      // everything goes smoothly
+      ogre_->frameStarted(evt);
+
+      if (mode_ != SERVER)
+        ogre_->renderOneFrame(); // only render in non-server mode
+
+      // 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
+      ogre_->frameEnded(evt);
+	  }
+  }
+
+  /**
+    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)
     {
-      keyboard_ = static_cast<OIS::Keyboard*>(inputManager_->createInputObject(OIS::OISKeyboard, false));
-      mouse_ = static_cast<OIS::Mouse*>(inputManager_->createInputObject(OIS::OISMouse, true));
+      if (now - *it > discardThreshold)
+        ++it;
+      else
+        break;
     }
-    catch (const OIS::Exception &e)
-    {
-      throw new Ogre::Exception(42, e.eText, "OrxApplication::setupInputSystem");
-    }
-  }
-
-  // FIXME we actually want to do this differently...
-  void Orxonox::createFrameListener()
-  {
-    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
-      frameListener_ = new OrxListener(keyboard_, auMan_, mode_);
-    ogre_->getRoot()->addFrameListener(frameListener_);
-  }
-
-  void Orxonox::startRenderLoop()
-  {
-    // FIXME
-    // this is a hack!!!
-    // the call to reset the mouse clipping size should probably be somewhere
-    // else, however this works for the moment.
-    unsigned int width, height, depth;
-    int left, top;
-    ogre_->getRoot()->getAutoCreatedWindow()->getMetrics(width, height, depth, left, top);
-
-    if(mode_!=CLIENT){
-      const OIS::MouseState &ms = mouse_->getMouseState();
-      ms.width = width;
-      ms.height = height;
-    }
-    ogre_->getRoot()->startRendering();
+
+    // Remove old times
+    times.erase(times.begin(), it);
+
+    return (float)(times.back() - times.front()) / ((times.size()-1) * 1000);
+  }
+
+  /**
+    @brief Test method for the InputHandler.
+    But: Is actually responsible for catching an exit event..
+  */
+  void Orxonox::eventOccured(InputEvent &evt)
+  {
+    if (evt.id == 1)
+      this->abortRequest();
   }
 }
Index: code/trunk/src/orxonox/Orxonox.h
===================================================================
--- code/trunk/src/orxonox/Orxonox.h	(revision 978)
+++ code/trunk/src/orxonox/Orxonox.h	(revision 1021)
@@ -11,11 +11,11 @@
 
 #include <OgrePrerequisites.h>
-#include <OIS/OISPrereqs.h>
+//#include <OIS/OISPrereqs.h>
 
 #include "OrxonoxPrereqs.h"
-//#include "loader/LoaderPrereqs.h"
 #include "audio/AudioPrereqs.h"
 
 #include "GraphicsEngine.h"
+#include "InputEventListener.h"
 
 
@@ -25,11 +25,10 @@
 
   enum gameMode{
-    STANDALONE,
     SERVER,
     CLIENT,
-    PRESENTATION
+    STANDALONE
   };
 
-  class _OrxonoxExport Orxonox
+  class _OrxonoxExport Orxonox : public InputEventListener
   {
     public:
@@ -37,49 +36,57 @@
       void start();
       // not sure if this should be private
-      void die(/* some error code */);
+      void abortImmediate(/* some error code */);
+      void abortRequest();
+      inline Ogre::SceneManager*  getSceneManager()        { return ogre_->getSceneManager(); };
+      inline GraphicsEngine*      getOgrePointer()         { return ogre_; };
+      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
+      inline BulletManager*       getBulletMgr()           { return this->bulletMgr_; }
+
       static Orxonox* getSingleton();
-      inline Ogre::SceneManager* getSceneManager()         { return ogre_->getSceneManager(); };
-      inline GraphicsEngine* getOgrePointer()              { return ogre_; };
-      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
-      inline OIS::Keyboard* getKeyboard()                  { return this->keyboard_; }
-      inline OIS::Mouse* getMouse()                        { return this->mouse_; }
-      inline BulletManager* getBulletMgr()                 { return this->bulletMgr_; }
+      static void destroy();
 
-    private:
+   private:
+      // don't mess with singletons
       Orxonox();
-      virtual ~Orxonox();
+      Orxonox(Orxonox& instance);
+      Orxonox& operator=(const Orxonox& instance);
+      ~Orxonox();
+
       // init functions
       void serverInit(std::string path);
       void clientInit(std::string path);
       void standaloneInit(std::string path);
+
       // run functions
-      void playableServer(std::string path);
-      void standalone();
-      void defineResources();
-      void setupRenderSystem();
-      void createRenderWindow();
-      void initializeResourceGroups();
-      void createScene(void);
-      void setupScene();
+      void serverStart();
+      void clientStart();
+      void standaloneStart();
+
+      void createScene();
       void setupInputSystem();
-      void createFrameListener();
       void startRenderLoop();
+      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
+
+      void eventOccured(InputEvent &evt);
 
     private:
       GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
       std::string           dataPath_;      //!< path to data
-//      loader::LevelLoader*  loader_;        //!< level loader builds the scene
       audio::AudioManager*  auMan_;         //!< audio manager
       BulletManager*        bulletMgr_;     //!< Keeps track of the thrown bullets
-      static Orxonox*       singletonRef_;
-      OIS::Keyboard*        keyboard_;
-      OIS::Mouse*           mouse_;
-      OIS::InputManager*    inputManager_;
-      OrxListener*          frameListener_;
-      Ogre::Root*           root_;
+      InputHandler*         inputHandler_;  //!< Handles input with key bindings
+      Ogre::Root*           root_;          //!< Holy grail of Ogre
+      Ogre::Timer*          timer_;         //!< Main loop timer
+      // 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_;
+      bool                  bAbort_;        //!< aborts the render loop if true
 
       // this is used to identify the mode (server/client/...) we're in
       gameMode              mode_;
       std::string           serverIp_;
+
+      static Orxonox *singletonRef_s;
   };
 }
Index: code/trunk/src/orxonox/OrxonoxPlatform.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPlatform.h	(revision 978)
+++ code/trunk/src/orxonox/OrxonoxPlatform.h	(revision 1021)
@@ -210,5 +210,9 @@
 //#   pragma warning (disable : 4503)
 
-// disable: "conversion from 'double' to 'float', possible loss of data
+// disable: conversion from 'double' to 'float', possible loss of data
+// disable: conversion from 'ogg_int64_t' to 'long', possible loss of data
+// This has been dealt with in base_properties of the solution since the
+// warning primarily occurs in library header files (which are mostly
+// included before OrxonoxPlatform.h is)
 //#   pragma warning (disable : 4244)
 
@@ -221,5 +225,12 @@
 // disable: "<type> needs to have dll-interface to be used by clients'
 // Happens on STL member variables which are not public therefore is ok
+// This has been dealt with in base_properties of the solution since the
+// warning primarily occurs in library header files (which are mostly
+// included before OrxonoxPlatform.h is)
 //#   pragma warning (disable : 4251)
+
+// disable: 'MultiTypeString' : multiple assignment operators specified
+// Used in MultiType and works fine so far
+#   pragma warning (disable : 4522)
 
 // disable: "non dll-interface class used as base for dll-interface class"
@@ -252,11 +263,7 @@
 
 
-// Create a logical xor operator
+// Define the english written operators like and, or, xor
 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
-#  define XOR ^
-#elif ORXONOX_COMPILER == ORXONOX_COMPILER_GCC
-#  define XOR xor
-#else
-#  define XOR ^
+#  include <iso646.h>
 #endif
 
Index: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 978)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 1021)
@@ -68,4 +68,7 @@
   class Camera;
   class GraphicsEngine;
+  struct InputEvent;
+  class InputEventListener;
+  class InputHandler;
   class Mesh;
   class Model;
Index: code/trunk/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxStableHeaders.h	(revision 978)
+++ code/trunk/src/orxonox/OrxonoxStableHeaders.h	(revision 1021)
@@ -41,7 +41,12 @@
 
 // not including the entire Ogre.h doesn't exceed the default heap size for pch
+#ifndef WIN32_LEAN_AND_MEAN
+// prevent Ogre from including winsock.h that messes with winsock2.h from enet
+#  define WIN32_LEAN_AND_MEAN
+#endif
 //#include <Ogre.h>
 #include <OgreBillboardSet.h>
 #include <OgreCamera.h>
+#include <OgreColourValue.h>
 #include <OgreConfigFile.h>
 #include <OgreEntity.h>
@@ -49,4 +54,6 @@
 #include <OgreFrameListener.h>
 #include <OgreLight.h>
+#include <OgreMath.h>
+#include <OgreMatrix3.h>
 #include <OgreOverlay.h>
 #include <OgreOverlayElement.h>
@@ -56,4 +63,6 @@
 #include <OgrePlatform.h>
 #include <OgrePrerequisites.h>
+#include <OgreQuaternion.h>
+#include <OgreResourceGroupManager.h>
 #include <OgreRenderWindow.h>
 #include <OgreRoot.h>
@@ -62,5 +71,10 @@
 #include <OgreStringConverter.h>
 #include <OgreTextureManager.h>
+#include <OgreTimer.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreVector3.h>
 #include <OgreViewport.h>
+#include <OgreWindowEventUtilities.h>
 
 #include <OIS/OIS.h>
@@ -68,13 +82,13 @@
 /**
 * Some of the not so stable header files.
-* But it's not very useful to include them anyway..
+* It's not very useful to include them anyway..
 **/
 
-//#include "audio/AudioManager.h"
-
-//#include "core/CoreIncludes.h"
+#include "core/CoreIncludes.h"
 #include "core/BaseObject.h"
-//#include "core/ArgReader.h"
+#include "core/Tickable.h"
 #include "core/Error.h"
+#include "core/Loader.h"
+#include "core/XMLPort.h"
 
 #include "network/Synchronisable.h"
@@ -97,31 +111,6 @@
 #include "util/tinyxml/tinyxml.h"
 
-//#include "hud/HUD.h"
-//#include "loader/LevelLoader.h"
-//#include "objects/weapon/AmmunitionDump.h"
-//#include "objects/weapon/BarrelGun.h"
-//#include "objects/weapon/Bullet.h"
-//#include "objects/weapon/BulletManager.h"
-//#include "objects/weapon/WeaponStation.h"
-//#include "objects/Ambient.h"
-//#include "objects/Camera.h"
-//#include "objects/Explosion.h"
-//#include "objects/Fighter.h"
 #include "objects/Model.h"
-//#include "objects/NPC.h"
-//#include "objects/Projectile.h"
-//#include "objects/Skybox.h"
-//#include "objects/SpaceShipSteeringObject.h"
-#include "objects/Tickable.h"
 #include "objects/WorldEntity.h"
-//#include "particle/ParticleInterface.h"
-//#include "tools/BillboardSet.h"
-//#include "tools/Light.h"
-//#include "tools/Mesh.h"
-//#include "tools/Timer.h"
-//#include "GraphicsEngine.h"
-//#include "InputManager.h"
-//#include "Orxonox.h"
-//#include "SpaceshipSteering.h"
 
 #endif
Index: code/trunk/src/orxonox/PrecompiledHeaderFiles.cc
===================================================================
--- code/trunk/src/orxonox/PrecompiledHeaderFiles.cc	(revision 978)
+++ code/trunk/src/orxonox/PrecompiledHeaderFiles.cc	(revision 1021)
@@ -27,5 +27,5 @@
 
 /**
- @file  PrecompiledHeaderFiles.cc
+ @file
  @brief This file actually generates the precompiled header file
  */
Index: code/trunk/src/orxonox/core/BaseObject.cc
===================================================================
--- code/trunk/src/orxonox/core/BaseObject.cc	(revision 978)
+++ code/trunk/src/orxonox/core/BaseObject.cc	(revision 1021)
@@ -27,5 +27,5 @@
 
 /**
-    @file BaseObject.cc
+    @file
     @brief Implementation of the BaseObject class.
 */
Index: code/trunk/src/orxonox/core/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/core/CMakeLists.txt	(revision 978)
+++ code/trunk/src/orxonox/core/CMakeLists.txt	(revision 1021)
@@ -17,4 +17,6 @@
   Executor.cc
   XMLPort.cc
+  Tickable.cc
+  Script.cc
 )
 
@@ -24,3 +26,4 @@
 TARGET_LINK_LIBRARIES( core
   util
+  ${Lua_LIBRARIES}
 )
Index: code/trunk/src/orxonox/core/ClassTreeMask.cc
===================================================================
--- code/trunk/src/orxonox/core/ClassTreeMask.cc	(revision 978)
+++ code/trunk/src/orxonox/core/ClassTreeMask.cc	(revision 1021)
@@ -592,5 +592,5 @@
         {
             const Identifier* subclass = it->getClass();
-            newmask.add(subclass, this->isIncluded(subclass) || other.isIncluded(subclass), false, false);
+            newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false);
         }
 
@@ -599,5 +599,5 @@
         {
             const Identifier* subclass = it->getClass();
-            newmask.add(subclass, this->isIncluded(subclass) || other.isIncluded(subclass), false, false);
+            newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false);
         }
 
@@ -623,5 +623,5 @@
         {
             const Identifier* subclass = it->getClass();
-            newmask.add(subclass, this->isIncluded(subclass) && other.isIncluded(subclass), false, false);
+            newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false);
         }
 
@@ -630,5 +630,5 @@
         {
             const Identifier* subclass = it->getClass();
-            newmask.add(subclass, this->isIncluded(subclass) && other.isIncluded(subclass), false, false);
+            newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false);
         }
 
@@ -737,5 +737,5 @@
         {
             const Identifier* subclass = it->getClass();
-            newmask.add(subclass, this->isIncluded(subclass) XOR other.isIncluded(subclass), false, false);
+            newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false);
         }
 
@@ -744,5 +744,5 @@
         {
             const Identifier* subclass = it->getClass();
-            newmask.add(subclass, this->isIncluded(subclass) XOR other.isIncluded(subclass), false, false);
+            newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false);
         }
 
Index: code/trunk/src/orxonox/core/DebugLevel.cc
===================================================================
--- code/trunk/src/orxonox/core/DebugLevel.cc	(revision 978)
+++ code/trunk/src/orxonox/core/DebugLevel.cc	(revision 1021)
@@ -95,5 +95,5 @@
 
         // Return a constant value while we're creating the object
-        return 4;
+        return 3;
     }
 }
Index: code/trunk/src/orxonox/core/Loader.cc
===================================================================
--- code/trunk/src/orxonox/core/Loader.cc	(revision 978)
+++ code/trunk/src/orxonox/core/Loader.cc	(revision 1021)
@@ -33,4 +33,5 @@
 #include "Debug.h"
 #include "CoreIncludes.h"
+#include "Script.h"
 
 #include "util/tinyxml/ticpp.h"
@@ -107,4 +108,13 @@
         Loader::currentMask_s = level->getMask() * mask;
 
+        // let Lua work this out:
+        //Script* lua;
+        /*Script::loadFile(level->getFile(), true);
+        Script::init(Script::getLuaState());
+        Script::run();*/
+        Script* lua = Script::getInstance();
+        lua->loadFile(level->getFile(), true);
+        lua->run();
+
         try
         {
@@ -112,6 +122,10 @@
             COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
 
-            ticpp::Document xmlfile(level->getFile());
-            xmlfile.LoadFile();
+            //ticpp::Document xmlfile(level->getFile());
+            //xmlfile.LoadFile();
+            //ticpp::Element myelement(*Script::getFileString());
+            ticpp::Document xmlfile;
+            //xmlfile.ToDocument();
+            xmlfile.Parse(lua->getLuaOutput(), true);
 
             for ( ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++ )
Index: code/trunk/src/orxonox/core/Script.cc
===================================================================
--- code/trunk/src/orxonox/core/Script.cc	(revision 1021)
+++ code/trunk/src/orxonox/core/Script.cc	(revision 1021)
@@ -0,0 +1,265 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Script.h"
+
+#include <fstream>
+#include <map>
+
+#include "../core/CoreIncludes.h"
+
+extern "C" {
+#include "lualib.h"
+#include "lauxlib.h"
+}
+
+#include "tolua++.h"
+#include "../../util/tolua/tolua_bind.h"
+
+namespace orxonox
+{
+  Script* Script::singletonRef = NULL;
+
+  Script::Script()
+  {
+    luaState_ = lua_open();
+    luaSource_ = "";
+    luaL_openlibs(luaState_);
+    tolua_orxonox_open(luaState_);
+    output_;
+  }
+
+  void Script::luaPrint(std::string str)
+  {
+    output_ += str;
+    COUT(0) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
+  }
+
+  /**
+      @brief Loads the specified file line by line
+      @param filename The filename of the file
+      @param luaTags if true, the loaded file gets stripped off luaTags
+  */
+  void Script::loadFile(std::string filename, bool luaTags)
+  {
+    std::ifstream file;
+    file.open(filename.c_str(), std::fstream::in);
+
+    if (!file.is_open())
+    {
+      // some error msg
+    }
+
+    char line[1024];
+    std::string levelString = "";
+
+    while (file.good() && !file.eof())
+    {
+      file.getline(line, 1024);
+      levelString += line;
+      levelString += "\n";
+    }
+
+    file.close();
+    //std::string output;
+
+    if (luaTags) luaSource_ = replaceLuaTags(levelString);
+    COUT(0) << "ParsedSourceCode: " << luaSource_ << std::endl;
+  }
+
+  void Script::run()
+  {
+    int error = 0;
+    std::string init = "local scr = orxonox.Script:getInstance()\nprint = function(s)\nscr:luaPrint(s)\nend\n";
+    init += luaSource_;
+    error = luaL_loadstring(luaState_, init.c_str());
+    if (error == 0)
+      error = lua_pcall(luaState_, 0, 0, 0);
+    if (error != 0) COUT(0) << "Error in Lua-script: " << lua_tostring(luaState_, -1) << std::endl;
+  }
+
+
+  unsigned int Script::getNextQuote(const std::string& text, unsigned int start)
+  {
+    unsigned int quote = start - 1;
+
+    while ((quote = text.find('\"', quote + 1)) != std::string::npos)
+    {
+      unsigned int backslash = quote;
+      unsigned int numbackslashes = 0;
+      for (; backslash > 0; backslash--, numbackslashes++)
+        if (text[backslash - 1] != '\\')
+          break;
+
+      if (numbackslashes % 2 == 0)
+        break;
+    }
+
+    return quote;
+  }
+
+  std::string Script::replaceLuaTags(const std::string& text)
+  {
+    // chreate map with all Lua tags
+    std::map<unsigned int, bool> luaTags;
+    {
+      unsigned int pos = 0;
+      while ((pos = text.find("<?lua", pos)) != std::string::npos)
+        luaTags[pos++] = true;
+    }
+    {
+      unsigned int pos = 0;
+      while ((pos = text.find("?>", pos)) != std::string::npos)
+        luaTags[pos++] = false;
+    }
+
+    // erase all tags from the map that are between two quotes
+    {
+      std::map<unsigned int, bool>::iterator it = luaTags.begin();
+      std::map<unsigned int, bool>::iterator it2 = it;
+      bool bBetweenQuotes = false;
+      bool bBetweenTags = false;
+      unsigned int pos = 0;
+      while ((pos = getNextQuote(text, pos)) != std::string::npos)
+      {
+        while ((it != luaTags.end()) && (it->first < pos))
+        {
+          if (bBetweenQuotes) {
+            it2++;
+            if(it->second && !(it2->second) && it2->first < pos)
+              it = ++it2;
+            else
+              luaTags.erase(it++);
+          }
+          else
+            ++it;
+        }
+        bBetweenQuotes = !bBetweenQuotes;
+        pos++;
+      }
+    }
+
+    // check whether on every opening <?lua tag a closing ?> tag follows
+    {
+      bool expectedValue = true;
+      for (std::map<unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
+      {
+        if ((*it).second == expectedValue)
+          expectedValue = !expectedValue;
+        else
+        {
+          expectedValue = false;
+          break;
+        }
+      }
+      if (!expectedValue) {
+        // todo: errorhandling
+        return "";
+      }
+    }
+
+    // cut the original string into pieces and put them together with print() instead of lua tags
+    std::string output;
+    {
+      std::map<unsigned int, bool>::iterator it = luaTags.begin();
+      bool bInPrintFunction = true;
+      unsigned int start = 0;
+      unsigned int end = 0;
+
+      do
+      {
+        if (it != luaTags.end())
+          end = (*(it++)).first;
+        else
+          end = std::string::npos;
+
+        unsigned int equalSignCounter = 0;
+
+        if (bInPrintFunction)
+        {
+          // count ['='[ and ]'='] and replace tags with print([[ and ]])
+          std::string temp = text.substr(start, end - start);
+          {
+            unsigned int pos = 0;
+            while ((pos = temp.find('[', pos)) != std::string::npos)
+            {
+              unsigned int tempCounter = 1;
+              unsigned int tempPos = pos++;
+              while(temp[++tempPos] == '=') {
+                tempCounter++;
+              }
+              if(temp[tempPos] != '[') {
+                tempCounter = 0;
+              }
+              else if(tempCounter == 0) {
+                tempCounter = 1;
+              }
+              if (tempCounter > equalSignCounter)
+                equalSignCounter = tempCounter;
+            }
+          }
+          {
+            unsigned int pos = 0;
+            while ((pos = temp.find(']', pos)) != std::string::npos)
+            {
+              unsigned int tempCounter = 1;
+              unsigned int tempPos = pos++;
+              while(temp[++tempPos] == '=') {
+                tempCounter++;
+              }
+              if(temp[tempPos] != ']') {
+                tempCounter = 0;
+              }
+              else if(tempCounter == 0) {
+                tempCounter = 1;
+              }
+              if (tempCounter > equalSignCounter)
+                equalSignCounter = tempCounter;
+            }
+          }
+          std::string equalSigns = "";
+          for(unsigned int i = 0; i < equalSignCounter; i++) {
+            equalSigns += "=";
+          }
+          output += "print([" + equalSigns + "[" + temp + "]" + equalSigns +"])";
+          start = end + 5;
+        }
+        else
+        {
+          output += text.substr(start, end - start);
+          start = end + 2;
+        }
+
+        bInPrintFunction = !bInPrintFunction;
+      }
+      while (end != std::string::npos);
+    }
+
+    return output;
+  }
+
+}
Index: code/trunk/src/orxonox/core/Script.h
===================================================================
--- code/trunk/src/orxonox/core/Script.h	(revision 1021)
+++ code/trunk/src/orxonox/core/Script.h	(revision 1021)
@@ -0,0 +1,49 @@
+/**
+ @file  script.h
+ @brief Representation of an interface to lua
+ @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _Script_H__
+#define _Script_H__
+
+extern "C" {
+#include "lua.h"
+}
+
+#include <list>
+#include <string>
+
+namespace orxonox // tolua_export
+{ // tolua_export
+
+  class Script // tolua_export
+  { // tolua_export
+    public:
+      inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
+      inline ~Script() { Script::singletonRef = NULL; };
+
+    void loadFile(std::string filename, bool luaTags);
+    //void init(lua_State *state_);
+    //void xmlToLua();
+    void run();
+    void luaPrint(std::string str); // tolua_export
+
+    inline lua_State* getLuaState() { return luaState_; };
+    inline std::string getLuaOutput() { return output_; };
+    //inline std::string* getFileString() { return &fileString_; };
+
+    unsigned int getNextQuote(const std::string& text, unsigned int start);
+    std::string replaceLuaTags(const std::string& text);
+
+    private:
+      Script();
+      static Script* singletonRef;
+
+      std::string luaSource_;
+      std::string output_;
+      lua_State* luaState_;
+
+  }; // tolua_export
+} // tolua_export
+#endif /* _Script_H__ */
Index: code/trunk/src/orxonox/core/Tickable.cc
===================================================================
--- code/trunk/src/orxonox/core/Tickable.cc	(revision 1021)
+++ code/trunk/src/orxonox/core/Tickable.cc	(revision 1021)
@@ -0,0 +1,40 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "core/CoreIncludes.h"
+#include "Tickable.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Registers the object in the Tickable-list
+    */
+    Tickable::Tickable()
+    {
+        RegisterRootObject(Tickable);
+    }
+}
Index: code/trunk/src/orxonox/core/Tickable.h
===================================================================
--- code/trunk/src/orxonox/core/Tickable.h	(revision 1021)
+++ code/trunk/src/orxonox/core/Tickable.h	(revision 1021)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*!
+    @file Tickable.h
+    @brief Definition of the Tickable interface.
+
+    The Tickable interface provides a tick(dt) function, that gets called every frame.
+    float dt is the time since the last frame in seconds.
+
+    Attention:
+    Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
+    parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
+*/
+
+#ifndef _Tickable_H__
+#define _Tickable_H__
+
+#include "CorePrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    //class TickFrameListener; // Forward declaration
+
+    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
+    class _CoreExport Tickable : virtual public OrxonoxClass
+    {
+        public:
+            /**
+                @brief Gets called every frame.
+                @param dt The time since the last frame in seconds
+            */
+            virtual void tick(float dt) = 0;
+
+        protected:
+            Tickable();
+    };
+
+}
+
+#endif /* _Tickable_H__ */
Index: code/trunk/src/orxonox/objects/Camera.cc
===================================================================
--- code/trunk/src/orxonox/objects/Camera.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/Camera.cc	(revision 1021)
@@ -6,5 +6,4 @@
 #include <OgreSceneManager.h>
 #include <OgreSceneNode.h>
-#include <OgreRoot.h>
 #include <OgreRenderWindow.h>
 #include <OgreViewport.h>
@@ -69,5 +68,5 @@
 
         // FIXME: unused var
-        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
+        Ogre::Viewport* vp = orxonox::Orxonox::getSingleton()->getOgrePointer()->getRenderWindow()->addViewport(cam);
 
 
Index: code/trunk/src/orxonox/objects/Fighter.cc
===================================================================
--- code/trunk/src/orxonox/objects/Fighter.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/Fighter.cc	(revision 1021)
@@ -37,7 +37,8 @@
 #include "util/tinyxml/tinyxml.h"
 #include "util/String2Number.h"
-#include "../core/CoreIncludes.h"
-#include "../Orxonox.h"
-#include "../particle/ParticleInterface.h"
+#include "core/CoreIncludes.h"
+#include "Orxonox.h"
+#include "InputHandler.h"
+#include "particle/ParticleInterface.h"
 #include "weapon/AmmunitionDump.h"
 #include "weapon/BarrelGun.h"
@@ -207,5 +208,5 @@
 
             node->attachObject(cam);
-            Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
+            Orxonox::getSingleton()->getOgrePointer()->getRenderWindow()->addViewport(cam);
     	}
     }
@@ -254,7 +255,7 @@
         if (!this->setMouseEventCallback_)
         {
-            if (Orxonox::getSingleton()->getMouse())
+            if (InputHandler::getSingleton()->getMouse())
             {
-                Orxonox::getSingleton()->getMouse()->setEventCallback(this);
+                InputHandler::getSingleton()->getMouse()->setEventCallback(this);
                 this->setMouseEventCallback_ = true;
             }
@@ -263,6 +264,6 @@
         WorldEntity::tick(dt);
 
-        OIS::Keyboard* mKeyboard = Orxonox::getSingleton()->getKeyboard();
-        OIS::Mouse* mMouse = Orxonox::getSingleton()->getMouse();
+        OIS::Keyboard* mKeyboard = InputHandler::getSingleton()->getKeyboard();
+        OIS::Mouse* mMouse = InputHandler::getSingleton()->getMouse();
 
         mKeyboard->capture();
Index: code/trunk/src/orxonox/objects/Model.cc
===================================================================
--- code/trunk/src/orxonox/objects/Model.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/Model.cc	(revision 1021)
@@ -44,4 +44,5 @@
     {
         RegisterObject(Model);
+        registerAllVariables();
     }
 
@@ -63,5 +64,6 @@
     /**
         @brief XML loading and saving.
-        @param xmlelement The XML-element
+    @p
+    aram xmlelement The XML-element
         @param loading Loading (true) or saving (false)
         @return The XML-element
@@ -82,4 +84,5 @@
 
     bool Model::create(){
+      WorldEntity::create();
       if(meshSrc_.compare("")!=0){
         this->mesh_.setMesh(meshSrc_);
@@ -87,10 +90,10 @@
         COUT(4) << "Loader: Created model" << std::endl;
       }
-      registerAllVariables();
       return true;
     }
 
     void Model::registerAllVariables(){
-//      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
+      WorldEntity::registerAllVariables();
+      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
     }
 }
Index: code/trunk/src/orxonox/objects/Model.h
===================================================================
--- code/trunk/src/orxonox/objects/Model.h	(revision 978)
+++ code/trunk/src/orxonox/objects/Model.h	(revision 1021)
@@ -22,8 +22,10 @@
             bool create();
 
+        protected:
+            void registerAllVariables();
+            
         private:
             std::string meshSrc_;
             Mesh mesh_;
-            void registerAllVariables();
     };
 }
Index: code/trunk/src/orxonox/objects/NPC.cc
===================================================================
--- code/trunk/src/orxonox/objects/NPC.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/NPC.cc	(revision 1021)
@@ -85,5 +85,5 @@
   void NPC::tick(float dt)
   {
-
+    update();
     this->setVelocity(0.995*this->getVelocity() + this->getAcceleration()*dt);
     this->translate(this->getVelocity()*dt);
Index: code/trunk/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1021)
@@ -39,8 +39,9 @@
 #include "util/String2Number.h"
 #include "util/Math.h"
-#include "../core/CoreIncludes.h"
-#include "../core/Debug.h"
-#include "../Orxonox.h"
-#include "../particle/ParticleInterface.h"
+#include "core/CoreIncludes.h"
+#include "core/Debug.h"
+#include "Orxonox.h"
+#include "InputHandler.h"
+#include "particle/ParticleInterface.h"
 #include "Projectile.h"
 #include "core/XMLPort.h"
@@ -55,4 +56,5 @@
     {
         RegisterObject(SpaceShip);
+        this->registerAllVariables();
 
         this->setConfigValues();
@@ -124,6 +126,7 @@
         this->brakeLoop(loop);
 */
-        this->init();
-
+//         this->create();
+
+        
         COUT(3) << "Info: SpaceShip was loaded" << std::endl;
     }
@@ -135,4 +138,19 @@
     }
 
+    bool SpaceShip::create(){
+      if(Model::create())
+        this->init();
+      else
+        return false;
+      return true;
+    }
+    
+    void SpaceShip::registerAllVariables(){
+      Model::registerAllVariables();
+      
+      
+      
+    }
+    
     void SpaceShip::init()
     {
@@ -202,4 +220,5 @@
     {
         Model::loadParams(xmlElem);
+        this->create();
 /*
         if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
@@ -267,5 +286,5 @@
 
         this->camNode_->attachObject(cam);
-        Orxonox::getSingleton()->getOgrePointer()->getRoot()->getAutoCreatedWindow()->addViewport(cam);
+        Orxonox::getSingleton()->getOgrePointer()->getRenderWindow()->addViewport(cam);
     }
 
@@ -400,7 +419,7 @@
         if (!this->setMouseEventCallback_)
         {
-            if (Orxonox::getSingleton()->getMouse())
+            if (InputHandler::getSingleton()->getMouse())
             {
-                Orxonox::getSingleton()->getMouse()->setEventCallback(this);
+                InputHandler::getSingleton()->getMouse()->setEventCallback(this);
                 this->setMouseEventCallback_ = true;
             }
@@ -427,6 +446,6 @@
         }
 
-        OIS::Keyboard* mKeyboard = Orxonox::getSingleton()->getKeyboard();
-        OIS::Mouse* mMouse = Orxonox::getSingleton()->getMouse();
+        OIS::Keyboard* mKeyboard = InputHandler::getSingleton()->getKeyboard();
+        OIS::Mouse* mMouse = InputHandler::getSingleton()->getMouse();
 
         mKeyboard->capture();
Index: code/trunk/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.h	(revision 978)
+++ code/trunk/src/orxonox/objects/SpaceShip.h	(revision 1021)
@@ -21,4 +21,6 @@
             SpaceShip();
             ~SpaceShip();
+            bool create();
+            void registerAllVariables();
             void init();
             void setConfigValues();
Index: code/trunk/src/orxonox/objects/Tickable.cc
===================================================================
--- code/trunk/src/orxonox/objects/Tickable.cc	(revision 978)
+++ 	(revision )
@@ -1,42 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "OrxonoxStableHeaders.h"
-
-#include "core/CoreIncludes.h"
-#include "Tickable.h"
-
-namespace orxonox
-{
-    /**
-        @brief Constructor: Registers the object in the Tickable-list
-    */
-    Tickable::Tickable()
-    {
-        RegisterRootObject(Tickable);
-    }
-}
Index: code/trunk/src/orxonox/objects/Tickable.h
===================================================================
--- code/trunk/src/orxonox/objects/Tickable.h	(revision 978)
+++ 	(revision )
@@ -1,82 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/*!
-    @file Tickable.h
-    @brief Definition of the Tickable interface.
-
-    The Tickable interface provides a tick(dt) function, that gets called every frame.
-    float dt is the time since the last frame in seconds.
-
-    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.
-*/
-
-#ifndef _Tickable_H__
-#define _Tickable_H__
-
-#include <OgreFrameListener.h>
-
-#include "../OrxonoxPrereqs.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
-    class TickFrameListener; // Forward declaration
-
-    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
-    class _OrxonoxExport Tickable : virtual public OrxonoxClass
-    {
-        public:
-            /**
-                @brief Gets called every frame.
-                @param dt The time since the last frame in seconds
-            */
-            virtual void tick(float dt) = 0;
-
-        protected:
-            Tickable();
-    };
-
-    //! The TickFrameListener calls the tick(dt) function of all Tickables every frame.
-    class _OrxonoxExport TickFrameListener : public Ogre::FrameListener
-    {
-        private:
-            /** @brief Gets called before a frame gets rendered. */
-            bool frameStarted(const Ogre::FrameEvent &evt)
-            {
-                // Iterate through all Tickables and call their tick(dt) function
-                for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )
-                    (it++)->tick(evt.timeSinceLastFrame);
-
-                return FrameListener::frameStarted(evt);
-            }
-    };
-}
-
-#endif /* _Tickable_H__ */
Index: code/trunk/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1021)
@@ -49,15 +49,5 @@
         RegisterObject(WorldEntity);
 
-        if (Orxonox::getSingleton()->getSceneManager())
-        {
-            std::ostringstream name;
-            name << (WorldEntity::worldEntityCounter_s++);
-            this->setName("WorldEntity" + name.str());
-            this->node_ = Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
-        }
-        else
-        {
-            this->node_ = 0;
-        }
+        //create();
 
         this->bStatic_ = true;
@@ -67,4 +57,18 @@
         this->rotationRate_ = 0;
         this->momentum_ = 0;
+        
+        if (Orxonox::getSingleton()->getSceneManager())
+        {
+          std::ostringstream name;
+          name << (WorldEntity::worldEntityCounter_s++);
+          this->setName("WorldEntity" + name.str());
+          this->node_ = Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
+        
+          registerAllVariables();
+        }
+        else
+        {
+          this->node_ = 0;
+        }
     }
 
@@ -89,4 +93,5 @@
 
         BaseObject::loadParams(xmlElem);
+        create();
 /*
         if (xmlElem->Attribute("position"))
@@ -185,12 +190,8 @@
     }
 
-    bool WorldEntity::create(){
-      registerAllVariables();
-      return true;
-    }
 
     void WorldEntity::registerAllVariables()
     {
-/*      // register coordinates
+      // register coordinates
       registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
       registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
@@ -200,7 +201,7 @@
       registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
       registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
-      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);*/
+      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
       // not needed at the moment, because we don't have prediction yet
-      /*// register velocity_
+      // register velocity_
       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
@@ -210,5 +211,5 @@
       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
-      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);*/
+      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
     }
 
Index: code/trunk/src/orxonox/objects/WorldEntity.h
===================================================================
--- code/trunk/src/orxonox/objects/WorldEntity.h	(revision 978)
+++ code/trunk/src/orxonox/objects/WorldEntity.h	(revision 1021)
@@ -12,10 +12,10 @@
 //#include "util/tinyxml/tinyxml.h"
 #include "core/BaseObject.h"
-#include "Tickable.h"
+#include "core/Tickable.h"
 #include "../tools/Mesh.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport WorldEntity : public BaseObject, public Tickable//, public network::Synchronisable
+    class _OrxonoxExport WorldEntity : public BaseObject, public Tickable, public network::Synchronisable
     {
         public:
@@ -26,5 +26,5 @@
             virtual void loadParams(TiXmlElement* xmlElem);
             virtual void XMLPort(Element& xmlelement, bool loading);
-            bool create();
+            inline bool create(){ return true; }
 
             void attachWorldEntity(WorldEntity* entity);
Index: code/trunk/src/orxonox/objects/weapon/AmmunitionDump.cc
===================================================================
--- code/trunk/src/orxonox/objects/weapon/AmmunitionDump.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/weapon/AmmunitionDump.cc	(revision 1021)
@@ -45,4 +45,5 @@
   {
     RegisterObject(AmmunitionDump);
+    registerAllVariables();
 
     for (int i = 0; i < numberOfAmmos_; i++)
@@ -114,3 +115,13 @@
     return stock_[id];
   }
+  
+  void AmmunitionDump::registerAllVariables(){
+    registerVar( &numberOfAmmos_, sizeof(int), network::DATA);
+    
+    for (int i = 0; i < numberOfAmmos_; i++)
+    {
+      registerVar(&stock_[i], sizeof(int), network::DATA);
+      registerVar(&capacity_[i], sizeof(int), network::DATA);
+    }
+  }
 }
Index: code/trunk/src/orxonox/objects/weapon/AmmunitionDump.h
===================================================================
--- code/trunk/src/orxonox/objects/weapon/AmmunitionDump.h	(revision 978)
+++ code/trunk/src/orxonox/objects/weapon/AmmunitionDump.h	(revision 1021)
@@ -60,4 +60,5 @@
   protected:
     inline bool create() { return true; }
+    void registerAllVariables();
 
     int numberOfAmmos_;
Index: code/trunk/src/orxonox/objects/weapon/BulletManager.cc
===================================================================
--- code/trunk/src/orxonox/objects/weapon/BulletManager.cc	(revision 978)
+++ code/trunk/src/orxonox/objects/weapon/BulletManager.cc	(revision 1021)
@@ -39,4 +39,5 @@
   {
     RegisterObject(BulletManager);
+    registerAllVariables();
     bullets_ = new Bullet*[bulletsSize_];
   }
@@ -103,3 +104,10 @@
   }
 
+  void BulletManager::registerAllVariables(){
+    registerVar(&bulletsSize_, sizeof(int), network::DATA);
+    registerVar(&bulletsIndex_, sizeof(int), network::DATA);
+    // TODO we got a problem here:
+    // there is no possibility (so far) to synchronise pointers to objects
+  }
+  
 }
Index: code/trunk/src/orxonox/objects/weapon/BulletManager.h
===================================================================
--- code/trunk/src/orxonox/objects/weapon/BulletManager.h	(revision 978)
+++ code/trunk/src/orxonox/objects/weapon/BulletManager.h	(revision 1021)
@@ -39,5 +39,5 @@
 #include "util/tinyxml/tinyxml.h"
 #include "core/BaseObject.h"
-#include "../Tickable.h"
+#include "core/Tickable.h"
 
 namespace orxonox {
@@ -60,4 +60,5 @@
   protected:
     inline bool create() { return true; }
+    void registerAllVariables();
 
     // Bullet array
Index: code/trunk/src/orxonox/particle/ParticleInterface.cc
===================================================================
--- code/trunk/src/orxonox/particle/ParticleInterface.cc	(revision 978)
+++ code/trunk/src/orxonox/particle/ParticleInterface.cc	(revision 1021)
@@ -69,5 +69,5 @@
   {
     //Abgleichen der anderen Emitter an die Variabeln
-    for (int i=0; i < numberOfEmitters_; i++) {
+    for (int i=1; i < numberOfEmitters_; i++) {
       particleSystem_->getEmitter(i)->setColour( colour_ );
       particleSystem_->getEmitter(i)->setTimeToLive( distance_ );
@@ -84,5 +84,5 @@
   }
 
-  void ParticleInterface::setRate(float r)
+  void ParticleInterface::setRate(int r)
   {
     rate_ = r;
@@ -127,5 +127,5 @@
   Vector3 ParticleInterface::getPositionOfEmitter ( int emitterNr )
   {
-    return particleSystem_->getEmitter(emitterNr)->getPosition();
+    return particleSystem_->getEmitter(0)->getPosition();
   }
 
Index: code/trunk/src/orxonox/particle/ParticleInterface.h
===================================================================
--- code/trunk/src/orxonox/particle/ParticleInterface.h	(revision 978)
+++ code/trunk/src/orxonox/particle/ParticleInterface.h	(revision 1021)
@@ -48,7 +48,7 @@
     void setVelocity( Real v );
 
-    inline float getRate()
+    inline int getRate()
       { return rate_; };
-    void setRate( float r );
+    void setRate( int r );
 
     inline Real getDistance()
@@ -71,5 +71,5 @@
     Real distance_;
     Real velocity_;
-    float rate_;
+    int rate_;
     ColourValue colour_;
     int numberOfEmitters_;
Index: code/trunk/src/orxonox/script/tolua++.h
===================================================================
--- code/trunk/src/orxonox/script/tolua++.h	(revision 1021)
+++ code/trunk/src/orxonox/script/tolua++.h	(revision 1021)
@@ -0,0 +1,182 @@
+/* tolua
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Apr 2003
+** $Id: $
+*/
+
+/* This code is free software; you can redistribute it and/or modify it.
+** The software provided hereunder is on an "as is" basis, and
+** the author has no obligation to provide maintenance, support, updates,
+** enhancements, or modifications.
+*/
+
+
+#ifndef TOLUA_H
+#define TOLUA_H
+
+#ifndef TOLUA_API
+#define TOLUA_API extern
+#endif
+
+#define TOLUA_VERSION "tolua++-1.0.92"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define tolua_pushcppstring(x,y)	tolua_pushstring(x,y.c_str())
+#define tolua_iscppstring	tolua_isstring
+
+#define tolua_iscppstringarray tolua_isstringarray
+#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str())
+
+#ifndef TEMPLATE_BIND
+ #define TEMPLATE_BIND(p)
+#endif
+
+#define TOLUA_TEMPLATE_BIND(p)
+
+#define TOLUA_PROTECTED_DESTRUCTOR
+#define TOLUA_PROPERTY_TYPE(p)
+
+typedef int lua_Object;
+
+#include "lua.h"
+#include "lauxlib.h"
+
+struct tolua_Error
+{
+	int index;
+	int array;
+	const char* type;
+};
+typedef struct tolua_Error tolua_Error;
+
+#define TOLUA_NOPEER	LUA_REGISTRYINDEX /* for lua 5.1 */
+
+TOLUA_API const char* tolua_typename (lua_State* L, int lo);
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err);
+TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err);
+TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isvaluearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isbooleanarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumberarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isstringarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_istablearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdataarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertypearray
+ (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err);
+
+TOLUA_API void tolua_open (lua_State* L);
+
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size);
+TOLUA_API int tolua_register_gc (lua_State* L, int lo);
+TOLUA_API int tolua_default_collect (lua_State* tolua_S);
+
+TOLUA_API void tolua_usertype (lua_State* L, char* type);
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name);
+TOLUA_API void tolua_endmodule (lua_State* L);
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar);
+TOLUA_API void tolua_class (lua_State* L, char* name, char* base);
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col);
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func);
+TOLUA_API void tolua_constant (lua_State* L, char* name, lua_Number value);
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set);
+TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set);
+
+/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
+/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
+
+TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
+TOLUA_API void tolua_pushboolean (lua_State* L, int value);
+TOLUA_API void tolua_pushnumber (lua_State* L, lua_Number value);
+TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
+TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
+TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, lua_Number v);
+TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
+TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
+TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
+TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
+
+TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def);
+TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
+TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
+TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
+TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
+TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
+TOLUA_API lua_Number tolua_tofieldnumber (lua_State* L, int lo, int index, lua_Number def);
+TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
+TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
+TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
+TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def);
+TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def);
+
+TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name);
+
+TOLUA_API int class_gc_event (lua_State* L);
+
+#ifdef __cplusplus
+static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) {
+
+	const char* s = tolua_tostring(L, narg, def);
+	return s?s:"";
+};
+
+static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) {
+
+	const char* s = tolua_tofieldstring(L, lo, index, def);
+	return s?s:"";
+};
+
+#else
+#define tolua_tocppstring tolua_tostring
+#define tolua_tofieldcppstring tolua_tofieldstring
+#endif
+
+TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index);
+
+#ifndef Mtolua_new
+#define Mtolua_new(EXP) new EXP
+#endif
+
+#ifndef Mtolua_delete
+#define Mtolua_delete(EXP) delete EXP
+#endif
+
+#ifndef Mtolua_delete_dim
+#define Mtolua_delete_dim(EXP) delete [] EXP
+#endif
+
+#ifndef tolua_outside
+#define tolua_outside
+#endif
+
+#ifndef tolua_owned
+#define tolua_owned
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: code/trunk/src/orxonox/tools/Timer.cc
===================================================================
--- code/trunk/src/orxonox/tools/Timer.cc	(revision 978)
+++ code/trunk/src/orxonox/tools/Timer.cc	(revision 1021)
@@ -46,3 +46,28 @@
         this->time_ = 0;
     }
+
+    /**
+        @brief Updates the timer before the frames are rendered.
+    */
+    void TimerBase::tick(float dt)
+    {
+        if (this->bActive_)
+        {
+            // If active: Decrease the timer by the duration of the last frame
+            this->time_ -= dt;
+
+            if (this->time_ <= 0)
+            {
+                // It's time to call the function
+                if (this->bLoop_)
+                    // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
+                    this->time_ += this->interval_;
+                else
+                    this->stopTimer(); // Stop the timer if we don't want to loop
+
+                this->run();
+            }
+        }
+    }
+
 }
Index: code/trunk/src/orxonox/tools/Timer.h
===================================================================
--- code/trunk/src/orxonox/tools/Timer.h	(revision 978)
+++ code/trunk/src/orxonox/tools/Timer.h	(revision 1021)
@@ -58,14 +58,12 @@
 #define _Timer_H__
 
-#include <OgreFrameListener.h>
 #include "../OrxonoxPrereqs.h"
+#include "core/Tickable.h"
 
 namespace orxonox
 {
     //! TimerBase is the parent of the Timer class.
-    class _OrxonoxExport TimerBase : public OrxonoxClass
+    class _OrxonoxExport TimerBase : public Tickable
     {
-        friend class TimerFrameListener;
-
         public:
             TimerBase();
@@ -83,4 +81,6 @@
             /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */
             inline bool isActive() const { return this->bActive_; }
+
+            void tick(float dt);
 
         protected:
@@ -145,39 +145,4 @@
     };
 
-    //! The TimerFrameListener manages all Timers in the game.
-    class TimerFrameListener : public Ogre::FrameListener
-    {
-        private:
-            /** @brief Gets called before a frame gets rendered. */
-            bool frameStarted(const Ogre::FrameEvent &evt)
-            {
-                // 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_ -= evt.timeSinceLastFrame;
-
-                        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;
-                }
-
-                return FrameListener::frameStarted(evt);
-            }
-    };
 }
 
