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;
