Index: code/branches/network/bin/levels/sample.oxw
===================================================================
--- code/branches/network/bin/levels/sample.oxw	(revision 861)
+++ code/branches/network/bin/levels/sample.oxw	(revision 868)
@@ -33,5 +33,5 @@
 
     <!--Fighter camera="true" position="0,0,0" scale="10" yaw="-90" pitch="-90" mesh="assf3.mesh"  forward="500" rotateupdown="200" rotaterightleft="200" looprightleft="200" /-->
-    <SpaceShip camera="true" position="0,0,0" scale="10" yaw="-90" pitch="-90" mesh="assf5.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" yaw="-90" pitch="-90" mesh="assf3.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"/>
@@ -41,6 +41,6 @@
     <NPC position="100,0,400" scale="1" mesh="razor.mesh"/>
 
-    <Model position="200,0,500" scale="10" mesh="starship.mesh" yaw="-90" pitch="-90" />
-    <Model position="-200,0,500" scale="10" mesh="drone.mesh" yaw="-90" pitch="-90" />
+<!--    <Model position="200,0,500" scale="10" mesh="starship.mesh" yaw="-90" pitch="-90" />
+    <Model position="-200,0,500" scale="10" mesh="drone.mesh" yaw="-90" pitch="-90" />-->
 
     <Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yaw="-90" pitch="-90" />
Index: code/branches/network/src/network/GameStateClient.cc
===================================================================
--- code/branches/network/src/network/GameStateClient.cc	(revision 861)
+++ code/branches/network/src/network/GameStateClient.cc	(revision 868)
@@ -61,12 +61,12 @@
   * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
   */
-  bool GameStateClient::loadSnapshot(GameState state) {
-    unsigned char *data=state.data;
-    std::cout << "loadSnapshot: loading gs: " << state.id << std::endl;
+  bool GameStateClient::loadSnapshot(GameState *state) {
+    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){
+    while(data < state->data+state->size){
       // prepare the syncData struct
       sync.length = (int)*data;
@@ -82,9 +82,9 @@
         // bad luck ;)
         // delete the synchronisable (obviously seems to be deleted on the server)
-        while(it != 0 && it->objectID!=sync.objectID){
+        while(it && it->objectID!=sync.objectID){
           removeObject(it);
         }
-        if(it==0){
-          std::cout << "classid: " << sync.classID << ", name: " << ID(sync.classID)->getName() << std::endl;
+        if(!it){
+          COUT(4) << "classid: " << sync.classID << ", name: " << ID(sync.classID)->getName() << std::endl;
           Synchronisable *no = (Synchronisable*)(ID(sync.classID)->fabricate());
           no->objectID=sync.objectID;
@@ -93,5 +93,5 @@
           // update data and create object/entity...
           if( !no->updateData(sync) && !no->create() )
-            COUT(0) << "We couldn't create/update the object: " << sync.objectID << std::endl;
+            COUT(2) << "We couldn't create/update the object: " << sync.objectID << std::endl;
           ++it;
         }
@@ -99,5 +99,5 @@
         // we have our object
         if(! it->updateData(sync))
-          std::cout << "We couldn't update objectID: " \
+          COUT(2) << "We couldn't update objectID: " \
           << sync.objectID << "; classID: " << sync.classID << std::endl;
       }
@@ -108,5 +108,5 @@
   }
 
-  GameState GameStateClient::diff(GameState a, GameState b) {
+  GameState *GameStateClient::diff(GameState a, GameState b) {
     unsigned char *ap = a.data, *bp = b.data;
     int of=0; // pointers offset
@@ -137,9 +137,13 @@
     // should be finished now
     // FIXME: is it true or false now? (struct has changed, producing warnings)
-    GameState r = {b.id, dest_length, true, dp};
+    GameState *r = new GameState;
+    r->id = b.id;
+    r->size = dest_length;
+    r->diffed = true;
+    r->data = dp;
     return r;
   }
 
-  GameState GameStateClient::decompress(GameStateCompressed a) {
+  GameState *GameStateClient::decompress(GameStateCompressed a) {
     int normsize = a.normsize;
     int compsize = a.compsize;
@@ -157,27 +161,42 @@
     //std::cout << "length " << length << std::endl;
     switch ( retval ) {
-      case Z_OK: std::cout << "successfully decompressed" << std::endl; break;
-      case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
-      case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
-      case Z_DATA_ERROR: std::cout << "data corrupted" << std::endl; break;
-    }
-
-    GameState gamestate;
-    gamestate.id = a.id;
-    gamestate.size = normsize;
-    gamestate.data = dest;
-    gamestate.diffed = a.diffed;
-
+      case Z_OK:
+        COUT(3) << "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" << std::endl;
+        return NULL;
+    }
+
+    GameState *gamestate = new GameState;
+    gamestate->id = a.id;
+    gamestate->size = normsize;
+    gamestate->data = dest;
+    gamestate->diffed = a.diffed;
+
+    free(a.data);
+    
     return gamestate;
   }
 
-  GameState GameStateClient::decode(GameState a, GameStateCompressed x) {
-    GameState t = decompress(x);
-    return diff(a, t);
-  }
-
-  GameState GameStateClient::decode(GameStateCompressed x) {
-    GameState t = decompress(x);
-    return t;
+  GameState *GameStateClient::decode(GameState a, GameStateCompressed x) {
+    GameState *t = decompress(x);
+    if(t==NULL)
+      return NULL;
+    else
+      return diff(a, *t);
+  }
+
+  GameState *GameStateClient::decode(GameStateCompressed x) {
+    GameState *t = decompress(x);
+    if(t==NULL)
+      return NULL;
+    else
+      return t;
   }
 
Index: code/branches/network/src/network/GameStateClient.h
===================================================================
--- code/branches/network/src/network/GameStateClient.h	(revision 861)
+++ code/branches/network/src/network/GameStateClient.h	(revision 868)
@@ -25,9 +25,9 @@
     bool pushGameState(GameStateCompressed *compstate);
   private:
-    bool loadSnapshot(GameState state);
-    GameState diff(GameState a, GameState b);
-    GameState decompress(GameStateCompressed a);
-    GameState decode(GameState a, GameStateCompressed x);
-    GameState decode(GameStateCompressed x);
+    bool loadSnapshot(GameState *state);
+    GameState *diff(GameState a, GameState b);
+    GameState *decompress(GameStateCompressed a);
+    GameState *decode(GameState a, GameStateCompressed x);
+    GameState *decode(GameStateCompressed x);
     void removeObject(orxonox::Iterator<Synchronisable> &it);
 
Index: code/branches/network/src/network/GameStateManager.cc
===================================================================
--- code/branches/network/src/network/GameStateManager.cc	(revision 861)
+++ code/branches/network/src/network/GameStateManager.cc	(revision 868)
@@ -109,5 +109,5 @@
     int offset=0;
     // go through all Synchronisables
-    for(it = orxonox::ObjectList<Synchronisable>::start(); it != 0; ++it){
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
       //std::cout << "gamestatemanager: in for loop" << std::endl;
       //get size of the synchronisable
Index: code/branches/network/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/network/src/orxonox/Orxonox.cc	(revision 861)
+++ code/branches/network/src/orxonox/Orxonox.cc	(revision 868)
@@ -80,12 +80,14 @@
 namespace orxonox
 {
-   // put this in a seperate Class or solve the problem in another fashion
-  class OrxListener : public Ogre::FrameListener
+  
+  
+  
+  // put this in a seperate Class or solve the problem in another fashion
+  class OrxListenerStandalone : public Ogre::FrameListener
   {
     public:
-      OrxListener(OIS::Keyboard *keyboard, audio::AudioManager*  auMan, gameMode mode)
+      OrxListenerStandalone(OIS::Keyboard *keyboard, audio::AudioManager*  auMan)
       {
         mKeyboard = keyboard;
-        mode_=mode;
         auMan_ = auMan;
       }
@@ -96,8 +98,4 @@
         updateAI();
 
-        if(mode_ == PRESENTATION)
-          server_g->tick(evt.timeSinceLastFrame);
-        else if(mode_ == CLIENT)
-          client_g->tick(evt.timeSinceLastFrame);
 
         usleep(10);
@@ -116,9 +114,70 @@
 
     private:
-      gameMode mode_;
       OIS::Keyboard *mKeyboard;
       audio::AudioManager*  auMan_;
   };
-
+  
+  class OrxListenerServer : public Ogre::FrameListener
+  {
+    public:
+      OrxListenerServer(){}
+
+      bool frameStarted(const Ogre::FrameEvent& evt)
+      {
+        updateAI();
+
+        server_g->tick(evt.timeSinceLastFrame);
+        usleep(10);
+
+        return true;
+      }
+
+      void updateAI()
+      {
+        for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it)
+        {
+          it->update();
+        }
+      }
+
+    private:
+  };
+  
+  
+  class OrxListenerClient : public Ogre::FrameListener
+  {
+    public:
+      OrxListenerClient(OIS::Keyboard *keyboard, audio::AudioManager*  auMan)
+      {
+        mKeyboard = keyboard;
+        auMan_ = auMan;
+      }
+
+      bool frameStarted(const Ogre::FrameEvent& evt)
+      {
+        auMan_->update();
+        updateAI();
+
+        client_g->tick(evt.timeSinceLastFrame);
+
+        usleep(10);
+
+        mKeyboard->capture();
+        return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
+      }
+
+      void updateAI()
+      {
+        for(Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it)
+        {
+          it->update();
+        }
+      }
+
+    private:
+      OIS::Keyboard *mKeyboard;
+      audio::AudioManager*  auMan_;
+  };
+    
   // init static singleton reference of Orxonox
   Orxonox* Orxonox::singletonRef_ = NULL;
@@ -137,5 +196,5 @@
     this->mouse_ = 0;
     this->inputManager_ = 0;
-    this->frameListener_ = 0;
+    this->frameListener_.client = 0;
     this->root_ = 0;
   }
@@ -181,9 +240,4 @@
       mode_ = CLIENT;
     }
-    else if(mode == std::string("presentation"))
-    {
-      serverInit(path);
-      mode_ = PRESENTATION;
-    }
     else{
       standaloneInit(path);
@@ -193,7 +247,64 @@
 
   /**
-   * start modules
+   * calls the appropriate start function
    */
   void Orxonox::start()
+  {
+    switch (mode_){
+      case CLIENT:
+        startClient();
+        break;
+      case SERVER:
+        startServer();
+        break;
+      case STANDALONE:
+      default:
+        startStandalone();
+        break;
+    }
+  }
+
+  /**
+   * start server modules
+   */
+  void Orxonox::startServer()
+  {
+    //TODO: start modules
+    //ogre_->startRender();
+    //TODO: run engine
+    Factory::createClassHierarchy();
+    createScene();
+    setupScene();
+    //setupInputSystem();
+    COUT(4) << "************** Server here *************" << std::endl;
+    createFrameListener();
+    
+    //TODO make a server framelistener caller 
+    // startRenderLoop();
+  }
+  
+  /**
+   * start client modules
+   */
+  void Orxonox::startClient()
+  {
+    //TODO: start modules
+    ogre_->startRender();
+    //TODO: run engine
+    Factory::createClassHierarchy();
+    createScene();
+    setupInputSystem();
+    
+    COUT(4) << "************** Client here *************" << std::endl;
+    createFrameListener();
+    client_g->establishConnection();
+    // TODO : server-client initialization
+    startRenderLoop();
+  }
+  
+  /**
+   * start standalone modules
+   */
+  void Orxonox::startStandalone()
   {
     //TODO: start modules
@@ -210,20 +321,15 @@
     createFrameListener();
     switch(mode_){
-    case PRESENTATION:
-      //ogre_->getRoot()->addFrameListener(new network::ServerFrameListener());
-      //std::cout << "could not add framelistener" << std::endl;
-      server_g->open();
-      break;
-    case CLIENT:
-      client_g->establishConnection();
-      break;
-    case SERVER:
-    case STANDALONE:
-    default:
-      break;
+      case CLIENT:
+        client_g->establishConnection();
+        break;
+      case SERVER:
+      case STANDALONE:
+      default:
+        break;
     }
     startRenderLoop();
   }
-
+  
   /**
    * @return singleton object
@@ -379,6 +485,8 @@
 
     // load this file from config
-    loader_ = new loader::LevelLoader("sample.oxw");
-    loader_->loadLevel();
+    if(mode_==STANDALONE){
+      loader_ = new loader::LevelLoader("sample.oxw");
+      loader_->loadLevel();
+    }
 
     Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
@@ -458,6 +566,15 @@
 
     //if(mode_!=CLIENT) // FIXME just a hack ------- remove this in future
-      frameListener_ = new OrxListener(keyboard_, auMan_, mode_);
-    ogre_->getRoot()->addFrameListener(frameListener_);
+      if(mode_==CLIENT){
+        frameListener_.client = new OrxListenerClient(keyboard_, auMan_);
+        ogre_->getRoot()->addFrameListener(frameListener_.client);
+      }else if(mode_==SERVER){
+        frameListener_.server = new OrxListenerServer();
+        ogre_->getRoot()->addFrameListener(frameListener_.server);
+      }else{
+        frameListener_.standalone = new OrxListenerStandalone(keyboard_, auMan_);
+        ogre_->getRoot()->addFrameListener(frameListener_.standalone);
+      }
+    
   }
 
@@ -479,3 +596,5 @@
     ogre_->getRoot()->startRendering();
   }
+  
 }
+
Index: code/branches/network/src/orxonox/Orxonox.h
===================================================================
--- code/branches/network/src/orxonox/Orxonox.h	(revision 861)
+++ code/branches/network/src/orxonox/Orxonox.h	(revision 868)
@@ -27,8 +27,13 @@
     STANDALONE,
     SERVER,
-    CLIENT,
-    PRESENTATION
+    CLIENT
   };
 
+  union OrxListener{
+    OrxListenerClient *client;
+    OrxListenerServer *server;
+    OrxListenerStandalone *standalone;
+  };
+  
   class _OrxonoxExport Orxonox
   {
@@ -50,4 +55,7 @@
       virtual ~Orxonox();
       // init functions
+      void startStandalone();
+      void startServer();
+      void startClient();
       void serverInit(std::string path);
       void clientInit(std::string path);
@@ -76,5 +84,5 @@
       OIS::Mouse*           mouse_;
       OIS::InputManager*    inputManager_;
-      OrxListener*          frameListener_;
+      OrxListener          frameListener_;
       Ogre::Root*           root_;
 
Index: code/branches/network/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/network/src/orxonox/OrxonoxPrereqs.h	(revision 861)
+++ code/branches/network/src/orxonox/OrxonoxPrereqs.h	(revision 868)
@@ -71,5 +71,7 @@
   class Model;
   class NPC;
-  class OrxListener;
+  class OrxListenerServer;
+  class OrxListenerClient;
+  class OrxListenerStandalone;
   class Orxonox;
   class Skybox;
