Index: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt	(revision 1292)
+++ code/trunk/CMakeLists.txt	(revision 1293)
@@ -22,4 +22,5 @@
 
 OPTION(NETWORK_TESTING_ENABLED "Do you want to build network testing tools: i.e. chatclient chatserver and alike")
+OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Do you want to build dummyserver4 and dummyclient4")
 
 
@@ -42,6 +43,6 @@
 
 # global compiler/linker flags. force -O2!
-SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O2 -Wall -g -ggdb")
-SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O2 -Wall -g -ggdb")
+SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O0 -Wall -g -ggdb")
+SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
 SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}")
 SET(CMAKE_EXE_LINKER_FLAGS " --no-undefined")
Index: code/trunk/TODO
===================================================================
--- code/trunk/TODO	(revision 1293)
+++ code/trunk/TODO	(revision 1293)
@@ -0,0 +1,2 @@
+very urgent: make sure receiver thread of connectionmanager is 
+threadsafe (event_type_receive, findclient)
Index: code/trunk/bin/keybindings.ini
===================================================================
--- code/trunk/bin/keybindings.ini	(revision 1292)
+++ code/trunk/bin/keybindings.ini	(revision 1293)
@@ -24,5 +24,5 @@
 R_6=
 H_6=
-P_7=
+P_7="exec disco.txt"
 R_7=
 H_7=
@@ -30,5 +30,5 @@
 R_8=
 H_8=
-P_9=
+P_9="disco.txt"
 R_9=
 H_9=
Index: code/trunk/bin/levels/sample.oxw
===================================================================
--- code/trunk/bin/levels/sample.oxw	(revision 1292)
+++ code/trunk/bin/levels/sample.oxw	(revision 1293)
@@ -9,8 +9,7 @@
   </audio--> 
 
-<Ambient colourvalue="1,1,1" />
+<!--Ambient colourvalue="1,1,1" /-->
 <Skybox src="Orxonox/StarSkyBox" />
-
-<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
+<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
 
 <NPC position="0,100,400" scale="1" mesh="razor.mesh"/>
@@ -31,9 +30,9 @@
 </Model-->
 
-<Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
+<!--Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
 <Model position="-200,1000,500" scale="10" mesh="hoover_gear0.mesh" yawpitchroll="-90,-90,0" />
 <Model position="-200,1000,500" scale="10" mesh="hoover_gear1.mesh" yawpitchroll="-90,-90,0" />
 <Model position="-200,1000,500" scale="10" mesh="hoover_gear2.mesh" yawpitchroll="-90,-90,0" />
-<Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" />
+<Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" /-->
 
 
Index: code/trunk/bin/ogre.cfg-init
===================================================================
--- code/trunk/bin/ogre.cfg-init	(revision 1292)
+++ code/trunk/bin/ogre.cfg-init	(revision 1293)
@@ -4,4 +4,4 @@
 FSAA=0
 Full Screen=No
-RTT Preferred Mode=PBuffer
+RTT Preferred Mode=FBO
 Video Mode=1024 x 768
Index: code/trunk/bin/run-script
===================================================================
--- code/trunk/bin/run-script	(revision 1292)
+++ code/trunk/bin/run-script	(revision 1293)
@@ -22,3 +22,4 @@
 	fi
 fi
+trap "xset r" EXIT HUP INT TERM ABRT KILL
 exec ./orxonox $@
Index: code/trunk/cmake/FindBoost.cmake
===================================================================
--- code/trunk/cmake/FindBoost.cmake	(revision 1292)
+++ code/trunk/cmake/FindBoost.cmake	(revision 1293)
@@ -101,4 +101,5 @@
 # Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
 SET(SUFFIX_FOR_PATH
+ boost
  boost-1_34_1
  boost-1_34_0
Index: code/trunk/src/core/BaseObject.cc
===================================================================
--- code/trunk/src/core/BaseObject.cc	(revision 1292)
+++ code/trunk/src/core/BaseObject.cc	(revision 1293)
@@ -45,12 +45,11 @@
         @brief Constructor: Registers the object in the BaseObject-list.
     */
-    BaseObject::BaseObject()
+    BaseObject::BaseObject() :
+      bActive_(true),
+      bVisible_(true),
+      level_(0),
+      namespace_(0)
     {
         RegisterRootObject(BaseObject);
-
-        this->bActive_ = true;
-        this->bVisible_ = true;
-        this->level_ = 0;
-        this->namespace_ = 0;
     }
 
Index: code/trunk/src/core/CommandExecutor.h
===================================================================
--- code/trunk/src/core/CommandExecutor.h	(revision 1292)
+++ code/trunk/src/core/CommandExecutor.h	(revision 1293)
@@ -89,4 +89,5 @@
             inline std::string getAdditionalParameter() const
                 { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
+            inline std::string getCommandString() const { return this->processedCommand_; }
 
             void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
Index: code/trunk/src/core/CoreIncludes.h
===================================================================
--- code/trunk/src/core/CoreIncludes.h	(revision 1292)
+++ code/trunk/src/core/CoreIncludes.h	(revision 1293)
@@ -59,5 +59,7 @@
     if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \
         this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
-    orxonox::ClassManager<ClassName>::getIdentifier()->addObject(this)
+    orxonox::ClassManager<ClassName>::getIdentifier()->addObject(this); \
+    if (orxonox::Identifier::isCreatingHierarchy()) \
+      return
 
 /**
Index: code/trunk/src/core/CorePrereqs.h
===================================================================
--- code/trunk/src/core/CorePrereqs.h	(revision 1292)
+++ code/trunk/src/core/CorePrereqs.h	(revision 1293)
@@ -144,12 +144,12 @@
 
   // input
+  //class GUIInputHandler;
   class InputBuffer;
   class InputBufferListener;
   class InputManager;
+  class JoyStickHandler;
   class KeyBinder;
-  class GUIInputHandler;
   class KeyHandler;
   class MouseHandler;
-  class JoyStickHandler;
 
 }
Index: code/trunk/src/core/Debug.h
===================================================================
--- code/trunk/src/core/Debug.h	(revision 1292)
+++ code/trunk/src/core/Debug.h	(revision 1293)
@@ -273,5 +273,5 @@
 #define CCOUT_EXEC(x) \
   orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
-  << "*** " << this->getIdentifier()->getName() << ": "
+  << this->getIdentifier()->getName() << ": "
 
 #ifndef CCOUT
Index: code/trunk/src/core/Error.cc
===================================================================
--- code/trunk/src/core/Error.cc	(revision 1292)
+++ code/trunk/src/core/Error.cc	(revision 1293)
@@ -37,15 +37,5 @@
 namespace orxonox
 {
-	Error::Error()
-	{
-		Error(0,"");
-	}
-
 	Error::Error(std::string errorMsg, int errorCode)
-	{
-		Error(errorCode, errorMsg);
-	}
-
-	Error::Error(int errorCode, std::string errorMsg)
 	{
 		COUT(1) << "############################ "<< std::endl
Index: code/trunk/src/core/Error.h
===================================================================
--- code/trunk/src/core/Error.h	(revision 1292)
+++ code/trunk/src/core/Error.h	(revision 1293)
@@ -44,7 +44,5 @@
 	{
 	public:
-		Error();
-		Error(std::string errorMsg, int errorCode = 0);
-		Error(int errorCode, std::string errorMsg = "");
+		Error(std::string errorMsg = "", int errorCode = 0);
 	private:
 
Index: code/trunk/src/core/InputBuffer.cc
===================================================================
--- code/trunk/src/core/InputBuffer.cc	(revision 1292)
+++ code/trunk/src/core/InputBuffer.cc	(revision 1293)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -32,162 +32,182 @@
 
 #include "util/Clipboard.h"
-#include "InputManager.h"
+#include "CoreIncludes.h"
+#include "ConfigValueIncludes.h"
 
 namespace orxonox
 {
-    InputBuffer::InputBuffer()
-    {
-        //this->bActivated_ = false;
-        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^";
-        this->keyboard_ = InputManager::getKeyboard();
-        this->buffer_ = "";
-
-        //this->keyboard_->setEventCallback(this);
-    }
-
-    InputBuffer::InputBuffer(const std::string allowedChars)
-    {
-        //this->bActivated_ = false;
-        this->allowedChars_ = allowedChars;
-        this->keyboard_ = InputManager::getKeyboard();
-        this->buffer_ = "";
-    }
-/*
-    void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), bool bOnlySingleInput)
-    {
-        struct InputBufferListenerTuple newListener = {listener, function, true, bOnlySingleInput, ' '};
-        this->listeners_.insert(this->listeners_.end(), newListener);
-    }
-
-    void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), char char_, bool bOnlySingleInput)
-    {
-        struct InputBufferListenerTuple newListener = {listener, function, false, bOnlySingleInput, char_};
-        this->listeners_.insert(this->listeners_.end(), newListener);
-    }
-*/
-    void InputBuffer::set(const std::string& input)
-    {
-        this->buffer_ = "";
-        this->append(input);
-    }
-
-    void InputBuffer::append(const std::string& input)
-    {
-        for (unsigned int i = 0; i < input.size(); i++)
-        {
-            if (this->charIsAllowed(input[i]))
-                this->buffer_ += input[i];
-
-            this->updated(input[i], false);
-        }
-        this->updated();
-    }
-
-    void InputBuffer::append(const char& input)
-    {
-        if (this->charIsAllowed(input))
-            this->buffer_ += input;
-
-        this->updated(input, true);
-    }
-
-    void InputBuffer::clear()
-    {
-        this->buffer_ = "";
-        this->updated();
-    }
-
-    void InputBuffer::removeLast()
-    {
-        this->buffer_ = this->buffer_.substr(0, this->buffer_.size() - 1);
-        this->updated();
-    }
-
-    void InputBuffer::updated()
-    {
-        for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it).bListenToAllChanges_)
-                (*(*it).listener_.*(*it).function_)();
-        }
-    }
-
-    void InputBuffer::updated(const char& update, bool bSingleInput)
-    {
-        for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if (((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))
-                (*(*it).listener_.*(*it).function_)();
-        }
-    }
-
-    /*void InputBuffer::activityChanged() const
-    {
-    }*/
-
-    bool InputBuffer::charIsAllowed(const char& input)
-    {
-        if (this->allowedChars_ == "")
-            return true;
-        else
-            return (this->allowedChars_.find(input) != std::string::npos);
-    }
-
-    bool InputBuffer::keyPressed(const OIS::KeyEvent &e)
-    {
-        /*if (e.key == OIS::KC_NUMPADENTER)
-        {
-            this->setActivated(!this->isActivated());
-            this->clear();
-            return true;
-        }*/
-
-        if (this->keyboard_->isModifierDown(OIS::Keyboard::Ctrl))
-        {
-            if (e.key == OIS::KC_V)
-            {
-                this->append(fromClipboard());
-                return true;
-            }
-            else if (e.key == OIS::KC_C)
-            {
-                toClipboard(this->buffer_);
-                return true;
-            }
-            else if (e.key == OIS::KC_X)
-            {
-                toClipboard(this->buffer_);
-                this->clear();
-                return true;
-            }
-        }
-        else if (this->keyboard_->isModifierDown(OIS::Keyboard::Shift))
-        {
-            if (e.key == OIS::KC_INSERT)
-            {
-                this->append(fromClipboard());
-                return true;
-            }
-            else if (e.key == OIS::KC_DELETE)
-            {
-                toClipboard(this->buffer_);
-                this->clear();
-                return true;
-            }
-        }
-
-        //std::cout << this->keyboard_->getAsString(e.key) << " / " << (char)e.text << std::endl;
-
-        std::string input = this->keyboard_->getAsString(e.key);
-        /*if (input.size() >= 1)
-            this->append(input[0]);*/
-
-        this->append((char)e.text);
-        return true;
-    }
-
-    bool InputBuffer::keyReleased(const OIS::KeyEvent &e)
-    {
-        return true;
-    }
+  InputBuffer::InputBuffer(const std::string allowedChars) :
+    buffer_(""),
+    allowedChars_(allowedChars),
+    lastKey_(KeyCode::Unassigned),
+    timeSinceKeyPressed_(0.0f),
+    timeSinceKeyRepeated_(0.0f),
+    keysToRepeat_(0)
+  {
+    RegisterObject(InputBuffer);
+    setConfigValues();
+  }
+
+  void InputBuffer::setConfigValues()
+  {
+    SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
+    SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
+    if (keyRepeatDeleay_ < 0.0)
+    {
+      ResetConfigValue(keyRepeatDeleay_);
+    }
+    if (keyRepeatTime_ < 0.0)
+    {
+      ResetConfigValue(keyRepeatTime_);
+    }
+  }
+  /*
+  void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), bool bOnlySingleInput)
+  {
+    struct InputBufferListenerTuple newListener = {listener, function, true, bOnlySingleInput, ' '};
+    listeners_.insert(listeners_.end(), newListener);
+  }
+
+  void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), char char_, bool bOnlySingleInput)
+  {
+    struct InputBufferListenerTuple newListener = {listener, function, false, bOnlySingleInput, char_};
+    listeners_.insert(listeners_.end(), newListener);
+  }
+  */
+  void InputBuffer::set(const std::string& input)
+  {
+    buffer_ = "";
+    append(input);
+  }
+
+  void InputBuffer::append(const std::string& input)
+  {
+    for (unsigned int i = 0; i < input.size(); i++)
+    {
+      if (charIsAllowed(input[i]))
+        buffer_ += input[i];
+
+      updated(input[i], false);
+    }
+    updated();
+  }
+
+  void InputBuffer::append(const char& input)
+  {
+    if (charIsAllowed(input))
+      buffer_ += input;
+
+    updated(input, true);
+  }
+
+  void InputBuffer::clear()
+  {
+    buffer_ = "";
+    updated();
+  }
+
+  void InputBuffer::removeLast()
+  {
+    buffer_ = buffer_.substr(0, buffer_.size() - 1);
+    updated();
+  }
+
+  void InputBuffer::updated()
+  {
+    for (std::list<InputBufferListenerTuple>::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
+    {
+      if ((*it).bListenToAllChanges_)
+        (*(*it).listener_.*(*it).function_)();
+    }
+  }
+
+  void InputBuffer::updated(const char& update, bool bSingleInput)
+  {
+    for (std::list<InputBufferListenerTuple>::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
+    {
+      if (((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))
+        (*(*it).listener_.*(*it).function_)();
+    }
+  }
+
+  bool InputBuffer::charIsAllowed(const char& input)
+  {
+    if (allowedChars_ == "")
+      return true;
+    else
+      return (allowedChars_.find(input) != std::string::npos);
+  }
+
+
+  void InputBuffer::processKey(const KeyEvent &evt)
+  {
+    if (evt.isModifierDown(KeyboardModifier::Ctrl))
+    {
+      if (evt.key == KeyCode::V)
+        append(fromClipboard());
+      else if (evt.key == KeyCode::C)
+        toClipboard(buffer_);
+      else if (evt.key == KeyCode::X)
+      {
+        toClipboard(buffer_);
+        clear();
+      }
+    }
+    else if (evt.isModifierDown(KeyboardModifier::Shift))
+    {
+      if (evt.key == KeyCode::Insert)
+      {
+        append(fromClipboard());
+      }
+      else if (evt.key == KeyCode::Delete)
+      {
+        toClipboard(buffer_);
+        clear();
+      }
+    }
+    //std::string input = keyboard_->getAsString(e.key);
+    /*if (input.size() >= 1)
+    append(input[0]);*/
+
+    append((char)evt.text);
+  }
+
+  void InputBuffer::tick(float dt)
+  {
+    timeSinceKeyPressed_ += dt;
+    if (keysToRepeat_ < 10 && timeSinceKeyPressed_ > keyRepeatDeleay_)
+    {
+      // initial time out has gone by, start repeating keys
+      while (timeSinceKeyPressed_ - timeSinceKeyRepeated_ > keyRepeatTime_)
+      {
+        timeSinceKeyRepeated_ += keyRepeatTime_;
+        keysToRepeat_++;
+      }
+    }
+  }
+
+  bool InputBuffer::keyPressed(const KeyEvent &evt)
+  {
+    lastKey_ = evt.key;
+    timeSinceKeyPressed_ = 0.0;
+    timeSinceKeyRepeated_ = keyRepeatDeleay_;
+    keysToRepeat_ = 0;
+
+    processKey(evt);
+    return true;
+  }
+
+  bool InputBuffer::keyHeld(const KeyEvent& evt)
+  {
+    if (evt.key == lastKey_)
+    {
+      while (keysToRepeat_)
+      {
+        processKey(evt);
+        keysToRepeat_--;
+      }
+    }
+    return true;
+  }
+
 }
Index: code/trunk/src/core/InputBuffer.h
===================================================================
--- code/trunk/src/core/InputBuffer.h	(revision 1292)
+++ code/trunk/src/core/InputBuffer.h	(revision 1293)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -35,89 +35,91 @@
 #include <list>
 
-#include "ois/OISKeyboard.h"
-#include "InputHandler.h"
+#include "InputInterfaces.h"
+#include "Tickable.h"
 
 namespace orxonox
 {
-    class _CoreExport InputBufferListener
-    {};
+  class _CoreExport InputBufferListener
+  {};
 
-    class _CoreExport InputBuffer : public KeyHandler
+  class _CoreExport InputBuffer : public KeyHandler, public TickableReal
+  {
+    struct InputBufferListenerTuple
     {
-        struct InputBufferListenerTuple
-        {
-            InputBufferListener* listener_;
-            void (InputBufferListener::*function_)();
-            bool bListenToAllChanges_;
-            bool bOnlySingleInput_;
-            char char_;
-        };
+      InputBufferListener* listener_;
+      void (InputBufferListener::*function_)();
+      bool bListenToAllChanges_;
+      bool bOnlySingleInput_;
+      char char_;
+    };
 
-        public:
-            InputBuffer();
-            InputBuffer(const std::string allowedChars);
+  public:
+    InputBuffer(const std::string allowedChars =
+      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^");
 
-            template <class T>
-            void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
-            {
-                struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
-                this->listeners_.insert(this->listeners_.end(), newListener);
-            }
-            template <class T>
-            void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
-            {
-                struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
-                this->listeners_.insert(this->listeners_.end(), newListener);
-            }
+    void setConfigValues();
 
-            template <class T>
-            void registerListener(T* listener, void (T::*function)(), char char_, bool bOnlySingleInput)
-            {
-                struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
-                this->listeners_.insert(this->listeners_.end(), newListener);
-            }
-            template <class T>
-            void registerListener(T* listener, void (T::*function)() const, char char_, bool bOnlySingleInput)
-            {
-                struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
-                this->listeners_.insert(this->listeners_.end(), newListener);
-            }
+    template <class T>
+    void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
+    {
+      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
+      this->listeners_.insert(this->listeners_.end(), newListener);
+    }
+    template <class T>
+    void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
+    {
+      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
+      this->listeners_.insert(this->listeners_.end(), newListener);
+    }
 
-            void set(const std::string& input);
-            void append(const std::string& input);
-            void append(const char& input);
-            void removeLast();
-            void clear();
+    template <class T>
+    void registerListener(T* listener, void (T::*function)(), char char_, bool bOnlySingleInput)
+    {
+      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
+      this->listeners_.insert(this->listeners_.end(), newListener);
+    }
+    template <class T>
+    void registerListener(T* listener, void (T::*function)() const, char char_, bool bOnlySingleInput)
+    {
+      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
+      this->listeners_.insert(this->listeners_.end(), newListener);
+    }
 
-            void updated();
-            void updated(const char& update, bool bSingleInput);
+    void set(const std::string& input);
+    void append(const std::string& input);
+    void append(const char& input);
+    void removeLast();
+    void clear();
 
-            inline std::string get() const
-                { return this->buffer_; }
+    void updated();
+    void updated(const char& update, bool bSingleInput);
 
-            /*inline void activate()
-                { this->setActivated(true); }
-            inline void deactivate()
-                { this->setActivated(false); }
-            inline void setActivated(bool bActivated)
-                { if (this->bActivated_ != bActivated) { this->bActivated_ = bActivated; this->activityChanged(); } else { this->bActivated_ = bActivated; } }
-            inline bool isActivated() const
-                { return this->bActivated_; }
+    inline std::string get() const
+    { return this->buffer_; }
 
-            void activityChanged() const;*/
+  private:  // functions
+    bool charIsAllowed(const char& input);
 
-        private:
-            bool charIsAllowed(const char& input);
+    bool keyPressed (const KeyEvent& evt);
+    bool keyReleased(const KeyEvent& evt) { return true; }
+    bool keyHeld    (const KeyEvent& evt);
+    void processKey (const KeyEvent &e);
 
-            bool keyPressed(const OIS::KeyEvent &e);
-            bool keyReleased(const OIS::KeyEvent &e);
-            bool keyHeld(const OIS::KeyEvent &e) { return true; }
+    void tick(float dt);
 
-            OIS::Keyboard* keyboard_;
-            //bool bActivated_;
-            std::string buffer_;
-            std::list<InputBufferListenerTuple> listeners_;
-            std::string allowedChars_;
-    };
+  private: // variables
+    std::string buffer_;
+    std::list<InputBufferListenerTuple> listeners_;
+    std::string allowedChars_;
+
+    KeyCode::Enum lastKey_;
+    float timeSinceKeyPressed_;
+    float timeSinceKeyRepeated_;
+    int keysToRepeat_;
+
+    // configured values
+    float keyRepeatDeleay_;
+    float keyRepeatTime_;
+  };
 }
 
Index: code/trunk/src/core/InputHandler.cc
===================================================================
--- code/trunk/src/core/InputHandler.cc	(revision 1292)
+++ code/trunk/src/core/InputHandler.cc	(revision 1293)
@@ -33,9 +33,9 @@
 
 #include "InputHandler.h"
+#include "util/Convert.h"
 #include "Debug.h"
 #include "ConfigValueIncludes.h"
 #include "CoreIncludes.h"
-#include "util/Convert.h"
-#include "core/CommandExecutor.h"
+#include "CommandExecutor.h"
 
 namespace orxonox
@@ -55,173 +55,173 @@
     std::string keyNames[] = {
     "UNASSIGNED",
-		"ESCAPE",
-		"1",
-		"2",
-		"3",
-		"4",
-		"5",
-		"6",
-		"7",
-		"8",
-		"9",
-		"0",
-		"MINUS",
-		"EQUALS",
-		"BACK",
-		"TAB",
-		"Q",
-		"W",
-		"E",
-		"R",
-		"T",
-		"Y",
-		"U",
-		"I",
-		"O",
-		"P",
-		"LBRACKET",
-		"RBRACKET",
-		"RETURN",
-		"LCONTROL",
-		"A",
-		"S",
-		"D",
-		"F",
-		"G",
-		"H",
-		"J",
-		"K",
-		"L",
-		"SEMICOLON",
-		"APOSTROPHE",
-		"GRAVE",
-		"LSHIFT",
-		"BACKSLASH",
-		"Z",
-		"X",
-		"C",
-		"V",
-		"B",
-		"N",
-		"M",
-		"COMMA",
-		"PERIOD",
-		"SLASH",
-		"RSHIFT",
-		"MULTIPLY",
-		"LMENU",
-		"SPACE",
-		"CAPITAL",
-		"F1",
-		"F2",
-		"F3",
-		"F4",
-		"F5",
-		"F6",
-		"F7",
-		"F8",
-		"F9",
-		"F10",
-		"NUMLOCK",
-		"SCROLL",
-		"NUMPAD7",
-		"NUMPAD8",
-		"NUMPAD9",
-		"SUBTRACT",
-		"NUMPAD4",
-		"NUMPAD5",
-		"NUMPAD6",
-		"ADD",
-		"NUMPAD1",
-		"NUMPAD2",
-		"NUMPAD3",
-		"NUMPAD0",
-		"DECIMAL",
+    "ESCAPE",
+    "1",
+    "2",
+    "3",
+    "4",
+    "5",
+    "6",
+    "7",
+    "8",
+    "9",
+    "0",
+    "MINUS",
+    "EQUALS",
+    "BACK",
+    "TAB",
+    "Q",
+    "W",
+    "E",
+    "R",
+    "T",
+    "Y",
+    "U",
+    "I",
+    "O",
+    "P",
+    "LBRACKET",
+    "RBRACKET",
+    "RETURN",
+    "LCONTROL",
+    "A",
+    "S",
+    "D",
+    "F",
+    "G",
+    "H",
+    "J",
+    "K",
+    "L",
+    "SEMICOLON",
+    "APOSTROPHE",
+    "GRAVE",
+    "LSHIFT",
+    "BACKSLASH",
+    "Z",
+    "X",
+    "C",
+    "V",
+    "B",
+    "N",
+    "M",
+    "COMMA",
+    "PERIOD",
+    "SLASH",
+    "RSHIFT",
+    "MULTIPLY",
+    "LMENU",
+    "SPACE",
+    "CAPITAL",
+    "F1",
+    "F2",
+    "F3",
+    "F4",
+    "F5",
+    "F6",
+    "F7",
+    "F8",
+    "F9",
+    "F10",
+    "NUMLOCK",
+    "SCROLL",
+    "NUMPAD7",
+    "NUMPAD8",
+    "NUMPAD9",
+    "SUBTRACT",
+    "NUMPAD4",
+    "NUMPAD5",
+    "NUMPAD6",
+    "ADD",
+    "NUMPAD1",
+    "NUMPAD2",
+    "NUMPAD3",
+    "NUMPAD0",
+    "DECIMAL",
     "","",
-		"OEM_102",
-		"F11",
-		"F12",
+    "OEM_102",
+    "F11",
+    "F12",
     "","","","","","","","","","","",
-		"F13",
-		"F14",
-		"F15",
+    "F13",
+    "F14",
+    "F15",
     "","","","","","","","","","",
-		"KANA",
+    "KANA",
     "","",
-		"ABNT_C1",
+    "ABNT_C1",
     "","","","","",
-		"CONVERT",
-    "",
-		"NOCONVERT",
-    "",
-		"YEN",
-		"ABNT_C2",
+    "CONVERT",
+    "",
+    "NOCONVERT",
+    "",
+    "YEN",
+    "ABNT_C2",
     "","","","","","","","","","","","","","",
-		"NUMPADEQUALS",
+    "NUMPADEQUALS",
     "","",
-		"PREVTRACK",
-		"AT",
-		"COLON",
-		"UNDERLINE",
-		"KANJI",
-		"STOP",
-		"AX",
-		"UNLABELED",
-		"NEXTTRACK",
+    "PREVTRACK",
+    "AT",
+    "COLON",
+    "UNDERLINE",
+    "KANJI",
+    "STOP",
+    "AX",
+    "UNLABELED",
+    "NEXTTRACK",
     "","",
-		"NUMPADENTER",
-		"RCONTROL",
+    "NUMPADENTER",
+    "RCONTROL",
     "","",
-		"MUTE",
-		"CALCULATOR",
-		"PLAYPAUSE",
-    "",
-		"MEDIASTOP",
+    "MUTE",
+    "CALCULATOR",
+    "PLAYPAUSE",
+    "",
+    "MEDIASTOP",
     "","","","","","","","","",
-		"VOLUMEDOWN",
-    "",
-		"VOLUMEUP",
-    "",
-		"WEBHOME",
-		"NUMPADCOMMA",
-    "",
-		"DIVIDE",
-    "",
-		"SYSRQ",
-		"RMENU",
+    "VOLUMEDOWN",
+    "",
+    "VOLUMEUP",
+    "",
+    "WEBHOME",
+    "NUMPADCOMMA",
+    "",
+    "DIVIDE",
+    "",
+    "SYSRQ",
+    "RMENU",
     "","","","","","","","","","","","",
-		"PAUSE",
-    "",
-		"HOME",
-		"UP",
-		"PGUP",
-    "",
-		"LEFT",
-    "",
-		"RIGHT",
-    "",
-		"END",
-		"DOWN",
-		"PGDOWN",
-		"INSERT",
-		"DELETE",
+    "PAUSE",
+    "",
+    "HOME",
+    "UP",
+    "PGUP",
+    "",
+    "LEFT",
+    "",
+    "RIGHT",
+    "",
+    "END",
+    "DOWN",
+    "PGDOWN",
+    "INSERT",
+    "DELETE",
     "","","","","","","",
-		"LWIN",
-		"RWIN",
-		"APPS",
-		"POWER",
-		"SLEEP",
+    "LWIN",
+    "RWIN",
+    "APPS",
+    "POWER",
+    "SLEEP",
     "","","",
-		"WAKE",
-    "",
-		"WEBSEARCH",
-		"WEBFAVORITES",
-		"WEBREFRESH",
-		"WEBSTOP",
-		"WEBFORWARD",
-		"WEBBACK",
-		"MYCOMPUTER",
-		"MAIL",
-		"MEDIASELECT"
+    "WAKE",
+    "",
+    "WEBSEARCH",
+    "WEBFAVORITES",
+    "WEBREFRESH",
+    "WEBSTOP",
+    "WEBFORWARD",
+    "WEBBACK",
+    "MYCOMPUTER",
+    "MAIL",
+    "MEDIASELECT"
     };
     for (int i = 0; i < numberOfKeys_s; i++)
@@ -229,7 +229,7 @@
 
     std::string mouseButtonNames[] = {
-    "MouseLeft", "MouseRight", "MouseMiddle",
-    "MouseButton3", "MouseButton4", "MouseButton5",
-    "MouseButton6", "MouseButton7" };
+      "MouseLeft", "MouseRight", "MouseMiddle",
+      "MouseButton3", "MouseButton4", "MouseButton5",
+      "MouseButton6", "MouseButton7" };
     for (int i = 0; i < numberOfMouseButtons_s; i++)
       mouseButtonNames_[i] = mouseButtonNames[i];
@@ -267,14 +267,12 @@
         switch (j)
         {
-          // note: the first element in the struct is the string, so the following pointer
-          //       arithmetic works.
           case 0:
             cont->getValue(&bindingsKeyPress_[i].commandStr);
             break;
           case 1:
-            cont->getValue(bindingsKeyRelease_ + i);
+            cont->getValue(&bindingsKeyRelease_[i].commandStr);
             break;
           case 2:
-            cont->getValue(bindingsKeyHold_ + i);
+            cont->getValue(&bindingsKeyHold_[i].commandStr);
         }
       }
@@ -295,11 +293,11 @@
         {
           case 0:
-            cont->getValue(bindingsMouseButtonPress_ + i);
+            cont->getValue(&bindingsMouseButtonPress_[i].commandStr);
             break;
           case 1:
-            cont->getValue(bindingsMouseButtonRelease_ + i);
+            cont->getValue(&bindingsMouseButtonRelease_[i].commandStr);
             break;
           case 2:
-            cont->getValue(bindingsMouseButtonHold_ + i);
+            cont->getValue(&bindingsMouseButtonHold_[i].commandStr);
         }
       }
@@ -320,11 +318,11 @@
         {
           case 0:
-            cont->getValue(bindingsJoyStickButtonPress_ + i);
+            cont->getValue(&bindingsJoyStickButtonPress_[i].commandStr);
             break;
           case 1:
-            cont->getValue(bindingsJoyStickButtonRelease_ + i);
+            cont->getValue(&bindingsJoyStickButtonRelease_[i].commandStr);
             break;
           case 2:
-            cont->getValue(bindingsJoyStickButtonHold_ + i);
+            cont->getValue(&bindingsJoyStickButtonHold_[i].commandStr);
         }
       }
@@ -345,13 +343,13 @@
     for (int i = 0; i < numberOfMouseButtons_s; i++)
     {
-      bindingsMouseButtonPress_  [i] = "";
-      bindingsMouseButtonRelease_[i] = "";
-      bindingsMouseButtonHold_   [i] = "";
+      bindingsMouseButtonPress_  [i].commandStr = "";
+      bindingsMouseButtonRelease_[i].commandStr = "";
+      bindingsMouseButtonHold_   [i].commandStr = "";
     }
     for (int i = 0; i < numberOfJoyStickButtons_s; i++)
     {
-      bindingsJoyStickButtonPress_  [i] = "";
-      bindingsJoyStickButtonRelease_[i] = "";
-      bindingsJoyStickButtonHold_   [i] = "";
+      bindingsJoyStickButtonPress_  [i].commandStr = "";
+      bindingsJoyStickButtonRelease_[i].commandStr = "";
+      bindingsJoyStickButtonHold_   [i].commandStr = "";
     }
   }
@@ -370,12 +368,12 @@
     // evaluate the key bindings
     // TODO: what if binding is invalid?
-    //for (int i = 0; i < numberOfKeys_s; i++)
-    //{
-    //  if (bindingsKeyPress_[i].commandStr != "")
-    //  {
-    //    bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
-    //    bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
-    //  }
-    //}
+    for (int i = 0; i < numberOfKeys_s; i++)
+    {
+      if (bindingsKeyPress_[i].commandStr != "")
+      {
+        bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
+        bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
+      }
+    }
 
     COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
@@ -383,15 +381,15 @@
   }
 
-  bool KeyBinder::executeBinding(KeyBinding& binding)
+  bool KeyBinder::executeSimpleBinding(KeyBinding& binding)
   {
     if (binding.commandStr != "")
     {
-      //if (binding.commandStr != binding.evaluation.getCommandString())
-      //{
-      //  // key binding has changed, reevaluate the command string.
-      //  binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
-      //  binding.commandStr = binding.evaluation.getCommandString();
-      //}
-      COUT(3) << "Executing command: " << binding.commandStr << std::endl;
+      if (binding.commandStr != binding.evaluation.getCommandString())
+      {
+        // key binding has changed, reevaluate the command string.
+        binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
+        binding.commandStr = binding.evaluation.getCommandString();
+      }
+      COUT(ORX_DEBUG) << "Keybinding: Executing command: " << binding.commandStr << std::endl;
       CommandExecutor::execute(binding.commandStr);
     }
@@ -405,10 +403,9 @@
     @param e Event information
   */
-  bool KeyBinder::keyPressed(const OIS::KeyEvent &e)
-  {
-    COUT(3) << "Key: " << e.key << std::endl;
-    // find the appropriate key binding
-    executeBinding(bindingsKeyPress_[int(e.key)]);
-     
+  bool KeyBinder::keyPressed(const KeyEvent& evt)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsKeyPress_[int(evt.key)]);
+
     return true;
   }
@@ -418,8 +415,8 @@
     @param e Event information
   */
-  bool KeyBinder::keyReleased(const OIS::KeyEvent &e)
-  {
-    // find the appropriate key binding
-    executeBinding(bindingsKeyRelease_[int(e.key)]);
+  bool KeyBinder::keyReleased(const KeyEvent& evt)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsKeyRelease_[int(evt.key)]);
 
     return true;
@@ -428,10 +425,10 @@
   /**
     @brief Event handler for the keyHeld Event.
-    @param e Event information
-  */
-  bool KeyBinder::keyHeld(const OIS::KeyEvent &e)
-  {
-    // find the appropriate key binding
-    executeBinding(bindingsKeyHold_[int(e.key)]);
+    @param e Mouse state information
+  */
+  bool KeyBinder::keyHeld(const KeyEvent& evt)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsKeyHold_[int(evt.key)]);
 
     return true;
@@ -440,7 +437,30 @@
   /**
     @brief Event handler for the mouseMoved Event.
-    @param e Event information
-  */
-  bool KeyBinder::mouseMoved(const OIS::MouseEvent &e)
+    @param e Mouse state information
+  */
+  bool KeyBinder::mouseMoved(const MouseState &evt)
+  {
+    /*if (bindingMouseMoved_.commandStr != "")
+    {
+      if (bindingMouseMoved_.commandStr != bindingMouseMoved_.evaluation.getCommandString())
+      {
+        // key binding has changed, reevaluate the command string.
+        bindingMouseMoved_.evaluation = CommandExecutor::evaluate(bindingMouseMoved_.commandStr);
+        bindingMouseMoved_.commandStr = bindingMouseMoved_.evaluation.getCommandString();
+      }
+      COUT(3) << "Executing command: " << bindingMouseMoved_.commandStr << std::endl;
+
+      bindingMouseMoved_.evaluation.setEvaluatedParameter(
+      CommandExecutor::execute(bindingMouseMoved_.commandStr);
+    }*/
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseScrolled Event.
+    @param e Mouse state information
+  */
+  bool KeyBinder::mouseScrolled(const MouseState &evt)
   {
     return true;
@@ -452,13 +472,8 @@
     @param id The ID of the mouse button
   */
-  bool KeyBinder::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsMouseButtonPress_[int(id)];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
+  bool KeyBinder::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsMouseButtonPress_[int(id)]);
 
     return true;
@@ -470,13 +485,8 @@
     @param id The ID of the mouse button
   */
-  bool KeyBinder::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsMouseButtonRelease_[int(id)];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
+  bool KeyBinder::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsMouseButtonRelease_[int(id)]);
 
     return true;
@@ -488,72 +498,52 @@
     @param id The ID of the mouse button
   */
-  bool KeyBinder::mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsMouseButtonHold_[int(id)];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
-
-    return true;
-  }
-
-  bool KeyBinder::buttonPressed(int joyStickID, const OIS::JoyStickEvent &arg, int button)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsJoyStickButtonPress_[button];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
-
-    return true;
-  }
-
-  bool KeyBinder::buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsJoyStickButtonRelease_[button];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
-
-    return true;
-  }
-
-  bool KeyBinder::buttonHeld(int joyStickID, const OIS::JoyStickEvent &arg, int button)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsJoyStickButtonHold_[button];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
-
-    return true;
-  }
-
-  bool KeyBinder::axisMoved(int joyStickID, const OIS::JoyStickEvent &arg, int axis)
-  {
-    return true;
-  }
-
-  bool KeyBinder::sliderMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
-  {
-    return true;
-  }
-
-  bool KeyBinder::povMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
-  {
-    return true;
-  }
-
-  bool KeyBinder::vector3Moved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
+  bool KeyBinder::mouseButtonHeld(const MouseState& state, MouseButton::Enum id)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsMouseButtonHold_[int(id)]);
+
+    return true;
+  }
+
+  bool KeyBinder::joyStickButtonPressed(const JoyStickState& state, int button)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsJoyStickButtonPress_[button]);
+
+    return true;
+  }
+
+  bool KeyBinder::joyStickButtonReleased(const JoyStickState& state, int button)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsJoyStickButtonRelease_[button]);
+
+    return true;
+  }
+
+  bool KeyBinder::joyStickButtonHeld(const JoyStickState& state, int button)
+  {
+    // find the appropriate key binding
+    executeSimpleBinding(bindingsJoyStickButtonHold_[button]);
+
+    return true;
+  }
+
+  bool KeyBinder::joyStickAxisMoved(const JoyStickState& state, int axis)
+  {
+    return true;
+  }
+
+  bool KeyBinder::joyStickSliderMoved(const JoyStickState& state, int index)
+  {
+    return true;
+  }
+
+  bool KeyBinder::joyStickPovMoved(const JoyStickState& state, int index)
+  {
+    return true;
+  }
+
+  bool KeyBinder::joyStickVector3Moved(const JoyStickState& state, int index)
   {
     return true;
@@ -586,6 +576,6 @@
   //bool GUIInputHandler::keyPressed(const OIS::KeyEvent &e)
   //{
-		////CEGUI::System::getSingleton().injectKeyDown( arg.key );
-		////CEGUI::System::getSingleton().injectChar( arg.text );
+    ////CEGUI::System::getSingleton().injectKeyDown( arg.key );
+    ////CEGUI::System::getSingleton().injectChar( arg.text );
   //  return true;
   //}
@@ -597,5 +587,5 @@
   //bool GUIInputHandler::keyReleased(const OIS::KeyEvent &e)
   //{
-		////CEGUI::System::getSingleton().injectKeyUp( arg.key );
+    ////CEGUI::System::getSingleton().injectKeyUp( arg.key );
   //  return true;
   //}
@@ -607,5 +597,5 @@
   //bool GUIInputHandler::mouseMoved(const OIS::MouseEvent &e)
   //{
-		////CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
+    ////CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
   //  return true;
   //}
@@ -616,7 +606,7 @@
   //  @param id The ID of the mouse button
   //*/
-  //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButton id)
   //{
-		////CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
+    ////CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
   //  return true;
   //}
@@ -627,7 +617,7 @@
   //  @param id The ID of the mouse button
   //*/
-  //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButton id)
   //{
-		////CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
+    ////CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
   //  return true;
   //}
Index: code/trunk/src/core/InputHandler.h
===================================================================
--- code/trunk/src/core/InputHandler.h	(revision 1292)
+++ code/trunk/src/core/InputHandler.h	(revision 1293)
@@ -38,7 +38,9 @@
 
 #include <string>
+
 #include "ois/OIS.h"
 #include "OrxonoxClass.h"
 #include "CommandExecutor.h"
+#include "InputInterfaces.h"
 
 namespace orxonox
@@ -54,40 +56,4 @@
     };
   }
-
-  /**
-    @brief Interface class used for key input listeners.
-  */
-  class _CoreExport KeyHandler : public OIS::KeyListener
-  {
-  public:
-    virtual ~KeyHandler() { }
-    virtual bool keyHeld(const OIS::KeyEvent &arg) = 0;
-  };
-
-  /**
-    @brief Interface class used for mouse input listeners.
-  */
-  class _CoreExport MouseHandler : public OIS::MouseListener
-  {
-  public:
-    virtual ~MouseHandler() { }
-    virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0;
-  };
-
-  /**
-    @brief Interface class used for joy stick input listeners.
-  */
-  class _CoreExport JoyStickHandler
-  {
-  public:
-    virtual ~JoyStickHandler() { }
-		virtual bool buttonPressed (int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
-		virtual bool buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
-    virtual bool buttonHeld    (int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
-		virtual bool axisMoved     (int joyStickID, const OIS::JoyStickEvent &arg, int axis)   = 0;
-		virtual bool sliderMoved   (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
-		virtual bool povMoved      (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
-		virtual bool vector3Moved  (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
-  };
 
   struct _CoreExport KeyBinding
@@ -113,26 +79,25 @@
     void setConfigValues();
 
-    std::string testtest;
-
   private: // functions
 
-    bool executeBinding(KeyBinding &binding);
+    bool executeSimpleBinding(KeyBinding &binding);
 
-		bool keyPressed   (const OIS::KeyEvent   &arg);
-		bool keyReleased  (const OIS::KeyEvent   &arg);
-		bool keyHeld      (const OIS::KeyEvent   &arg);
+    bool keyPressed (const KeyEvent& evt);
+    bool keyReleased(const KeyEvent& evt);
+    bool keyHeld    (const KeyEvent& evt);
 
-    bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-		bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-    bool mouseMoved   (const OIS::MouseEvent &arg);
+    bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
+    bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
+    bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id);
+    bool mouseMoved         (const MouseState& state);
+    bool mouseScrolled      (const MouseState& state);
 
-		bool buttonPressed (int joyStickID, const OIS::JoyStickEvent &arg, int button);
-		bool buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button);
-		bool buttonHeld    (int joyStickID, const OIS::JoyStickEvent &arg, int button);
-		bool axisMoved     (int joyStickID, const OIS::JoyStickEvent &arg, int axis);
-		bool sliderMoved   (int joyStickID, const OIS::JoyStickEvent &arg, int id);
-		bool povMoved      (int joyStickID, const OIS::JoyStickEvent &arg, int id);
-		bool vector3Moved  (int joyStickID, const OIS::JoyStickEvent &arg, int id);
+    bool joyStickButtonPressed (const JoyStickState& state, int button);
+    bool joyStickButtonReleased(const JoyStickState& state, int button);
+    bool joyStickButtonHeld    (const JoyStickState& state, int button);
+    bool joyStickAxisMoved     (const JoyStickState& state, int axis)  ;
+    bool joyStickSliderMoved   (const JoyStickState& state, int index) ;
+    bool joyStickPovMoved      (const JoyStickState& state, int index) ;
+    bool joyStickVector3Moved  (const JoyStickState& state, int index) ;
 
   private: // variables
@@ -152,9 +117,13 @@
     static const int numberOfMouseButtons_s = 8;
     //! Array of input events for every pressed mouse button
-    std::string bindingsMouseButtonPress_  [numberOfMouseButtons_s];
+    KeyBinding bindingsMouseButtonPress_  [numberOfMouseButtons_s];
     //! Array of input events for every released mouse button
-    std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s];
+    KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s];
     //! Array of input events for every held mouse button
-    std::string bindingsMouseButtonHold_   [numberOfMouseButtons_s];
+    KeyBinding bindingsMouseButtonHold_   [numberOfMouseButtons_s];
+    //! Key binding for mouse moved event
+    KeyBinding bindingMouseMoved_;
+    //! Key binding for mouse scrolled event
+    KeyBinding bindingMouseScrolled_;
     //! Names of the mouse buttons as strings
     std::string mouseButtonNames_[numberOfMouseButtons_s];
@@ -163,9 +132,9 @@
     static const int numberOfJoyStickButtons_s = 32;
     //! Array of input events for every pressed joy stick button
-    std::string bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
+    KeyBinding bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
     //! Array of input events for every released joy stick button
-    std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
+    KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
     //! Array of input events for every held joy stick button
-    std::string bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
+    KeyBinding bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
     //! Names of the joy stick buttons as strings
     std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
@@ -186,19 +155,19 @@
   //private:
   //  // input events
-		//bool keyPressed   (const OIS::KeyEvent   &arg);
-		//bool keyReleased  (const OIS::KeyEvent   &arg);
-		//bool keyHeld      (const OIS::KeyEvent   &arg);
+    //bool keyPressed   (const OIS::KeyEvent   &arg);
+    //bool keyReleased  (const OIS::KeyEvent   &arg);
+    //bool keyHeld      (const OIS::KeyEvent   &arg);
 
-  //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-		//bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-		//bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+  //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButton id);
+    //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButton id);
+    //bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButton id);
   //  bool mouseMoved   (const OIS::MouseEvent &arg);
 
-		//bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
-		//bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
-		//bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
-		//bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
-		//bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
-		//bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+    //bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+    //bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+    //bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
+    //bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+    //bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+    //bool povMoved      (const OIS::JoyStickEvent &arg, int id);
   //};
 
Index: code/trunk/src/core/InputInterfaces.h
===================================================================
--- code/trunk/src/core/InputInterfaces.h	(revision 1293)
+++ code/trunk/src/core/InputInterfaces.h	(revision 1293)
@@ -0,0 +1,296 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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 Declarations of various interface classes for the input management.
+*/
+
+#ifndef _InputInterfaces_H__
+#define _InputInterfaces_H__
+
+#include "CorePrereqs.h"
+
+#include "ois/OIS.h"
+
+namespace orxonox
+{
+  namespace KeyCode
+  {
+    // note: KeyCode comments were directly taken from OISKeyboard.h
+    enum Enum
+    {
+      Unassigned    = OIS::KC_UNASSIGNED,  
+      Escape        = OIS::KC_ESCAPE,      
+      NumRow1       = OIS::KC_1,           
+      NumRow2       = OIS::KC_2,           
+      NumRow3       = OIS::KC_3,           
+      NumRow4       = OIS::KC_4,           
+      NumRow5       = OIS::KC_5,           
+      NumRow6       = OIS::KC_6,           
+      NumRow7       = OIS::KC_7,           
+      NumRow8       = OIS::KC_8,           
+      NumRow9       = OIS::KC_9,           
+      NumRow0       = OIS::KC_0,           
+      Minus         = OIS::KC_MINUS,           // - on main keyboard
+      Equals        = OIS::KC_EQUALS,      
+      Back          = OIS::KC_BACK,            // backspace
+      Tab           = OIS::KC_TAB,         
+      Q             = OIS::KC_Q,           
+      W             = OIS::KC_W,           
+      E             = OIS::KC_E,           
+      R             = OIS::KC_R,           
+      T             = OIS::KC_T,           
+      Y             = OIS::KC_Y,           
+      U             = OIS::KC_U,           
+      I             = OIS::KC_I,           
+      O             = OIS::KC_O,           
+      P             = OIS::KC_P,           
+      LeftBracket   = OIS::KC_LBRACKET,    
+      RightBracket  = OIS::KC_RBRACKET,    
+      Return        = OIS::KC_RETURN,          // Enter on main keyboard
+      LeftControl   = OIS::KC_LCONTROL,    
+      A             = OIS::KC_A,           
+      S             = OIS::KC_S,           
+      D             = OIS::KC_D,           
+      F             = OIS::KC_F,           
+      G             = OIS::KC_G,           
+      H             = OIS::KC_H,           
+      J             = OIS::KC_J,           
+      K             = OIS::KC_K,           
+      L             = OIS::KC_L,           
+      Semicolon     = OIS::KC_SEMICOLON,   
+      Apostrophe    = OIS::KC_APOSTROPHE,  
+      Grave         = OIS::KC_GRAVE,           // accent
+      LeftShift     = OIS::KC_LSHIFT,      
+      Backslash     = OIS::KC_BACKSLASH,   
+      Z             = OIS::KC_Z,           
+      X             = OIS::KC_X,           
+      C             = OIS::KC_C,           
+      V             = OIS::KC_V,           
+      B             = OIS::KC_B,           
+      N             = OIS::KC_N,           
+      M             = OIS::KC_M,           
+      Comma         = OIS::KC_COMMA,       
+      Period        = OIS::KC_PERIOD,          // . on main keyboard
+      Slash         = OIS::KC_SLASH,           // / on main keyboard
+      RightShift    = OIS::KC_RSHIFT,      
+      Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
+      LeftAlt       = OIS::KC_LMENU,           // left Alt
+      Space         = OIS::KC_SPACE,       
+      CapsLock      = OIS::KC_CAPITAL,     
+      F1            = OIS::KC_F1,          
+      F2            = OIS::KC_F2,          
+      F3            = OIS::KC_F3,          
+      F4            = OIS::KC_F4,          
+      F5            = OIS::KC_F5,          
+      F6            = OIS::KC_F6,          
+      F7            = OIS::KC_F7,          
+      F8            = OIS::KC_F8,          
+      F9            = OIS::KC_F9,          
+      F10           = OIS::KC_F10,         
+      Numlock       = OIS::KC_NUMLOCK,     
+      Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
+      Numpad7       = OIS::KC_NUMPAD7,     
+      Numpad8       = OIS::KC_NUMPAD8,     
+      Numpad9       = OIS::KC_NUMPAD9,     
+      NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
+      Numpad4       = OIS::KC_NUMPAD4,     
+      Numpad5       = OIS::KC_NUMPAD5,     
+      Numpad6       = OIS::KC_NUMPAD6,     
+      NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
+      Numpad1       = OIS::KC_NUMPAD1,     
+      Numpad2       = OIS::KC_NUMPAD2,     
+      Numpad3       = OIS::KC_NUMPAD3,     
+      Numpad0       = OIS::KC_NUMPAD0,     
+      NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
+      LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
+      F11           = OIS::KC_F11,         
+      F12           = OIS::KC_F12,         
+      F13           = OIS::KC_F13,             //                     (NEC PC98)
+      F14           = OIS::KC_F14,             //                     (NEC PC98)
+      F15           = OIS::KC_F15,             //                     (NEC PC98)
+      Kana          = OIS::KC_KANA,            // (Japanese keyboard)
+      ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
+      Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
+      NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
+      Yen           = OIS::KC_YEN,             // (Japanese keyboard)
+      ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
+      NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
+      PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+      AT            = OIS::KC_AT,              //                     (NEC PC98)
+      Colon         = OIS::KC_COLON,           //                     (NEC PC98)
+      Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
+      Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
+      Stop          = OIS::KC_STOP,            //                     (NEC PC98)
+      AX            = OIS::KC_AX,              //                     (Japan AX)
+      Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
+      NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
+      NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
+      RightControl  = OIS::KC_RCONTROL,    
+      Mute          = OIS::KC_MUTE,            // Mute
+      Calculator    = OIS::KC_CALCULATOR,      // Calculator
+      PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
+      MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
+      VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
+      VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
+      WebHome       = OIS::KC_WEBHOME,         // Web home
+      NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
+      Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
+      SYSRQ         = OIS::KC_SYSRQ,       
+      RightAlt      = OIS::KC_RMENU,           // right Alt
+      Pause         = OIS::KC_PAUSE,           // Pause
+      Home          = OIS::KC_HOME,            // Home on arrow keypad
+      Up            = OIS::KC_UP,              // UpArrow on arrow keypad
+      PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
+      Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
+      Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
+      End           = OIS::KC_END,             // End on arrow keypad
+      Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
+      PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
+      Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
+      Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
+      LeftWindows   = OIS::KC_LWIN,            // Left Windows key
+      RightWindows  = OIS::KC_RWIN,            // Right Windows key
+      Apps          = OIS::KC_APPS,            // AppMenu key
+      Power         = OIS::KC_POWER,           // System Power
+      Sleep         = OIS::KC_SLEEP,           // System Sleep
+      Wake          = OIS::KC_WAKE,            // System Wake
+      WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
+      WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
+      WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
+      WebStop       = OIS::KC_WEBSTOP,         // Web Stop
+      WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
+      WebBack       = OIS::KC_WEBBACK,         // Web Back
+      MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
+      Mail          = OIS::KC_MAIL,            // Mail
+      MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
+    };
+  }
+
+  namespace MouseButton
+  {
+    enum Enum
+    {
+      Left    = OIS::MB_Left,
+      Right   = OIS::MB_Right,
+      Middle  = OIS::MB_Middle,
+      Button3 = OIS::MB_Button3,
+      Button4 = OIS::MB_Button4,
+      Button5 = OIS::MB_Button5,
+      Button6 = OIS::MB_Button6,
+      Button7 = OIS::MB_Button7
+    };
+  }
+
+  namespace KeyboardModifier
+  {
+    enum Enum
+    {
+      Shift = 0x0000001,
+      Ctrl  = 0x0000010,
+      Alt   = 0x0000100
+    };
+  }
+
+  struct _CoreExport Key
+  {
+    Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
+    KeyCode::Enum key;
+    unsigned int text;
+  };
+
+  class _CoreExport KeyEvent
+  {
+  public:
+    KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
+    KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
+    KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
+    bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; }
+
+    const KeyCode::Enum key;
+    unsigned int text;
+    unsigned int modifiers;
+  };
+
+  typedef OIS::MouseState MouseState;
+
+  class _CoreExport JoyStickState : OIS::JoyStickState
+  {
+  public:
+    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }
+    JoyStickState() { clear(); }
+    int mJoyStickID;
+  };
+
+  /**
+    @brief Interface class used for key input listeners.
+  */
+  class _CoreExport KeyHandler
+  {
+  public:
+    virtual ~KeyHandler() { }
+    virtual bool keyPressed (const KeyEvent& evt) = 0;
+    virtual bool keyReleased(const KeyEvent& evt) = 0;
+    virtual bool keyHeld    (const KeyEvent& evt) = 0;
+  };
+
+  /**
+    @brief Interface class used for mouse input listeners.
+  */
+  class _CoreExport MouseHandler 
+  {
+  public:
+    virtual ~MouseHandler() { }
+    virtual bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id) = 0;
+    virtual bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id) = 0;
+    virtual bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) = 0;
+    virtual bool mouseMoved         (const MouseState& state) = 0;
+    virtual bool mouseScrolled      (const MouseState& state) = 0;
+  };
+
+
+  /**
+    @brief Interface class used for joy stick input listeners.
+  */
+  class _CoreExport JoyStickHandler
+  {
+  public:
+    virtual ~JoyStickHandler() { }
+    virtual bool joyStickButtonPressed (const JoyStickState& state, int button) = 0;
+    virtual bool joyStickButtonReleased(const JoyStickState& state, int button) = 0;
+    virtual bool joyStickButtonHeld    (const JoyStickState& state, int button) = 0;
+    virtual bool joyStickAxisMoved     (const JoyStickState& state, int axis)   = 0;
+    virtual bool joyStickSliderMoved   (const JoyStickState& state, int index) {return true;}
+    virtual bool joyStickPovMoved      (const JoyStickState& state, int index) {return true;}
+    virtual bool joyStickVector3Moved  (const JoyStickState& state, int index) {return true;}
+  };
+
+}
+
+#endif /* _InputInterfaces_H__ */
Index: code/trunk/src/core/InputManager.cc
===================================================================
--- code/trunk/src/core/InputManager.cc	(revision 1292)
+++ code/trunk/src/core/InputManager.cc	(revision 1293)
@@ -30,5 +30,5 @@
   @file
   @brief Implementation of the InputManager that captures all the input from OIS
-         and redirects it to handlers if necessary.
+         and redirects it to handlers.
  */
 
@@ -52,12 +52,9 @@
   InputManager::InputManager() :
       inputSystem_(0), keyboard_(0), mouse_(0),
-      state_(IS_UNINIT), stateRequest_(IS_UNINIT)
+      joySticksSize_(0),
+      state_(IS_UNINIT), stateRequest_(IS_UNINIT),
+      keyboardModifiers_(0)
   {
     RegisterObject(InputManager);
-
-    this->joySticks_.reserve(5);
-    //this->activeJoyStickHandlers_.reserve(10);
-    this->activeKeyHandlers_.reserve(10);
-    this->activeMouseHandlers_.reserve(10);
   }
 
@@ -87,9 +84,10 @@
     @param windowHeight The height of the render window
   */
-  bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
-        const bool createKeyboard, const bool createMouse, const bool createJoySticks)
+  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+        bool createKeyboard, bool createMouse, bool createJoySticks)
   {
     if (state_ == IS_UNINIT)
     {
+      CCOUT(3) << "Initialising Input System..." << std::endl;
       CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
 
@@ -145,4 +143,5 @@
     addKeyHandler(binder, "keybinder");
     addMouseHandler(binder, "keybinder");
+    addJoyStickHandler(binder, "keybinder");
 
     // Read all the key bindings and assign them
@@ -234,5 +233,5 @@
   bool InputManager::_initialiseJoySticks()
   {
-    if (joySticks_.size() > 0)
+    if (joySticksSize_ > 0)
     {
       CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
@@ -265,4 +264,7 @@
       return false;
     }
+    joySticksSize_ = joySticks_.size();
+    activeJoyStickHandlers_.resize(joySticksSize_);
+    joyStickButtonsDown_.resize(joySticksSize_);
     return success;
   }
@@ -273,8 +275,8 @@
   void InputManager::_destroy()
   {
-    CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
-
     if (state_ != IS_UNINIT)
     {
+      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
+
       if (keyHandlers_.find("buffer") != keyHandlers_.end())
         delete keyHandlers_["buffer"];
@@ -296,9 +298,6 @@
 
       state_ = IS_UNINIT;
-    }
-    else
-      CCOUT(ORX_WARNING) << "Warning: Cannot be destroyed, since not initialised." << std::endl;
-
-    CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
+      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
+    }
   }
 
@@ -336,12 +335,13 @@
   void InputManager::_destroyJoySticks()
   {
-    if (joySticks_.size() > 0)
+    if (joySticksSize_ > 0)
     {
       // note: inputSystem_ can never be 0, or else the code is mistaken
-      for (unsigned int i = 0; i < joySticks_.size(); i++)
+      for (unsigned int i = 0; i < joySticksSize_; i++)
         if (joySticks_[i] != 0)
           inputSystem_->destroyInputObject(joySticks_[i]);
 
       joySticks_.clear();
+      joySticksSize_ = 0;
       activeJoyStickHandlers_.clear();
       joyStickButtonsDown_.clear();
@@ -372,5 +372,6 @@
         activeKeyHandlers_.clear();
         activeMouseHandlers_.clear();
-        activeJoyStickHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
 
         switch (stateRequest_)
@@ -381,8 +382,8 @@
           activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
           activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
-          activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
-          for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
-                it != joySticks_.end(); it++)
-            activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
+          if (getMouseHandler("SpaceShip"))
+            activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
+          for (unsigned int i = 0; i < joySticksSize_; i++)
+            activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
           break;
 
@@ -393,7 +394,8 @@
         case IS_CONSOLE:
           activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
-          for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
-                it != joySticks_.end(); it++)
-            activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
+          if (getMouseHandler("SpaceShip"))
+            activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
+          for (unsigned int i = 0; i < joySticksSize_; i++)
+            activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
 
           activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
@@ -412,39 +414,25 @@
     if (keyboard_)
       keyboard_->capture();
+    for (unsigned  int i = 0; i < joySticksSize_; i++)
+      joySticks_[i]->capture();
 
 
     // call all the handlers for the held key events
-    for (std::list<OIS::KeyCode>::const_iterator itKey = keysDown_.begin();
-          itKey != keysDown_.end(); itKey++)
-    {
-      OIS::KeyEvent keyArg(keyboard_, *itKey, 0);
-      for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-        activeKeyHandlers_[i]->keyHeld(keyArg);
-    }
+    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+      for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
+        activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
 
     // call all the handlers for the held mouse button events
-    for (std::list<OIS::MouseButtonID>::const_iterator itMouseButton = mouseButtonsDown_.begin();
-          itMouseButton != mouseButtonsDown_.end(); itMouseButton++)
-    {
-      OIS::MouseEvent mouseButtonArg(mouse_, mouse_->getMouseState());
-      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-        activeMouseHandlers_[i]->mouseHeld(mouseButtonArg, *itMouseButton);
-    }
+    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+      for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
+        activeMouseHandlers_[iHandler]->mouseButtonHeld(mouse_->getMouseState(), mouseButtonsDown_[iButton]);
 
     // call all the handlers for the held joy stick button events
-    for (std::map< OIS::JoyStick*, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
-          itJoyStick != joyStickButtonsDown_.end(); itJoyStick++)
-    {
-      OIS::JoyStick* joyStick = (*itJoyStick).first;
-      for (std::list<int>::const_iterator itJoyStickButton = (*itJoyStick).second.begin();
-            itJoyStickButton != (*itJoyStick).second.end(); itJoyStickButton++)
-      {
-        OIS::JoyStickEvent joyStickButtonArg(joyStick, joyStick->getJoyStickState());
-        for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-          activeJoyStickHandlers_[joyStick][i]->buttonHeld(i, joyStickButtonArg, *itJoyStickButton);
-      }
-    }
-  }
-
+    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
+        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(
+              JoyStickState(joySticks_[iJoyStick]->getJoyStickState(), iJoyStick), joyStickButtonsDown_[iJoyStick][iButton]);
+  }
 
   // ###### Key Events ######
@@ -457,16 +445,20 @@
   {
     // check whether the key already is in the list (can happen when focus was lost)
-    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
-    {
-      if (*it == e.key)
-      {
-        keysDown_.erase(it);
-        break;
-      }
-    }
-    keysDown_.push_back(e.key);
+    unsigned int iKey = 0;
+    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
+      iKey++;
+    if (iKey == keysDown_.size())
+      keysDown_.push_back(Key(e));
+
+    // update modifiers
+    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
+    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
+    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
 
     for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-      activeKeyHandlers_[i]->keyPressed(e);
+      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
 
     return true;
@@ -480,15 +472,23 @@
   {
     // remove the key from the keysDown_ list
-    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
-    {
-      if (*it == e.key)
-      {
-        keysDown_.erase(it);
+    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+    {
+      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
+      {
+        keysDown_.erase(keysDown_.begin() + iKey);
         break;
       }
     }
 
+    // update modifiers
+    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
+    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
+    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
+
     for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-      activeKeyHandlers_[i]->keyReleased(e);
+      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
 
     return true;
@@ -504,6 +504,17 @@
   bool InputManager::mouseMoved(const OIS::MouseEvent &e)
   {
-    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mouseMoved(e);
+    // check for actual moved event
+    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
+    {
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseMoved(e.state);
+    }
+
+    // check for mouse scrolled event
+    if (e.state.Z.rel != 0)
+    {
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseScrolled(e.state);
+    }
 
     return true;
@@ -518,16 +529,12 @@
   {
     // check whether the button already is in the list (can happen when focus was lost)
-    for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
-    {
-      if (*it == id)
-      {
-        mouseButtonsDown_.erase(it);
-        break;
-      }
-    }
-    mouseButtonsDown_.push_back(id);
+    unsigned int iButton = 0;
+    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
+      iButton++;
+    if (iButton == mouseButtonsDown_.size())
+      mouseButtonsDown_.push_back((MouseButton::Enum)id);
 
     for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mousePressed(e, id);
+      activeMouseHandlers_[i]->mouseButtonPressed(e.state, (MouseButton::Enum)id);
 
     return true;
@@ -542,9 +549,9 @@
   {
     // remove the button from the keysDown_ list
-    for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
-    {
-      if (*it == id)
-      {
-        mouseButtonsDown_.erase(it);
+    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+    {
+      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
+      {
+        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
         break;
       }
@@ -552,5 +559,5 @@
 
     for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mouseReleased(e, id);
+      activeMouseHandlers_[i]->mouseButtonReleased(e.state, (MouseButton::Enum)id);
 
     return true;
@@ -562,77 +569,101 @@
   bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
   {
+    // use the device to identify which one called the method
     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+      iJoyStick++;
 
     // check whether the button already is in the list (can happen when focus was lost)
-    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
-    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
-    {
-      if (*it == button)
-      {
-        buttonsDownList.erase(it);
+    std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];
+    unsigned int iButton = 0;
+    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
+      iButton++;
+    if (iButton == buttonsDown.size())
+      buttonsDown.push_back(button);
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(JoyStickState(arg.state, iJoyStick), button);
+
+    return true;
+  }
+
+  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+  {
+    // use the device to identify which one called the method
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+      iJoyStick++;
+
+    // remove the button from the joyStickButtonsDown_ list
+    std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];
+    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
+    {
+      if (buttonsDown[iButton] == button)
+      {
+        buttonsDown.erase(buttonsDown.begin() + iButton);
         break;
       }
     }
-    joyStickButtonsDown_[joyStick].push_back(button);
-
-    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-      activeJoyStickHandlers_[joyStick][i]->buttonPressed(i, arg, button);
-
-    return true;
-  }
-
-  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
-  {
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(JoyStickState(arg.state, iJoyStick), button);
+
+    return true;
+  }
+
+  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
+  {
+    // use the device to identify which one called the method
     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-
-    // remove the button from the joyStickButtonsDown_ list
-    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
-    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
-    {
-      if (*it == button)
-      {
-        buttonsDownList.erase(it);
-        break;
-      }
-    }
-
-    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-      activeJoyStickHandlers_[joyStick][i]->buttonReleased(i, arg, button);
-
-    return true;
-  }
-
-  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
-  {
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+      iJoyStick++;
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(JoyStickState(arg.state, iJoyStick), axis);
+
+    return true;
+  }
+
+  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    // use the device to identify which one called the method
     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-      activeJoyStickHandlers_[joyStick][i]->axisMoved(i, arg, axis);
-
-    return true;
-  }
-
-  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
-  {
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+      iJoyStick++;
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickSliderMoved(JoyStickState(arg.state, iJoyStick), id);
+
+    return true;
+  }
+
+  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    // use the device to identify which one called the method
     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-      activeJoyStickHandlers_[joyStick][i]->sliderMoved(i, arg, id);
-
-    return true;
-  }
-
-  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
-  {
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+      iJoyStick++;
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickPovMoved(JoyStickState(arg.state, iJoyStick), id);
+
+    return true;
+  }
+
+  bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
+  {
+    // use the device to identify which one called the method
     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-      activeJoyStickHandlers_[joyStick][i]->povMoved(i, arg, id);
-
-    return true;
-  }
-
-  bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
-  {
-    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
-      activeJoyStickHandlers_[joyStick][i]->vector3Moved(i, arg, id);
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+      iJoyStick++;
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
 
     return true;
@@ -645,6 +676,6 @@
   // ################################
 
-  bool InputManager::initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
-    const bool createKeyboard, const bool createMouse, const bool createJoySticks)
+  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+    bool createKeyboard, bool createMouse, bool createJoySticks)
   {
     return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
@@ -685,5 +716,37 @@
   int InputManager::numberOfJoySticks()
   {
-    return _getSingleton().joySticks_.size();
+    return _getSingleton().joySticksSize_;
+  }
+
+  bool InputManager::isKeyDown(KeyCode::Enum key)
+  {
+    if (_getSingleton().keyboard_)
+      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
+    else
+      return false;
+  }
+
+  bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
+  {
+    if (_getSingleton().keyboard_)
+      return isModifierDown(modifier);
+    else
+      return false;
+  }
+
+  const MouseState InputManager::getMouseState()
+  {
+    if (_getSingleton().mouse_)
+      return _getSingleton().mouse_->getMouseState();
+    else
+      return MouseState();
+  }
+
+  const JoyStickState InputManager::getJoyStickState(unsigned int ID)
+  {
+    if (ID < _getSingleton().joySticksSize_)
+      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
+    else
+      return JoyStickState();
   }
 
@@ -757,4 +820,6 @@
   bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
   {
+    if (!handler)
+      return false;
     if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
     {
@@ -883,4 +948,6 @@
   bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
   {
+    if (!handler)
+      return false;
     if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
     {
@@ -1010,4 +1077,6 @@
   bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
   {
+    if (!handler)
+      return false;
     if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
     {
@@ -1061,5 +1130,5 @@
     @return False if name or id was not found, true otherwise.
   */
-  bool InputManager::enableJoyStickHandler(const std::string& name, const int ID)
+  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
   {
     // get handler pointer from the map with all stored handlers
@@ -1069,11 +1138,10 @@
 
     // check for existence of the ID
-    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
-      return false;
-    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
 
     // see whether the handler already is in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
-          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
     {
       if ((*it) == (*handlerIt).second)
@@ -1083,5 +1151,5 @@
       }
     }
-    _getSingleton().activeJoyStickHandlers_[joyStick].push_back((*handlerIt).second);
+    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
     _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
@@ -1093,5 +1161,5 @@
     @return False if name or id was not found, true otherwise.
   */
-  bool InputManager::disableJoyStickHandler(const std::string &name, int ID)
+  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
   {
     // get handler pointer from the map with all stored handlers
@@ -1101,15 +1169,14 @@
 
     // check for existence of the ID
-    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
-      return false;
-    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
 
     // look for the handler in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
-          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
     {
       if ((*it) == (*handlerIt).second)
       {
-        _getSingleton().activeJoyStickHandlers_[joyStick].erase(it);
+        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
         _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
@@ -1124,5 +1191,5 @@
     @return False if key handler is not active or doesn't exist, true otherwise.
   */
-  bool InputManager::isJoyStickHandlerActive(const std::string& name, const int ID)
+  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
   {
     // get handler pointer from the map with all stored handlers
@@ -1132,11 +1199,10 @@
 
     // check for existence of the ID
-    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
-      return false;
-    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
 
     // see whether the handler already is in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
-          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
     {
       if ((*it) == (*handlerIt).second)
Index: code/trunk/src/core/InputManager.h
===================================================================
--- code/trunk/src/core/InputManager.h	(revision 1292)
+++ code/trunk/src/core/InputManager.h	(revision 1293)
@@ -39,20 +39,17 @@
 
 #include <map>
-#include <list>
+#include <vector>
 
 #include "ois/OIS.h"
 #include "Tickable.h"
+#include "InputInterfaces.h"
 
 namespace orxonox
 {
-  class Mouse : public OIS::Mouse
-  {
-  };
-
   /**
     @brief Captures and distributes mouse and keyboard input.
   */
   class _CoreExport InputManager
-        : public Tickable,
+        : public TickableReal,
           public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
   {
@@ -72,6 +69,6 @@
 
   public: // static functions
-    static bool initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
-          const bool createKeyboard = true, const bool createMouse = true, const bool createJoySticks = false);
+    static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
     static bool initialiseKeyboard();
     static bool initialiseMouse();
@@ -85,4 +82,9 @@
     static void destroyMouse();
     static void destroyJoySticks();
+
+    static bool isModifierDown(KeyboardModifier::Enum modifier);
+    static bool isKeyDown(KeyCode::Enum key);
+    static const MouseState getMouseState();
+    static const JoyStickState getJoyStickState(unsigned int ID);
 
     static void setWindowExtents(const int width, const int height);
@@ -108,11 +110,7 @@
     static bool removeJoyStickHandler         (const std::string& name);
     static JoyStickHandler* getJoyStickHandler(const std::string& name);
-    static bool enableJoyStickHandler         (const std::string& name, const int id);
-    static bool disableJoyStickHandler        (const std::string& name, const int id);
-    static bool isJoyStickHandlerActive       (const std::string& name, const int id);
-
-    // Temporary solutions. Will be removed soon!
-    static OIS::Mouse*    getMouse()    { return _getSingleton().mouse_   ; }
-    static OIS::Keyboard* getKeyboard() { return _getSingleton().keyboard_; }
+    static bool enableJoyStickHandler         (const std::string& name, unsigned int id);
+    static bool disableJoyStickHandler        (const std::string& name, unsigned int id);
+    static bool isJoyStickHandlerActive       (const std::string& name, unsigned int id);
 
   private: // functions
@@ -123,5 +121,5 @@
 
     // Intenal methods
-    bool _initialise(const size_t, const int, const int, const bool, const bool, const bool);
+    bool _initialise(const size_t, int, int, bool, bool, bool);
     bool _initialiseKeyboard();
     bool _initialiseMouse();
@@ -133,20 +131,18 @@
     void _destroyJoySticks();
 
-    //void _setNumberOfJoysticks(int size);
-
     void tick(float dt);
 
     // input events
-		bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
-		bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+    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);
-		bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
-		bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
-		bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
-		bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
-		bool povMoved      (const OIS::JoyStickEvent &arg, int id);
-		bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
+    bool keyPressed    (const OIS::KeyEvent      &arg);
+    bool keyReleased   (const OIS::KeyEvent      &arg);
+    bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+    bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+    bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+    bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
 
     static InputManager& _getSingleton();
@@ -158,7 +154,9 @@
     OIS::Mouse*                                 mouse_;       //!< OIS keyboard
     std::vector<OIS::JoyStick*>                 joySticks_;   //!< OIS joy sticks
+    unsigned int                                joySticksSize_;
 
     InputState state_;
     InputState stateRequest_;
+    unsigned int keyboardModifiers_;
 
     std::map<std::string, KeyHandler*>          keyHandlers_;
@@ -168,11 +166,12 @@
     std::vector<KeyHandler*>                    activeKeyHandlers_;
     std::vector<MouseHandler*>                  activeMouseHandlers_;
-    std::map< OIS::JoyStick*, std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
+    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
 
-    std::list<OIS::KeyCode>                     keysDown_;
-    std::list<OIS::MouseButtonID>               mouseButtonsDown_;
-    std::map< OIS::JoyStick*, std::list<int> >  joyStickButtonsDown_;
+    std::vector<Key>                            keysDown_;
+    std::vector<MouseButton::Enum>              mouseButtonsDown_;
+    std::vector<std::vector<int> >              joyStickButtonsDown_;
 
   };
+
 }
 
Index: code/trunk/src/core/Namespace.cc
===================================================================
--- code/trunk/src/core/Namespace.cc	(revision 1292)
+++ code/trunk/src/core/Namespace.cc	(revision 1293)
@@ -37,11 +37,10 @@
     CreateFactory(Namespace);
 
-    Namespace::Namespace()
+    Namespace::Namespace() :
+      bAutogeneratedFileRootNamespace_(false),
+      bRoot_(false),
+      operator_("or")
     {
         RegisterObject(Namespace);
-
-        this->bAutogeneratedFileRootNamespace_ = false;
-        this->bRoot_ = false;
-        this->operator_ = "or";
     }
 
Index: code/trunk/src/core/OrxonoxClass.cc
===================================================================
--- code/trunk/src/core/OrxonoxClass.cc	(revision 1292)
+++ code/trunk/src/core/OrxonoxClass.cc	(revision 1293)
@@ -37,10 +37,9 @@
 {
     /** @brief Constructor: Sets the default values. */
-    OrxonoxClass::OrxonoxClass()
+    OrxonoxClass::OrxonoxClass() :
+      identifier_(0),
+      parents_(0)
     {
         this->setConfigValues();
-
-        this->identifier_ = 0;
-        this->parents_ = 0;
     }
 
Index: code/trunk/src/core/SignalHandler.cc
===================================================================
--- code/trunk/src/core/SignalHandler.cc	(revision 1292)
+++ code/trunk/src/core/SignalHandler.cc	(revision 1293)
@@ -35,4 +35,5 @@
 
 #include <assert.h>
+#include <iostream>
 
 #include "Debug.h"
@@ -43,4 +44,9 @@
 
 #include <wait.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+
+bool SignalHandler::bXAutoKeyRepeatOn_ = false;
 
 SignalHandler::SignalHandler()
@@ -58,4 +64,23 @@
   this->fileName = fileName;
 
+  // prepare for restoring XAutoKeyRepeat
+  Display* display;
+  if ((display = XOpenDisplay(0)))
+  {
+    XKeyboardState oldState;
+    XGetKeyboardControl(display, &oldState);
+    if (oldState.global_auto_repeat == AutoRepeatModeOn)
+      bXAutoKeyRepeatOn_ = true;
+    else
+      bXAutoKeyRepeatOn_ = false;
+    XCloseDisplay(display);
+  }
+  else
+  {
+    std::cout << "Warning: couldn't open X display to restore XAutoKeyRepeat." << std::endl;
+    bXAutoKeyRepeatOn_ = false;
+  }
+
+
   // make sure doCatch is only called once without calling dontCatch
   assert( sigRecList.size() == 0 );
@@ -120,4 +145,15 @@
       sigName = "SIGILL";
       break;
+  }
+
+  if (bXAutoKeyRepeatOn_)
+  {
+    std::cout << "Trying to restore XAutoKeyRepeat" << std::endl;
+	Display* display;
+	  if ((display = XOpenDisplay(0)))
+    {
+			XAutoRepeatOn(display);
+		  XCloseDisplay(display);
+    }
   }
 
Index: code/trunk/src/core/SignalHandler.h
===================================================================
--- code/trunk/src/core/SignalHandler.h	(revision 1292)
+++ code/trunk/src/core/SignalHandler.h	(revision 1293)
@@ -86,4 +86,7 @@
     std::string appName;
     std::string fileName;
+
+    // used to turn on KeyAutoRepeat if OIS crashes
+    static bool bXAutoKeyRepeatOn_;
 };
 
Index: code/trunk/src/core/Tickable.cc
===================================================================
--- code/trunk/src/core/Tickable.cc	(revision 1292)
+++ code/trunk/src/core/Tickable.cc	(revision 1293)
@@ -40,3 +40,11 @@
         RegisterRootObject(Tickable);
     }
+
+    /**
+        @brief Constructor: Registers the object in the TickableReal-list
+    */
+    TickableReal::TickableReal()
+    {
+        RegisterRootObject(TickableReal);
+    }
 }
Index: code/trunk/src/core/Tickable.h
===================================================================
--- code/trunk/src/core/Tickable.h	(revision 1292)
+++ code/trunk/src/core/Tickable.h	(revision 1293)
@@ -62,4 +62,18 @@
     };
 
+    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
+    class _CoreExport TickableReal : 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:
+            TickableReal();
+    };
+
 }
 
Index: code/trunk/src/network/CMakeLists.txt
===================================================================
--- code/trunk/src/network/CMakeLists.txt	(revision 1292)
+++ code/trunk/src/network/CMakeLists.txt	(revision 1293)
@@ -11,5 +11,4 @@
   Server.cc
   Synchronisable.cc
-  dummyserver3.cc
 )
 
@@ -30,4 +29,89 @@
 # build those parts only on request.
 IF(NETWORK_TESTING_ENABLED)
+  ##### test for gamestate stuff #####
+  SET( TEST_SRC_FILES
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    ClientConnection.cc
+    ClientInformation.cc
+    diffTest.cc
+    GameStateClient.cc
+    Server.cc
+    Client.cc  
+    Synchronisable.cc  
+  )
+
+  ADD_EXECUTABLE(networktest ${TEST_SRC_FILES})
+  TARGET_LINK_LIBRARIES( networktest
+    ${OGRE_LIBRARIES}
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+  ##### end test for gamestate stuff #####
+ENDIF(NETWORK_TESTING_ENABLED)
+# build this if you want dummyserver4 and dummyclient4
+IF(NETWORKTRAFFIC_TESTING_ENABLED)
+  ##### test network traffic #####
+  SET( DUMMYSERVER4_SRC_FILES
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    ClientConnection.cc
+    ClientInformation.cc
+    GameStateClient.cc
+    Server.cc
+    Client.cc  
+    Synchronisable.cc
+    dummyserver4.cc
+  )
+
+  SET( DUMMYCLIENT4_SRC_FILES
+    ConnectionManager.cc
+    GameStateManager.cc
+    PacketBuffer.cc
+    PacketDecoder.cc
+    PacketGenerator.cc
+    ClientConnection.cc
+    ClientInformation.cc
+    GameStateClient.cc
+    Server.cc
+    Client.cc  
+    Synchronisable.cc
+    dummyclient4.cc
+  )
+
+  ADD_EXECUTABLE(dummyserver4 ${DUMMYSERVER4_SRC_FILES})
+  TARGET_LINK_LIBRARIES( dummyserver4
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+    ${Boost_thread_LIBRARIES}
+    core
+    orxonoxs
+    audio
+  )
+
+  ADD_EXECUTABLE(dummyclient4 ${DUMMYCLIENT4_SRC_FILES})
+  TARGET_LINK_LIBRARIES( dummyclient4
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+    ${Boost_thread_LIBRARIES}
+    core
+    orxonoxs
+    audio
+  )
+ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+IF(BLABLA)
   SET( CHATCLIENT_SRC_FILES
     ClientConnection.cc
@@ -95,3 +179,4 @@
     ${WINDOWS_ENET_DEPENDENCIES}
   )
-ENDIF(NETWORK_TESTING_ENABLED)
+ENDIF(BLABLA)
+
Index: code/trunk/src/network/Client.cc
===================================================================
--- code/trunk/src/network/Client.cc	(revision 1292)
+++ code/trunk/src/network/Client.cc	(revision 1293)
@@ -40,8 +40,41 @@
 
 #include "Client.h"
+#include "Synchronisable.h"
 #include "core/CoreIncludes.h"
 
 namespace network
 {
+  Client* Client::_sClient = 0;
+  
+  Client* Client::createSingleton(){
+    if(!_sClient){
+      _sClient = new Client();
+    }
+    return _sClient;
+  }
+  
+  Client* Client::createSingleton(std::string address, int port){
+    if(!_sClient)
+      _sClient = new Client(address, port);
+    return _sClient;
+  }
+  
+  Client* Client::createSingleton(const char *address, int port){
+    if(!_sClient)
+      _sClient = new Client(address, port);
+    return _sClient;
+  }
+  
+  void Client::destroySingleton(){
+    if(_sClient){
+      delete _sClient;
+      _sClient = 0;
+    }
+  }
+  
+  Client* Client::getSingleton(){
+    return _sClient; 
+  }
+  
   /**
   * Constructor for the Client class
@@ -51,4 +84,5 @@
     // set server address to localhost
     isConnected=false;
+    isSynched_=false;
   }
 
@@ -60,4 +94,5 @@
   Client::Client(std::string address, int port) : client_connection(port, address){
     isConnected=false;
+    isSynched_=false;
   }
 
@@ -69,6 +104,12 @@
   Client::Client(const char *address, int port) : client_connection(port, address){
     isConnected=false;
-  }
-
+    isSynched_=false;
+  }
+
+  Client::~Client(){
+    if(isConnected)
+      closeConnection();
+  }
+  
   /**
   * Establish the Connection to the Server
@@ -76,5 +117,12 @@
   */
   bool Client::establishConnection(){
+    Synchronisable::setClient(true);
     isConnected=client_connection.createConnection();
+    if(isConnected){
+      COUT(4) << "sending connectrequest" << std::endl;
+      client_connection.addPacket(pck_gen.generateConnectRequest());
+      client_connection.sendPackets();
+    }else
+      COUT(1) << "could not create connection" << std::endl;
     return isConnected;
   }
@@ -181,4 +229,17 @@
   */
   void Client::tick(float time){
+    if(client_connection.isConnected() && isSynched_){
+      COUT(4) << "popping partial gamestate: " << std::endl;
+      GameStateCompressed *gs = gamestate.popPartialGameState();
+      if(gs){
+        COUT(4) << "client tick: sending gs " << gs << std::endl;
+        ENetPacket *packet = pck_gen.gstate(gs);
+        if( packet == NULL || !client_connection.addPacket(packet))
+          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
+        // now delete it to save memory
+        delete[] gs->data;
+        delete gs;
+      }
+    }
     ENetPacket *packet;
     // stop if the packet queue is empty
@@ -188,14 +249,20 @@
       elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
     }
+    if(!client_connection.sendPackets())
+      COUT(3) << "Problem sending packets to server" << std::endl;
     return;
   }
 
-  void Client::processGamestate( GameStateCompressed *data){
+  void Client::processGamestate( GameStateCompressed *data, int clientID){
     int id = data->id;
     COUT(5) << "received gamestate id: " << data->id << std::endl;
-    gamestate.pushGameState(data);
-    client_connection.addPacket(pck_gen.acknowledgement(id));
-    client_connection.sendPackets();
-    return;
+    if(gamestate.pushGameState(data)){
+      if(!isSynched_)
+        isSynched_=true;
+      client_connection.addPacket(pck_gen.acknowledgement(id));
+        // we do this at the end of a tick
+       if(!client_connection.sendPackets())
+         COUT(2) << "Could not send acknowledgment" << std::endl;
+    }
   }
 
@@ -205,5 +272,6 @@
     if(id!=NULL)
       id->setNetworkID(clid->clid);
-    COUT(4) << "received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl;
+    COUT(4) << "Client: received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl;
+    delete clid;
     return;
   }
@@ -211,4 +279,14 @@
   void Client::processChat( chat *data){
     COUT(0) << "Server: " << data->message << std::endl;
+    delete[] data->message;
+    delete data;
+  }
+  
+  bool Client::processWelcome( welcome *w ){
+    COUT(4) << "processing welcome message" << std::endl;
+    clientID_ = w->clientID;
+    shipID_ = w->shipID;
+    delete w;
+    return true;
   }
 
Index: code/trunk/src/network/Client.h
===================================================================
--- code/trunk/src/network/Client.h	(revision 1292)
+++ code/trunk/src/network/Client.h	(revision 1293)
@@ -65,8 +65,11 @@
   class _NetworkExport Client : PacketDecoder, public orxonox::Tickable{
   public:
-    Client();
-    Client(std::string address, int port);
-    Client(const char *address, int port);
-
+    
+    static Client* createSingleton();
+    static Client* createSingleton(std::string address, int port);
+    static Client* createSingleton(const char *address, int port);
+    static void destroySingleton();
+    static Client *getSingleton();
+    
     bool establishConnection();
     bool closeConnection();
@@ -80,17 +83,31 @@
 
     bool sendPackets();
+    
+    int getShipID(){return shipID_;}
+    int getClientID(){return clientID_;}
 
     void tick(float time);
 
   private:
+    Client();
+    Client(std::string address, int port);
+    Client(const char *address, int port);
+    ~Client();
+    
+    static Client* _sClient;
+    
     ClientConnection client_connection;
     PacketGenerator pck_gen;
     GameStateClient gamestate;
     bool isConnected;
+    bool isSynched_;
 
     // implement data processing functions of PacketDecoder
-    void processGamestate( GameStateCompressed *data);
+    void processGamestate( GameStateCompressed *data, int clientID);
     void processClassid(classid *clid);
     void processChat( chat *data);
+    bool processWelcome( welcome *w );
+    int clientID_;     // this is the id the server gave to us
+    int shipID_;
   };
 
Index: code/trunk/src/network/ClientConnection.cc
===================================================================
--- code/trunk/src/network/ClientConnection.cc	(revision 1292)
+++ code/trunk/src/network/ClientConnection.cc	(revision 1293)
@@ -42,5 +42,4 @@
 #include <iostream>
 // boost.thread library for multithreading support
-#include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
 
@@ -50,5 +49,5 @@
 namespace network
 {
-  static boost::thread_group network_threads;
+  //static boost::thread_group network_threads;
 
   ClientConnection::ClientConnection(int port, std::string address) {
@@ -87,5 +86,5 @@
 
   ENetPacket *ClientConnection::getPacket() {
-    ENetAddress address;
+    ENetAddress address; //sems that address is not needed
     return getPacket(address);
   }
@@ -96,5 +95,6 @@
 
   bool ClientConnection::createConnection() {
-    network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
+    receiverThread_ = new boost::thread(boost::bind(&ClientConnection::receiverThread, this));
+    //network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
     // wait 10 seconds for the connection to be established
     return waitEstablished(10000);
@@ -103,5 +103,6 @@
   bool ClientConnection::closeConnection() {
     quit=true;
-    network_threads.join_all();
+    //network_threads.join_all();
+    receiverThread_->join();
     established=false;
     return true;
@@ -112,7 +113,12 @@
     if(server==NULL)
       return false;
-    if(enet_peer_send(server, 1, packet)!=0)
-      return false;
-    return true;
+    if(packet==NULL){
+      COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl;
+      return false;
+    }
+    if(enet_peer_send(server, 0, packet)<0)
+      return false;
+    else
+      return true;
   }
 
@@ -162,6 +168,7 @@
       case ENET_EVENT_TYPE_CONNECT:
       case ENET_EVENT_TYPE_RECEIVE:
-        COUT(5) << "receiver-Thread: got new packet" << std::endl;
-        processData(&event);
+        COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
+        if ( !processData(&event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl;
+        COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;
         break;
       case ENET_EVENT_TYPE_DISCONNECT:
@@ -173,4 +180,5 @@
         continue;
       }
+      //receiverThread_->yield();
     }
     // now disconnect
@@ -203,5 +211,5 @@
   bool ClientConnection::establishConnection() {
     ENetEvent event;
-    // connect to peer
+    // connect to peer (server is type ENetPeer*)
     server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS);
     if(server==NULL)
@@ -218,5 +226,5 @@
 
   bool ClientConnection::processData(ENetEvent *event) {
-    COUT(5) << "got packet, pushing to queue" << std::endl;
+    COUT(5) << "Cl.Con: got packet, pushing to queue" << std::endl;
     // just add packet to the buffer
     // this can be extended with some preprocessing
Index: code/trunk/src/network/ClientConnection.h
===================================================================
--- code/trunk/src/network/ClientConnection.h	(revision 1292)
+++ code/trunk/src/network/ClientConnection.h	(revision 1293)
@@ -45,4 +45,5 @@
 #include <string>
 #include <enet/enet.h>
+#include <boost/thread/thread.hpp>
 
 #include "PacketBuffer.h"
@@ -53,5 +54,5 @@
 #define NETWORK_PORT 55556
 #define NETWORK_CLIENT_MAX_CONNECTIONS 5
-#define NETWORK_CLIENT_TIMEOUT 10
+#define NETWORK_CLIENT_TIMEOUT 100
 #define NETWORK_SEND_WAIT 5
 #define NETWORK_CLIENT_CHANNELS 2
@@ -76,4 +77,5 @@
     bool sendPackets(ENetEvent *event);
     bool waitEstablished(int milisec);
+    bool isConnected(){return established;}
   private:
     bool processData(ENetEvent *event);
@@ -92,4 +94,5 @@
     // clientlist
     ENetPeer *server;
+    boost::thread *receiverThread_;
   };
 
Index: code/trunk/src/network/ClientInformation.cc
===================================================================
--- code/trunk/src/network/ClientInformation.cc	(revision 1292)
+++ code/trunk/src/network/ClientInformation.cc	(revision 1293)
@@ -190,5 +190,5 @@
   * This function should only be applied to the head of the list
   * @param clientID id to look for
-  * @return pointer to the element in the list or 0 if the search was unsuccessfull
+  * @return pointer to the last element in the list or 0 if the search was unsuccessfull
   */
   ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) {
@@ -196,5 +196,6 @@
     if (temp->head)
       temp=temp->next();
-    while(temp!=0 && temp->getID()!=clientID){
+    //bugfix: temp to temp->next(), get last elem if not found, not segflt
+    while(temp->next()!=0 && temp->getID()!=clientID){
       temp = temp->next();
     }
@@ -211,5 +212,6 @@
   ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) {
     ClientInformation *temp = this;
-    while(temp!=0){
+    //bugfix: temp to temp->next(), get last elem if not found, not segflt
+    while(temp->next()!=0){
       if(temp->head){
         temp = temp->next();
Index: code/trunk/src/network/ClientInformation.h
===================================================================
--- code/trunk/src/network/ClientInformation.h	(revision 1292)
+++ code/trunk/src/network/ClientInformation.h	(revision 1293)
@@ -67,13 +67,23 @@
     ClientInformation *insertBefore(ClientInformation *ins);
     ClientInformation *insertBack(ClientInformation *ins);
+    
+    // set functions
     void setID(int clientID);
     void setPeer(ENetPeer *peer);
     void setGamestateID(int id);
+    inline void setShipID(int id){ShipID_=id;}
+    
+    // get functions
+    inline int getShipID(){return ShipID_;}
     int getID();
+    int getGamestateID();
     ENetPeer *getPeer();
-    int getGamestateID();
+    
+    
     bool removeClient(int clientID);
     bool removeClient(ENetPeer *peer);
+    //## add bool mask-function eventually
     ClientInformation *findClient(int clientID, bool look_backwards=false);
+    //## add bool mask-function eventually
     ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
 
@@ -82,4 +92,5 @@
 
     bool head;
+    unsigned short failures_;
 
   private:
@@ -90,4 +101,5 @@
     int clientID_;
     int gamestateID_;
+    int ShipID_;   // this is the unique objectID
     bool synched_;
   };
Index: code/trunk/src/network/ConnectionManager.cc
===================================================================
--- code/trunk/src/network/ConnectionManager.cc	(revision 1292)
+++ code/trunk/src/network/ConnectionManager.cc	(revision 1293)
@@ -40,10 +40,13 @@
 #include <iostream>
 // boost.thread library for multithreading support
-#include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
 
 #include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "util/Math.h"
+#include "objects/SpaceShip.h"
 #include "ClientInformation.h"
 #include "ConnectionManager.h"
+#include "Synchronisable.h"
 
 namespace std
@@ -59,7 +62,9 @@
 namespace network
 {
-  boost::thread_group network_threads;
-
-  ConnectionManager::ConnectionManager(ClientInformation *head) {
+  //boost::thread_group network_threads;
+  
+  ConnectionManager::ConnectionManager():receiverThread_(0){}
+  
+  ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) {
     quit=false;
     bindAddress.host = ENET_HOST_ANY;
@@ -68,5 +73,5 @@
   }
 
-  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) {
+  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) :receiverThread_(0) {
     quit=false;
     enet_address_set_host (& bindAddress, address.c_str());
@@ -75,5 +80,5 @@
   }
 
-  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) {
+  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) : receiverThread_(0) {
     quit=false;
     enet_address_set_host (& bindAddress, address);
@@ -88,5 +93,8 @@
       return NULL;
   }
-
+/**
+This function only pops the first element in PacketBuffer (first in first out)
+used by processQueue in Server.cc
+*/
   ENetPacket *ConnectionManager::getPacket(int &clientID) {
     ENetAddress address;
@@ -102,6 +110,7 @@
 
   void ConnectionManager::createListener() {
-    network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
-    //     boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+    receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this));
+    //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+         //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
     return;
   }
@@ -109,5 +118,6 @@
   bool ConnectionManager::quitListener() {
     quit=true;
-    network_threads.join_all();
+    //network_threads.join_all();
+    receiverThread_->join();
     return true;
   }
@@ -156,5 +166,5 @@
     enet_initialize();
     atexit(enet_deinitialize);
-    ENetEvent event;
+    ENetEvent *event = new ENetEvent;
     server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
     if(server==NULL){
@@ -165,25 +175,33 @@
 
     while(!quit){
-      if(enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT)<0){
+      if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
         // we should never reach this point
         quit=true;
         // add some error handling here ========================
       }
-      switch(event.type){
+      switch(event->type){
         // log handling ================
         case ENET_EVENT_TYPE_CONNECT:
-          addClient(&event);
+          addClient(event);
+          //this is a workaround to ensure thread safety
+          /*if(!addFakeConnectRequest(&event))
+            COUT(3) << "Problem pushing fakeconnectRequest to queue" << std::endl;*/
+          COUT(5) << "Con.Man: connection event has occured" << std::endl;
           break;
         case ENET_EVENT_TYPE_RECEIVE:
           //std::cout << "received data" << std::endl;
-          processData(&event);
+          COUT(5) << "Con.Man: receive event has occured" << std::endl;
+          // only add, if client has connected yet and not been disconnected
+          if(head_->findClient(&event->peer->address))
+            processData(event);
           break;
         case ENET_EVENT_TYPE_DISCONNECT:
-          // add some error/log handling here
-          clientDisconnect(event.peer);
+          clientDisconnect(event->peer);
           break;
         case ENET_EVENT_TYPE_NONE:
           break;
       }
+//       usleep(100);
+      receiverThread_->yield(); //TODO: find apropriate
     }
     disconnectClients();
@@ -191,5 +209,8 @@
     enet_host_destroy(server);
   }
-
+  
+  //### added some bugfixes here, but we cannot test them because
+  //### the server crashes everytime because of some gamestates
+  //### (trying to resolve that now)
   void ConnectionManager::disconnectClients() {
     ENetEvent event;
@@ -199,16 +220,19 @@
       temp = temp->next();
     }
-    temp = temp->next();
+    //bugfix: might be the reason why server crashes when clients disconnects
+    //temp = temp->next();
+    temp = head_->next();
     while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) > 0){
       switch (event.type)
       {
-      case ENET_EVENT_TYPE_NONE:
-      case ENET_EVENT_TYPE_CONNECT:
+      case ENET_EVENT_TYPE_NONE: break;
+      case ENET_EVENT_TYPE_CONNECT: break;
       case ENET_EVENT_TYPE_RECEIVE:
         enet_packet_destroy(event.packet);
         break;
       case ENET_EVENT_TYPE_DISCONNECT:
-        std::cout << "disconnecting client" << std::endl;
+        COUT(4) << "disconnecting all clients" << std::endl;
         delete head_->findClient(&(event.peer->address));
+        //maybe needs bugfix: might also be a reason for the server to crash
         temp = temp->next();
         break;
@@ -224,22 +248,23 @@
   }
 
-  //bool ConnectionManager::clientDisconnect(ENetPeer *peer) {
-  //  return clientDisconnect(*peer);
-  //}
-
   bool ConnectionManager::clientDisconnect(ENetPeer *peer) {
-    return head_->removeClient(peer);
-  }
-
+    COUT(4) << "removing client from list" << std::endl;
+    return removeClient(head_->findClient(&(peer->address))->getID());
+  }
+/**
+This function adds a client that connects to the clientlist of the server
+NOTE: if you change this, don't forget to change the test function
+addClientTest in diffTest.cc since addClient is not good for testing because of syncClassid
+*/
   bool ConnectionManager::addClient(ENetEvent *event) {
     ClientInformation *temp = head_->insertBack(new ClientInformation);
-    if(temp->prev()->head)
+    if(temp->prev()->head) { //not good if you use anything else than insertBack
+      temp->prev()->setID(0); //bugfix: not necessary but usefull
       temp->setID(1);
+    }
     else
       temp->setID(temp->prev()->getID()+1);
     temp->setPeer(event->peer);
-    std::cout << "added client id: " << temp->getID() << std::endl;
-    syncClassid(temp->getID());
-    temp->setSynched(true);
+    COUT(4) << "Con.Man: added client id: " << temp->getID() << std::endl;
     return true;
   }
@@ -268,5 +293,5 @@
       classname = id->getName();
       network_id = id->getNetworkID();
-      COUT(4) << "network_id: " << network_id << ", classname: " << classname << std::endl;
+      COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
 
       addPacket(packet_gen.clid( (int)network_id, classname ), clientID);
@@ -275,36 +300,123 @@
     }
     sendPackets();
-  }
-
-
-
-  void ConnectionManager::addClientsObjectID( int clientID, int objectID ) {
-    COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl;
-    clientsShip.insert( std::make_pair( clientID, objectID ) );
-  }
+    COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
+  }
+
+  bool ConnectionManager::createClient(int clientID){
+    ClientInformation *temp = head_->findClient(clientID);
+    COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+    syncClassid(temp->getID());
+    COUT(4) << "creating spaceship for clientid: " << temp->getID() << std::endl;
+    // TODO: this is only a hack, untill we have a possibility to define default player-join actions
+    createShip(temp);
+    COUT(4) << "created spaceship" << std::endl;
+    temp->setSynched(true);
+    COUT(4) << "sending welcome" << std::endl;
+    sendWelcome(temp->getID(), temp->getShipID(), true);
+    return true;
+  }
+  
+  bool ConnectionManager::removeClient(int clientID){
+    orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();
+    while(it){
+      if(it->objectID!=head_->findClient(clientID)->getShipID()){
+        ++it;
+        continue;
+      }
+      orxonox::Iterator<orxonox::SpaceShip> temp=it;
+      ++it;
+      delete  *temp;
+      return head_->removeClient(clientID);
+    }
+    return false;
+  }
+  
+  bool ConnectionManager::createShip(ClientInformation *client){
+    orxonox::Identifier* id = ID("SpaceShip");
+    if(!id){
+      COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl;
+      return false;
+    }
+    orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate());
+    no->setPosition(orxonox::Vector3(0,80,0));
+    no->setScale(10);
+    no->setYawPitchRoll(orxonox::Degree(-90),orxonox::Degree(-90),orxonox::Degree(0));
+    no->setMesh("assff.mesh");
+    no->setMaxSpeed(500);
+    no->setMaxSideAndBackSpeed(50);
+    no->setMaxRotation(1.0);
+    no->setTransAcc(200);
+    no->setRotAcc(3.0);
+    no->setTransDamp(75);
+    no->setRotDamp(1.0);
+    no->setCamera("cam_"+client->getID());
+    no->create();
+    
+    client->setShipID(no->objectID);
+    return true;
+  }
+  
+  bool ConnectionManager::removeShip(ClientInformation *client){
+    int id=client->getShipID();
+    orxonox::Iterator<orxonox::SpaceShip> it;
+    for(it = orxonox::ObjectList<orxonox::SpaceShip>::start(); it; ++it){
+      if(it->objectID!=id)
+        continue;
+      delete *it;
+    }
+    return true;
+  }
+  
+  bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){
+    addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID);
+    sendPackets();
+    return true;
+  }
+  
+  void ConnectionManager::disconnectClient(ClientInformation *client){
+    enet_peer_disconnect(client->getPeer(), 0);
+    removeShip(client);
+  }
+  
+  bool ConnectionManager::addFakeConnectRequest(ENetEvent *ev){
+    ENetEvent event;
+    event.peer=ev->peer;
+    event.packet = packet_gen.generateConnectRequest();
+    return buffer.push(&event);
+  }
+  
+  
+//   int ConnectionManager::getNumberOfClients() {
+//     
+//     return clientsShip.size();
+//   }
+  
+  /*void ConnectionManager::addClientsObjectID( int clientID, int objectID ) {
+  COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl;
+  clientsShip.insert( std::make_pair( clientID, objectID ) );
+}
 
   int ConnectionManager::getClientsShipID( int clientID ) {
-    return clientsShip[clientID];
-  }
+  return clientsShip[clientID];
+}
 
   int ConnectionManager::getObjectsClientID( int objectID ) {
-    std::map<int, int>::iterator iter = clientsShip.begin();
-    while( iter != clientsShip.end() ) {
-      if( iter->second == objectID ) return iter->first;
-    }
-    return -99;
-  }
+  std::map<int, int>::iterator iter;
+  for( iter = clientsShip.begin(); iter != clientsShip.end(); iter++ ) {
+  if( iter->second == objectID ) return iter->first;
+}
+  return -99;
+}
 
   void ConnectionManager::deleteClientIDReg( int clientID ) {
-    clientsShip.erase( clientID );
-  }
+  clientsShip.erase( clientID );
+}
 
   void ConnectionManager::deleteObjectIDReg( int objectID ) {
-    std::map<int, int>::iterator iter = clientsShip.begin();
-    while( iter != clientsShip.end() ) {
-      if( iter->second == objectID ) break;
-    }
-    clientsShip.erase( iter->first );
-  }
-
-}
+  std::map<int, int>::iterator iter = clientsShip.begin();
+  for( iter = clientsShip.begin(); iter != clientsShip.end(); iter++ ) {
+  if( iter->second == objectID ) break;
+}
+  clientsShip.erase( iter->first );
+}*/
+}
Index: code/trunk/src/network/ConnectionManager.h
===================================================================
--- code/trunk/src/network/ConnectionManager.h	(revision 1292)
+++ code/trunk/src/network/ConnectionManager.h	(revision 1293)
@@ -47,4 +47,5 @@
 // enet library for networking support
 #include <enet/enet.h>
+#include <boost/thread/thread.hpp>
 
 #include "PacketBuffer.h"
@@ -71,4 +72,5 @@
   class ConnectionManager{
   public:
+    ConnectionManager();
     ConnectionManager(ClientInformation *head);
     ConnectionManager(int port, const char *address, ClientInformation *head);
@@ -84,7 +86,10 @@
     bool sendPackets(ENetEvent *event);
     bool sendPackets();
+    bool createClient(int clientID);
+    void disconnectClient(ClientInformation *client);
+
   private:
     bool clientDisconnect(ENetPeer *peer);
-    //bool clientDisconnect(ENetPeer peer);
+    bool removeClient(int clientID);
     bool processData(ENetEvent *event);
     bool addClient(ENetEvent *event);
@@ -95,4 +100,8 @@
     void syncClassid(int clientID);
     ENetPeer *getClientPeer(int clientID);
+    bool createShip(ClientInformation *client);
+    bool removeShip(ClientInformation *client);
+    bool sendWelcome(int clientID, int shipID, bool allowed);
+    bool addFakeConnectRequest(ENetEvent *ev);
     PacketBuffer buffer;
     PacketGenerator packet_gen;
@@ -104,19 +113,14 @@
     ClientInformation *head_;
 
+    boost::thread *receiverThread_;
+//     int getNumberOfClients();
     //functions to map what object every clients uses
-    std::map<int, int> clientsShip;
+    /*std::map<int, int> clientsShip;
     void addClientsObjectID( int clientID, int objectID );
     int getClientsShipID( int clientID );
     int getObjectsClientID( int objectID );
     void deleteClientIDReg( int clientID );
-    void deleteObjectIDReg( int objectID );
+    void deleteObjectIDReg( int objectID );*/
   };
-
-
-
-
-
-
-
 
 }
Index: code/trunk/src/network/GameStateClient.cc
===================================================================
--- code/trunk/src/network/GameStateClient.cc	(revision 1292)
+++ code/trunk/src/network/GameStateClient.cc	(revision 1293)
@@ -32,9 +32,19 @@
 
 #include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
 #include "Synchronisable.h"
+
+#define GAMESTATEID_INITIAL -1
 
 namespace network
 {
+  struct GameStateItem{
+    GameState *state;
+    int id;
+  };
+  
   GameStateClient::GameStateClient() {
+    COUT(5) << "this: " << this << std::endl;
+    last_diff_=0;
   }
 
@@ -43,14 +53,48 @@
 
   bool GameStateClient::pushGameState(GameStateCompressed *compstate) {
-    GameState *gs;
-    if(compstate->diffed)
+    cleanup();
+    printGameStateMap();
+    GameState *gs, *reference;
+    if(compstate->diffed && compstate->base_id!=GAMESTATEID_INITIAL){
+      std::map<int, GameState*>::iterator it = gameStateMap.find(compstate->base_id);
+      if(it!=gameStateMap.end())
+        reference = (it)->second;
+      else
+        reference = NULL;
+      if(!reference){
+        COUT(4) << "pushGameState: no reference found to diff" << std::endl;
+        delete[] compstate->data;
+        delete compstate;
+        return false;
+      }
       gs = decode(reference, compstate);
+    }
     else
       gs = decode(compstate);
-    if(gs)
-      return loadSnapshot(gs);
+    if(gs){
+      if (loadSnapshot(gs)){
+        gameStateMap.insert(std::pair<int, GameState*>(gs->id, gs));
+        COUT(4) << "adding decoded gs with id: " << gs->id << " diffed from: " << gs->base_id << std::endl;
+        last_diff_=gs->base_id;
+        return true;
+      }else{
+        COUT(4) << "could not decode gs with id: " << gs->id << " diffed from: " << gs->base_id << std::endl;
+        delete[] gs->data;
+        delete gs;
+        return false;
+      }
+    }
     COUT(4) << "could not use gamestate sent by server" << std::endl;
     return false;
   }
+  
+  GameStateCompressed *GameStateClient::popPartialGameState(){
+    GameState *gs = getPartialSnapshot();
+    GameStateCompressed *cgs = compress_(gs);
+    delete[] gs->data;
+    delete gs;
+    return cgs;
+  }
+  
 
   /**
@@ -78,14 +122,14 @@
     while(data < state->data+state->size){
       // prepare the syncData struct
-      sync.length = (int)*data;
+      sync.length = *(int *)data;
       data+=sizeof(int);
-      sync.objectID = (int)*data;
+      sync.objectID = *(int*)data;
       data+=sizeof(int);
-      sync.classID = (int)*data;
+      sync.classID = *(int*)data;
       data+=sizeof(int);
       sync.data = data;
       data+=sync.length;
 
-      if(it->objectID!=sync.objectID){
+      if(!it || it->objectID!=sync.objectID){
         // bad luck ;)
         // delete the synchronisable (obviously seems to be deleted on the server)
@@ -95,13 +139,22 @@
 
         if(!it){
-          COUT(5) << "classid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
-          Synchronisable *no = (Synchronisable*)(ID((unsigned int) sync.classID)->fabricate());
+          //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
+          ///sigsegv may happen here again for some reason
+          ///sigsegv is receved after the COUT(4) above
+          orxonox::Identifier* id = ID((unsigned int)sync.classID);
+          if(!id){
+            COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl;
+            continue;
+          }
+          Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
+          COUT(4) << "loadsnapshot: classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
           no->objectID=sync.objectID;
           no->classID=sync.classID;
+          // update data and create object/entity...
+          if( !no->updateData(sync) )
+            COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl;
+          if( !no->create() )
+            COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl;
           it=orxonox::ObjectList<Synchronisable>::end();
-          // update data and create object/entity...
-          if( !no->updateData(sync) && !no->create() )
-            COUT(1) << "We couldn't create/update the object: " << sync.objectID << std::endl;
-          ++it;
         }
       } else {
@@ -117,20 +170,87 @@
   }
 
-  GameState *GameStateClient::undiff(GameState *a, GameState *b) {
-    unsigned char *ap = a->data, *bp = b->data;
+  GameState *GameStateClient::getPartialSnapshot(){
+    //std::cout << "begin getSnapshot" << std::endl;
+    //the size of the gamestate
+    int totalsize=0;
+    int memsize=0;
+    //the size of one specific synchronisable
+    int tempsize=0;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it;
+    // struct for return value of Synchronisable::getData()
+    syncData sync;
+
+    GameState *retval=new GameState; //return value
+//     retval->id=reference->id;
+    if(gameStateMap.size()!=0)
+      retval->id=(--gameStateMap.end())->second->id;
+    retval->diffed=false;
+    retval->complete=false;
+    COUT(4) << "G.ST.Client: producing partial gamestate with id: " << retval->id << std::endl;
+    // offset of memory functions
+    int offset=0, size=0;
+    // get total size of gamestate
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      if(!it->getBacksync())
+        continue;
+      size+=it->getSize(); // size of the actual data of the synchronisable
+      size+=3*sizeof(int); // size of datasize, classID and objectID
+      COUT(4) << "getpartialsnapshot: size: " << size << std::endl;
+    }
+    //retval->data = (unsigned char*)malloc(size);
+    retval->data = new unsigned char[size];
+    if(!retval->data){
+      COUT(2) << "GameStateClient: could not allocate memory" << std::endl;
+      return NULL;
+    }
+    memsize=size;
+    // go through all Synchronisables
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      if(!it->getBacksync())
+        continue;
+      //get size of the synchronisable
+      tempsize=it->getSize();
+      // add place for data and 3 ints (length,classid,objectid)
+      totalsize+=tempsize+3*sizeof(int);
+      // allocate+tempsize additional space
+      if(totalsize > size){
+        COUT(3) << "G.St.Cl: need additional memory" << std::endl;
+      }
+
+      // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
+      sync=it->getData((retval->data)+offset+3*sizeof(int));
+      memcpy(retval->data+offset, (void *)&(sync.length), sizeof(int));
+      memcpy(retval->data+offset+sizeof(int), (void *)&(sync.objectID), sizeof(int));
+      memcpy(retval->data+offset+2*sizeof(int), (void *)&(sync.classID), sizeof(int));
+      // increase data pointer
+      offset+=tempsize+3*sizeof(int);
+    }
+    retval->size=totalsize;
+    COUT(5) << "G.ST.Cl: Gamestate size: " << totalsize << std::endl;
+    COUT(5) << "G.ST.Cl: 'estimated' Gamestate size: " << size << std::endl;
+    return retval;
+  }
+  
+  
+  GameState *GameStateClient::undiff(GameState *old, GameState *diff) {
+    if(!old || !diff)
+      return NULL;
+    unsigned char *ap = old->data, *bp = diff->data;
     int of=0; // pointers offset
     int dest_length=0;
-    if(a->size>=b->size)
-      dest_length=a->size;
+    if(old->size>=diff->size)
+      dest_length=old->size;
     else
-      dest_length=b->size;
-    unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
-    while(of<a->size && of<b->size){
+      dest_length=diff->size;
+//     unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
+    while(of<old->size && of<diff->size){
       *(dp+of)=*(ap+of)^*(bp+of); // do the xor
       ++of;
     }
-    if(a->size!=b->size){ // do we have to fill up ?
+    if(old->size!=diff->size){ // do we have to fill up ?
       unsigned char n=0;
-      if(a->size<b->size){
+      if(old->size<diff->size){
         while(of<dest_length){
           *(dp+of)=n^*(bp+of);
@@ -147,12 +267,49 @@
     // FIXME: is it true or false now? (struct has changed, producing warnings)
     GameState *r = new GameState;
-    r->id = b->id;
+    r->id = diff->id;
     r->size = dest_length;
+    r->base_id = old->id;
     r->diffed = false;
     r->data = dp;
+    r->complete = true;
     return r;
   }
 
+
+
+  GameStateCompressed *GameStateClient::compress_(GameState *a) {
+    if(!a)
+      return NULL;
+    int size = a->size;
+
+    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
+    unsigned char *dest = new unsigned char[buffer];
+    int retval;
+    retval = compress( dest, &buffer, a->data, (uLong)size );
+
+    switch ( retval ) {
+      case Z_OK: COUT(5) << "G.St.Cl: compress: successfully compressed" << std::endl; break;
+      case Z_MEM_ERROR: COUT(1) << "G.St.Cl: compress: not enough memory available in gamestate.compress" << std::endl; 
+      return NULL;
+      case Z_BUF_ERROR: COUT(2) << "G.St.Cl: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
+      return NULL;
+      case Z_DATA_ERROR: COUT(2) << "G.St.Cl: compress: data corrupted in gamestate.compress" << std::endl;
+      return NULL;
+    }
+
+    GameStateCompressed *compressedGamestate = new GameStateCompressed;
+    compressedGamestate->compsize = buffer;
+    compressedGamestate->normsize = size;
+    compressedGamestate->id = a->id;
+    compressedGamestate->data = dest;
+    compressedGamestate->diffed = a->diffed;
+    compressedGamestate->complete = a->complete;
+    compressedGamestate->base_id = a->base_id;
+    return compressedGamestate;
+  }
+  
+  
   GameState *GameStateClient::decompress(GameStateCompressed *a) {
+    //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
     int normsize = a->normsize;
     int compsize = a->compsize;
@@ -162,5 +319,6 @@
     else
       bufsize = normsize;
-    unsigned char* dest = (unsigned char*)malloc( bufsize );
+//     unsigned char* dest = (unsigned char*)malloc( bufsize );
+    unsigned char *dest = new unsigned char[bufsize];
     int retval;
     uLongf length=normsize;
@@ -173,5 +331,5 @@
       case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return NULL;
       case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL;
-      case Z_DATA_ERROR: COUT(2) << "data corrupted" << std::endl; return NULL;
+      case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return NULL;
     }
 
@@ -180,21 +338,63 @@
     gamestate->size = normsize;
     gamestate->data = dest;
+    gamestate->base_id = a->base_id;
     gamestate->diffed = a->diffed;
-
-    delete a->data; //delete compressed data
-    delete a; //we do not need the old (struct) gamestate anymore
+    gamestate->complete = a->complete;
+
 
     return gamestate;
   }
 
-  GameState *GameStateClient::decode(GameState *a, GameStateCompressed *x) {
-    GameState *t = decompress(x);
-    return undiff(a, t);
+  GameState *GameStateClient::decode(GameState *old, GameStateCompressed *diff) {
+    COUT(4) << "using diffed gamestate" << std::endl;
+    GameState *t = decode(diff);
+    GameState *r = undiff(old, t);
+    delete[] t->data;
+    delete t;
+    return r;
   }
 
   GameState *GameStateClient::decode(GameStateCompressed *x) {
     GameState *t = decompress(x);
+    delete[] x->data;
+    delete x;
     return t;
   }
-
+  
+  void GameStateClient::cleanup(){
+    std::map<int, GameState*>::iterator temp, it = gameStateMap.begin();
+    while(it!=gameStateMap.end()){
+      if(it->first>=last_diff_)
+        break;
+      // otherwise delete that stuff
+      delete[] (*it).second->data;
+      delete (*it).second;
+      temp=it++;
+      gameStateMap.erase(temp);
+    }
+  }
+
+  void GameStateClient::printGameStateMap(){
+    std::map<int, GameState*>::iterator it;
+    COUT(4) << "gamestates: ";
+    for(it=gameStateMap.begin(); it!=gameStateMap.end(); it++){
+      COUT(4) << it->first << ":" << it->second << "|";
+    }
+    COUT(4) << std::endl;
+    
+  }
+  
+  
+    //##### ADDED FOR TESTING PURPOSE #####
+  GameState* GameStateClient::testDecompress( GameStateCompressed* gc ) {
+    return decompress( gc );
+  }
+  
+  GameState* GameStateClient::testUndiff( GameState* g_old, GameState* g_diffed ) {
+    return undiff( g_old, g_diffed );
+  }
+  //##### ADDED FOR TESTING PURPOSE #####
+  
+  
 }
+
Index: code/trunk/src/network/GameStateClient.h
===================================================================
--- code/trunk/src/network/GameStateClient.h	(revision 1292)
+++ code/trunk/src/network/GameStateClient.h	(revision 1293)
@@ -41,7 +41,10 @@
 #define _GameStateClient_H__
 
+#include <map>
+// 
 #include "NetworkPrereqs.h"
 #include "core/CorePrereqs.h"
-#include "GameStateManager.h"
+#include "PacketTypes.h"
+
 
 namespace network
@@ -52,14 +55,30 @@
     GameStateClient();
     ~GameStateClient();
+    
     bool pushGameState(GameStateCompressed *compstate);
+    GameStateCompressed *popPartialGameState();
   private:
     bool loadSnapshot(GameState *state);
-    GameState *undiff(GameState *a, GameState *b);
+    GameState *getPartialSnapshot();
+    void cleanup();
+    GameState *undiff(GameState *old, GameState *diff);
+    GameStateCompressed *compress_(GameState *a);
     GameState *decompress(GameStateCompressed *a);
-    GameState *decode(GameState *a, GameStateCompressed *x);
+    GameState *decode(GameState *old, GameStateCompressed *diff);
     GameState *decode(GameStateCompressed *x);
     void removeObject(orxonox::Iterator<Synchronisable> &it);
+    void printGameStateMap();
 
-    GameState *reference;
+    int           last_diff_;
+    std::map<int, GameState *> gameStateMap;
+    
+    
+    
+    
+  public:
+    //#### ADDED FOR TESTING PURPOSE ####
+    GameState* testDecompress( GameStateCompressed* gc );
+    GameState* testUndiff( GameState* g_old, GameState* g_diffed );
+    //#### END TESTING PURPOSE ####
   };
 
Index: code/trunk/src/network/GameStateManager.cc
===================================================================
--- code/trunk/src/network/GameStateManager.cc	(revision 1292)
+++ code/trunk/src/network/GameStateManager.cc	(revision 1293)
@@ -46,4 +46,5 @@
 
 #include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
 #include "ClientInformation.h"
 #include "Synchronisable.h"
@@ -52,5 +53,5 @@
 {
   GameStateManager::GameStateManager(ClientInformation *head) {
-    id=0;
+    id_=0;
     head_=head;
   }
@@ -60,25 +61,84 @@
 
   void GameStateManager::update(){
-    reference = getSnapshot(id);
-    gameStateMap.insert(std::pair<int, GameState*>(id, reference));
-    gameStateUsed[id]=0;
-    ++id;
+    cleanup();
+    reference = getSnapshot();
+    COUT(4) << "inserting gamestate: " << reference << std::endl;
+    gameStateMap.insert(std::pair<int, GameState*>(id_, reference));
+    gameStateUsed[id_]=0;
+    printGameStates();
     return;
   }
+  
+  
+  /**
+   * this function is used to keep the memory usage low
+   * it tries to delete all the unused gamestates
+   * 
+   * 
+   */
+  void GameStateManager::cleanup(){
+    std::map<int,int>::iterator it = gameStateUsed.begin();
+    while(it!=gameStateUsed.end()){
+      if((id_-(*it).first)<KEEP_GAMESTATES)
+        break;
+      if( (*it).second <= 0 ){
+        COUT(4) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
+        std::map<int, GameState *>::iterator tempit = gameStateMap.find((*it).first);
+        if( tempit != gameStateMap.end() ){
+          GameState *temp = tempit->second;
+          if(temp){
+            delete[] gameStateMap[(*it).first]->data;
+            delete gameStateMap[(*it).first];
+            gameStateMap.erase((*it).first);
+          }
+        }
+        gameStateUsed.erase(it++);
+        continue;
+      }/*else if(id_-it->first<=KEEP_GAMESTATES){  //as soon as we got a used gamestate break here because we could use newer gamestates in future but only if we do not exceed KEEP_GAMESTATES # of gamestates in cache
+        COUT(4) << "breaking " << std::endl;
+        break;
+      }*/
+      it++;
+    }
+  }
 
   GameStateCompressed *GameStateManager::popGameState(int clientID) {
+    //why are we searching the same client's gamestate id as we searched in
+    //Server::sendGameState?
     int gID = head_->findClient(clientID)->getGamestateID();
-    COUT(4) << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
-    if(gID!=GAMESTATEID_INITIAL){
-      GameState *client = gameStateMap[gID];
+    COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
+//     COUT(3) << "gamestatemap: " << &gameStateMap << std::endl;
+    //chose wheather the next gamestate is the first or not
+    if(gID != GAMESTATEID_INITIAL){
+      // TODO something with the gamestatemap is wrong
+      GameState *client=NULL;
+      std::map<int, GameState*>::iterator it = gameStateMap.find(gID);
+      if(it!=gameStateMap.end())
+        client = it->second;
       GameState *server = reference;
       //head_->findClient(clientID)->setGamestateID(id);
-      return encode(client, server);
+      COUT(3) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << std::endl;
+      if(client)
+        return encode(client, server);
+      else
+        return encode(server);
     } else {
+      COUT(4) << "we got a GAMESTATEID_INITIAL for clientID: " << clientID << std::endl;
       GameState *server = reference;
+//       ackGameState(clientID, reference->id);
       //head_->findClient(clientID)->setGamestateID(id);
       return encode(server);
       // return an undiffed gamestate and set appropriate flags
     }
+  }
+  
+  bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){
+    GameState *ugs = decompress(gs);
+    delete[] gs->data;
+    delete gs;
+    bool result = loadPartialSnapshot(ugs, clientID);
+    delete[] ugs->data;
+    delete ugs;
+    return result;
   }
 
@@ -88,9 +148,10 @@
   * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
   */
-  GameState *GameStateManager::getSnapshot(int id)
+  GameState *GameStateManager::getSnapshot()
   {
+    //std::cout << "begin getSnapshot" << std::endl;
     //the size of the gamestate
     int totalsize=0;
-    int memsize=1000;
+    int memsize=0;
     //the size of one specific synchronisable
     int tempsize=0;
@@ -101,58 +162,148 @@
 
     GameState *retval=new GameState; //return value
-    retval->id=id++;
-    COUT(4) << "producing gamestate with id: " << retval->id << std::endl;
-    // reserve a little memory and increase it later on
-    COUT(5) << "mallocing" << std::endl;
-    retval->data = (unsigned char*)malloc(memsize);
-    COUT(5) << "malloced" << std::endl;
-
+    retval->id=++id_;
+    COUT(4) << "G.ST.Man: producing gamestate with id: " << retval->id << std::endl;
     // offset of memory functions
-    int offset=0;
+    int offset=0, size=0;
+    // get total size of gamestate
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
+      size+=it->getSize(); // size of the actual data of the synchronisable
+      size+=3*sizeof(int); // size of datasize, classID and objectID
+    }
+    //retval->data = (unsigned char*)malloc(size);
+    retval->data = new unsigned char[size];
+    if(!retval->data){
+      COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
+      return NULL;
+    }
+    memsize=size;
     // go through all Synchronisables
     for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
-      //std::cout << "gamestatemanager: in for loop" << std::endl;
       //get size of the synchronisable
       tempsize=it->getSize();
-//       COUT(5) << "size of temp gamestate: " << tempsize << std::endl;
-      //COUT(2) << "size of synchronisable: " << tempsize << std::endl;
       // add place for data and 3 ints (length,classid,objectid)
       totalsize+=tempsize+3*sizeof(int);
-      //std::cout << "totalsize: " << totalsize << std::endl;
-      // allocate additional space
-      if(totalsize+tempsize>memsize){
-        if(tempsize<1000){
-          retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
-          memsize+=1000;
-        } else {
-          retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
-          memsize+=tempsize+1000;
-        }
+      // allocate+tempsize additional space
+      if(totalsize > size){
+        COUT(3) << "G.St.Man: need additional memory" << std::endl;
+//         if(tempsize < 1000){
+//           retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
+//           memsize+=1000;
+//         } else {
+//           retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
+//           memsize+=tempsize+1000;
+//         }
+//         COUT(5) << "G.St.Man: additional space allocation finished" << std::endl;
       }
 
       // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
       sync=it->getData((retval->data)+offset+3*sizeof(int));
-      *(retval->data+offset)=(unsigned char)sync.length;
-      *(retval->data+offset+sizeof(int))=(unsigned char)sync.objectID;
-      *(retval->data+offset+2*sizeof(int))=(unsigned char)sync.classID;
+      memcpy(retval->data+offset, (void *)&(sync.length), sizeof(int));
+      memcpy(retval->data+offset+sizeof(int), (void *)&(sync.objectID), sizeof(int));
+      memcpy(retval->data+offset+2*sizeof(int), (void *)&(sync.classID), sizeof(int));
       // increase data pointer
       offset+=tempsize+3*sizeof(int);
     }
-    COUT(5) << "Gamestate size: " << totalsize << std::endl;
     retval->size=totalsize;
+    //#### bugfix
+    retval->diffed = false;
+    retval->complete = true;
+    //std::cout << "end snapShot" << std::endl;
+    COUT(5) << "G.ST.Man: Gamestate size: " << totalsize << std::endl;
+    COUT(5) << "G.ST.Man: 'estimated' Gamestate size: " << size << std::endl;
     return retval;
   }
 
+  bool GameStateManager::loadPartialSnapshot(GameState *state, int clientID){
+    if(!state)
+      return false;
+    unsigned char *data=state->data;
+    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
+    syncData sync;
+    // loop as long as we have some data ;)
+    while(data < state->data+state->size){
+      // prepare the syncData struct
+      sync.length = *(int *)data;
+      data+=sizeof(int);
+      sync.objectID = *(int*)data;
+      data+=sizeof(int);
+      sync.classID = *(int*)data;
+      data+=sizeof(int);
+      sync.data = data;
+      data+=sync.length;
+      COUT(4) << "objectID: " << sync.objectID << " classID: " << sync.classID << std::endl;
+      while(it && it->objectID!=sync.objectID)
+        ++it;
+
+
+      if(!it){
+        // the object does not exist yet
+        COUT(4) << "loadsnapshot: creating new object " << std::endl;
+        //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
+        orxonox::Identifier* id = ID((unsigned int)sync.classID);
+        if(!id){
+          COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl;
+          continue;
+        }
+        Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
+        COUT(4) << "loadpartialsnapshot (generating new object): classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
+        no->objectID=sync.objectID;
+        no->classID=sync.classID;
+        it=orxonox::ObjectList<Synchronisable>::end();
+        // update data and create object/entity...
+        if( !no->updateData(sync) )
+          COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl;
+        if( !no->create() )
+          COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl;
+      }else{
+        // we have our object
+        COUT(4) << "loadpartialsnapshot: we found the appropriate object" << std::endl;
+        if(checkAccess(clientID, sync.objectID)){
+          if(! it->updateData(sync))
+            COUT(1) << "We couldn't update objectID: " \
+              << sync.objectID << "; classID: " << sync.classID << std::endl;
+        }else
+          COUT(4) << "loadPartialSnapshot: no access to change objectID: " << sync.objectID << std::endl;
+      }
+      ++it;
+    }
+    
+    return true;
+  }
+  
+  
+  //##### ADDED FOR TESTING PURPOSE #####
+  GameStateCompressed* GameStateManager::testCompress( GameState* g ) {
+    return compress_( g );
+  }
+
+  GameState* GameStateManager::testDiff( GameState* a, GameState* b ) {
+    return diff( a, b );
+  }
+  //##### END TESTING PURPOSE #####
+
   GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
-    //GameState r = diff(a,b);
-    //r.diffed = true;
-    GameState *r = b;
-    r->diffed = false;
-    return compress_(r);
+    COUT(4) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
+    GameState *r = diff(a,b);
+    GameStateCompressed *c = compress_(r);
+    delete[] r->data;
+    delete r;
+    return c;
   }
 
   GameStateCompressed *GameStateManager::encode(GameState *a) {
-    a->diffed=false;
+    COUT(5) << "G.St.Man: encoding gamestate (compress)" << std::endl;
+    a->base_id=GAMESTATEID_INITIAL;
     return compress_(a);
+    /*GameStateCompressed *g = new GameStateCompressed;
+    g->base_id = a->base_id;
+    g->id = a->id;
+    g->diffed = a->diffed;
+    g->data = a->data;
+    g->normsize = a->size;
+    g->compsize = a->size;
+    return g;*/
   }
 
@@ -165,5 +316,6 @@
     else
       dest_length=b->size;
-    unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    //unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
     while(of<a->size && of<b->size){
       *(dp+of)=*(ap+of)^*(bp+of); // do the xor
@@ -189,25 +341,34 @@
     r->size = dest_length;
     r->diffed = true;
+    r->base_id = a->id;
     r->data = dp;
+    r->complete = true;
     return r;
   }
 
   GameStateCompressed *GameStateManager::compress_(GameState *a) {
-    COUT(5) << "compressing gamestate" << std::endl;
+    //COUT(4) << "G.St.Man: compressing gamestate" << std::endl;
+
+    //COUT(4) << "G.St.Man: a: id: " << a->id << " base_id: " << a->base_id << " size: " << a->size << " diffed: " << a->diffed << std::endl;
     int size = a->size;
+
     uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
-    unsigned char* dest = (unsigned char*)malloc( buffer );
+    //COUT(4) << "size: " << size << ", buffer: " << buffer << std::endl;
+    //unsigned char* dest = (unsigned char*)malloc( buffer );
+    unsigned char *dest = new unsigned char[buffer];
+    //COUT(4) << "dest: " << dest << std::endl;
     int retval;
     //std::cout << "before ziped " << buffer << std::endl;
     retval = compress( dest, &buffer, a->data, (uLong)size );
+    //COUT(4) << "bloablabla aft3er compress" << std::endl;
     //std::cout << "after ziped " << buffer << std::endl;
 
     switch ( retval ) {
-      case Z_OK: COUT(5) << "successfully compressed" << std::endl; break;
-      case Z_MEM_ERROR: COUT(1) << "not enough memory available in gamestate.compress" << std::endl;
+      case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
+      case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; 
       return NULL;
-      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer in gamestate.compress" << std::endl;
+      case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
       return NULL;
-      case Z_DATA_ERROR: COUT(2) << "decompress: data corrupted in gamestate.compress" << std::endl;
+      case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl;
       return NULL;
     }
@@ -221,15 +382,56 @@
     compressedGamestate->data = dest;
     compressedGamestate->diffed = a->diffed;
-
+    compressedGamestate->complete = a->complete;
+    compressedGamestate->base_id = a->base_id;
+    //COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed:" << std::endl;
     return compressedGamestate;
   }
+  
+  GameState *GameStateManager::decompress(GameStateCompressed *a) {
+    //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
+    int normsize = a->normsize;
+    int compsize = a->compsize;
+    int bufsize;
+    if(normsize < compsize)
+      bufsize = compsize;
+    else
+      bufsize = normsize;
+//     unsigned char* dest = (unsigned char*)malloc( bufsize );
+    unsigned char *dest = new unsigned char[bufsize];
+    int retval;
+    uLongf length=normsize;
+    //std::cout << "gamestateclient" << std::endl;
+    //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
+    retval = uncompress( dest, &length, a->data, (uLong)compsize );
+    //std::cout << "length " << length << std::endl;
+    switch ( retval ) {
+      case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;
+      case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return NULL;
+      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL;
+      case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return NULL;
+    }
+
+    GameState *gamestate = new GameState;
+    gamestate->id = a->id;
+    gamestate->size = normsize;
+    gamestate->data = dest;
+    gamestate->base_id = a->base_id;
+    gamestate->diffed = a->diffed;
+    gamestate->complete = a->complete;
+
+
+    return gamestate;
+  }
+  
 
   void GameStateManager::ackGameState(int clientID, int gamestateID) {
     ClientInformation *temp = head_->findClient(clientID);
-    int curid = temp->getID();
+    int curid = temp->getGamestateID();
+    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
     // decrease usage of gamestate and save it
-    deleteUnusedGameState(curid);
+//     deleteUnusedGameState(curid);
     //increase gamestateused
-    ++gameStateUsed.find(gamestateID)->second;
+    --(gameStateUsed.find(curid)->second);
+    ++(gameStateUsed.find(gamestateID)->second);
     temp->setGamestateID(gamestateID);
     /*
@@ -239,13 +441,23 @@
   }
 
-  bool GameStateManager::deleteUnusedGameState(int gamestateID) {
-    int used = --(gameStateUsed.find(gamestateID)->second);
-    if(id-gamestateID>KEEP_GAMESTATES && used==0){
-      // delete gamestate
-      delete gameStateMap.find(gamestateID)->second;
-      gameStateMap.erase(gamestateID);
-      return true;
-    }
-    return false;
+  bool GameStateManager::printGameStates() {
+    std::map<int, GameState*>::iterator it;
+    COUT(4) << "gamestates: ";
+    for(it = gameStateMap.begin(); it!=gameStateMap.end(); it++){
+      COUT(4) << (*it).first << ":" << (*it).second << " | ";
+    }
+    COUT(4) << std::endl;
+    return true;
+  }
+  
+  bool GameStateManager::checkAccess(int clientID, int objectID){
+    // currently we only check, wheter the object is the clients spaceship
+//     return head_->findClient(objectID)->getShipID()==objectID;
+    return true; // TODO: change this
+  }
+  
+  void GameStateManager::removeClient(ClientInformation* client){
+    gameStateUsed[client->getGamestateID()]--;
+    head_->removeClient(client->getID());
   }
 
Index: code/trunk/src/network/GameStateManager.h
===================================================================
--- code/trunk/src/network/GameStateManager.h	(revision 1292)
+++ code/trunk/src/network/GameStateManager.h	(revision 1293)
@@ -50,5 +50,5 @@
 {
 
-#define KEEP_GAMESTATES 20
+#define KEEP_GAMESTATES 10
 
   /**
@@ -71,15 +71,21 @@
     GameStateManager(ClientInformation *head);
     ~GameStateManager();
+    
     void update();
     GameStateCompressed *popGameState(int clientID);
+    bool pushGameState(GameStateCompressed *gs, int clientID);
     void ackGameState(int clientID, int gamestateID);
-    int id;
+    void removeClient(ClientInformation *client);
   private:
-    GameState *getSnapshot(int id);
+    void cleanup(); // "garbage handler"
+    GameState *getSnapshot();
+    bool loadPartialSnapshot(GameState *state, int clientID);
     GameStateCompressed *encode(GameState *a, GameState *b);
     GameStateCompressed *encode(GameState *a);
     GameState *diff(GameState *a, GameState *b);
     GameStateCompressed *compress_(GameState *a);
-    bool deleteUnusedGameState(int gamestateID);
+    GameState *decompress(GameStateCompressed *a);
+    bool printGameStates();
+    bool checkAccess(int clientID, int objectID);
 
     std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
@@ -87,4 +93,14 @@
     GameState *reference;
     ClientInformation *head_;
+    int id_;
+    
+    
+    
+    
+  public:
+    //#### ADDED FOR TESTING PURPOSE ####
+    GameStateCompressed* testCompress( GameState* g );
+    GameState* testDiff( GameState* a, GameState* b );
+  //#### END TESTING PURPOSE ####
   };
 
Index: code/trunk/src/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/network/NetworkPrereqs.h	(revision 1292)
+++ code/trunk/src/network/NetworkPrereqs.h	(revision 1293)
@@ -78,4 +78,6 @@
   struct chat;
   struct classid;
+  struct welcome;
+  struct connectRequest;
   struct ClientList;
   struct GameState;
Index: code/trunk/src/network/PacketBuffer.cc
===================================================================
--- code/trunk/src/network/PacketBuffer.cc	(revision 1292)
+++ code/trunk/src/network/PacketBuffer.cc	(revision 1293)
@@ -61,7 +61,7 @@
       last=first;
       last->next=NULL;
-      // change this!!!!!!!
+      // change this!!!!!!! 
       last->packet = ev->packet;
-      last->address = ev->peer->address;
+      //last->address = ev->peer->address;
     } else {
       //insert a new element at the bottom
@@ -72,9 +72,13 @@
       // save the packet to the new element
       last->packet = ev->packet;
-      last->address = ev->peer->address;
+      //last->address = ev->peer->address;
     }
-    return true;
+    // pseudo bugfix: added a return false statement for error handling
+    if ( last->packet == ev->packet ) return true;
+    return false;
   }
 
+  //returns the first element in the list without deleting it but
+  //moving first pointer to next element
   ENetPacket *PacketBuffer::pop() {
     boost::mutex::scoped_lock lock(networkPacketBufferMutex);
Index: code/trunk/src/network/PacketDecoder.cc
===================================================================
--- code/trunk/src/network/PacketDecoder.cc	(revision 1292)
+++ code/trunk/src/network/PacketDecoder.cc	(revision 1293)
@@ -53,37 +53,43 @@
   bool PacketDecoder::elaborate( ENetPacket* packet, int clientId )
   {
-    int client = clientId;
-    COUT(5) << "clientId: " << client << std::endl; //control cout, not important, just debugging info
+    COUT(5) << "PacketDecoder: clientId: " << clientId << std::endl; //control cout, not important, just debugging info
     int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
-    COUT(5) << "packet id: " << id << std::endl;
-//     COUT(5) << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
+    COUT(5) << "PacketDecoder: packet id: " << id << std::endl;
+    //COUT(5) << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
+
+    if ( packet == NULL ) {
+      COUT(4) << "PacketDecoder: no packets->packetbuffer queue is empty" << std::endl;
+      return false;
+    }
     switch( id ) {
-  case ACK:
-    acknowledgement( packet, clientId );
-    return true;
-    break;
-  case MOUSE:
-    mousem( packet, clientId );
-    return true;
-    break;
-  case KEYBOARD:
-    keystrike( packet, clientId );
-    return true;
-    break;
-  case CHAT:
-    chatMessage( packet, clientId );
-    return true;
-    break;
-  case GAMESTATE:
-    gstate( packet );
-    return true;
-    break;
-  case CLASSID:
-    clid(packet);
-    return true;
-    break;
+    case ACK:
+      acknowledgement( packet, clientId );
+      return true;
+    case COMMAND:
+      return command( packet, clientId );
+    case MOUSE:
+      mousem( packet, clientId );
+      return true;
+    case KEYBOARD:
+      keystrike( packet, clientId );
+      return true;
+    case CHAT:
+      chatMessage( packet, clientId );
+      return true;
+    case GAMESTATE:
+      gstate( packet, clientId );
+      return true;
+    case CLASSID:
+      clid(packet);
+      return true;
+    case WELCOME:
+      return decodeWelcome( packet, clientId );
+    case CONNECT:
+      return decodeConnectRequest( packet, clientId );
     }
     return false;
   }
+  
+  // ATTENTION: TODO watch, that arguments we pass over to the processFunction gets deleted in THE PROCESSXXX function
 
   //following are the decode functions for the data of the packets
@@ -92,12 +98,18 @@
   {
     ack* a = new ack;
-    *a = *(ack*)packet->data; //press pattern of ack on new data
-
-
-    COUT(5) << "got ack id: " << a->id << std::endl;
+    *a = *(ack*)(packet->data); //press pattern of ack on new data
+
+
+    COUT(4) << "PacketDecoder: got ack id: " << a->a << std::endl;
     processAck( a, clientId ); //debug info
-
-    //clean memory
-    enet_packet_destroy( packet );
+    //clean memory
+    enet_packet_destroy( packet );
+  }
+  
+  bool PacketDecoder::command( ENetPacket* packet, int clientId ){
+    int length = *(int*)((unsigned char *)packet->data+sizeof(int));
+    void *data = (void *)new unsigned char[length];
+    memcpy(data, (void *)(packet->data+2*sizeof(int)), length);
+    return true;
   }
 
@@ -110,5 +122,4 @@
     //clean memory
     enet_packet_destroy( packet );
-
     printMouse( mouseMove ); //debug info
   }
@@ -121,5 +132,4 @@
     //clean memory
     enet_packet_destroy( packet );
-
     printKey( key ); //debug info
 
@@ -144,10 +154,10 @@
   }
 
-  void PacketDecoder::gstate( ENetPacket* packet )
+  void PacketDecoder::gstate( ENetPacket* packet, int clientID )
   {
     GameStateCompressed* currentState = NULL;
     currentState = new GameStateCompressed;
     if(currentState == NULL){
-      COUT(3) << "could not generate new GameStateCompressed" << std::endl;
+      COUT(3) << "PacketDecoder: could not generate new GameStateCompressed" << std::endl;
       return;
     }
@@ -156,36 +166,28 @@
     unsigned char* data = (unsigned char *)(packet->data);
     //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
-    //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
-    //currentState->id = *((int *)packet->data+sizeof(int));
     memcpy( (void*)&(currentState->id), (const void*)(packet->data+1*sizeof( int )), sizeof( int) );
-    COUT(5) << "decoder: received gs id: " << currentState->id << std::endl;
-//     std::cout << "id: " << currentState->id << std::endl;
+    COUT(5) << "PacketDecoder: received gs id: " << currentState->id << std::endl;
     //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
     //position of the data stream, data+2*sizeof( int )
     memcpy( (void*)&(currentState->compsize), (const void*)(packet->data+2*sizeof( int )), sizeof( int) );
-    //currentState->compsize = (int)*(data+2*sizeof(int));
-//     std::cout << "compsize: " << currentState->compsize << std::endl;
     //size of uncompressed data
     memcpy( (void*)&(currentState->normsize), (const void*)(packet->data+3*sizeof( int )), sizeof( int ) );
-    //currentState->normsize = (int)*(data+3*sizeof(int));
-//     std::cout << "normsize. " << currentState->normsize << std::endl;
+    memcpy( (void*)&(currentState->base_id), (const void*)(packet->data+4*sizeof( int )), sizeof( int ) );
     //since the packetgenerator was changed, due to a new parameter, change this function too
-    memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+4*sizeof(int)), sizeof(bool));
-    //currentState->diffed = (bool)*(data+4*sizeof(int));
-//     std::cout << "diffed: " << currentState->diffed << std::endl;
+    memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+5*sizeof(int)), sizeof(bool));
+    memcpy( (void*)&(currentState->complete), (const void*)(packet->data+5*sizeof(int)+sizeof(bool)), sizeof(bool));
     //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
     if(currentState->compsize==0)
-      COUT(2) << "compsize is 0" << std::endl;
-    currentState->data = (unsigned char*)(malloc( currentState->compsize ));
+      COUT(2) << "PacketDecoder: compsize is 0" << std::endl;
+//     currentState->data = (unsigned char*)(malloc( currentState->compsize ));
+    currentState->data = new unsigned char[currentState->compsize];
     if(currentState->data==NULL)
-      COUT(2) << "Gamestatepacket-decoder: memory leak" << std::endl;
+      COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl;
     //copy the GameStateCompressed data
-    //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
-    //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
-    memcpy( (void*)(currentState->data), (const void*)(packet->data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
-
-    //clean memory
-    enet_packet_destroy( packet );
-    processGamestate(currentState);
+    memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + 2*sizeof(bool)), currentState->compsize );
+
+    //clean memory
+    enet_packet_destroy( packet );
+    processGamestate(currentState, clientID);
   }
 
@@ -196,11 +198,30 @@
     cid->id = ((classid *)(packet->data))->id;
     cid->clid = ((classid *)(packet->data))->clid;
-    cid->message = (const char *)malloc(cid->length);
+//     cid->message = (const char *)malloc(cid->length);
+    cid->message = new char[cid->length];
     void *data  = (void *)cid->message;
     memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
-    COUT(4) << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
+    COUT(4) << "PacketDecoder: classid: " << cid->clid << ", name: " << cid->message << std::endl;
     enet_packet_destroy( packet );
     processClassid(cid);
   }
+  
+  
+  bool PacketDecoder::decodeWelcome( ENetPacket* packet, int clientID ){
+    welcome *w = new welcome;
+    w->allowed = ((welcome *)(packet->data))->allowed;
+    w->shipID = ((welcome *)(packet->data))->shipID;
+    w->clientID = ((welcome *)(packet->data))->clientID;
+    w->id = ((welcome *)(packet->data))->id;
+    enet_packet_destroy( packet );
+    return processWelcome(w);
+  }
+  
+  bool PacketDecoder::decodeConnectRequest( ENetPacket *packet, int clientID ){
+    connectRequest *con = new connectRequest;
+    con->id = ((connectRequest *)(packet->data))->id;
+    enet_packet_destroy( packet );
+    return processConnectRequest(con, clientID );
+  }
 
 
@@ -210,8 +231,14 @@
   {
     printChat(data, clientId);
-  }
-
-  void PacketDecoder::processGamestate( GameStateCompressed *state )
-  {
+    delete[] data->message;
+    delete data;
+  }
+
+  void PacketDecoder::processGamestate( GameStateCompressed *state, int clientID )
+  {
+    COUT(3) << "PacketDecoder-process: processing Gamestate" << std::endl;
+    //printGamestate( state );
+//     delete[] state->data;
+//     delete state;
   }
 
@@ -219,4 +246,5 @@
   {
     printClassid(cid);
+    delete cid;
     return;
   }
@@ -225,7 +253,18 @@
   {
     printAck(data);
+    delete data;
     return;
   }
-
+  
+  bool PacketDecoder::processWelcome( welcome *w ){
+    delete w;
+    return true;
+  }
+  
+  bool PacketDecoder::processConnectRequest( connectRequest *con, int clientID ){
+    COUT(3) << "packetdecoder: processing connectRequest" << std::endl;
+    delete con;
+    return true;
+  }
 
   //these are some print functions for test stuff
Index: code/trunk/src/network/PacketGenerator.cc
===================================================================
--- code/trunk/src/network/PacketGenerator.cc	(revision 1292)
+++ code/trunk/src/network/PacketGenerator.cc	(revision 1293)
@@ -52,5 +52,5 @@
   ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
   {
-    COUT(4) << "generating new acknowledgement, id: " << state << std::endl;
+    COUT(4) << "PacketGenerator: generating new acknowledgement, id: " << state << std::endl;
     ack* ackreq = new ack;
     ackreq->id = ACK;
@@ -58,5 +58,19 @@
 
     ENetPacket *packet = enet_packet_create( ackreq , sizeof( *ackreq ), reliable );
-
+    delete ackreq;
+    return packet;
+  }
+  
+  ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE )
+  {
+    void *stream = new char[dataLength + 2*sizeof(int)];
+    if(!stream)
+      return NULL;
+    packet_id a = COMMAND;
+    memcpy(stream, (void*)&a, sizeof(int));
+    memcpy((unsigned char *)stream+sizeof(int), (void*)&dataLength, sizeof(int));
+    memcpy((unsigned char *)stream+2*sizeof(int), data, dataLength);
+    ENetPacket *packet = enet_packet_create(stream, dataLength+2*sizeof(int), reliable);
+    delete[] stream; // TODO: we could also tell enet not to copy the data, but to use the exisiting memory
     return packet;
   }
@@ -65,5 +79,5 @@
   ENetPacket* PacketGenerator::mousem( double x, double y, int reliable )
   {
-    COUT(4) << "generating new mouse" << std::endl;
+    COUT(4) << "PacketGenerator: generating new mouse" << std::endl;
     mouse* mousemove = new mouse;
     mousemove->id = MOUSE;
@@ -72,5 +86,5 @@
 
     ENetPacket *packet = enet_packet_create( mousemove , sizeof( *mousemove ), reliable );
-
+    delete mousemove;
     return packet;
   }
@@ -79,5 +93,5 @@
   ENetPacket* PacketGenerator::keystrike( char press, int reliable )
   {
-    COUT(4) << "generating new keyboard" << std::endl;
+    COUT(4) << "PacketGenerator: generating new keyboard" << std::endl;
     keyboard* key = new keyboard;
     key->id = KEYBOARD;
@@ -85,5 +99,5 @@
 
     ENetPacket *packet = enet_packet_create( key , sizeof( *key ), reliable );
-
+    delete key;
     return packet;
   }
@@ -97,5 +111,5 @@
     memcpy( &trans[1], (const void*)message, strlen( message ) + 1);
     ENetPacket *packet = enet_packet_create( trans , sizeof( int ) + strlen( message ) + 1, reliable );
-
+    delete[] trans;
     return packet;
   }
@@ -108,25 +122,21 @@
     //std::cout << "states->compsize " << states->compsize << std::endl;
     int gid = GAMESTATE; //first assign the correct enet id
-    int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
+    int totalLen = 5*sizeof( int ) + 2*sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
     //std::cout << "totalLen " << totalLen << std::endl;
-    unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
+    //unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
+    unsigned char *data = new unsigned char[totalLen];
     memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
     memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
     memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int));
     memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
-    memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
-    /*(int)*(data) = gid;
-    (int)*(data+sizeof(int)) = states->id;
-    //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
-    (int)*(data+2*sizeof(int)) = states->compsize;
-    //this is the uncompressed size of GameStateCompressed data
-    (int)*(data+3*sizeof(int)) = states->normsize;
-    //since there is a new parameter inside GameStateCompressed, change this function to create packet
-    (bool)*(data+4*sizeof(int)) = states->diffed;*/
+    memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->base_id), sizeof(int));
+    memcpy( (void*)(data+5*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
     //place the GameStateCompressed data at the end of the enet datastream
-    memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
+    memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)&(states->complete), sizeof(bool) );
+    memcpy( (void*)(data+5*sizeof( int ) + 2*sizeof(bool)), (const void*)states->data, states->compsize );
     //create an enet packet with the generated bytestream
+    COUT(4) << "PacketGenerator generating totalLen " << totalLen << std::endl;
     ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
-    //delete data;
+    delete[] data;
     return packet;
   }
@@ -134,6 +144,7 @@
   ENetPacket* PacketGenerator::clid( int classid, std::string classname, int reliable )
   {
-    unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
-    std::cout << "classid: " << classid << ", name: " << classname << std::endl;
+    //unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
+    unsigned char *data = new unsigned char[3*sizeof(int)+classname.length()+1];
+    std::cout << "PacketGenerator: classid: " << classid << ", name: " << classname << std::endl;
     *(int *)data = CLASSID;
     *((int *)data+1) = classname.length()+1;
@@ -141,4 +152,24 @@
     memcpy( (void *)(data+3*sizeof(int)), classname.c_str(), classname.length()+1);
     ENetPacket *packet = enet_packet_create( data , 3*sizeof(int)+classname.length()+1, reliable );
+    delete[] data;
+    return packet;
+  }
+  
+  ENetPacket* PacketGenerator::generateWelcome( int clientID,int shipID, bool allowed , int reliable ){
+    welcome *wc = new welcome;
+    wc->id = WELCOME;
+    wc->clientID = clientID;
+    wc->shipID = shipID;
+    wc->allowed = true;
+    ENetPacket *packet = enet_packet_create( wc, sizeof(welcome), reliable);
+    delete wc;
+    return packet;
+  }
+  
+  ENetPacket* PacketGenerator::generateConnectRequest( int reliable ){
+    connectRequest *con = new connectRequest;
+    con->id=CONNECT;
+    ENetPacket *packet = enet_packet_create( con, sizeof(connectRequest), reliable);
+    delete con;
     return packet;
   }
Index: code/trunk/src/network/PacketManager.h
===================================================================
--- code/trunk/src/network/PacketManager.h	(revision 1292)
+++ code/trunk/src/network/PacketManager.h	(revision 1293)
@@ -54,4 +54,5 @@
     //call one of this functions out of an instance of PacketGenerator to create a packet
     ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE );
     ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
     ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
@@ -59,4 +60,6 @@
     ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
     ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* generateWelcome( int clientID,int shipID, bool allowed, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* generateConnectRequest( int reliable = ENET_PACKET_FLAG_RELIABLE );
   private:
   };
@@ -85,15 +88,20 @@
 
     void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    bool command( ENetPacket* packet, int clientId );
     void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
     void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
-    void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT);
-    void gstate( ENetPacket* packet );
+    void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    void gstate( ENetPacket* packet, int clientID = CLIENTID_CLIENT );
     void clid( ENetPacket *packet);
+    bool decodeWelcome( ENetPacket* packet, int clientID = CLIENTID_CLIENT );
+    bool decodeConnectRequest( ENetPacket *packet, int clientID = CLIENTID_CLIENT );
 
     //process data
     //two functions are note yet implemented!
-    virtual void processGamestate(GameStateCompressed *state);
+    virtual void processGamestate(GameStateCompressed *state, int clientID);
     virtual void processAck( ack *data, int clientID);
     virtual void processClassid( classid *cid);
+    virtual bool processWelcome( welcome *w );
+    virtual bool processConnectRequest( connectRequest *con, int clientID );
     //virtual void processAck( ack *data);
 
Index: code/trunk/src/network/PacketTypes.h
===================================================================
--- code/trunk/src/network/PacketTypes.h	(revision 1292)
+++ code/trunk/src/network/PacketTypes.h	(revision 1293)
@@ -49,8 +49,11 @@
     ACK,
     MOUSE,
+    COMMAND,
     KEYBOARD,
     CHAT,
     GAMESTATE ,
-    CLASSID
+    CLASSID,
+    WELCOME,
+    CONNECT,
   };
 
@@ -65,5 +68,7 @@
     int size;                       //!< total size of data
     // new ---- change functions
+    int base_id;                    // if gamestate is diffed this is the id of the old gamestate (base)
     bool diffed;
+    bool complete;                  // this determines, wheter all objects are in this gamestate (server) or only few objects (client)
     unsigned char *data;            //!< pointer to data
   };
@@ -80,5 +85,7 @@
     int normsize;                   //!< size of uncompressed data
     // new ----- change functions
+    int base_id;                  // if gamestate is diffed this is the id of the old gamestate (base)
     bool diffed;
+    bool complete;                  // this determines, wheter all objects are in this gamestate (server) or only few objects (client)
     unsigned char *data;            //!< gamestate data
   };
@@ -114,4 +121,14 @@
   };
 
+  struct welcome {
+    int id;
+    int clientID;
+    int shipID;
+    bool allowed;
+  };
+  
+  struct connectRequest{
+    int id;
+  };
 }
 
Index: code/trunk/src/network/Server.cc
===================================================================
--- code/trunk/src/network/Server.cc	(revision 1292)
+++ code/trunk/src/network/Server.cc	(revision 1293)
@@ -53,4 +53,9 @@
 namespace network
 {
+  
+  
+#define MAX_FAILURES 20;
+  
+  
   /**
   * Constructor for default values (bindaddress is set to ENET_HOST_ANY
@@ -124,9 +129,9 @@
   bool Server::sendMSG(const char *msg) {
     ENetPacket *packet = packet_gen.chatMessage(msg);
-    std::cout <<"adding Packets" << std::endl;
+    COUT(4) <<"Server: adding Packets" << std::endl;
     connection->addPacketAll(packet);
     //std::cout <<"added packets" << std::endl;
     if (connection->sendPackets()){
-      std::cout << "Sucessfully" << std::endl;
+      COUT(4) << "Server: Sucessfully" << std::endl;
       return true;
     }
@@ -143,5 +148,5 @@
     updateGamestate();
 
-    sleep(1); // TODO remove
+//     usleep(500000); // TODO remove
     return;
   }
@@ -155,6 +160,9 @@
     while(!connection->queueEmpty()){
       //std::cout << "Client " << clientID << " sent: " << std::endl;
+      //clientID here is a reference to grab clientID from ClientInformation
       packet = connection->getPacket(clientID);
-      elaborate(packet, clientID);
+      //if statement to catch case that packetbuffer is empty
+      if( !elaborate(packet, clientID) ) 
+        COUT(4) << "Server: PacketBuffer empty" << std::endl;
     }
   }
@@ -165,7 +173,9 @@
   void Server::updateGamestate() {
     gamestates->update();
+    COUT(4) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
     //std::cout << "updated gamestate, sending it" << std::endl;
     //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
-      sendGameState();
+    sendGameState();
+    COUT(4) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
     //std::cout << "sent gamestate" << std::endl;
   }
@@ -175,42 +185,80 @@
   */
   bool Server::sendGameState() {
-    COUT(5) << "starting sendGameState" << std::endl;
+    COUT(5) << "Server: starting function sendGameState" << std::endl;
     ClientInformation *temp = clients;
     bool added=false;
-    while(temp!=NULL){
+    while(temp != NULL){
       if(temp->head){
         temp=temp->next();
+        //think this works without continue
         continue;
       }
       if( !(temp->getSynched()) ){
-        COUT(5) << "not sending gamestate" << std::endl;
+        COUT(5) << "Server: not sending gamestate" << std::endl;
         temp=temp->next();
+        //think this works without continue
         continue;
       }
-      COUT(5) << "doing gamestate gamestate preparation" << std::endl;
-      int gid = temp->getGamestateID();
-      int cid = temp->getID();
-      COUT(5) << "server, got acked (gamestate) ID: " << gid << std::endl;
+      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
+      int gid = temp->getGamestateID(); //get gamestate id
+      int cid = temp->getID(); //get client id
+      COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
       GameStateCompressed *gs = gamestates->popGameState(cid);
       if(gs==NULL){
-        COUT(2) << "could not generate gamestate" << std::endl;
+        COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
         return false;
       }
       //std::cout << "adding gamestate" << std::endl;
-      connection->addPacket(packet_gen.gstate(gs), cid);
+      if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ){
+        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->failures_ << std::endl; 
+        temp->failures_++;
+        if(temp->failures_ > 20 )
+          disconnectClient(temp);
       //std::cout << "added gamestate" << std::endl;
+      }
       added=true;
       temp=temp->next();
-    }
-    if(added)
+      // now delete gamestate
+      delete[] gs->data;
+      delete gs;
+    }
+    if(added) {
+      //std::cout << "send gamestates from server.cc in sendGameState" << std::endl;
       return connection->sendPackets();
-    COUT(5) << "had no gamestates to send" << std::endl;
+    }
+    COUT(5) << "Server: had no gamestates to send" << std::endl;
     return false;
   }
 
   void Server::processAck( ack *data, int clientID) {
-    COUT(5) << "processing ack from client: " << clientID << "; ack-id: " << data->id << std::endl;
-    clients->findClient(clientID)->setGamestateID(data->a);
-  }
-
+    COUT(4) << "\b\b\b\n\n\n\n\nServer: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
+    gamestates->ackGameState(clientID, data->a);
+    delete data;
+  }
+  
+  bool Server::processConnectRequest( connectRequest *con, int clientID ){
+    COUT(4) << "processing connectRequest " << std::endl;
+    //connection->addPacket(packet_gen.gstate(gamestates->popGameState(clientID)) , clientID);
+    connection->createClient(clientID);
+    delete con;
+    return true;
+  }
+  
+  void Server::processGamestate( GameStateCompressed *data, int clientID){
+    COUT(4) << "processing partial gamestate from client " << clientID << std::endl;
+    if(!gamestates->pushGameState(data, clientID))
+        COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
+    else
+        clients->findClient(clientID)->failures_=0;
+  }
+
+  void Server::disconnectClient(int clientID){
+    ClientInformation *client = clients->findClient(clientID);
+    disconnectClient(client);
+  }
+  void Server::disconnectClient( ClientInformation *client){
+    connection->disconnectClient(client);
+    gamestates->removeClient(client);
+  }
+  
 }
Index: code/trunk/src/network/Server.h
===================================================================
--- code/trunk/src/network/Server.h	(revision 1292)
+++ code/trunk/src/network/Server.h	(revision 1293)
@@ -71,6 +71,10 @@
     void updateGamestate();
   private:
+    void disconnectClient(int clientID);
+    void disconnectClient( ClientInformation *client);
     bool sendGameState();
     void processAck( ack *data, int clientID);
+    bool processConnectRequest( connectRequest *con, int clientID );
+    void processGamestate( GameStateCompressed *data, int clientID);
     ConnectionManager *connection;
     GameStateManager *gamestates;
Index: code/trunk/src/network/Synchronisable.cc
===================================================================
--- code/trunk/src/network/Synchronisable.cc	(revision 1292)
+++ code/trunk/src/network/Synchronisable.cc	(revision 1293)
@@ -48,4 +48,8 @@
 namespace network
 {
+  
+  
+  int Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+  
   /**
   * Constructor:
@@ -57,8 +61,16 @@
     datasize=0;
     objectID=idCounter++;
+    syncList = new std::list<synchronisableVariable *>;
     //registerAllVariables();
   }
 
   Synchronisable::~Synchronisable(){
+  }
+  
+  void Synchronisable::setClient(bool b){
+    if(b) // client
+      state_=0x2;
+    else  // server
+      state_=0x1;
   }
 
@@ -69,11 +81,17 @@
   * @param size size of the datatype the variable consists of
   */
-  void Synchronisable::registerVar(const void *var, int size, variableType t){
+  void Synchronisable::registerVar(void *var, int size, variableType t, int mode){
     // create temporary synch.Var struct
-    synchronisableVariable temp={size, var, t};
+    synchronisableVariable *temp = new synchronisableVariable;
+    temp->size = size;
+    temp->var = var;
+    temp->mode = mode; 
+    temp->type = t;
+    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl; 
     // increase datasize
     datasize+=sizeof(int)+size;
-    // push temp to syncList (at the bottom)
-    syncList.push_back(temp);
+    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
+    COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;
+    syncList->push_back(temp);
   }
 
@@ -91,5 +109,5 @@
   //   int totalsize=0;
   //   //figure out size of data to be allocated
-  //   for(i=syncList.begin(); i!=syncList.end(); i++){
+  //   for(i=syncList->begin(); i!=syncList->end(); i++){
   //     // increase size (size of variable and size of size of variable ;)
   //     if(i->type == STRING)
@@ -107,5 +125,5 @@
   //   //CHANGED: REMOVED DECLARATION int n=0 FROM LOOP
   //   int n=0;
-  //   for(i=syncList.begin(); n<totalsize && i!=syncList.end(); i++){
+  //   for(i=syncList->begin(); n<totalsize && i!=syncList->end(); i++){
   //     std::memcpy(retVal.data+n, (const void*)(i->size), sizeof(int));
   //     n+=sizeof(int);
@@ -134,25 +152,33 @@
   */
   syncData Synchronisable::getData(unsigned char *mem){
-    std::list<synchronisableVariable>::iterator i;
+    //std::cout << "inside getData" << std::endl;
+    classID=this->getIdentifier()->getNetworkID();
+    std::list<synchronisableVariable *>::iterator i;
     syncData retVal;
     retVal.objectID=this->objectID;
     retVal.classID=this->classID;
     retVal.length=getSize();
+    COUT(5) << "Synchronisable getting data from objectID: " << retVal.objectID << " classID: " << retVal.classID << " length: " << retVal.length << std::endl;
     retVal.data=mem;
     // copy to location
-    int n=0;
-    for(i=syncList.begin(); n<datasize && i!=syncList.end(); ++i){
-      //COUT(2) << "size of variable: " << i->size << std::endl;
+    int n=0; //offset
+    for(i=syncList->begin(); n<datasize && i!=syncList->end(); ++i){
       //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
-      memcpy( (void *)(retVal.data+n), (const void*)&(i->size), sizeof(int) );
-      n+=sizeof(int);
-      switch(i->type){
+      if( ((*i)->mode & state_) == 0 ){
+        COUT(5) << "not getting data: " << std::endl;
+        continue;  // this variable should only be received
+      }
+      switch((*i)->type){
       case DATA:
-        std::memcpy( (void *)(retVal.data+n), (const void*)(i->var), i->size);
-        n+=i->size;
+        std::memcpy( (void *)(retVal.data+n), (void*)((*i)->var), (*i)->size);
+        n+=(*i)->size;
         break;
       case STRING:
-        std::memcpy( retVal.data+n, (const void*)( ( (std::string *) i->var)->c_str()), ( (std::string *)i->var )->length()+1);
-        n+=((std::string *) i->var)->length()+1;
+        memcpy( (void *)(retVal.data+n), (void *)&((*i)->size), sizeof(int) );
+        n+=sizeof(int);
+        const char *data = ( ( *(std::string *) (*i)->var).c_str());
+        std::memcpy( retVal.data+n, (void*)data, (*i)->size);
+        COUT(5) << "synchronisable: char: " << (const char *)(retVal.data+n) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
+        n+=(*i)->size;
         break;
       }
@@ -168,22 +194,30 @@
   bool Synchronisable::updateData(syncData vars){
     unsigned char *data=vars.data;
-    std::list<synchronisableVariable>::iterator i;
-    for(i=syncList.begin(); i!=syncList.end(); i++){
-      if((int)*data==i->size || i->type==STRING){
-        switch(i->type){
+    std::list<synchronisableVariable *>::iterator i;
+    if(syncList->empty()){
+      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
+      return false;
+    }
+    COUT(5) << "Synchronisable: objectID " << vars.objectID << ", classID " << vars.classID << " size: " << vars.length << " synchronising data" << std::endl;
+    for(i=syncList->begin(); i!=syncList->end(); i++){
+      if( ((*i)->mode ^ state_) == 0 ){
+        COUT(5) << "synchronisable: not updating variable " << std::endl;
+        continue;  // this variable should only be updated
+      }
+      COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
+      switch((*i)->type){
       case DATA:
+        memcpy((void*)(*i)->var, data, (*i)->size);
+        data+=(*i)->size;
+        break;
+      case STRING:
+        (*i)->size = *(int *)data;
+        COUT(5) << "string size: " << (*i)->size << std::endl;
         data+=sizeof(int);
-        memcpy((void*)i->var, data, i->size);
-        data+=i->size;
-        break;
-      case STRING:
-        i->size = (int)*data;
-        data+=sizeof(int);
-        *((std::string *)i->var) = std::string((const char*)data);
-        data += i->size;
-        break;
-        }
-      } else
-        return false; //there was some problem with registerVar
+        *((std::string *)((*i)->var)) = std::string((const char*)data);
+        COUT(5) << "synchronisable: char: " << (const char*)data << " string: " << std::string((const char*)data) << std::endl;
+        data += (*i)->size;
+        break;
+      }
     }
     return true;
@@ -196,19 +230,30 @@
   int Synchronisable::getSize(){
     int tsize=0;
-    std::list<synchronisableVariable>::iterator i;
-    for(i=syncList.begin(); i!=syncList.end(); i++){
-      switch(i->type){
-    case DATA:
-      tsize+=sizeof(int);
-      tsize+=i->size;
-      break;
-    case STRING:
-      tsize+=sizeof(int);
-      tsize+=((std::string *)i->var)->length()+1;
-      break;
+    std::list<synchronisableVariable *>::iterator i;
+    for(i=syncList->begin(); i!=syncList->end(); i++){
+      if( ((*i)->mode & state_) == 0 )
+        continue;  // this variable should only be received, so dont add its size to the send-size
+      switch((*i)->type){
+      case DATA:
+        tsize+=(*i)->size;
+        break;
+      case STRING:
+        tsize+=sizeof(int);
+        (*i)->size=((std::string *)(*i)->var)->length()+1;
+        COUT(5) << "String size: " << (*i)->size << std::endl;
+        tsize+=(*i)->size;
+        break;
       }
     }
     return tsize;
   }
-
+  
+  void Synchronisable::setBacksync(bool sync){
+    backsync_=sync;
+  }
+
+  bool Synchronisable::getBacksync(){
+    return backsync_;
+  }
+  
 }
Index: code/trunk/src/network/Synchronisable.h
===================================================================
--- code/trunk/src/network/Synchronisable.h	(revision 1292)
+++ code/trunk/src/network/Synchronisable.h	(revision 1293)
@@ -62,5 +62,6 @@
   typedef struct synchronisableVariable{
     int size;
-    const void *var;
+    int mode; // this determines in which direction the variable gets synchronised
+    void *var;
     variableType type;
   }SYNCVAR;
@@ -69,5 +70,6 @@
   /**
   * This class is the base class of all the Objects in the universe that need to be synchronised over the network
-  * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list.
+   * Every class, t
+  int mode;hat inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list.
   * @author Oliver Scheuss
   */
@@ -75,15 +77,18 @@
   public:
 
-      virtual ~Synchronisable();
+    virtual ~Synchronisable();
     int objectID;
     int classID;
 
-    void registerVar(const void *var, int size, variableType t);
+    void registerVar(void *var, int size, variableType t, int mode=1);
     //  syncData getData();
     syncData getData(unsigned char *mem);
     int getSize();
     bool updateData(syncData vars);
+    void setBacksync(bool sync);
+    bool getBacksync();
     virtual void registerAllVariables()=0;
     virtual bool create()=0;
+    static void setClient(bool b);
   protected:
     Synchronisable();
@@ -91,6 +96,8 @@
     /*  bool removeObject(Iterator<Synchronisable> it);*/
 
-    std::list<SYNCVAR> syncList;
+    std::list<synchronisableVariable *> *syncList;
     int datasize;
+    static int state_; // detemines wheter we are server (default) or client
+    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
   };
 }
Index: code/trunk/src/network/diffTest.cc
===================================================================
--- code/trunk/src/network/diffTest.cc	(revision 1293)
+++ code/trunk/src/network/diffTest.cc	(revision 1293)
@@ -0,0 +1,723 @@
+#include "enet/enet.h"
+#include "Orxonox.h"
+#include "NetworkPrereqs.h"
+#include "PacketTypes.h"
+#include "GameStateManager.h"
+#include "Synchronisable.h"
+#include "GameStateClient.h"
+#include "iostream"
+#include "core/CoreIncludes.h"
+#include "time.h"
+#include "ConnectionManager.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+#include "util/Sleep.h"
+
+using namespace network;
+
+void printData( unsigned char* data, int length ) {
+  for ( int i=0; i<length; i++ )
+    std::cout << (int)data[i] << " ";
+  std::cout << std::endl;
+}
+
+void printGameStateCompressed( GameStateCompressed* gc ) {
+  //std::cout << "=================================================" << std::endl;
+  std::cout << "GameStateCompressed id:\t\t" << gc->id << std::endl;
+  std::cout << "GameStateCompressed normsize:\t" << gc->normsize << std::endl;
+  std::cout << "GameStateCompressed compsize:\t" << gc->compsize << std::endl;
+  std::cout << "GameStateCompressed diffed:\t" << gc->diffed << std::endl;
+  //std::cout << "GameState data:\t" << gc->data << std::endl;
+  std::cout << "GameStateCompressed compressing rate:\t" << 100.0-((100.0/(gc->normsize))*(gc->compsize)) << "%" << std::endl;
+  std::cout << "=================================================" << std::endl;
+  return;
+}
+
+bool compareData( GameState* g1, GameState* g2 ) {
+  if ( g1->id != g2->id ) {
+    std::cout << "\t--> GameStates are not comparable -> not same id" << std::endl;
+    return true;
+  }
+  else if ( g1->size != g2->size ) {
+    std::cout << "\t--> GameStates are not the same size!!" << std::endl;
+    std::cout << g1->size << " != " << g2->size << std::endl;
+  }
+  int length = g1->size;
+  for ( int i=0; i<length; i++ ) {
+    if ( g1->data[i] != g2->data[i] ) {
+      std::cout << "\t--> data of both GameStates are not identical" << std::endl;
+      return false;
+    }
+  }
+  //std::cout << "\t--> GameData are identical (compareData)" << std::endl;
+  return true;
+}
+
+bool compareData2( GameState* g1, GameState* g2 ) {
+  int length = g1->size;
+  for ( int i=0; i<length; i++ ) {
+    if ( g1->data[i] != g2->data[i] ) {
+      return false;
+    }
+  }
+  //std::cout << "\t--> GameData are identical (compareData)" << std::endl;
+  return true;
+}
+
+bool compareGameStates( GameState* g1, GameState* g2 ) {
+  if ( g1->id != g2->id ) {
+    std::cout << "\t==> GameState id's not identical (GameStateCompare)" << std::endl;
+  }
+  if( g1->size != g2->size ) {
+    std::cout << "\t==> GameState sizes are not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  else if ( g1->diffed != g2->diffed ) {
+    std::cout << "\t==> GameState diffed params not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  else if ( !compareData2( g1, g2 ) ) {
+    std::cout << "\t==> GameState data are not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  //std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl;
+  return true;
+}
+
+void printGameState( GameState* gstate ) {
+  //std::cout << "=================================================" << std::endl;
+  std::cout << "GameState id:\t\t" << gstate->id << std::endl;
+  std::cout << "GameState size:\t\t" << gstate->size << std::endl;
+  std::cout << "GameState diffed:\t" << gstate->diffed << std::endl;
+  //std::cout << "GameState data:\t" << gstate->data << std::endl;
+  std::cout << "=================================================" << std::endl;
+  return;
+}
+
+unsigned char* createData( int length, int mode ) {
+  char* data = new char[ length ];
+  if ( mode == 1 ) {
+    for ( int i=0; i<length; i++ )
+      data[i] = (char)(i%255);
+  }
+  else if ( mode == 2 ) {
+    for ( int i=0; i<length; i++ ) {
+      if ( i%98 == 0 ) data[i] = (char)(i%255);
+      else data[i] = (char)0;
+    }
+  }
+  else if ( mode == 3 ) {
+    for ( int i=0; i<length; i++ ){
+      data[i] = (char)(rand()%255);
+    }
+  }
+  else if ( mode == 4 ) {
+    for ( int i=0; i<length; i++ ){
+      data[i] = (char)(rand()%127);
+    }
+  }
+
+  //printData( data, length );  
+
+  unsigned char* dat = (unsigned char*)data;
+  return dat;
+}
+
+GameState* changeGameStateABit( GameState* a, int mode ) {
+  int length = a->size;
+  GameState* b = new GameState;
+  b->id = a->id;
+  b->diffed = a->diffed;
+
+  if ( mode == 1 ) {
+    b->data = new unsigned char[length];
+    b->size = a->size;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+  else if ( mode == 2 ) {
+    b->data = new unsigned char[length];
+    b->size = length;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%(rand()%((length)/11)+rand()) == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+  else if ( mode == 3 ) {
+    int s = length + (rand()%(length));
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+    for( int i=length; i<s; i++ ) {
+      b->data[i] = (char)rand()%255;
+    }
+  }
+  else if ( mode == 4 ) {
+    int s = length + (rand()%(length));
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%(rand()%(length)+rand()) == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+    for( int i=length; i<s; i++ ) {
+      b->data[i] = rand()%255;
+    }
+  }
+    else if ( mode == 5 ) {
+    int s = (length)/2;
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<s; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+
+  return b;
+}
+
+void testCompression( int size, int mode ) {
+  std::cout << "testing compression with: size = " << size << " ,mode = " << mode << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameState* g_new = new GameState;
+  GameState* g_old = new GameState;
+  GameStateCompressed* gc = new GameStateCompressed;
+  
+  g_old->data = createData( size, mode );
+  g_old->size = size;
+  g_old->id = 0;
+  g_old->diffed = false;
+  printGameState( g_old );
+  
+  gc = g_manager->testCompress( g_old );
+  printGameStateCompressed( gc );
+
+  g_new = g_client->testDecompress( gc );
+  printGameState( g_new );
+
+  compareGameStates( g_new, g_old );
+
+  return;
+}
+
+void testDifferentiation( int size, int modeCreateData, int modeChangeData ) {
+  std::cout << "testing diff with: size = " << size << " modeCreateData = " 
+            << modeCreateData << " modeChangeData = " << modeChangeData << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;
+  
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_result;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  printGameState( g_undiff1 );
+
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  printGameState( g_undiff2 );
+
+  if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " BUT THAT'S HOW IT HAS TO BE" << std::endl;
+
+  //printData( g_undiff1->data, g_undiff1->size );
+  //printData( g_undiff2->data, g_undiff2->size );
+  
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  printGameState( g_diffed );
+  //printData( g_diffed->data, g_diffed->size );
+  
+  g_result = g_client->testUndiff( g_undiff1, g_diffed );
+  compareGameStates( g_result, g_undiff2 );
+
+  return;
+}
+
+void testCompressWithDiff( int size, int modeCreateData, int modeChangeData ) {
+  std::cout << "testing CompressWithDiff with: size = " << size << " modeCreateData = " 
+            << modeCreateData << " modeChangeData = " << modeChangeData << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameStateCompressed* gc = new GameStateCompressed;
+  GameStateCompressed* g_compressedNoDiff;
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_resultDiffed;
+  GameState* g_resultUndiffed;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  
+  std::cout << "---First generated Gamestate" << std::endl;
+  printGameState( g_undiff1 );
+
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  std::cout << "---First gererated Gamestate with some changes ev. longer" << std::endl;
+  printGameState( g_undiff2 );  
+
+  if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " DATA not identical.. ok" << std::endl;
+
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  std::cout << "---Diffed Gamestate not compressed" << std::endl;
+  printGameState( g_diffed );
+
+  gc = g_manager->testCompress( g_diffed );
+  std::cout << "---Diffed Gamestate compressed" << std::endl;
+  printGameStateCompressed( gc );
+
+  g_compressedNoDiff = g_manager->testCompress( g_undiff2 );
+  std::cout << "---Same not Diffed Gamestate compressen" << std::endl;
+  printGameStateCompressed( g_compressedNoDiff ); 
+
+  g_resultDiffed = g_client->testDecompress( gc );
+  std::cout << "---Diffed Gamestate of above uncompressed" << std::endl;
+  printGameState( g_resultDiffed );
+
+  std::cout << "---Diffed Gamestates before compressed and after uncompress comparsion" << std::endl;
+  if ( compareGameStates( g_resultDiffed, g_diffed ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl;
+ 
+  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
+  std::cout << "---New Gamestate of pseudo Server compared with new gamestate that Client gets" << std::endl;
+  if ( compareGameStates( g_resultUndiffed, g_undiff2 ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl;
+
+  return;  
+}
+
+bool testNCompressWithDiff( int n, int size, int modeCreateData, int modeChangeData ) { 
+
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameStateCompressed* gc = new GameStateCompressed;
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_resultDiffed;
+  GameState* g_resultUndiffed;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  //l = -1;
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+
+  while( compareData2( g_undiff1, g_undiff2 ) ) {
+    delete g_undiff2->data;
+    g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  } 
+  //l = -2;
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  gc = g_manager->testCompress( g_diffed );
+  g_resultDiffed = g_client->testDecompress( gc );
+
+  if ( !compareGameStates( g_resultDiffed, g_diffed ) ) return false;
+  //l = -3;
+  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
+  if ( !compareGameStates( g_resultUndiffed, g_undiff2 ) ) return false;
+  //l = 1;
+  /*if ( gc != NULL && gc->data != NULL )
+    delete gc->data;
+  //l = 2;
+  //if ( gc != NULL ) 
+    //delete gc;
+  //l = 3;
+  if ( g_undiff1 != NULL && g_undiff1->data != NULL )
+    delete g_undiff1->data;
+  //l = 4; 
+  //if ( g_undiff1 != NULL )
+   //delete g_undiff1;
+  //l = 5;
+  if ( g_undiff2 != NULL && g_undiff2->data )
+    delete g_undiff2->data;
+  //l = 6; 
+  //if ( g_undiff2 != NULL )
+    //delete g_undiff2;
+  //l = 7;
+  if ( g_diffed != NULL && g_diffed->data )
+    //delete g_diffed->data;
+  //l = 8; 
+  //if ( g_diffed )
+    //delete g_diffed;
+  //l = 9;
+  if ( g_resultDiffed != NULL && g_resultDiffed->data )
+    delete g_resultDiffed->data;
+  //l = 10; 
+  //if ( g_resultDiffed )
+    //delete g_resultDiffed;
+  //l = 11;*/
+  
+  return true;
+}
+
+bool testNCompression( int n, int size, int mode ) { 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameState* g_new = new GameState;
+  GameState* g_old = new GameState;
+  GameStateCompressed* gc = new GameStateCompressed;
+  
+  g_old->data = createData( size, mode );
+  g_old->size = size;
+  g_old->id = 0;
+  g_old->diffed = false;
+  
+  gc = g_manager->testCompress( g_old );
+
+  g_new = g_client->testDecompress( gc );
+
+  if ( !compareGameStates( g_new, g_old ) ) return false;
+  
+  
+  if ( g_new != NULL && g_new->data != NULL )
+    delete g_new->data;
+
+  if ( g_old != NULL && g_old->data != NULL )
+    delete g_old->data;
+
+  if ( gc != NULL && gc->data )
+    delete gc->data;
+
+  return true;
+}
+
+void printClientObjectMapping( ConnectionManager* cmanager, int clients ) {
+  std::map<int, int>::iterator iter;
+  std::map<int, int> clientsmap = cmanager->testGetClientsShip();   
+  for( iter = clientsmap.begin(); iter != clientsmap.end(); iter++ ) {
+    std::cout << "clientID: " << iter->first << "\t-> objectID: " << iter->second << std::endl;
+  }
+  return;
+}
+
+bool is( int a[], int b, int size ) {
+  for ( int i=0; i<size; i++ ) {
+    if ( a[i] == b ) return true;
+  }
+  return false;
+}
+
+void testClientObjectMapping( int clients ) {
+  ConnectionManager* cmanager = new ConnectionManager();
+  int shift = 2;
+  std::cout << "create a map length [clients]" << std::endl;
+  for ( int i=0; i<clients; i++ ) {
+    cmanager->testAddClientsShipID( i, i+shift );
+  }
+  printClientObjectMapping( cmanager, clients );
+  
+  std::cout << "get random client's ship id" << std::endl;
+  int id;
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = rand()%clients;
+    std::cout << "client: " << id << "\t-> ship: " << cmanager->testGetClientsShipID( id ) << std::endl;  
+  }
+
+  std::cout <<"get random ship's client id" << std::endl;
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = (rand()%clients)+shift;
+    std::cout << "ship:   " << id << "\t-> client: " << cmanager->testGetObjectsClientID( id ) << std::endl;  
+  }
+
+  std::cout << "delete random client from map" << std::endl;
+  int deleted[clients/3];
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = rand()%clients;
+    if ( !is( deleted, id, clients/3 ) ) {
+      std::cout << "delete client " << id << std::endl;
+      cmanager->testDeleteClientsIDReg( id ); 
+    }
+    deleted[i] = id;
+  }
+  std::cout << "resulting list:" << std::endl;
+  printClientObjectMapping( cmanager, clients-(clients/3));
+  
+  std::cout << "delete random object from map" << std::endl;
+  int jap = 0;
+  while( jap < 3 ) {
+    id = (rand()%clients) + shift;
+    if ( !is( deleted, id, clients/3 ) ) {
+      std::cout << "delete object: " << id << std::endl;
+      cmanager->testDeleteObjectIDReg( id );
+      jap++;
+    }
+  }
+  std::cout << "resulting list:" << std::endl;
+  printClientObjectMapping( cmanager, clients-(clients/3)-3);
+}
+
+bool addClientTest( ENetEvent* event, ClientInformation*& head ) {
+  ClientInformation *temp = head->insertBack(new ClientInformation);
+  if(temp->prev()->head) {
+    temp->prev()->setID(0);
+    temp->setID(1);
+  }
+  else
+    temp->setID(temp->prev()->getID()+1);
+  temp->setPeer(event->peer);
+  std::cout << "added client id: " << temp->getID() << std::endl;
+
+  temp->setSynched(true);
+  return true;
+}
+
+void printClientInformationBox( ClientInformation* box ) {
+  std::cout << "ClientList: id: " << box->getID() << "\t";
+  std::cout << "g_id: " << box->getGamestateID() << " \t";
+  std::cout << "synched: " << box->getSynched() << "\t";
+  std::cout << "is head: " << box->head << std::endl;
+}
+
+void printClientInformationList( ClientInformation* list ) {
+  printClientInformationBox( list );
+  list = list->next();
+  
+  while( list != 0 ) {
+    printClientInformationBox( list );
+    list = list->next();
+  }
+  return;
+}
+
+void testClientInformation( int numberOfClients ) {
+  ClientInformation* head = new ClientInformation( true );
+  ConnectionManager* connectionManager;
+  ENetEvent event;
+  
+  for ( int i=0; i<numberOfClients; i++ ) {
+    if ( !addClientTest( &event, head ) ) {
+      std::cout << "addClientTest didn't work with: " << i << std::endl;
+    }
+  }
+  std::cout << "(now id should be synched, since that works and this is test of list, this step is left out)" << std::endl;
+
+  printClientInformationList( head );
+
+  std::cout << "remove some clients" << std::endl;
+  if ( head->removeClient( numberOfClients/3 ) ) std::cout << "client " << numberOfClients/3 << " removed" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients/3 << std::endl;
+  if ( head->removeClient( numberOfClients ) ) std::cout << "client " << numberOfClients << " removed" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients << std::endl;
+  if ( head->removeClient( 1 ) ) std::cout << "client " << 1 << " removed" << std::endl;
+  else std::cout << "could not remove client: " << 1 << std::endl;
+  if ( head->removeClient( 1 ) ) std::cout << "client " << 1 << " removed a second time" << std::endl;
+  else std::cout << "could not remove client: " << 1 << std::endl;
+  if ( head->removeClient( numberOfClients + 100 ) ) std::cout << "client " << numberOfClients + 100 << " removed a second time" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients + 100 << std::endl;
+
+  printClientInformationList( head );
+  
+  std::cout << "try to find some clients with findClient(..., false)" << std::endl;
+  ClientInformation* temp = head->findClient( 2 );
+  printClientInformationBox( temp );
+  temp = head->findClient( numberOfClients/3 );
+  printClientInformationBox( temp );
+  temp = head->findClient( 0 );
+  printClientInformationBox( temp );
+  temp = head->findClient( 8 );
+  printClientInformationBox( temp );
+
+  std::cout << "find the same, output should be identical with above but with findClient(..., TRUE)" << std::endl;
+  temp = head->findClient( 2, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( numberOfClients/3, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( 0, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( 8, true );
+  printClientInformationBox( temp );
+
+  std::cout << "test setGamestateID" << std::endl;
+  temp->setGamestateID( 8 );
+  printClientInformationBox( temp );
+
+  std::cout << "test insertAfter() and insertBefore()" << std::endl;
+  ClientInformation* newInfo = new ClientInformation;
+  ClientInformation* toool = new ClientInformation;
+  newInfo->setGamestateID( 200 );
+  newInfo->setID( numberOfClients+2);
+  newInfo->setSynched( true );
+  newInfo->setPeer( NULL );
+  toool->setGamestateID( 199 );
+  toool->setID( numberOfClients+1);
+  toool->setSynched( true );
+  toool->setPeer( NULL );
+
+  //never use the same ClientInformation box in this situation
+  //-> results in endless loop
+  temp->insertAfter( newInfo );
+  temp->insertBefore( toool );
+
+  printClientInformationList( head );
+  return;
+}
+
+//### following stuff is to test buffer, took from PacketBufferTestExt.cc ###
+
+void write(PacketBuffer *test){
+  ENetEvent event;
+  ENetPacket *packet;
+  if(test->isEmpty())
+    std::cout << "buffer is empty" << std::endl;
+  for(int i=0; i<10; i++){
+    std::string temp = "packet ";
+    packet = enet_packet_create("packet", strlen("packet ")+1,
+      ENET_PACKET_FLAG_RELIABLE);
+    std::cout << i << ": pushing " << packet->data << std::endl;
+    event.packet=packet;
+    test->push(&event);
+    if(i==5)
+      usleep(200000);
+  }
+  test->setClosed(true);
+  return;
+}
+
+void read(PacketBuffer *test){
+  //test->print();
+  // exit if the queue is closed and empty
+  while(!test->isClosed() || !test->isEmpty()){
+    // only pop if the queue isn't empty
+    while(!test->isEmpty()){
+      std::cout << "We popped the value " << test->pop()->data << std::endl;
+    }
+  }
+  return;
+}
+
+void testPacketBuffer() {
+  PacketBuffer test = PacketBuffer();
+  boost::thread thrd1(boost::bind(&write, &test));
+  boost::thread thrd2(boost::bind(&read, &test));
+
+  thrd1.join();
+  thrd2.join();
+  return;
+}
+
+//### end packetbuffer test stuff ###
+
+void testSynchronisable() {
+  Synchronisable* synchtest;
+  unsigned char* data = new unsigned char[100];
+  for( int i=0; i<100; i++ ) {
+    data[i] = i%10;
+  }
+  //synchtest->registerVar( (const void*)data, 100, network::DATA );
+}
+
+//#########################################################################
+//### this stuff is only a loop to chose one of the prev test functions ###
+//#########################################################################
+void displayModes() {
+  std::cout << "mode datalength: length of data array to create" << std::endl;
+  std::cout << "mode Data:" << std::endl;
+  std::cout << "\t-1 -> array[length] with numbers length%255" << std::endl;
+  std::cout << "\t-2 -> array[length] with numbers length%255, every %98 is != 0" << std::endl;
+  std::cout << "\t-3 -> array[length] with random numbers (-126:127) no modulo zeros" << std::endl;
+  std::cout << "\t-4 -> array[length] with random numbers (0:127) no modulo zeros" << std::endl;
+  std::cout << "---------------------------------------------------------------------------------" << std::endl;
+  std::cout << "mode Change:" << std::endl;
+  std::cout << "\t-1 -> every %10 == 0 index is different from original" << std::endl;
+  std::cout << "\t-2 -> every %(rand()%(length/11)) is different from original" << std::endl;
+  std::cout << "\t-3 -> every %10 == 0 index is different and randomly longer till 2xlonger" << std::endl;
+  std::cout << "\t-4 -> random differences and randomly longer" << std::endl;
+  std::cout << "\t-5 -> only half as long and ever %10 == 0 index is different" << std::endl;
+}
+
+int main( int argc, char* argv[] ) {
+  int a,b,c,n;
+  std::string dec = "nothing";
+  std::cout << "############### START TEST (quit q) ###############" << std::endl;
+  std::cout << "possible tests: " << std::endl;
+  std::cout << "displayModes:\t\t modes" << std::endl;
+  std::cout << "testCompression:\t tc [datalength] [mode Data]" << std::endl;
+  std::cout << "testNCompression:\t tnc [#of loops] [datalength] [mode Data]" << std::endl;
+  std::cout << "testDifferentiation:\t td [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testCompressWithDiff:\t tcd [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testNCompressWithDiff:\t tncd [#of loops] [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testClientObjectMapping: tcom [#clients]" << std::endl;
+  std::cout << "testClientInformation:\t tci [#clients] (call with >10)" << std::endl;
+  std::cout << "testPacketBuffer:\t tbuf (comment address assignements in PacketBuffer.cc!)" << std::endl;
+  while ( dec.compare("q") != 0 ) {
+    std::cin >> dec;
+    if ( dec.compare("tc") == 0 ) {
+      std::cin >> a; std::cin >> b;
+      testCompression( a, b );
+    }
+    else if ( dec.compare("td") == 0 ) {
+      std::cin>> a; std::cin >> b; std::cin >> c;
+      testDifferentiation( a, b, c );
+    }
+    else if ( dec.compare("tcd") == 0 ) {
+      std::cin>> a; std::cin >> b; std::cin >> c;
+      testCompressWithDiff( a, b, c );
+    }
+    else if ( dec.compare("modes") == 0 )
+      displayModes();
+    else if ( dec.compare("tcom") == 0 ) {
+      std::cin>> a;
+      testClientObjectMapping( a );
+    }
+    else if ( dec.compare("tci") == 0 ) {
+      std::cin >> a;
+      testClientInformation( a );
+    } 
+    else if ( dec.compare("tbuf") == 0 ) {
+      testPacketBuffer();
+    } 
+    else if ( dec.compare("tncd") == 0 ) {
+      std::cin >> n; std::cin >> a; std::cin >> b; std::cin >> c;
+      for ( int i=1; i<=n; i++ ) {  
+        std::cout << i << " s" << a << " ";      
+        //std::cout << "start loop test " << i << std::endl;
+        if ( !testNCompressWithDiff( i, a, b, c ) ) {
+          std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl;
+          break;
+        }
+      }
+      std::cout << "end loop comparsion test" << std::endl;
+    }
+    else if ( dec.compare("tnc") == 0 ) {
+      std::cin >> n; std::cin >> a; std::cin >> b;
+      for ( int i=1; i<=n; i++ ) {  
+        std::cout << i << " s" << a << " ";      
+        //std::cout << "start loop test " << i << std::endl;
+        if ( !testNCompression( i, a, b ) ) {
+          std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl;
+          break;
+        }
+      }
+      std::cout << "end loop comparsion test" << std::endl;
+    }
+    else std::cout << "invalid input" << std::endl;  
+    std::cout << "################## END ONE TURN ##################@" << std::endl;
+  }
+  return 0;
+}
+/*
+int main() {
+  std::cout << "############### START TEST (quit q) ###############" << std::endl;
+  testSynchronisable();
+}*/
+
+//#########################################################################
+//### the prev loop is only to chose one prev prev test functions       ###
+//#########################################################################
Index: code/trunk/src/network/dummyclient4.cc
===================================================================
--- code/trunk/src/network/dummyclient4.cc	(revision 1293)
+++ code/trunk/src/network/dummyclient4.cc	(revision 1293)
@@ -0,0 +1,29 @@
+#include <iostream>
+#include <string>
+#include <enet/enet.h>
+#include <network/PacketManager.h>
+#include <network/PacketTypes.h>
+#include <network/Client.h>
+#include "core/Tickable.h"
+#include "core/BaseObject.h"
+#include "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "objects/SpaceShip.h"
+
+int main() {
+  std::cout << "dummyclient4" << std::endl;
+  network::Client* client;
+  client = network::Client::createSingleton( "127.0.0.1", 55556 );
+  if(client->establishConnection())
+    std::cout << "established connection" << std::endl;
+  else{
+    std::cout << "could not establish connection" << std::endl;
+    return -1;
+  }
+  if(client->closeConnection())
+    std::cout << "closed connection" << std::endl;
+  else
+    std::cout << "could not close connection" << std::endl;
+}
+
+
Index: code/trunk/src/network/dummyserver4.cc
===================================================================
--- code/trunk/src/network/dummyserver4.cc	(revision 1293)
+++ code/trunk/src/network/dummyserver4.cc	(revision 1293)
@@ -0,0 +1,22 @@
+#include <iostream>
+#include <string>
+#include <enet/enet.h>
+#include <network/PacketManager.h>
+#include <network/PacketTypes.h>
+#include <network/Server.h>
+#include "core/Tickable.h"
+#include "core/BaseObject.h"
+#include "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "objects/SpaceShip.h"
+#include "util/Sleep.h"
+
+int main() {
+  network::Server *server = new network::Server();
+  server->open();
+  while(true){
+    usleep( 1000 );
+  }
+  server->close();
+  return 0;
+}
Index: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	(revision 1292)
+++ code/trunk/src/orxonox/CMakeLists.txt	(revision 1293)
@@ -16,4 +16,5 @@
   objects/Ambient.cc
   objects/Camera.cc
+  objects/CameraHandler.cc
   objects/Explosion.cc
   objects/Model.cc
@@ -42,4 +43,23 @@
 ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
 
+IF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+  SET( ORXONOXS_SRC_FILES
+    GraphicsEngine.cc
+    objects/Ambient.cc
+    objects/Camera.cc
+    objects/CameraHandler.cc
+    objects/Explosion.cc
+    objects/Model.cc
+    objects/NPC.cc
+    objects/Projectile.cc
+    objects/Skybox.cc
+    objects/SpaceShip.cc
+    objects/WorldEntity.cc
+  )
+
+  ADD_LIBRARY(orxonoxs SHARED ${ORXONOX_SRC_FILES})
+ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
+
 TARGET_LINK_LIBRARIES( orxonox
   ${OGRE_LIBRARIES}
Index: code/trunk/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/trunk/src/orxonox/GraphicsEngine.cc	(revision 1292)
+++ code/trunk/src/orxonox/GraphicsEngine.cc	(revision 1293)
@@ -9,6 +9,6 @@
  *   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.
- *
+ *   of the License, or (atl your option) any later version.
+ *lo
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -44,5 +44,5 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/Debug.h"
-#include "core/TclBind.h"
+#include "core/CommandExecutor.h"
 
 
@@ -53,5 +53,5 @@
     @return The only instance of GraphicsEngine.
   */
-  GraphicsEngine& GraphicsEngine::getSingleton()
+  /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
   {
     static GraphicsEngine theOnlyInstance;
@@ -62,15 +62,25 @@
     @brief Only use constructor to initialise variables and pointers!
   */
-  GraphicsEngine::GraphicsEngine()
+  GraphicsEngine::GraphicsEngine() :
+    root_(0),
+    scene_(0),
+    renderWindow_(0),
+    //configPath_(""),
+    dataPath_(""),
+    ogreLogfile_("")
   {
     RegisterObject(GraphicsEngine);
-    //this->bOverwritePath_ = false;
+
     this->setConfigValues();
-    // set to standard values
-    this->configPath_ = "";
-    this->root_ = 0;
-    this->scene_ = 0;
-    this->renderWindow_ = 0;
-    COUT(4) << "*** GraphicsEngine: Constructed" << std::endl;
+    CCOUT(4) << "Constructed" << std::endl;
+  }
+
+  void GraphicsEngine::setConfigValues()
+  {
+    SetConfigValue(dataPath_, "../../Media/").description("relative path to media data");
+    SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
+    SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
+    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
+    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
   }
 
@@ -89,5 +99,5 @@
   void GraphicsEngine::destroy()
   {
-    COUT(4) << "*** GraphicsEngine: Destroying objects..." << std::endl;
+    CCOUT(4) << "Destroying objects..." << std::endl;
     Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
     if (this->root_)
@@ -103,16 +113,5 @@
       delete Ogre::LogManager::getSingletonPtr();
     }
-    COUT(4) << "*** GraphicsEngine: Destroying objects done" << std::endl;
-  }
-
-  void GraphicsEngine::setConfigValues()
-  {
-    SetConfigValue(dataPath_, "../../Media/").description("relative path to media data");
-    SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
-    SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
-    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
-    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
-
-    TclBind::getInstance().setDataPath(this->dataPath_);
+    CCOUT(4) << "Destroying objects done" << std::endl;
   }
 
@@ -120,13 +119,16 @@
     @brief Creates the Ogre Root object and sets up the ogre log.
   */
-  void GraphicsEngine::setup()
-  {
+  bool GraphicsEngine::setup(std::string& dataPath)
+  {
+    CCOUT(3) << "Setting up..." << std::endl;
+    // temporary overwrite of dataPath, change ini file for permanent change
+    if (dataPath != "")
+      dataPath_ = dataPath;
+    if (dataPath_ == "")
+      return false;
+    if (dataPath_[dataPath_.size() - 1] != '/')
+      dataPath_ += "/";
+
     //TODO: Check if file exists (maybe not here)
-/*#ifndef OGRE_STATIC_LIB
-    root_ = new Ogre::Root(configPath_ + "plugins.cfg", configPath_ + "ogre.cfg",
-                     configPath_ + "Ogre.log");
-#else
-    root_ = new Ogre::Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
-#endif*/
 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(_DEBUG)
     std::string plugin_filename = "plugins_d.cfg";
@@ -135,11 +137,9 @@
 #endif
 
-    // create a logManager
-    Ogre::LogManager *logger;
-		if (Ogre::LogManager::getSingletonPtr() == 0)
-			logger = new Ogre::LogManager();
-    else
-      logger = Ogre::LogManager::getSingletonPtr();
-    COUT(4) << "*** GraphicsEngine: Ogre LogManager created/assigned" << std::endl;
+/*    // create a logManager
+    // note: If there's already a logManager, Ogre will complain by a failed assertation.
+    // but that shouldn't happen, since this is the first time to create a logManager..
+    Ogre::LogManager* logger = new Ogre::LogManager();
+    CCOUT(4) << "Ogre LogManager created" << std::endl;
 
     // create our own log that we can listen to
@@ -148,56 +148,30 @@
       myLog = logger->createLog("ogre.log", true, false, true);
     else
-      myLog = logger->createLog(this->ogreLogfile_, true, false, false);
-    COUT(4) << "*** GraphicsEngine: Ogre Log created" << std::endl;
+          myLog = logger->createLog(this->ogreLogfile_, true, false, false);
+    CCOUT(4) << "Ogre Log created" << std::endl;
 
     myLog->setLogDetail(Ogre::LL_BOREME);
-    myLog->addListener(this);
+    myLog->addListener(this);*/
 
     // Root will detect that we've already created a Log
-    COUT(4) << "*** GraphicsEngine: Creating Ogre Root..." << std::endl;
+    CCOUT(4) << "Creating Ogre Root..." << std::endl;
     root_ = new Ogre::Root(plugin_filename);
-    COUT(4) << "*** GraphicsEngine: Creating Ogre Root done" << std::endl;
-  }
-
-  /**
-   * @return scene manager
-   */
-  Ogre::SceneManager* GraphicsEngine::getSceneManager()
-  {
-    if(!scene_)
-    {
-      scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
-      COUT(3) << "Info: Created SceneMan: " << scene_ << std::endl;
-    }
-    return scene_;
-  }
-
-  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())
-      return false;
+    CCOUT(4) << "Creating Ogre Root done" << std::endl;
+
+    // specify where Ogre has to look for resources. This call doesn't parse anything yet!
+    declareRessourceLocations();
+
+    CCOUT(3) << "Set up done." << std::endl;
     return true;
   }
 
-  void GraphicsEngine::initialise()
-  {
-    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
-    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
-    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
-    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
-    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
-  }
-
-  void GraphicsEngine::loadRessourceLocations(std::string dataPath)
-  {
+  void GraphicsEngine::declareRessourceLocations()
+  {
+    CCOUT(4) << "Declaring Resources" << std::endl;
     //TODO: Specify layout of data file and maybe use xml-loader
     //TODO: Work with ressource groups (should be generated by a special loader)
     // Load resource paths from data file using configfile ressource type
     Ogre::ConfigFile cf;
-    cf.load(dataPath + "resources.cfg");
+    cf.load(dataPath_ + "resources.cfg");
 
     // Go through all sections & settings in the file
@@ -216,8 +190,64 @@
 
         Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
-                                           std::string(dataPath + archName),
+                                           std::string(dataPath_ + archName),
                                            typeName, secName);
       }
     }
+  }
+
+  bool GraphicsEngine::loadRenderer()
+  {
+    CCOUT(4) << "Configuring Renderer" << std::endl;
+    if (!root_->restoreConfig() && !root_->showConfigDialog())
+      return false;
+
+    CCOUT(4) << "Creating render window" << std::endl;
+    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
+    if (!root_->isInitialised())
+    {
+      CCOUT(2) << "Error: Creating Ogre root object failed" << std::endl;
+      return false;
+    }
+    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
+    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
+    return true;
+  }
+
+  bool GraphicsEngine::initialiseResources()
+  {
+    CCOUT(4) << "Initialising resources" << std::endl;
+    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
+    try
+    {
+      Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+      /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+      for (unsigned int i = 0; i < str.size(); i++)
+      {
+        Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
+      }*/
+    }
+    catch (Ogre::Exception e)
+    {
+      CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
+      CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * @brief Creates the SceneManager
+   */
+  bool GraphicsEngine::createNewScene()
+  {
+    CCOUT(4) << "Creating new SceneManager" << std::endl;
+    if (scene_)
+    {
+      CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
+      return false;
+    }
+    scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
+    CCOUT(3) << "Created SceneManager: " << scene_ << std::endl;
+    return true;
   }
 
@@ -291,23 +321,47 @@
     }
     OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
-        << "*** Ogre: " << message << std::endl;
-  }
-
-    void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw){
-        int w = rw->getWidth();
-        int h = rw->getHeight();
-        InputManager::setWindowExtents(w, h);
-    }
-
-    void GraphicsEngine::windowResized(Ogre::RenderWindow *rw){
-        int w = rw->getWidth();
-        int h = rw->getHeight();
-        InputManager::setWindowExtents(w, h);
-    }
-
-    void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw){
-        int w = rw->getWidth();
-        int h = rw->getHeight();
-        InputManager::setWindowExtents(w, h);
-    }
+        << "Ogre: " << message << std::endl;
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  */
+  void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
+  {
+    // note: this doesn't change the window extents
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  * @note GraphicsEngine has a render window stored itself. This is the same
+  *       as rw. But we have to be careful when using multiple render windows!
+  */
+  void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
+  {
+    // change the mouse clipping size for absolute mouse movements
+    int w = rw->getWidth();
+    int h = rw->getHeight();
+    InputManager::setWindowExtents(w, h);
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  */
+  void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
+  {
+    // note: this doesn't change the window extents
+  }
+
+  /**
+  * Window has resized.
+  * @param rw The render window it occured in
+  */
+  void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
+  {
+    // using CommandExecutor in order to avoid depending on Orxonox class.
+    CommandExecutor::execute("exit", false);
+  }
 }
Index: code/trunk/src/orxonox/GraphicsEngine.h
===================================================================
--- code/trunk/src/orxonox/GraphicsEngine.h	(revision 1292)
+++ code/trunk/src/orxonox/GraphicsEngine.h	(revision 1293)
@@ -52,16 +52,18 @@
     @brief Graphics engine manager class
     */
-    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public OrxonoxClass, public Ogre::LogListener
+    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
     {
-        friend class ClassIdentifier<GraphicsEngine>;
         public:
-            void setConfigPath(std::string path) { this->configPath_ = path; };
             void setConfigValues();
-            void setup();
-            bool load(std::string path);
-            void loadRessourceLocations(std::string path);
-            Ogre::SceneManager* getSceneManager();
-            void initialise();
+            bool setup(std::string& dataPath);
+            void declareRessourceLocations();
+            bool loadRenderer();
+            bool initialiseResources();
+            bool createNewScene();
+
             void destroy();
+
+            Ogre::SceneManager* getSceneManager() { return scene_; }
+            std::string& getDataPath() { return dataPath_; }
 
             // several window properties
@@ -71,10 +73,11 @@
             int getWindowHeight() const;
 
+            void windowMoved       (Ogre::RenderWindow* rw);
+            void windowResized     (Ogre::RenderWindow* rw);
+            void windowFocusChanged(Ogre::RenderWindow* rw);
+            void windowClosed      (Ogre::RenderWindow* rw);
+
             static GraphicsEngine& getSingleton();
             static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
-
-            void windowMoved(Ogre::RenderWindow* rw);
-            void windowResized(Ogre::RenderWindow* rw);
-            void windowFocusChanged(Ogre::RenderWindow* rw);
 
         private:
@@ -92,5 +95,5 @@
             Ogre::RenderWindow* renderWindow_;//!< the current render window
             //bool               bOverwritePath_; //!< overwrites path
-            std::string         configPath_;  //!< path to config file
+            //std::string         configPath_;  //!< path to config file
             std::string         dataPath_;    //!< path to data file
             std::string         ogreLogfile_; //!< log file name for Ogre log messages
Index: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc	(revision 1292)
+++ code/trunk/src/orxonox/Main.cc	(revision 1293)
@@ -78,11 +78,13 @@
     Orxonox* orx = Orxonox::getSingleton();
 
+    bool res = false;
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
-    orx->init(argc, argv, macBundlePath());
+    res = orx->init(argc, argv, macBundlePath());
 #else
-    orx->init(argc, argv, "");
+    res = orx->init(argc, argv, "");
 #endif
 
-    orx->start();
+    if (res)
+      orx->start();
     orx->destroySingleton();
   /*}
Index: code/trunk/src/orxonox/Orxonox.cc
===================================================================
--- code/trunk/src/orxonox/Orxonox.cc	(revision 1292)
+++ code/trunk/src/orxonox/Orxonox.cc	(revision 1293)
@@ -37,10 +37,7 @@
 
 //****** STD *******
-//#include <iostream>
-//#include <exception>
 #include <deque>
 
 //****** OGRE ******
-//#include <OgreException.h>
 #include <OgreFrameListener.h>
 #include <OgreOverlay.h>
@@ -65,4 +62,5 @@
 #include "core/InputBuffer.h"
 #include "core/InputManager.h"
+#include "core/TclBind.h"
 
 // audio
@@ -158,24 +156,23 @@
 
   /**
-   * create a new instance of Orxonox
-   */
-  Orxonox::Orxonox()
-  {
-    this->mode_ = STANDALONE;
-    this->serverIp_ = "";
-    this->ogre_ = &GraphicsEngine::getSingleton();
-    this->timer_ = 0;
-    this->dataPath_ = "";
-    this->auMan_ = 0;
-    this->orxonoxHUD_ = 0;
-    this->inputHandler_ = 0;
+   * Create a new instance of Orxonox. Avoid doing any actual work here.
+   */
+  Orxonox::Orxonox() :
+    ogre_(0),
+    //auMan_(0),
+    timer_(0),
     // turn on frame smoothing by setting a value different from 0
-    this->frameSmoothingTime_ = 0.0f;
-    this->bAbort_ = false;
-    this->timefactor_ = 1.0f;
-  }
-
-  /**
-   * destruct Orxonox
+    frameSmoothingTime_(0.0f),
+    orxonoxConsole_(0),
+    orxonoxHUD_(0),
+    bAbort_(false),
+    timefactor_(1.0f),
+    mode_(STANDALONE),
+    serverIp_("")
+  {
+  }
+
+  /**
+   * Destruct Orxonox.
    */
   Orxonox::~Orxonox()
@@ -186,25 +183,16 @@
     Loader::close();
     InputManager::destroy();
-    if (this->auMan_)
-      delete this->auMan_;
+    //if (this->auMan_)
+    //  delete this->auMan_;
     if (this->timer_)
       delete this->timer_;
     GraphicsEngine::getSingleton().destroy();
 
-    if (client_g)
-      delete client_g;
+    if (network::Client::getSingleton())
+      network::Client::destroySingleton();
     if (server_g)
       delete server_g;
   }
 
-  /**
-    @brief Immediately deletes the orxonox object.
-    Never use if you can help it while rendering!
-  */
-  void Orxonox::abortImmediateForce()
-  {
-    COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl;
-    delete this;
-  }
 
   /**
@@ -213,10 +201,10 @@
   void Orxonox::abortRequest()
   {
-    COUT(3) << "*** Orxonox: Abort requested." << std::endl;
+    COUT(3) << "Orxonox: Abort requested." << std::endl;
     bAbort_ = true;
   }
 
   /**
-   * @return singleton object
+   * @return singleton reference
    */
   Orxonox* Orxonox::getSingleton()
@@ -243,5 +231,5 @@
    * @param path path to config (in home dir or something)
    */
-  void Orxonox::init(int argc, char **argv, std::string path)
+  bool Orxonox::init(int argc, char **argv, std::string path)
   {
     //TODO: find config file (assuming executable directory)
@@ -249,57 +237,40 @@
     //TODO: give config file to Ogre
     std::string mode;
+    std::string dataPath;
 
     ArgReader ar(argc, argv);
     ar.checkArgument("mode", mode, false);
-    ar.checkArgument("data", this->dataPath_, false);
+    ar.checkArgument("data", dataPath, false);
     ar.checkArgument("ip", serverIp_, false);
-    if(ar.errorHandling()) abortImmediateForce();
-    if(mode == std::string("client"))
+    if(ar.errorHandling())
+      return false;
+
+    if (mode == "client")
+      mode_ = CLIENT;
+    else if (mode == "server")
+      mode_ = SERVER;
+    else
     {
-      mode_ = CLIENT;
-      clientInit(path);
+      mode = "standalone";
+      mode_ = STANDALONE;
     }
-    else if(mode== std::string("server")){
-      mode_ = SERVER;
-      serverInit(path);
-    }
-    else{
-      mode_ = STANDALONE;
-      standaloneInit(path);
-    }
-  }
-
-  void Orxonox::serverInit(std::string path)
-  {
-    COUT(2) << "initialising server" << std::endl;
-
-    ogre_->setConfigPath(path);
-    ogre_->setup();
-    //root_ = ogre_->getRoot();
-    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
-
-    server_g = new network::Server();
-  }
-
-  void Orxonox::clientInit(std::string path)
-  {
-    COUT(2) << "initialising client" << std::endl;\
-
-    ogre_->setConfigPath(path);
-    ogre_->setup();
-    if(serverIp_.compare("")==0)
-      client_g = new network::Client();
-    else
-      client_g = new network::Client(serverIp_, NETWORK_PORT);
-    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
-  }
-
-  void Orxonox::standaloneInit(std::string path)
-  {
-    COUT(2) << "initialising standalone mode" << std::endl;
-
-    ogre_->setConfigPath(path);
-    ogre_->setup();
-    if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
+    COUT(3) << "Orxonox: Mode is " << mode << "." << std::endl;
+
+    //if (mode_ == DEDICATED)
+      // TODO: decide what to do here
+    //else
+
+    // for playable server, client and standalone, the startup
+    // procedure until the GUI is identical
+
+    TclBind::getInstance().setDataPath(dataPath);
+    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
+    Factory::createClassHierarchy();
+
+    ogre_ = &GraphicsEngine::getSingleton();
+    if (!ogre_->setup(path))       // creates ogre root and other essentials
+      return false;
+
+    return true;
   }
 
@@ -307,26 +278,73 @@
    * start modules
    */
-  void Orxonox::start()
-  {
-    switch(mode_){
+  bool Orxonox::start()
+  {
+    //if (mode == DEDICATED)
+    // do something else
+    //else
+
+    if (!ogre_->loadRenderer())    // creates the render window
+      return false;
+
+    // Calls the InputManager which sets up the input devices.
+    // The render window width and height are used to set up the mouse movement.
+    if (!InputManager::initialise(ogre_->getWindowHandle(),
+          ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
+      return false;
+
+    // TODO: Spread this so that this call only initialises things needed for the GUI
+    if (!ogre_->initialiseResources())
+      return false;
+
+    // TOOD: load the GUI here
+    // set InputManager to GUI mode
+    InputManager::setInputState(InputManager::IS_GUI);
+    // TODO: run GUI here
+
+    // The following lines depend very much on the GUI output, so they're probably misplaced here..
+
+    InputManager::setInputState(InputManager::IS_NONE);
+
+    if (!loadPlayground())
+      return false;
+
+    switch (mode_)
+    {
+    case SERVER:
+      if (!serverLoad())
+        return false;
+      break;
     case CLIENT:
-      clientStart();
-      break;
-    case SERVER:
-      serverStart();
+      if (!clientLoad())
+        return false;
       break;
     default:
-      standaloneStart();
+      if (!standaloneLoad())
+        return false;
     }
-  }
-
-  void Orxonox::clientStart(){
-    ogre_->initialise();
-    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
-    Factory::createClassHierarchy();
-
-
-    auMan_ = new audio::AudioManager();
-
+
+    InputManager::setInputState(InputManager::IS_NORMAL);
+
+    return startRenderLoop();
+  }
+
+  /**
+   * Loads everything in the scene except for the actual objects.
+   * This includes HUD, Console..
+   */
+  bool Orxonox::loadPlayground()
+  {
+    ogre_->createNewScene();
+
+	  // Init audio
+    //auMan_ = new audio::AudioManager();
+    //auMan_->ambientAdd("a1");
+    //auMan_->ambientAdd("a2");
+    //auMan_->ambientAdd("a3");
+    //auMan->ambientAdd("ambient1");
+    //auMan_->ambientStart();
+
+    // Load the HUD
+    COUT(3) << "Orxonox: Loading HUD..." << std::endl;
     Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
     orxonoxHUD_ = new HUD();
@@ -335,91 +353,5 @@
     hudOverlay->show();
 
-    client_g->establishConnection();
-    client_g->tick(0);
-
-
-    //setupInputSystem();
-
-    startRenderLoop();
-  }
-
-  void Orxonox::serverStart(){
-    //TODO: start modules
-    ogre_->initialise();
-    //TODO: run engine
-    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
-    Factory::createClassHierarchy();
-    createScene();
-    setupInputSystem();
-
-    server_g->open();
-
-    startRenderLoop();
-  }
-
-  void Orxonox::standaloneStart(){
-    //TODO: start modules
-    ogre_->initialise();
-    //TODO: run engine
-    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
-    Factory::createClassHierarchy();
-    createScene();
-    setupInputSystem();
-
-    startRenderLoop();
-  }
-
-  void Orxonox::createScene(void)
-  {
-	  // Init audio
-    auMan_ = new audio::AudioManager();
-
-    // 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();
-
-	/*
-    auMan_->ambientAdd("a1");
-    auMan_->ambientAdd("a2");
-    auMan_->ambientAdd("a3");
-    //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()
-  {
-    if (!InputManager::initialise(ogre_->getWindowHandle(),
-          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
-      abortImmediateForce();
-    InputManager::setInputState(InputManager::IS_NORMAL);
-  }
-
-  /**
-    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 the time smoothing feature from ogre has been
-    implemented too. 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()
-  {
+    COUT(3) << "Orxonox: Loading Console..." << std::endl;
     InputBuffer* ib = dynamic_cast<InputBuffer*>(InputManager::getKeyHandler("buffer"));
     /*
@@ -432,5 +364,4 @@
     ib->registerListener(console, &Testconsole::exit, (char)0x1B, true);
     */
-
     orxonoxConsole_ = new InGameConsole(ib);
     ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true);
@@ -441,9 +372,82 @@
     ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true);
 
+    return true;
+  }
+
+  /**
+   * Level loading method for server mode.
+   */
+  bool Orxonox::serverLoad()
+  {
+    COUT(2) << "Loading level in server mode" << std::endl;
+
+    server_g = new network::Server();
+
+    if (!loadScene())
+      return false;
+
+    server_g->open();
+
+    return true;
+  }
+
+  /**
+   * Level loading method for client mode.
+   */
+  bool Orxonox::clientLoad()
+  {
+    COUT(2) << "Loading level in client mode" << std::endl;\
+
+    if (serverIp_.compare("") == 0)
+      client_g = network::Client::createSingleton();
+    else
+      client_g = network::Client::createSingleton(serverIp_, NETWORK_PORT);
+
+    client_g->establishConnection();
+    client_g->tick(0);
+
+    return true;
+  }
+
+  /**
+   * Level loading method for standalone mode.
+   */
+  bool Orxonox::standaloneLoad()
+  {
+    COUT(2) << "Loading level in standalone mode" << std::endl;
+
+    if (!loadScene())
+      return false;
+
+    return true;
+  }
+
+  /**
+   * Helper method to load a level.
+   */
+  bool Orxonox::loadScene()
+  {
+    Level* startlevel = new Level("levels/sample.oxw");
+    Loader::open(startlevel);
+
+    return true;
+  }
+
+
+  /**
+    Main loop of the orxonox game.
+    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 the time smoothing feature from ogre has been
+    implemented too. 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.
+  */
+  bool Orxonox::startRenderLoop()
+  {
     // first check whether ogre root object has been created
     if (Ogre::Root::getSingletonPtr() == 0)
     {
-      COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
-      return;
+      COUT(2) << "Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
+      return false;
     }
     Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
@@ -465,4 +469,5 @@
     timer_->reset();
 
+    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
 	  while (!bAbort_)
 	  {
@@ -490,5 +495,8 @@
       for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
         it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
-      orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);
+      // Iterate through all TickableReals and call their tick(dt) function
+      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
+        it->tick((float)evt.timeSinceLastFrame);
+      orxonoxConsole_->tick((float)evt.timeSinceLastFrame);
 
       // don't forget to call _fireFrameStarted in ogre to make sure
@@ -510,4 +518,10 @@
       ogreRoot._fireFrameEnded(evt);
 	  }
+
+    if(mode_==CLIENT)
+      network::Client::getSingleton()->closeConnection();
+    else if(mode_==SERVER)
+      server_g->close();
+    return true;
   }
 
@@ -550,6 +564,10 @@
   }
 
+  /**
+   * Static function that shows the console in game mode.
+   */
   void Orxonox::activateConsole()
   {
+    // currently, the console shows itself when feeded with input.
     InputManager::setInputState(InputManager::IS_CONSOLE);
   }
Index: code/trunk/src/orxonox/Orxonox.h
===================================================================
--- code/trunk/src/orxonox/Orxonox.h	(revision 1292)
+++ code/trunk/src/orxonox/Orxonox.h	(revision 1293)
@@ -57,9 +57,9 @@
   {
     public:
-      void init(int argc, char **argv, std::string path);
-      void start();
-      void abortImmediateForce();
+      bool init(int argc, char **argv, std::string path);
+      bool start();
+
       void abortRequest();
-      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
+      //inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
 
       static Orxonox* getSingleton();
@@ -79,24 +79,19 @@
       ~Orxonox();
 
-      // init functions
-      void serverInit(std::string path);
-      void clientInit(std::string path);
-      void standaloneInit(std::string path);
+      bool loadPlayground();
 
-      // run functions
-      void serverStart();
-      void clientStart();
-      void standaloneStart();
+      bool serverLoad();
+      bool clientLoad();
+      bool standaloneLoad();
 
-      void createScene();
-      void setupInputSystem();
-      void startRenderLoop();
+      bool loadScene();
+
+      bool startRenderLoop();
+
       float calculateEventTime(unsigned long, std::deque<unsigned long>&);
 
     private:
       GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
-      std::string           dataPath_;      //!< path to data
-      audio::AudioManager*  auMan_;         //!< audio manager
-      InputManager*         inputHandler_;  //!< Handles input with key bindings
+      //audio::AudioManager*  auMan_;         //!< audio manager
       Ogre::Timer*          timer_;         //!< Main loop timer
       // TODO: make this a config-value by creating a config class for orxonox
Index: code/trunk/src/orxonox/OrxonoxPlatform.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPlatform.h	(revision 1292)
+++ code/trunk/src/orxonox/OrxonoxPlatform.h	(revision 1293)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      An unknown man from the Ogre development crew
+ *      ...
  *   Co-authors:
  *      Reto Grieder
Index: code/trunk/src/orxonox/console/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/console/InGameConsole.cc	(revision 1292)
+++ code/trunk/src/orxonox/console/InGameConsole.cc	(revision 1293)
@@ -54,9 +54,18 @@
     const float BLINK = 0.25;
 
-    InGameConsole::InGameConsole(InputBuffer* ib){
+    InGameConsole::InGameConsole(InputBuffer* ib) :
+        windowW(0), windowH(0),
+        scroll(0), scrollTimer(0.0f),
+        cursor(0.0f),
+        active(false),
+        ib_(ib),
+        om(0),
+        consoleOverlay(0),
+        consoleOverlayContainer(0),
+        consoleOverlayNoise(0),
+        consoleOverlayBorder(0),
+        consoleOverlayTextAreas(0)
+    {
         //RegisterObject(InGameConsole);
-        ib_ = ib;
-        active = false;
-        cursor = 0.0;
         init();
     }
Index: code/trunk/src/orxonox/objects/Ambient.cc
===================================================================
--- code/trunk/src/orxonox/objects/Ambient.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/Ambient.cc	(revision 1293)
@@ -57,4 +57,5 @@
         RegisterObject(Ambient);
         Ambient::instance_s = this;
+        registerAllVariables();
     }
 
@@ -63,4 +64,14 @@
     }
 
+    bool Ambient::create(){
+      GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
+      return true;
+    }
+    
+    void Ambient::registerAllVariables(){
+      registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
+      
+    }
+    
     void Ambient::loadParams(TiXmlElement* xmlElem)
     {
@@ -83,4 +94,5 @@
    {
     	GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
+      ambientLight_=colour;	
    }
 
@@ -96,4 +108,5 @@
 
         XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
+        create();
     }
 }
Index: code/trunk/src/orxonox/objects/Ambient.h
===================================================================
--- code/trunk/src/orxonox/objects/Ambient.h	(revision 1292)
+++ code/trunk/src/orxonox/objects/Ambient.h	(revision 1293)
@@ -34,8 +34,9 @@
 #include "util/Math.h"
 #include "core/BaseObject.h"
+#include "network/Synchronisable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Ambient : public BaseObject
+    class _OrxonoxExport Ambient : public BaseObject, network::Synchronisable
     {
         public:
@@ -46,4 +47,6 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setAmbientLight(const ColourValue& colour);
+            bool create();
+            void registerAllVariables();
 
             static void setAmbientLightTest(const ColourValue& colour)
@@ -52,4 +55,5 @@
         private:
             static Ambient* instance_s;
+            ColourValue ambientLight_;
 
     };
Index: code/trunk/src/orxonox/objects/Camera.cc
===================================================================
--- code/trunk/src/orxonox/objects/Camera.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/Camera.cc	(revision 1293)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Benjamin Knecht
  *
  */
@@ -29,4 +29,5 @@
 #include "OrxonoxStableHeaders.h"
 #include "Camera.h"
+#include "CameraHandler.h"
 
 #include <string>
@@ -47,56 +48,69 @@
 namespace orxonox
 {
-    CreateFactory(Camera);
 
-    Camera::Camera()
+  Camera::Camera(Ogre::SceneNode* node)
+  {
+    this->bHasFocus_ = false;
+    this->cameraNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
+    if( node != NULL )
+      this->setPositionNode(node);
+  }
+
+  Camera::~Camera()
+  {
+    CameraHandler::getInstance()->releaseFocus(this);
+  }
+
+  void Camera::setPositionNode(Ogre::SceneNode* node)
+  {
+    this->positionNode_ = node;
+    // set camera to node values according to camera mode
+  }
+
+  void Camera::setTargetNode(Ogre::SceneNode* obj)
+  {
+    this->targetNode_ = obj;
+  }
+
+  void Camera::tick(float dt)
+  {
+    if(this->positionNode_ != NULL) {
+      // this stuff here may need some adjustments
+      Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getPosition();
+      this->cameraNode_->translate(15*dt*offset);
+
+      this->cameraNode_->setOrientation(Quaternion::Slerp(0.7, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false));
+    }
+  }
+
+  /**
+    don't move anything before here! here the Ogre camera is set to values of this camera
+    always call update after changes
+  */
+  void Camera::update()
+  {
+    if(this->positionNode_ != NULL)
     {
-        RegisterObject(Camera);
+      this->cameraNode_->setPosition(this->positionNode_->getWorldPosition());
+      this->cameraNode_->setOrientation(this->positionNode_->getWorldOrientation());
     }
+  }
 
-    Camera::~Camera()
-    {
-    }
+  /**
+    what to do when camera loses focus (do not request focus in this function!!)
+    this is called by the CameraHandler singleton class to notify the camera
+  */
+  void Camera::removeFocus()
+  {
+    this->bHasFocus_ = false;
+    this->cameraNode_->detachObject(this->cam_);
+  }
 
-    void Camera::loadParams(TiXmlElement* xmlElem)
-    {
-      Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
-
-      if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
-      {
-        //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
-
-        std::string name = xmlElem->Attribute("name");
-        std::string pos = xmlElem->Attribute("pos");
-        std::string lookat = xmlElem->Attribute("lookat");
-
-        Ogre::Camera *cam = mgr->createCamera(name);
-
-        float x, y, z;
-        SubString posVec(xmlElem->Attribute("pos"), ',');
-        convertValue<std::string, float>(&x, posVec[0]);
-        convertValue<std::string, float>(&y, posVec[1]);
-        convertValue<std::string, float>(&z, posVec[2]);
-
-        cam->setPosition(Vector3(x,y,z));
-
-        posVec = SubString(xmlElem->Attribute("lookat"), ',');
-        convertValue<std::string, float>(&x, posVec[0]);
-        convertValue<std::string, float>(&y, posVec[1]);
-        convertValue<std::string, float>(&z, posVec[2]);
-
-        cam->lookAt(Vector3(x,y,z));
-
-        std::string node = xmlElem->Attribute("node");
-
-        Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
-        sceneNode->attachObject((Ogre::MovableObject*)cam);
-
-        // FIXME: unused var
-        //Ogre::Viewport* vp = 
-        GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
-
-
-        COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
-      }
-   }
+  void Camera::setFocus(Ogre::Camera* ogreCam)
+  {
+    this->bHasFocus_ = true;
+    this->cam_ = ogreCam;
+    this->cam_->setOrientation(this->cameraNode_->getWorldOrientation());
+    this->cameraNode_->attachObject(this->cam_);
+  }
 }
Index: code/trunk/src/orxonox/objects/Camera.h
===================================================================
--- code/trunk/src/orxonox/objects/Camera.h	(revision 1292)
+++ code/trunk/src/orxonox/objects/Camera.h	(revision 1293)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Benjamin Knecht
  *
  */
@@ -30,22 +30,39 @@
 #define _Camera_H__
 
+#include <OgrePrerequisites.h>
+#include <OgreSceneNode.h>
+#include <OgreCamera.h>
+
 #include "OrxonoxPrereqs.h"
-
-#include "core/BaseObject.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Camera : public BaseObject
+    class _OrxonoxExport Camera
     {
-        public:
-            Camera();
-            virtual ~Camera();
+      friend class CameraHandler;
+      public:
+        Camera(Ogre::SceneNode* node = NULL);
+        virtual ~Camera();
 
+        void setPositionNode(Ogre::SceneNode* node);
+        inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; }
+        // maybe also BaseObject
+        void setTargetNode(Ogre::SceneNode* obj);
 
-            void loadParams(TiXmlElement* xmlElem);
+        void tick(float dt);
+        void update();
+        inline bool hasFocus() { return this->bHasFocus_; }
 
-        private:
+      private:
+        void removeFocus();
+        void setFocus(Ogre::Camera* ogreCam);
 
-
+      private:
+        Ogre::SceneNode* targetNode_;
+        Ogre::SceneNode* positionNode_;
+        Ogre::SceneNode* cameraNode_;
+        Ogre::Vector3 oldPos;
+        Ogre::Camera* cam_;
+        bool bHasFocus_;
     };
 }
Index: code/trunk/src/orxonox/objects/CameraHandler.cc
===================================================================
--- code/trunk/src/orxonox/objects/CameraHandler.cc	(revision 1293)
+++ code/trunk/src/orxonox/objects/CameraHandler.cc	(revision 1293)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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 <OgreSceneManager.h>
+#include <OgreRenderWindow.h>
+
+#include "OrxonoxStableHeaders.h"
+#include "core/ObjectList.h"
+#include "CameraHandler.h"
+#include "Camera.h"
+#include "GraphicsEngine.h"
+
+#include <OgreCamera.h>
+
+namespace orxonox {
+
+  CameraHandler* CameraHandler::singletonRef = NULL;
+
+  CameraHandler::CameraHandler()
+  {
+    this->cam_ = GraphicsEngine::getSingleton().getSceneManager()->createCamera("Cam");
+    GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_);
+    /*this->activeCamera_ = *ObjectList<Camera>::begin();
+    this->activeCamera_->cam_ = this->cam_;*/
+  }
+
+  void CameraHandler::requestFocus(Camera* requestCam)
+  {
+    // notify old camera (if it exists)
+    if(focusList_.size() > 0)
+      focusList_.back()->removeFocus();
+    // add to list
+    focusList_.push_back(requestCam);
+    // set focus to new camera and update (if necessary)
+    if(!requestCam->hasFocus()) {
+      requestCam->setFocus(this->cam_);
+      requestCam->update();
+    }
+    // delete dublicates
+    focusList_.unique();
+  }
+
+  void CameraHandler::releaseFocus(Camera* cam)
+  {
+    // notify the cam of releasing the focus
+    if(cam->hasFocus())
+      cam->removeFocus();
+    // delete camera from list
+    focusList_.remove(cam);
+    // set new focus if necessary
+    if(focusList_.size() > 0 && !(focusList_.back()->hasFocus()))
+      focusList_.back()->setFocus(this->cam_);
+  }
+/*
+  void CameraHandler::changeActiveCamera(Camera* setCam)
+  {
+    cam_->getParentSceneNode()->detachObject(cam_);
+    //setCam->attachCamera(cam_);
+    activeCamera_ = setCam;
+  }
+*/
+/*  bool isInVector(Camera* cam)
+  {
+    for(std::vector<Camera*>::iterator it = cams_.begin(); it != cams_.end(); it++)
+    {
+      if (*it == cam) return true;
+    }
+    return false;
+  }*/
+}
Index: code/trunk/src/orxonox/objects/CameraHandler.h
===================================================================
--- code/trunk/src/orxonox/objects/CameraHandler.h	(revision 1293)
+++ code/trunk/src/orxonox/objects/CameraHandler.h	(revision 1293)
@@ -0,0 +1,75 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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:
+ *      ...
+ *
+ */
+
+ /**
+ @file  CameraHandler.h
+ @brief Handles the instances of Camera class
+ @author Benjamin Knecht <beni_at_orxonox.net>
+  */
+
+#ifndef _Camera_Handler_H__
+#define _Camera_Handler_H__
+
+#include <list>
+
+#include <OgreCamera.h>
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+#include "Camera.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport CameraHandler
+  {
+
+    public:
+      inline static CameraHandler* getInstance() { if (!CameraHandler::singletonRef) CameraHandler::singletonRef = new CameraHandler(); return CameraHandler::singletonRef; }
+      inline ~CameraHandler() { CameraHandler::singletonRef = NULL; }
+      inline Camera* getActiveCamera() { return this->focusList_.back(); }
+      /*void registerCamera(Camera* newCam);
+      void changeActiveCamera(Camera* setCam);*/
+      void requestFocus(Camera* requestCam);
+      void releaseFocus(Camera* cam);
+
+    private:
+      CameraHandler();
+      //bool isInVector(Camera* cam);
+
+    private:
+      static CameraHandler* singletonRef;
+      Ogre::Camera* cam_;
+      std::list<Camera*> focusList_;
+      //std::vector<Camera*> cams_;
+
+  };
+}
+
+#endif /* _Camera_Handler_H__ */
Index: code/trunk/src/orxonox/objects/Explosion.cc
===================================================================
--- code/trunk/src/orxonox/objects/Explosion.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/Explosion.cc	(revision 1293)
@@ -45,10 +45,9 @@
     CreateFactory(Explosion);
 
-    Explosion::Explosion(WorldEntity* owner)
+    Explosion::Explosion(WorldEntity* owner) :
+      lifetime_(0.4),
+      particle_(0)
     {
         RegisterObject(Explosion);
-
-        this->particle_ = 0;
-        this->lifetime_ = 0.4;
 
         if (owner)
Index: code/trunk/src/orxonox/objects/Model.cc
===================================================================
--- code/trunk/src/orxonox/objects/Model.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/Model.cc	(revision 1293)
@@ -49,15 +49,4 @@
     }
 
-    void Model::loadParams(TiXmlElement* xmlElem)
-    {
-        WorldEntity::loadParams(xmlElem);
-
-        if (xmlElem->Attribute("mesh"))
-        {
-            meshSrc_ = xmlElem->Attribute("mesh");
-        }
-        create();
-    }
-
     /**
         @brief XML loading and saving.
@@ -73,5 +62,5 @@
         XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
 
-        create();
+        Model::create();
     }
 
@@ -82,10 +71,11 @@
 
     bool Model::create(){
-      WorldEntity::create();
+      if(!WorldEntity::create())
+        return false;
       if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
       {
         this->mesh_.setMesh(meshSrc_);
         this->attachObject(this->mesh_.getEntity());
-        COUT(4) << "Loader: Created model" << std::endl;
+        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
       }
       return true;
@@ -93,5 +83,6 @@
 
     void Model::registerAllVariables(){
-      WorldEntity::registerAllVariables();
+//       WorldEntity::registerAllVariables();
+      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
       registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
     }
Index: code/trunk/src/orxonox/objects/Model.h
===================================================================
--- code/trunk/src/orxonox/objects/Model.h	(revision 1292)
+++ code/trunk/src/orxonox/objects/Model.h	(revision 1293)
@@ -43,5 +43,4 @@
             Model();
             virtual ~Model();
-            virtual void loadParams(TiXmlElement* xmlElem);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setMesh(const std::string& meshname);
Index: code/trunk/src/orxonox/objects/NPC.cc
===================================================================
--- code/trunk/src/orxonox/objects/NPC.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/NPC.cc	(revision 1293)
@@ -36,8 +36,9 @@
   CreateFactory(NPC);
 
-  NPC::NPC()
+  NPC::NPC() :
+    movable_(true)
   {
     RegisterObject(NPC);
-    movable_ = true;
+    registerAllVariables();
   }
 
@@ -59,4 +60,14 @@
     this->translate(location);
     movable_ = movable;
+  }
+  
+  void NPC::registerAllVariables(){
+    Model::registerAllVariables();
+    registerVar(&movable_, sizeof(movable_), network::DATA);
+  }
+  
+  bool NPC::create(){
+    Model::create();
+    return true;
   }
 
Index: code/trunk/src/orxonox/objects/NPC.h
===================================================================
--- code/trunk/src/orxonox/objects/NPC.h	(revision 1292)
+++ code/trunk/src/orxonox/objects/NPC.h	(revision 1293)
@@ -52,4 +52,6 @@
       void update();
       void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
+      void registerAllVariables();
+      bool create();
 
     private:
Index: code/trunk/src/orxonox/objects/Projectile.cc
===================================================================
--- code/trunk/src/orxonox/objects/Projectile.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/Projectile.cc	(revision 1293)
@@ -42,11 +42,10 @@
     CreateFactory(Projectile);
 
-    Projectile::Projectile(SpaceShip* owner)
+    Projectile::Projectile(SpaceShip* owner) :
+      owner_(owner)
     {
         RegisterObject(Projectile);
 
         this->setConfigValues();
-
-        this->owner_ = owner;
 
         this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
Index: code/trunk/src/orxonox/objects/Skybox.cc
===================================================================
--- code/trunk/src/orxonox/objects/Skybox.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/Skybox.cc	(revision 1293)
@@ -47,4 +47,5 @@
     {
         RegisterObject(Skybox);
+        registerAllVariables();
     }
 
@@ -57,8 +58,8 @@
     	if (xmlElem->Attribute("src"))
     	{
-    		std::string skyboxSrc = xmlElem->Attribute("src");
-	    	this->setSkybox(skyboxSrc);
+    		skyboxSrc_ = xmlElem->Attribute("src");
+        this->create();
 
-	    	COUT(4) << "Loader: Set skybox: "<< skyboxSrc << std::endl << std::endl;
+	    	COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl;
     	}
    }
@@ -69,4 +70,8 @@
    }
 
+   void Skybox::setSkyboxSrc(const std::string& src){
+     skyboxSrc_ = src;
+   }
+   
     /**
         @brief XML loading and saving.
@@ -79,5 +84,16 @@
         BaseObject::XMLPort(xmlelement, mode);
 
-        XMLPortParamLoadOnly(Skybox, "src", setSkybox, xmlelement, mode);
+        XMLPortParamLoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);
+        create();
     }
+    
+    bool Skybox::create(){
+      this->setSkybox(skyboxSrc_);
+      return true;
+    }
+    
+    void Skybox::registerAllVariables(){
+      registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
+    }
+    
 }
Index: code/trunk/src/orxonox/objects/Skybox.h
===================================================================
--- code/trunk/src/orxonox/objects/Skybox.h	(revision 1292)
+++ code/trunk/src/orxonox/objects/Skybox.h	(revision 1293)
@@ -33,8 +33,9 @@
 
 #include "core/BaseObject.h"
+#include "network/Synchronisable.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport Skybox : public BaseObject
+    class _OrxonoxExport Skybox : public BaseObject, public network::Synchronisable
     {
         public:
@@ -45,6 +46,11 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setSkybox(const std::string& skyboxname);
+            
+            bool create();
+            void registerAllVariables();
+            void setSkyboxSrc(const std::string &src);
 
         private:
+            std::string skyboxSrc_;
 
 
Index: code/trunk/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1293)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Benjamin Knecht
  *
  */
@@ -37,4 +37,5 @@
 #include <OgreSceneNode.h>
 
+#include "CameraHandler.h"
 #include "tinyxml/tinyxml.h"
 #include "ois/OIS.h"
@@ -50,4 +51,5 @@
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
+#include "network/Client.h"
 
 namespace orxonox
@@ -62,5 +64,38 @@
     SpaceShip* SpaceShip::instance_s;
 
-    SpaceShip::SpaceShip()
+    SpaceShip::SpaceShip() :
+      //testvector_(0,0,0),
+      //bInvertYAxis_(false),
+      setMouseEventCallback_(false),
+      bLMousePressed_(false),
+      bRMousePressed_(false),
+      camNode_(0),
+      cam_(0),
+      camName_("CamNode"),
+      tt_(0),
+      redNode_(0),
+      greenNode_(0),
+      blinkTime_(0.0f),
+      chNearNode_(0),
+      chFarNode_(0),
+      timeToReload_(0.0f),
+      //reloadTime_(0.0f),
+      maxSideAndBackSpeed_(0.0f),
+      maxSpeed_(0.0f),
+      maxRotation_(0.0f),
+      translationAcceleration_(0.0f),
+      rotationAcceleration_(0.0f),
+      translationDamping_(0.0f),
+      rotationDamping_(0.0f),
+      maxRotationRadian_(0),
+      rotationAccelerationRadian_(0),
+      rotationDampingRadian_(0),
+      zeroRadian_(0),
+      mouseXRotation_(0),
+      mouseYRotation_(0),
+      mouseX_(0.0f),
+      mouseY_(0.0f),
+      emitterRate_(0.0f),
+      server_(false)
     {
         RegisterObject(SpaceShip);
@@ -71,72 +106,7 @@
         this->setConfigValues();
 
-        this->setMouseEventCallback_ = false;
-        this->bLMousePressed_ = false;
-        this->bRMousePressed_ = false;
-        this->mouseX_ = 0;
-        this->mouseY_ = 0;
-
-        this->camNode_ = 0;
-
-        this->tt_ = 0;
-        this->redNode_ = 0;
-        this->greenNode_ = 0;
-        this->blinkTime_ = 0;
-
-        this->timeToReload_ = 0;
-
-        this->maxSpeed_ = 0;
-        this->maxSideAndBackSpeed_ = 0;
-        this->maxRotation_ = 0;
-        this->translationAcceleration_ = 0;
-        this->rotationAcceleration_ = 0;
-        this->translationDamping_ = 0;
-        this->rotationDamping_ = 0;
-
-        this->maxRotationRadian_ = 0;
-        this->rotationAccelerationRadian_ = 0;
-        this->rotationDampingRadian_ = 0;
-        this->zeroRadian_ = Radian(0);
 
         this->setRotationAxis(1, 0, 0);
         this->setStatic(false);
-/*
-        this->moveForward_ = 0;
-        this->rotateUp_ = 0;
-        this->rotateDown_ = 0;
-        this->rotateRight_ = 0;
-        this->rotateLeft_ = 0;
-        this->loopRight_ = 0;
-        this->loopLeft_ = 0;
-        this->brakeForward_ = 0;
-        this->brakeRotate_ = 0;
-        this->brakeLoop_ = 0;
-        this->speedForward_ = 0;
-        this->speedRotateUpDown_ = 0;
-        this->speedRotateRightLeft_ = 0;
-        this->speedLoopRightLeft_ = 0;
-        this->maxSpeedForward_ = 0;
-        this->maxSpeedRotateUpDown_ = 0;
-        this->maxSpeedRotateRightLeft_ = 0;
-        this->maxSpeedLoopRightLeft_ = 0;
-        this->accelerationForward_ = 0;
-        this->accelerationRotateUpDown_ = 0;
-        this->accelerationRotateRightLeft_ = 0;
-        this->accelerationLoopRightLeft_ = 0;
-
-        this->speed = 250;
-        this->loop = 100;
-        this->rotate = 10;
-        this->mouseX = 0;
-        this->mouseY = 0;
-        this->maxMouseX = 0;
-        this->minMouseX = 0;
-        this->moved = false;
-
-        this->brakeRotate(rotate*10);
-        this->brakeLoop(loop);
-*/
-//         this->create();
-
 
         COUT(3) << "Info: SpaceShip was loaded" << std::endl;
@@ -147,4 +117,8 @@
         if (this->tt_)
             delete this->tt_;
+        if(setMouseEventCallback_)
+          InputManager::removeMouseHandler("SpaceShip");
+        if (this->cam_)
+          delete this->cam_;
     }
 
@@ -158,7 +132,14 @@
 
     void SpaceShip::registerAllVariables(){
-      Model::registerAllVariables();
-
-
+      registerVar( &camName_, camName_.length()+1, network::STRING, 0x1);
+      registerVar( &maxSpeed_, sizeof(maxSpeed_), network::DATA, 0x1);
+      registerVar( &maxSideAndBackSpeed_, sizeof(maxSideAndBackSpeed_), network::DATA, 0x1);
+      registerVar( &maxRotation_, sizeof(maxRotation_), network::DATA, 0x1);
+      registerVar( &translationAcceleration_, sizeof(translationAcceleration_), network::DATA, 0x1);
+      registerVar( &rotationAcceleration_, sizeof(rotationAcceleration_), network::DATA, 0x1);
+      registerVar( &rotationAccelerationRadian_, sizeof(rotationAccelerationRadian_), network::DATA, 0x1);
+      registerVar( &translationDamping_, sizeof(translationDamping_), network::DATA, 0x1);
+      registerVar( &rotationDamping_, sizeof(rotationDamping_), network::DATA, 0x1);
+      registerVar( &rotationDampingRadian_, sizeof(rotationDampingRadian_), network::DATA, 0x1);
 
     }
@@ -166,4 +147,13 @@
     void SpaceShip::init()
     {
+    if ((server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==objectID ) ))
+    {
+          if (!setMouseEventCallback_)
+          {
+              InputManager::addMouseHandler(this, "SpaceShip");
+              setMouseEventCallback_ = true;
+          }
+    }
+
         // START CREATING THRUSTER
         this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
@@ -191,7 +181,7 @@
         this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
 
-        this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.7, -0.3));
+        this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
         this->redNode_->setInheritScale(false);
-        this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.7, -0.3));
+        this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
         this->greenNode_->setInheritScale(false);
 
@@ -218,4 +208,5 @@
         this->chFarNode_->setScale(0.4, 0.4, 0.4);
 
+        createCamera();
         // END of testing crosshair
     }
@@ -232,4 +223,5 @@
         Model::loadParams(xmlElem);
         this->create();
+        this->getFocus();
 /*
         if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
@@ -246,5 +238,5 @@
 
             COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;
-    	}
+      }
 */
         if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp"))
@@ -272,30 +264,43 @@
 
             COUT(4) << "Loader: Initialized SpaceShip" << std::endl;
-    	}
-
-    	if (xmlElem->Attribute("camera"))
-    	{
-    	    this->setCamera();
-    	}
+        }
+
+        if (xmlElem->Attribute("camera"))
+        {
+            this->setCamera();
+        }
     }
 
     void SpaceShip::setCamera(const std::string& camera)
     {
-        Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");
-        this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
-/*
-//        node->setInheritOrientation(false);
-        cam->setPosition(Vector3(0,50,-150));
-        cam->lookAt(Vector3(0,20,0));
-        cam->roll(Degree(0));
-*/
-
-        cam->setPosition(Vector3(-200,0,35));
+      camName_=camera;
+      // change camera attributes here, if you want to ;)
+    }
+    
+    void SpaceShip::getFocus(){
+      COUT(4) << "requesting focus" << std::endl;
+      if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID)
+        CameraHandler::getInstance()->requestFocus(cam_);
+      
+    }
+    
+    void SpaceShip::createCamera(){
+//       COUT(4) << "begin camera creation" << std::endl;
+      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
+      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
+      this->camNode_->setPosition(Vector3(-50,0,10));
+      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));
+      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1));
+      camNode_->setOrientation(q1*q2);
+      COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl;
+      cam_ = new Camera(this->camNode_);
+
+      cam_->setTargetNode(this->getNode());
 //        cam->setPosition(Vector3(0,-350,0));
-        cam->lookAt(Vector3(0,0,35));
-        cam->roll(Degree(-90));
-
-        this->camNode_->attachObject(cam);
-        GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
+      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
+        this->setBacksync(true);
+        CameraHandler::getInstance()->requestFocus(cam_);
+      }
+
     }
 
@@ -333,4 +338,7 @@
         XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
         XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
+        server_=true; // TODO: this is only a hack
+        SpaceShip::create();
+        getFocus();
     }
 
@@ -343,5 +351,5 @@
     }
 
-    bool SpaceShip::mouseMoved(const OIS::MouseEvent &e)
+    bool SpaceShip::mouseMoved(const MouseState& state)
     {
 /*
@@ -360,14 +368,14 @@
         if (this->bRMousePressed_)
         {
-            this->camNode_->roll(Degree(-e.state.X.rel * 0.10));
-            this->camNode_->yaw(Degree(e.state.Y.rel * 0.10));
-        }
-        else
-        {
-            float minDimension = e.state.height;
-            if (e.state.width < minDimension)
-                minDimension = e.state.width;
-
-            this->mouseX_ += e.state.X.rel;
+            this->camNode_->roll(Degree(-state.X.rel * 0.10));
+            this->camNode_->yaw(Degree(state.Y.rel * 0.10));
+        }
+        else
+        {
+            float minDimension = state.height;
+            if (state.width < minDimension)
+                minDimension = state.width;
+
+            this->mouseX_ += state.X.rel;
             if (this->mouseX_ < -minDimension)
                 this->mouseX_ = -minDimension;
@@ -375,5 +383,5 @@
                 this->mouseX_ = minDimension;
 
-            this->mouseY_ += e.state.Y.rel;
+            this->mouseY_ += state.Y.rel;
             if (this->mouseY_ < -minDimension)
                 this->mouseY_ = -minDimension;
@@ -403,9 +411,9 @@
     }
 
-    bool SpaceShip::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-    {
-        if (id == OIS::MB_Left)
+    bool SpaceShip::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
+    {
+        if (id == MouseButton::Left)
             this->bLMousePressed_ = true;
-        else if (id == OIS::MB_Right)
+        else if (id == MouseButton::Right)
             this->bRMousePressed_ = true;
 
@@ -413,9 +421,9 @@
     }
 
-    bool SpaceShip::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-    {
-        if (id == OIS::MB_Left)
+    bool SpaceShip::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
+    {
+        if (id == MouseButton::Left)
             this->bLMousePressed_ = false;
-        else if (id == OIS::MB_Right)
+        else if (id == MouseButton::Right)
         {
             this->bRMousePressed_ = false;
@@ -428,9 +436,6 @@
     void SpaceShip::tick(float dt)
     {
-        if (!setMouseEventCallback_)
-        {
-          InputManager::addMouseHandler(this, "SpaceShip");
-          setMouseEventCallback_ = true;
-        }
+        if (this->cam_)
+            this->cam_->tick(dt);
 
         if (this->redNode_ && this->greenNode_)
@@ -450,9 +455,8 @@
         if (this->bLMousePressed_ && this->timeToReload_ <= 0)
         {
-            new Projectile(this);
+            Projectile *p = new Projectile(this);
+            p->setBacksync(true);
             this->timeToReload_ = this->reloadTime_;
         }
-
-        OIS::Keyboard* mKeyboard = InputManager::getKeyboard();
 
 
@@ -522,24 +526,29 @@
         }
 
-        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
+        if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ )
+        {
+          COUT(4) << "steering our ship: " << objectID << std::endl;
+          if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W))
             this->acceleration_.x = this->translationAcceleration_;
-        else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
+          else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S))
             this->acceleration_.x = -this->translationAcceleration_;
-        else
+          else
             this->acceleration_.x = 0;
 
-        if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
+          if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D))
             this->acceleration_.y = -this->translationAcceleration_;
-        else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
+          else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A))
             this->acceleration_.y = this->translationAcceleration_;
-        else
+          else
             this->acceleration_.y = 0;
 
-        if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
+          if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q))
             this->momentum_ = Radian(-this->rotationAccelerationRadian_);
-        else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
+          else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E))
             this->momentum_ = Radian(this->rotationAccelerationRadian_);
-        else
+          else
             this->momentum_ = 0;
+        }/*else
+          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
 
         WorldEntity::tick(dt);
Index: code/trunk/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.h	(revision 1292)
+++ code/trunk/src/orxonox/objects/SpaceShip.h	(revision 1293)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Benjamin Knecht
  *
  */
@@ -34,5 +34,6 @@
 #include <OgrePrerequisites.h>
 
-#include "core/InputHandler.h"
+#include "core/InputInterfaces.h"
+#include "Camera.h"
 #include "Model.h"
 #include "../tools/BillboardSet.h"
@@ -62,14 +63,18 @@
             void setRotDamp(float value);
 
+            void getFocus();
+
             static void setMaxSpeedTest(float value)
                 { SpaceShip::instance_s->setMaxSpeed(value); }
 
-            bool mouseMoved(const OIS::MouseEvent &e);
-            bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
-            bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
-            bool mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
+            bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
+            bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
+            bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) { return true; }
+            bool mouseMoved         (const MouseState& state);
+            bool mouseScrolled      (const MouseState& state) { return true; }
 
 
         private:
+            void createCamera();
             static SpaceShip* instance_s;
 
@@ -81,4 +86,7 @@
 
             Ogre::SceneNode* camNode_;
+            Camera* cam_;  
+            std::string camName_;
+
 
             ParticleInterface* tt_;
@@ -117,4 +125,5 @@
 
             float emitterRate_;
+            bool server_;
     };
 }
Index: code/trunk/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1292)
+++ code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1293)
@@ -45,16 +45,14 @@
     unsigned int WorldEntity::worldEntityCounter_s = 0;
 
-    WorldEntity::WorldEntity()
+    WorldEntity::WorldEntity() :
+      velocity_    (0, 0, 0),
+      acceleration_(0, 0, 0),
+      rotationAxis_(0, 1, 0),
+      rotationRate_(0),
+      momentum_    (0),
+      node_        (0),
+      bStatic_     (true)
     {
         RegisterObject(WorldEntity);
-
-        //create();
-
-        this->bStatic_ = true;
-        this->velocity_ = Vector3(0, 0, 0);
-        this->acceleration_ = Vector3(0, 0, 0);
-        this->rotationAxis_ = Vector3(0, 1, 0);
-        this->rotationRate_ = 0;
-        this->momentum_ = 0;
 
         if (GraphicsEngine::getSingleton().getSceneManager())
@@ -67,12 +65,12 @@
           registerAllVariables();
         }
-        else
-        {
-          this->node_ = 0;
-        }
     }
+    
 
     WorldEntity::~WorldEntity()
     {
+      // just to make sure we clean out all scene nodes
+      if(this->getNode())
+        this->getNode()->removeAndDestroyAllChildren();
     }
 
@@ -81,4 +79,5 @@
         if (!this->bStatic_)
         {
+//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
             this->velocity_ += (dt * this->acceleration_);
             this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
@@ -94,72 +93,6 @@
         BaseObject::loadParams(xmlElem);
         create();
-/*
-        if (xmlElem->Attribute("position"))
-        {
-            std::vector<std::string> pos = tokenize(xmlElem->Attribute("position"),",");
-            float x, y, z;
-            String2Number<float>(x, pos[0]);
-            String2Number<float>(y, pos[1]);
-            String2Number<float>(z, pos[2]);
-            this->setPosition(x, y, z);
-        }
-
-        if (xmlElem->Attribute("direction"))
-        {
-            std::vector<std::string> pos = tokenize(xmlElem->Attribute("direction"),",");
-            float x, y, z;
-            String2Number<float>(x, pos[0]);
-            String2Number<float>(y, pos[1]);
-            String2Number<float>(z, pos[2]);
-            this->setDirection(x, y, z);
-        }
-
-        if (xmlElem->Attribute("yaw") || xmlElem->Attribute("pitch") || xmlElem->Attribute("roll"))
-        {
-            float yaw = 0.0, pitch = 0.0, roll = 0.0;
-            if (xmlElem->Attribute("yaw"))
-                String2Number<float>(yaw,xmlElem->Attribute("yaw"));
-
-            if (xmlElem->Attribute("pitch"))
-                String2Number<float>(pitch,xmlElem->Attribute("pitch"));
-
-            if (xmlElem->Attribute("roll"))
-                String2Number<float>(roll,xmlElem->Attribute("roll"));
-
-            this->yaw(Degree(yaw));
-            this->pitch(Degree(pitch));
-            this->roll(Degree(roll));
-        }
-
-        if (xmlElem->Attribute("scale"))
-        {
-            std::string scaleStr = xmlElem->Attribute("scale");
-            float scale;
-            String2Number<float>(scale, scaleStr);
-            this->setScale(scale);
-        }
-
-        if (xmlElem->Attribute("rotationAxis"))
-        {
-            std::vector<std::string> pos = tokenize(xmlElem->Attribute("rotationAxis"),",");
-            float x, y, z;
-            String2Number<float>(x, pos[0]);
-            String2Number<float>(y, pos[1]);
-            String2Number<float>(z, pos[2]);
-            this->setRotationAxis(x, y, z);
-        }
-
-        if (xmlElem->Attribute("rotationRate"))
-        {
-            float rotationRate;
-            String2Number<float>(rotationRate, xmlElem->Attribute("rotationRate"));
-            this->setRotationRate(Degree(rotationRate));
-            if (rotationRate != 0)
-                this->setStatic(false);
-        }
-
-        create();
-*/
     }
+    
 
     void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
@@ -188,4 +121,6 @@
 
         XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
+        
+        WorldEntity::create();
     }
 
@@ -194,22 +129,32 @@
     {
       // register coordinates
-      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
-      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
-      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA);
+      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
       // register orientation
-      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA);
-      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);
-      // not needed at the moment, because we don't have prediction yet
+      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
       // register velocity_
-      registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
-      registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
-      registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA);
-      // register rotationAxis/rate
-      registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA);
-      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->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
+//       // register rotationAxis/rate
+//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
+      // register scale of node
+      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
+      //register staticity
+      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
+      //register acceleration
+      // register velocity_
+//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
+//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
     }
 
Index: code/trunk/src/orxonox/particle/ParticleInterface.cc
===================================================================
--- code/trunk/src/orxonox/particle/ParticleInterface.cc	(revision 1292)
+++ code/trunk/src/orxonox/particle/ParticleInterface.cc	(revision 1293)
@@ -63,4 +63,6 @@
   ParticleInterface::~ParticleInterface(void)
   {
+    while(particleSystem_->getNumEmitters()>0)
+      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
     sceneManager_->destroyParticleSystem(particleSystem_);
   }
Index: code/trunk/src/orxonox/tools/Timer.cc
===================================================================
--- code/trunk/src/orxonox/tools/Timer.cc	(revision 1292)
+++ code/trunk/src/orxonox/tools/Timer.cc	(revision 1293)
@@ -68,6 +68,4 @@
     TimerBase::TimerBase()
     {
-        RegisterRootObject(TimerBase);
-
         this->executor_ = 0;
         this->interval_ = 0;
@@ -76,4 +74,6 @@
 
         this->time_ = 0;
+
+        RegisterRootObject(TimerBase);
     }
 
@@ -83,5 +83,6 @@
     TimerBase::~TimerBase()
     {
-        delete this->executor_;
+      if (this->executor_)
+          delete this->executor_;
     }
 
Index: code/trunk/visual_studio/base_properties_debug.vsprops
===================================================================
--- code/trunk/visual_studio/base_properties_debug.vsprops	(revision 1292)
+++ code/trunk/visual_studio/base_properties_debug.vsprops	(revision 1293)
@@ -13,5 +13,5 @@
 		BasicRuntimeChecks="3"
 		RuntimeLibrary="3"
-		DebugInformationFormat="4"
+		DebugInformationFormat="3"
 	/>
 	<Tool
Index: code/trunk/visual_studio/network_properties.vsprops
===================================================================
--- code/trunk/visual_studio/network_properties.vsprops	(revision 1292)
+++ code/trunk/visual_studio/network_properties.vsprops	(revision 1293)
@@ -8,5 +8,5 @@
 	<Tool
 		Name="VCCLCompilerTool"
-		PreprocessorDefinitions="NETWORK_SHARED_BUILD;WIN32_LEAN_AND_MEAN"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;WIN32_LEAN_AND_MEAN"
 	/>
 	<Tool
Index: code/trunk/visual_studio/orxonox_properties.vsprops
===================================================================
--- code/trunk/visual_studio/orxonox_properties.vsprops	(revision 1292)
+++ code/trunk/visual_studio/orxonox_properties.vsprops	(revision 1293)
@@ -8,5 +8,5 @@
 	<Tool
 		Name="VCCLCompilerTool"
-		PreprocessorDefinitions="ORXONOX_SHARED_BUILD"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD"
 		UsePrecompiledHeader="2"
 		PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
@@ -14,7 +14,7 @@
 	<Tool
 		Name="VCLinkerTool"
-		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib"
+		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet$(CS).lib zlib$(CS).lib"
 		OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
-		IgnoreDefaultLibraryNames=""
+		IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD"
 	/>
 </VisualStudioPropertySheet>
Index: code/trunk/visual_studio/vc8/core.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/core.vcproj	(revision 1292)
+++ code/trunk/visual_studio/vc8/core.vcproj	(revision 1293)
@@ -351,4 +351,8 @@
 			</File>
 			<File
+				RelativePath="..\..\src\core\InputInterfaces.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\InputManager.h"
 				>
Index: code/trunk/visual_studio/vc8/network.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/network.vcproj	(revision 1292)
+++ code/trunk/visual_studio/vc8/network.vcproj	(revision 1293)
@@ -18,5 +18,5 @@
 		<Configuration
 			Name="Debug|Win32"
-			ConfigurationType="2"
+			ConfigurationType="4"
 			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\network_properties.vsprops"
 			CharacterSet="1"
@@ -50,5 +50,5 @@
 			/>
 			<Tool
-				Name="VCLinkerTool"
+				Name="VCLibrarianTool"
 			/>
 			<Tool
@@ -56,7 +56,4 @@
 			/>
 			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
 				Name="VCXDCMakeTool"
 			/>
@@ -66,10 +63,4 @@
 			<Tool
 				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
 			/>
 			<Tool
Index: code/trunk/visual_studio/vc8/ois.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/ois.vcproj	(revision 1292)
+++ code/trunk/visual_studio/vc8/ois.vcproj	(revision 1293)
@@ -560,4 +560,128 @@
 				</File>
 			</Filter>
+			<Filter
+				Name="linux"
+				>
+				<File
+					RelativePath="..\..\src\ois\linux\EventHelpers.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxForceFeedback.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxInputManager.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxKeyboard.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxMouse.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
 		</Filter>
 		<Filter
@@ -650,4 +774,36 @@
 				<File
 					RelativePath="..\..\src\ois\OISInterface.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="linux"
+				>
+				<File
+					RelativePath="..\..\src\ois\linux\EventHelpers.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxInputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxKeyboard.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxMouse.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxPrereqs.h"
 					>
 				</File>
Index: code/trunk/visual_studio/vc8/orxonox.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/orxonox.vcproj	(revision 1292)
+++ code/trunk/visual_studio/vc8/orxonox.vcproj	(revision 1293)
@@ -204,4 +204,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\orxonox\objects\CameraHandler.cc"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\orxonox\objects\Explosion.cc"
 					>
@@ -459,4 +463,8 @@
 				<File
 					RelativePath="..\..\src\orxonox\objects\Camera.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\CameraHandler.h"
 					>
 				</File>
