Index: /code/branches/presentation3/data/gui/layouts/MultiplayerMenu.layout
===================================================================
--- /code/branches/presentation3/data/gui/layouts/MultiplayerMenu.layout	(revision 7160)
+++ /code/branches/presentation3/data/gui/layouts/MultiplayerMenu.layout	(revision 7161)
@@ -16,5 +16,5 @@
             <Property Name="VertFormatting" Value="TopAligned" />
             <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
-            <Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerLevelListbox" >
+            <Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerListbox" >
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.8,0}}" />
Index: /code/branches/presentation3/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- /code/branches/presentation3/data/gui/scripts/MultiplayerMenu.lua	(revision 7160)
+++ /code/branches/presentation3/data/gui/scripts/MultiplayerMenu.lua	(revision 7161)
@@ -4,6 +4,72 @@
 
 function P.onLoad()
-    listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox")
-    preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
+    P.multiplayerMode = "startClient"
+end
+
+function P.onShow()
+    if P.multiplayerMode == "startClient" then
+        local window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
+        local button = tolua.cast(window,"CEGUI::RadioButton")
+        button:setSelected(true)
+        P.showServerList()
+    end
+    if P.multiplayerMode == "startServer" then
+        local window = winMgr:getWindow("orxonox/MultiplayerHostButton")
+        local button = tolua.cast(window,"CEGUI::RadioButton")
+        button:setSelected(true)
+        P.showLevelList()
+    end
+    if P.multiplayerMode == "startDedicated" then
+        local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
+        local button = tolua.cast(window,"CEGUI::RadioButton")
+        button:setSelected(true)
+        P.showLevelList()
+    end
+end
+
+function P.MultiplayerJoinButton_clicked(e)
+    P.multiplayerMode = "startClient"
+    P.showServerList()
+end
+
+function P.MultiplayerHostButton_clicked(e)
+    P.multiplayerMode = "startServer"
+    P.showLevelList()
+end
+
+function P.MultiplayerDedicatedButton_clicked(e)
+    P.multiplayerMode = "startDedicated"
+    P.showLevelList()
+end
+
+function P.MultiplayerStartButton_clicked(e)
+    local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem()
+    if P.multiplayerMode == "startClient" then
+        if choice then
+            local client = orxonox.Client:getInstance()
+            local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID()
+            client:setDestination( P.serverList[index][2], 55556 )
+        else
+            return
+        end
+    else
+        if choice then
+            orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
+        else
+            return
+        end
+    end
+    orxonox.execute(P.multiplayerMode)
+    hideAllMenuSheets()
+end
+
+function P.MultiplayerBackButton_clicked(e)
+    hideMenuSheet(P.name)
+end
+
+function P.showLevelList()
+    local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
+    CEGUI.toListbox(listbox):resetList()
+    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     orxonox.LevelManager:getInstance():compileAvailableLevelList()
     local levelList = {}
@@ -19,7 +85,10 @@
     end
     table.sort(levelList)
+    index = 1
     for k,v in pairs(levelList) do
-        item = CEGUI.createListboxTextItem(v)
+        local item = CEGUI.createListboxTextItem(v)
         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+        item:setID(index)
+        index = index + 1
         CEGUI.toListbox(listbox):addItem(item)
         if v .. ".oxw" == preselect then
@@ -27,45 +96,35 @@
         end
     end
-    local multiplayerMode = "startClient"
-    if multiplayerMode == "startClient" then
-        window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
-        button = tolua.cast(window,"CEGUI::RadioButton")
-        button:setSelected(true)
     end
-    if multiplayerMode == "startServer" then
-        window = winMgr:getWindow("orxonox/MultiplayerHostButton")
-        button = tolua.cast(window,"CEGUI::RadioButton")
-        button:setSelected(true)
+    
+function P.showServerList()
+    local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
+    CEGUI.toListbox(listbox):resetList()
+    local discovery = orxonox.LANDiscovery:getInstance()
+    discovery:discover()
+    P.serverList = {}
+    local index = 0
+    local servername = ""
+    local serverip = ""
+    while true do
+        servername = discovery:getServerListItemName(index)
+        if servername == "" then
+            break
+        end
+        serverip = discovery:getServerListItemIP(index)
+        if serverip == "" then
+          break
+        end
+        table.insert(P.serverList, {servername, serverip})
+        index = index + 1
     end
-    if multiplayerMode == "startDedicated" then
-        window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
-        button = tolua.cast(window,"CEGUI::RadioButton")
-        button:setSelected(true)
+    index = 1
+    for k,v in pairs(P.serverList) do
+        local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] )
+        item:setID(index)
+        index = index + 1
+        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+        CEGUI.toListbox(listbox):addItem(item)
     end
-end
-
-function P.MultiplayerJoinButton_clicked(e)
-    multiplayerMode = "startClient"
-end
-
-function P.MultiplayerHostButton_clicked(e)
-    multiplayerMode = "startServer"
-end
-
-function P.MultiplayerDedicatedButton_clicked(e)
-    multiplayerMode = "startDedicated"
-end
-
-function P.MultiplayerStartButton_clicked(e)
-    local choice = winMgr:getWindow("orxonox/MultiplayerLevelListbox"):getFirstSelectedItem()
-    if choice then
-        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
-        orxonox.execute(multiplayerMode)
-        hideAllMenuSheets()
-    end
-end
-
-function P.MultiplayerBackButton_clicked(e)
-    hideMenuSheet(P.name)
 end
 
Index: /code/branches/presentation3/src/libraries/network/CMakeLists.txt
===================================================================
--- /code/branches/presentation3/src/libraries/network/CMakeLists.txt	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/CMakeLists.txt	(revision 7161)
@@ -29,4 +29,6 @@
   GamestateClient.cc
   GamestateHandler.cc
+  LANDiscoverable.cc
+  LANDiscovery.cc
   NetworkFunction.cc
   Host.cc
@@ -48,4 +50,6 @@
   GamestateManager.h
   Host.h
+  LANDiscoverable.h
+  LANDiscovery.h
   NetworkFunction.h
   NetworkPrecompiledHeaders.h
@@ -60,4 +64,7 @@
 
 ORXONOX_ADD_LIBRARY(network
+  TOLUA_FILES
+    Client.h
+    LANDiscovery.h
   PCH_FILE
     NetworkPrecompiledHeaders.h
Index: /code/branches/presentation3/src/libraries/network/Client.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/Client.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Client.cc	(revision 7161)
@@ -50,9 +50,12 @@
 #include "FunctionCallManager.h"
 #include "core/CoreIncludes.h"
+#include "core/CommandLineParser.h"
 #include "core/Game.h"
+#include "core/ScopedSingletonManager.h"
 
 namespace orxonox
 {
 
+  ManageScopedSingleton( Client, ScopeID::Root, true );
 
   /**
@@ -61,25 +64,14 @@
   */
   Client::Client():
+      gamestate(0),
       isSynched_(false),
       gameStateFailure_(false),
       timeSinceLastUpdate_(0)
   {
-  }
-
-  /**
-  * Constructor for the Client class
-  * @param address the server address
-  * @param port port of the application on the server
-  */
-  Client::Client(const std::string& address, int port):
-      isSynched_(false),
-      gameStateFailure_(false),
-      timeSinceLastUpdate_(0)
-  {
-      setPort( port );
-      setServerAddress( address );
-  }
-
-  Client::~Client(){
+    this->setDestination( CommandLineParser::getValue("dest").getString(), CommandLineParser::getValue("port") );
+  }
+
+  Client::~Client()
+  {
     if ( ClientConnection::isConnected() )
       closeConnection();
@@ -90,7 +82,15 @@
   * @return true/false
   */
-  bool Client::establishConnection(){
+  bool Client::establishConnection()
+  {
     Synchronisable::setClient(true);
-    return ClientConnection::establishConnection();
+    this->gamestate = new GamestateClient();
+    if( ClientConnection::establishConnection() )
+    {
+      Host::setActive(true);
+      return true;
+    }
+    else
+      return false;
   }
 
@@ -99,9 +99,21 @@
   * @return true/false
   */
-  bool Client::closeConnection(){
+  bool Client::closeConnection()
+  {
+    assert(this->gamestate);
+    delete this->gamestate;
+    this->gamestate = 0;
+    Host::setActive(false);
     return ClientConnection::closeConnection();
   }
-
-  bool Client::queuePacket(ENetPacket *packet, int clientID){
+  
+  void Client::setDestination(const std::string& serverAddress, unsigned int port)
+  {
+    ClientConnection::setServerAddress(serverAddress);
+    ClientConnection::setPort(port);
+  }
+
+  bool Client::queuePacket(ENetPacket *packet, int clientID)
+  {
     bool b = ClientConnection::addPacket(packet);
     assert(b);
@@ -109,10 +121,12 @@
   }
 
-  bool Client::processChat(const std::string& message, unsigned int playerID){
+  bool Client::processChat(const std::string& message, unsigned int playerID)
+  {
 //    COUT(1) << "Player " << playerID << ": " << message << std::endl;
     return true;
   }
 
-  void Client::printRTT(){
+  void Client::printRTT()
+  {
     COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
   }
@@ -123,5 +137,6 @@
    * @return result(true/false)
    */
-  bool Client::chat(const std::string& message){
+  bool Client::chat(const std::string& message)
+  {
     packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
     return m->send();
@@ -133,5 +148,6 @@
    * @param time
    */
-  void Client::update(const Clock& time){
+  void Client::update(const Clock& time)
+  {
     //this steers our network frequency
     timeSinceLastUpdate_+=time.getDeltaTime();
@@ -143,5 +159,5 @@
       {
         COUT(4) << "popping partial gamestate: " << std::endl;
-        packet::Gamestate *gs = gamestate.getGamestate();
+        packet::Gamestate *gs = gamestate->getGamestate();
         //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
         if(gs){
@@ -157,10 +173,10 @@
 
     Connection::processQueue();
-    if(gamestate.processGamestates())
+    if(gamestate->processGamestates())
     {
       if(!isSynched_)
         isSynched_=true;
     }
-    gamestate.cleanup();
+    gamestate->cleanup();
     Connection::sendPackets();
 
@@ -184,3 +200,5 @@
   }
 
+
+
 }
Index: /code/branches/presentation3/src/libraries/network/Client.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/Client.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Client.h	(revision 7161)
@@ -47,10 +47,15 @@
 
 #include "util/UtilPrereqs.h"
+#include "util/Singleton.h"
 #include "ClientConnection.h"
 #include "GamestateClient.h"
 #include "Host.h"
+#include "LANDiscovery.h"
+#include "packet/ServerInformation.h"
 
+// tolua_begin
 namespace orxonox
 {
+// tolua_end
   /**
   Client *client;
@@ -60,11 +65,16 @@
   *
   */
-  class _NetworkExport Client : public Host, public ClientConnection{
+  class _NetworkExport Client // tolua_export
+    : public Host, protected ClientConnection, public Singleton<Client>
+  { // tolua_export
+  friend class Singleton<Client>;
   public:
     Client();
-    Client(const std::string& address, int port);
     ~Client();
+    
+    static Client* getInstance(){ return singletonPtr_s; } // tolua_export
 
     bool establishConnection();
+    void setDestination( const std::string& serverAddress, unsigned int port ); // tolua_export
     bool closeConnection();
     bool queuePacket(ENetPacket *packet, int clientID);
@@ -81,13 +91,14 @@
     virtual bool isServer_(){return false;}
 
-    GamestateClient gamestate;
+    static Client* singletonPtr_s;
+    GamestateClient* gamestate;
     bool isSynched_;
 
     bool gameStateFailure_;
     float timeSinceLastUpdate_;
-  };
+  }; // tolua_export
 
 
-}
+} // tolua_export
 
 #endif /* _Client_H__ */
Index: /code/branches/presentation3/src/libraries/network/Connection.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/Connection.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Connection.cc	(revision 7161)
@@ -36,11 +36,11 @@
 namespace orxonox
 {
-  Connection *Connection::instance_=0;
+//   Connection *Connection::instance_=0;
 
   Connection::Connection():
     host_(0)
   {
-    assert(instance_==0);
-    Connection::instance_=this;
+//     assert(instance_==0);
+//     Connection::instance_=this;
     enet_initialize();
     atexit(enet_deinitialize);
@@ -48,5 +48,5 @@
 
   Connection::~Connection(){
-    Connection::instance_=0;
+//     Connection::instance_=0;
   }
 
@@ -67,5 +67,5 @@
 
   bool Connection::sendPackets() {
-    if ( !Connection::instance_ || this->host_==NULL )
+    if ( /*!Connection::instance_ || */this->host_==NULL )
       return false;
     enet_host_flush(this->host_);
Index: /code/branches/presentation3/src/libraries/network/Connection.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/Connection.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Connection.h	(revision 7161)
@@ -61,5 +61,5 @@
   protected:
     Connection();
-    static Connection* getInstance(){ return Connection::instance_; }
+//     static Connection* getInstance(){ return Connection::instance_; }
 
     int service(ENetEvent* event);
@@ -75,5 +75,5 @@
     ENetAddress *bindAddress_;
 
-    static Connection *instance_;
+//     static Connection *instance_;
 
   };
Index: /code/branches/presentation3/src/libraries/network/Host.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/Host.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Host.cc	(revision 7161)
@@ -38,81 +38,127 @@
 namespace orxonox {
 
-SetConsoleCommandShortcut(Host, Chat);
+  SetConsoleCommandShortcut(Host, Chat);
 
-Host *Host::instance_=0;
+  // Host*               Host::instance_=0;
+  uint32_t            Host::clientID_s=0;
+  uint32_t            Host::shipID_s=-1;
+  std::vector<Host*>  Host::instances_s;
 
-/**
- * @brief Constructor: assures that only one reference will be created and sets the pointer
- */
-Host::Host()
-{
-  clientID_=0;
-  assert(instance_==0);
-  instance_=this;
-  this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" );
-  CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ );
-}
+  /**
+  * @brief Constructor: assures that only one reference will be created and sets the pointer
+  */
+  Host::Host()
+  {
+  //   assert(instance_==0);
+    instances_s.push_back(this);
+    this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" );
+    CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ );
+    this->bIsActive_ = false;
+  }
 
 
-/**
- * @brief Destructor: resets the instance pointer to 0
- */
-Host::~Host()
-{
-  instance_=0;
-  if( this->printRTTCC_ )
-    delete this->printRTTCC_;
-}
+  /**
+  * @brief Destructor: resets the instance pointer to 0
+  */
+  Host::~Host()
+  {
+    assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
+    instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
+    if( this->printRTTCC_ )
+      delete this->printRTTCC_;
+  }
 
-/**
- * This function is used to add an enetpacket to be sent to another peer
- * @param packet Packet to be added
- * @param clientID ID of the client the packet should be sent to
- * @return success?
- */
-bool Host::addPacket(ENetPacket *packet, int clientID){
-  if(instance_)
-    return instance_->queuePacket(packet, clientID);
-  else
-    return false;
-}
+  /**
+  * This function is used to add an enetpacket to be sent to another peer
+  * @param packet Packet to be added
+  * @param clientID ID of the client the packet should be sent to
+  * @return success?
+  */
+  bool Host::addPacket(ENetPacket *packet, int clientID)
+  {
+    bool result = true;
+    for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+    {
+      if( (*it)->isActive() )
+      {
+        if( !(*it)->queuePacket(packet, clientID) )
+          result = false;
+      }
+    }
+    return result;
+  }
 
-/**
- * This function returns the ID of the player
- * @return playerID
- */
-unsigned int Host::getPlayerID(){
-  if(!instance_)
-    return 0;
-  return instance_->clientID_;
-}
+  bool Host::Chat(const std::string& message)
+  {
+    if(instances_s.size()==0)
+    {
+      for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
+        it->incomingChat(message, 0);
+      return true;
+    }
+    else
+    {
+      bool result = true;
+      for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+      {
+        if( (*it)->isActive() )
+        {
+          if( !(*it)->chat(message) )
+            result = false;
+        }
+      }
+      return result;
+    }
+  }
 
-bool Host::Chat(const std::string& message){
-  if(!instance_)
+  bool Host::Broadcast(const std::string& message)
+  {
+    if(instances_s.size()==0)
+    {
+      for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
+        it->incomingChat(message, CLIENTID_UNKNOWN);
+      return true;
+    }
+    else
+    {
+      bool result = true;
+      for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+      {
+        if( (*it)->isActive() )
+        {
+          if( !(*it)->broadcast(message) )
+            result = false;
+        }
+      }
+      return result;
+    }
+  }
+
+  bool Host::incomingChat(const std::string& message, unsigned int playerID)
   {
     for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
-      it->incomingChat(message, 0);
-    return true;
+      it->incomingChat(message, playerID);
+    
+    bool result = true;
+    for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+    {
+      if( (*it)->isActive() )
+      {
+        if( !(*it)->processChat(message, playerID) )
+          result = false;
+      }
+    }
+    return result;
   }
-  return instance_->chat(message);
-}
 
-bool Host::Broadcast(const std::string& message){
-  if(!instance_)
+  bool Host::isServer()
   {
-    for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
-      it->incomingChat(message, CLIENTID_UNKNOWN);
-    return true;
+    for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it )
+    {
+      if( (*it)->isServer_() )
+        return true;
+    }
+    return false;
   }
-  else
-    return instance_->broadcast(message);
-}
-
-bool Host::incomingChat(const std::string& message, unsigned int playerID){
-  for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
-    it->incomingChat(message, playerID);
-
-  return instance_->processChat(message, playerID);
-}
 
 }//namespace orxonox
Index: /code/branches/presentation3/src/libraries/network/Host.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/Host.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Host.h	(revision 7161)
@@ -33,4 +33,6 @@
 #include "core/CorePrereqs.h"
 
+#include <vector>
+
 namespace orxonox {
 
@@ -63,24 +65,29 @@
     Host();
     virtual ~Host();
-    static Host *instance_;
-    unsigned int clientID_;
-    unsigned int shipID_;
+    void setActive( bool bActive ){ bIsActive_ = bActive; }
+//     static Host *instance_;
 
   public:
-    static bool running(){return instance_!=0;}
+//     static Host* getInstance(){ return instance_; }
+    static bool running(){ return instances_s.size(); }
     static bool addPacket(ENetPacket *packet, int clientID=0);
     //static bool chat(std::string& message);
 //     static bool receiveChat(packet::Chat *message, unsigned int clientID);
-    static unsigned int getPlayerID();
-    static unsigned int getShipID(){return instance_->shipID_;}
-    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
-    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
-    static bool isServer(){ return instance_->isServer_(); }
+    static unsigned int getPlayerID(){ return clientID_s; }
+    static unsigned int getShipID(){return shipID_s;}
+    static void setClientID(unsigned int id){ clientID_s = id; }
+    static void setShipID(unsigned int id){ shipID_s = id; }
+    static bool isServer();
     static bool Chat(const std::string& message);
     static bool Broadcast(const std::string& message);
     static bool incomingChat(const std::string& message, unsigned int playerID);
     virtual void printRTT()=0;
+    bool isActive(){ return bIsActive_; }
   private:
     ConsoleCommand* printRTTCC_;
+    static uint32_t clientID_s;
+    static uint32_t shipID_s;
+    static std::vector<Host*> instances_s;
+    bool bIsActive_;
 };
 
Index: /code/branches/presentation3/src/libraries/network/LANDiscoverable.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/LANDiscoverable.cc	(revision 7161)
+++ /code/branches/presentation3/src/libraries/network/LANDiscoverable.cc	(revision 7161)
@@ -0,0 +1,109 @@
+/*
+ *   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:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "LANDiscoverable.h"
+
+#include "NetworkPrereqs.h"
+#include "packet/ServerInformation.h"
+
+#include <enet/enet.h>
+#include <cassert>
+#include <cstring>
+
+namespace orxonox
+{
+  const char* LAN_DISCOVERY_MESSAGE = "Orxonox Client";
+  const char* LAN_DISCOVERY_ACK     = "Orxonox Server Ack";
+
+  LANDiscoverable::LANDiscoverable()
+  {
+    this->host_ = 0;
+    this->bActive_ = false;
+    this->setActivity(true);
+  }
+
+  LANDiscoverable::~LANDiscoverable()
+  {
+    if( this->host_ )
+    {
+      enet_host_destroy( this->host_ );
+      assert( this->bActive_ );
+    }
+  }
+
+  void LANDiscoverable::setActivity(bool bActive)
+  {
+    if( bActive == this->bActive_ )        // no change
+      return;
+    
+    if( bActive )
+    {
+      ENetAddress bindAddress = { ENET_HOST_ANY, LAN_DISCOVERY_PORT };
+      assert( this->host_ == 0 );
+      this->host_ = enet_host_create( &bindAddress, 10, 0, 0 );
+    }
+    else
+    {
+      enet_host_destroy( this->host_ );
+      this->host_ = 0;
+    }
+      this->bActive_ = bActive;
+  }
+
+  void LANDiscoverable::update()
+  {
+    ENetEvent event;
+    
+    if( this->bActive_==false )
+      return;
+    assert(this->host_);
+    
+    while( enet_host_service( this->host_, &event, 0 ) > 0 )
+    {
+      switch(event.type)
+      {
+        case ENET_EVENT_TYPE_CONNECT:
+        case ENET_EVENT_TYPE_DISCONNECT:
+        case ENET_EVENT_TYPE_NONE:
+          break;
+        case ENET_EVENT_TYPE_RECEIVE:
+          if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 )      // check for a suitable orxonox client
+          {
+            packet::ServerInformation info;
+            info.setServerName("Orxonox Server");
+            info.send(event.peer);
+//             ENetPacket* packet = enet_packet_create( LAN_DISCOVERY_ACK, strlen(LAN_DISCOVERY_ACK)+1, ENET_PACKET_FLAG_RELIABLE );
+//             enet_peer_send(event.peer, 0, packet );
+            enet_host_flush(this->host_);
+          }
+          break;
+      }
+    }
+  }
+
+}
Index: /code/branches/presentation3/src/libraries/network/LANDiscoverable.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/LANDiscoverable.h	(revision 7161)
+++ /code/branches/presentation3/src/libraries/network/LANDiscoverable.h	(revision 7161)
@@ -0,0 +1,52 @@
+/*
+ *   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:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _LANDISCOVERABLE_H__
+#define _LANDISCOVERABLE_H__
+
+#include "NetworkPrereqs.h"
+
+namespace orxonox
+{
+  
+  class LANDiscoverable
+  {
+    public:
+      LANDiscoverable();
+      ~LANDiscoverable();
+      void setActivity( bool bActive );
+      void update();
+      
+    private:
+      bool            bActive_;
+      ENetHost*       host_;
+  };
+
+}
+
+#endif // LANDISCOVERABLE_H
Index: /code/branches/presentation3/src/libraries/network/LANDiscovery.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/LANDiscovery.cc	(revision 7161)
+++ /code/branches/presentation3/src/libraries/network/LANDiscovery.cc	(revision 7161)
@@ -0,0 +1,113 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "LANDiscovery.h"
+
+#include <enet/enet.h>
+#include <cstring>
+
+#include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
+
+
+namespace orxonox
+{ 
+  ManageScopedSingleton(LANDiscovery, ScopeID::Root, true);
+  
+  LANDiscovery::LANDiscovery()
+  {
+    this->host_ = enet_host_create(NULL, 10, 0, 0 );
+  }
+
+  LANDiscovery::~LANDiscovery()
+  {
+    enet_host_destroy(this->host_);
+  }
+  
+  void LANDiscovery::discover()
+  {
+    this->servers_.clear();
+    ENetAddress address;
+    enet_address_set_host(&address, "255.255.255.255");
+    address.port = LAN_DISCOVERY_PORT;
+    
+    ENetPeer* peer;
+    peer = enet_host_connect(this->host_, &address, 0);
+    
+    ENetEvent event;
+    while( enet_host_service(this->host_, &event, 1000 ) )
+    {
+      switch( event.type )
+      {
+        case ENET_EVENT_TYPE_CONNECT:
+        {
+          COUT(0) << "connect from server: " << event.peer->address.host << endl;
+          ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE);
+          enet_peer_send(event.peer, 0, packet);
+          break;
+        }
+        case ENET_EVENT_TYPE_RECEIVE:
+          {
+            packet::ServerInformation info(&event);
+            COUT(0) << "received server information; name: " << info.getServerName() << ", IP: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
+            std::vector<packet::ServerInformation>::iterator it;
+            for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
+            {
+              if( (*it).getServerIP() == info.getServerIP() )
+                break;
+            }
+            if( it==this->servers_.end() )
+              this->servers_.push_back(info);
+          }
+//           enet_address_get_host_ip(&event.peer->address, buffer, buflen );
+//           serverIPs.push_back(std::string(buffer));
+          break;
+        default:
+          break;
+      }
+    }
+  }
+  
+  std::string LANDiscovery::getServerListItemName(unsigned int index)
+  {
+    if( index >= this->servers_.size() )
+      return BLANKSTRING;
+    else
+      return this->servers_[index].getServerName();
+  }
+  
+  std::string LANDiscovery::getServerListItemIP(unsigned int index)
+  {
+    if( index >= this->servers_.size() )
+      return BLANKSTRING;
+    else
+      return this->servers_[index].getServerIP();
+  }
+  
+  
+} // namespace orxonox
Index: /code/branches/presentation3/src/libraries/network/LANDiscovery.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/LANDiscovery.h	(revision 7161)
+++ /code/branches/presentation3/src/libraries/network/LANDiscovery.h	(revision 7161)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef LANDISCOVERY_H
+#define LANDISCOVERY_H
+
+#include "NetworkPrereqs.h"
+#include "packet/ServerInformation.h"
+#include "util/Singleton.h"
+
+#include <vector>
+
+// tolua_begin
+namespace orxonox
+{
+
+  class _NetworkExport LANDiscovery
+// tolua_end
+    : public Singleton<LANDiscovery>
+  { // tolua_export
+    friend class Singleton<LANDiscovery>;
+    public:
+      LANDiscovery();
+      ~LANDiscovery();
+      void discover(); // tolua_export
+      std::string getServerListItemName( unsigned int index ); // tolua_export
+      std::string getServerListItemIP( unsigned int index ); // tolua_export
+      static LANDiscovery& getInstance(){ return Singleton<LANDiscovery>::getInstance(); } // tolua_export
+      
+    private:
+      static LANDiscovery* singletonPtr_s;
+      ENetHost* host_;
+      std::vector<packet::ServerInformation> servers_;
+  }; // tolua_export
+
+} // tolua_export
+
+#endif // LANDISCOVERY_H
Index: /code/branches/presentation3/src/libraries/network/NetworkPrereqs.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/NetworkPrereqs.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/NetworkPrereqs.h	(revision 7161)
@@ -64,6 +64,9 @@
 namespace orxonox
 {
-  static const unsigned int GAMESTATEID_INITIAL = static_cast<unsigned int>(-1);
-  static const unsigned int CLIENTID_UNKNOWN    = static_cast<unsigned int>(-2);
+  static const unsigned int GAMESTATEID_INITIAL     = static_cast<unsigned int>(-1);
+  static const unsigned int CLIENTID_UNKNOWN        = static_cast<unsigned int>(-2);
+  extern const char* LAN_DISCOVERY_MESSAGE;
+  extern const char* LAN_DISCOVERY_ACK;
+  static const unsigned int LAN_DISCOVERY_PORT      = 55557;
 }
 
Index: /code/branches/presentation3/src/libraries/network/Server.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/Server.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Server.cc	(revision 7161)
@@ -69,9 +69,11 @@
   *
   */
-  Server::Server() {
+  Server::Server()
+  {
     this->timeSinceLastUpdate_=0;
   }
 
-  Server::Server(int port){
+  Server::Server(int port)
+  {
     this->setPort( port );
     this->timeSinceLastUpdate_=0;
@@ -83,5 +85,6 @@
   * @param bindAddress Address to listen on
   */
-  Server::Server(int port, const std::string& bindAddress) {
+  Server::Server(int port, const std::string& bindAddress)
+  {
     this->setPort( port );
     this->setBindAddress( bindAddress );
@@ -92,5 +95,6 @@
   * @brief Destructor
   */
-  Server::~Server(){
+  Server::~Server()
+  {
   }
 
@@ -98,7 +102,10 @@
   * This function opens the server by creating the listener thread
   */
-  void Server::open() {
+  void Server::open()
+  {
+    Host::setActive(true);
     COUT(4) << "opening server" << endl;
     this->openListener();
+    LANDiscoverable::setActivity(true);
     return;
   }
@@ -107,12 +114,16 @@
   * This function closes the server
   */
-  void Server::close() {
+  void Server::close()
+  {
+    Host::setActive(false);
     COUT(4) << "closing server" << endl;
     this->disconnectClients();
     this->closeListener();
+    LANDiscoverable::setActivity(false);
     return;
   }
 
-  bool Server::processChat(const std::string& message, unsigned int playerID){
+  bool Server::processChat(const std::string& message, unsigned int playerID)
+  {
     ClientInformation *temp = ClientInformation::getBegin();
     packet::Chat *chat;
@@ -134,7 +145,10 @@
   * @param time time since last tick
   */
-  void Server::update(const Clock& time) {
+  void Server::update(const Clock& time)
+  {
     // receive incoming packets
     Connection::processQueue();
+    // receive and process incoming discovery packets
+    LANDiscoverable::update();
 
     if ( ClientInformation::hasClients() )
@@ -157,5 +171,6 @@
   }
 
-  bool Server::queuePacket(ENetPacket *packet, int clientID){
+  bool Server::queuePacket(ENetPacket *packet, int clientID)
+  {
     return ServerConnection::addPacket(packet, clientID);
   }
@@ -164,5 +179,6 @@
    * @brief: returns ping time to client in milliseconds
    */
-  unsigned int Server::getRTT(unsigned int clientID){
+  unsigned int Server::getRTT(unsigned int clientID)
+  {
     assert(ClientInformation::findClient(clientID));
     return ClientInformation::findClient(clientID)->getRTT();
@@ -178,5 +194,6 @@
    * @brief: return packet loss ratio to client (scales from 0 to 1)
    */
-  double Server::getPacketLoss(unsigned int clientID){
+  double Server::getPacketLoss(unsigned int clientID)
+  {
     assert(ClientInformation::findClient(clientID));
     return ClientInformation::findClient(clientID)->getPacketLoss();
@@ -186,5 +203,6 @@
   * takes a new snapshot of the gamestate and sends it to the clients
   */
-  void Server::updateGamestate() {
+  void Server::updateGamestate()
+  {
     if( ClientInformation::getBegin()==NULL )
       //no client connected
@@ -208,5 +226,6 @@
   * sends the gamestate
   */
-  bool Server::sendGameState() {
+  bool Server::sendGameState()
+  {
 //     COUT(5) << "Server: starting function sendGameState" << std::endl;
 //     ClientInformation *temp = ClientInformation::getBegin();
@@ -244,5 +263,6 @@
   }
 
-  bool Server::sendObjectDeletes(){
+  bool Server::sendObjectDeletes()
+  {
     ClientInformation *temp = ClientInformation::getBegin();
     if( temp == NULL )
@@ -257,5 +277,6 @@
 //     COUT(3) << "sending DeleteObjects" << std::endl;
     while(temp != NULL){
-      if( !(temp->getSynched()) ){
+      if( !(temp->getSynched()) )
+      {
         COUT(5) << "Server: not sending gamestate" << std::endl;
         temp=temp->next();
@@ -276,10 +297,12 @@
 
 
-  void Server::addPeer(ENetEvent *event){
+  void Server::addPeer(ENetEvent *event)
+  {
     static unsigned int newid=1;
 
     COUT(2) << "Server: adding client" << std::endl;
     ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
-    if(!temp){
+    if(!temp)
+    {
       COUT(2) << "Server: could not add client" << std::endl;
     }
@@ -310,7 +333,9 @@
   }
 
-  bool Server::createClient(int clientID){
+  bool Server::createClient(int clientID)
+  {
     ClientInformation *temp = ClientInformation::findClient(clientID);
-    if(!temp){
+    if(!temp)
+    {
       COUT(2) << "Conn.Man. could not create client with id: " << clientID << std::endl;
       return false;
@@ -345,5 +370,6 @@
   }
 
-  void Server::disconnectClient( ClientInformation *client ){
+  void Server::disconnectClient( ClientInformation *client )
+  {
     ServerConnection::disconnectClient( client );
     GamestateManager::removeClient(client);
@@ -352,16 +378,20 @@
   }
 
-  bool Server::chat(const std::string& message){
+  bool Server::chat(const std::string& message)
+  {
       return this->sendChat(message, Host::getPlayerID());
   }
 
-  bool Server::broadcast(const std::string& message){
+  bool Server::broadcast(const std::string& message)
+  {
       return this->sendChat(message, CLIENTID_UNKNOWN);
   }
 
-  bool Server::sendChat(const std::string& message, unsigned int clientID){
+  bool Server::sendChat(const std::string& message, unsigned int clientID)
+  {
     ClientInformation *temp = ClientInformation::getBegin();
     packet::Chat *chat;
-    while(temp){
+    while(temp)
+    {
       chat = new packet::Chat(message, clientID);
       chat->setClientID(temp->getID());
@@ -377,5 +407,6 @@
   }
 
-  void Server::syncClassid(unsigned int clientID) {
+  void Server::syncClassid(unsigned int clientID)
+  {
     int failures=0;
     packet::ClassID *classid = new packet::ClassID();
Index: /code/branches/presentation3/src/libraries/network/Server.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/Server.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/Server.h	(revision 7161)
@@ -37,4 +37,5 @@
 #include "GamestateManager.h"
 #include "ServerConnection.h"
+#include "LANDiscoverable.h"
 
 namespace orxonox
@@ -45,5 +46,5 @@
   * It implements all functions necessary for a Server
   */
-  class _NetworkExport Server : public Host, public ServerConnection, public GamestateManager{
+  class _NetworkExport Server : public Host, public ServerConnection, public GamestateManager, public LANDiscoverable{
   public:
     Server();
Index: /code/branches/presentation3/src/libraries/network/ServerConnection.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/ServerConnection.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/ServerConnection.cc	(revision 7161)
@@ -94,7 +94,7 @@
 
   bool ServerConnection::addPacketAll(ENetPacket *packet) {
-    if ( !Connection::getInstance() )
-      return false;
-    enet_host_broadcast( Connection::getInstance()->getHost(), 0, packet);
+//     if ( !Connection::getInstance() )
+//       return false;
+    enet_host_broadcast( Connection::getHost(), 0, packet);
     return true;
   }
Index: /code/branches/presentation3/src/libraries/network/ServerConnection.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/ServerConnection.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/ServerConnection.h	(revision 7161)
@@ -56,6 +56,6 @@
     bool openListener();
     bool closeListener();
-    static bool addPacket(ENetPacket *packet, unsigned int ID);
-    static bool addPacketAll(ENetPacket *packet);
+    bool addPacket(ENetPacket *packet, unsigned int ID);
+    bool addPacketAll(ENetPacket *packet);
     virtual void disconnectClient(ClientInformation *client);
     void disconnectClient(int clientID);
Index: /code/branches/presentation3/src/libraries/network/packet/CMakeLists.txt
===================================================================
--- /code/branches/presentation3/src/libraries/network/packet/CMakeLists.txt	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/packet/CMakeLists.txt	(revision 7161)
@@ -11,4 +11,5 @@
   Welcome.cc
 COMPILATION_END
+  ServerInformation.cc
 )
 
@@ -23,4 +24,5 @@
   Gamestate.h
   Packet.h
+  ServerInformation.h
   Welcome.h
 )
Index: /code/branches/presentation3/src/libraries/network/packet/Packet.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/packet/Packet.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/packet/Packet.cc	(revision 7161)
@@ -62,5 +62,6 @@
 std::map<size_t, Packet *> Packet::packetMap_;
 
-Packet::Packet(){
+Packet::Packet()
+{
   flags_ = PACKET_FLAG_DEFAULT;
   packetDirection_ = Direction::Outgoing;
@@ -71,5 +72,6 @@
 }
 
-Packet::Packet(uint8_t *data, unsigned int clientID){
+Packet::Packet(uint8_t *data, unsigned int clientID)
+{
   flags_ = PACKET_FLAG_DEFAULT;
   packetDirection_ = Direction::Incoming;
Index: /code/branches/presentation3/src/libraries/network/packet/ServerInformation.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/packet/ServerInformation.cc	(revision 7161)
+++ /code/branches/presentation3/src/libraries/network/packet/ServerInformation.cc	(revision 7161)
@@ -0,0 +1,84 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ServerInformation.h"
+
+#include <enet/enet.h>
+#include <cassert>
+#include <cstring>
+
+#include "util/Serialise.h"
+
+namespace orxonox
+{
+  namespace packet
+  {
+    
+    ServerInformation::ServerInformation()
+    {
+      
+    }
+    
+    ServerInformation::ServerInformation(ENetEvent* event)
+    {
+      // Save Server Round Trip Time
+      this->serverRTT_ = event->peer->roundTripTime;
+      // Save Server IP
+      char* serverIP = new char[16];
+      enet_address_get_host_ip(&event->peer->address, serverIP, 16);
+      this->serverIP_ = std::string(serverIP);
+      // Save ACK
+      uint8_t* temp = event->packet->data;
+      char* ack = new char[strlen(LAN_DISCOVERY_ACK)+1];
+      loadAndIncrease((char*&)ack, temp);
+      assert(strcmp(ack, (const char*)LAN_DISCOVERY_ACK)==0);
+      // Save Server Name
+      loadAndIncrease(this->serverName_, temp);
+    }
+
+    ServerInformation::~ServerInformation()
+    {
+      
+    }
+
+    void ServerInformation::send(ENetPeer* peer)
+    {
+      uint32_t size = returnSize((char*&)LAN_DISCOVERY_ACK) + returnSize(this->serverName_);
+      uint8_t* temp = new uint8_t[size];
+      uint8_t* temp2 = temp;
+      saveAndIncrease((char*&)LAN_DISCOVERY_ACK, temp2);
+      saveAndIncrease(this->serverName_, temp2);
+      ENetPacket* packet = enet_packet_create( temp, size, 0 );
+      enet_peer_send(peer, 0, packet);
+      
+      delete[] temp;
+    }
+  
+  } // namespace packet
+} // namespace orxonox
+
Index: /code/branches/presentation3/src/libraries/network/packet/ServerInformation.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/packet/ServerInformation.h	(revision 7161)
+++ /code/branches/presentation3/src/libraries/network/packet/ServerInformation.h	(revision 7161)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "../NetworkPrereqs.h"
+
+#include <string>
+
+#ifndef SERVERINFORMATION_H
+#define SERVERINFORMATION_H
+
+namespace orxonox
+{
+  namespace packet
+  {
+
+    class ServerInformation
+    {
+      public:
+        ServerInformation();
+        ServerInformation(ENetEvent* event);
+        ~ServerInformation();
+        
+        void          send( ENetPeer* peer );
+        std::string   getServerIP() { return this->serverIP_; }
+        std::string   getServerName() { return this->serverName_; }
+        void          setServerName(std::string name) { this->serverName_ = name; }
+        uint32_t      getServerRTT() { return this->serverRTT_; }
+        
+      private:
+        std::string   serverName_;
+        std::string   serverIP_;
+        uint32_t      serverRTT_;
+    };
+
+  }
+}
+
+#endif // SERVERINFORMATION_H
Index: /code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc	(revision 7160)
+++ /code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc	(revision 7161)
@@ -54,5 +54,5 @@
     static uint32_t idCounter=0;
     objectMode_=0x1; // by default do not send data to server
-    if ( GameMode::isMaster() || ( Host::running() && Host::isServer() ) )
+    if ( GameMode::isMaster()/* || ( Host::running() && Host::isServer() )*/ )
     {
       this->setObjectID( idCounter++ );
Index: /code/branches/presentation3/src/libraries/util/Serialise.h
===================================================================
--- /code/branches/presentation3/src/libraries/util/Serialise.h	(revision 7160)
+++ /code/branches/presentation3/src/libraries/util/Serialise.h	(revision 7161)
@@ -53,4 +53,33 @@
     template <class T> inline bool checkEquality( const T& variable, uint8_t* mem );
 
+  
+  // =========== char*
+    
+  inline uint32_t returnSize( char*& variable )
+  {
+    return strlen(variable)+1;
+  }
+      
+  inline void saveAndIncrease( char*& variable, uint8_t*& mem )
+  {
+    strcpy((char*)mem, variable);
+    mem += returnSize(variable);
+  }
+        
+  inline void loadAndIncrease( char*& variable, uint8_t*& mem )
+  {
+    if( variable )
+      delete variable;
+    uint32_t len = strlen((char*)mem)+1;
+    variable = new char[len];
+    strcpy((char*)variable, (char*)mem);
+    mem += len;
+  }
+          
+  inline bool checkEquality( char*& variable, uint8_t* mem )
+  {
+    return strcmp(variable, (char*)mem)==0;
+  }
+    
 // =================== Template specialisation stuff =============
 
@@ -394,5 +423,5 @@
         return memcmp(&temp, mem, sizeof(uint64_t))==0;
     }
-
+        
 // =========== string
 
Index: /code/branches/presentation3/src/orxonox/CameraManager.cc
===================================================================
--- /code/branches/presentation3/src/orxonox/CameraManager.cc	(revision 7160)
+++ /code/branches/presentation3/src/orxonox/CameraManager.cc	(revision 7161)
@@ -68,4 +68,5 @@
     void CameraManager::requestFocus(Camera* camera)
     {
+      COUT(0) << "bliub" << endl;
         // notify old camera (if it exists)
         if (!this->cameraList_.empty())
Index: /code/branches/presentation3/src/orxonox/Main.cc
===================================================================
--- /code/branches/presentation3/src/orxonox/Main.cc	(revision 7160)
+++ /code/branches/presentation3/src/orxonox/Main.cc	(revision 7161)
@@ -40,4 +40,5 @@
 #include "core/LuaState.h"
 #include "ToluaBindOrxonox.h"
+#include "ToluaBindNetwork.h"
 #include "Main.h"
 
@@ -51,4 +52,5 @@
 
 DeclareToluaInterface(Orxonox);
+DeclareToluaInterface(Network);
 
 namespace orxonox
Index: /code/branches/presentation3/src/orxonox/gamestates/GSClient.cc
===================================================================
--- /code/branches/presentation3/src/orxonox/gamestates/GSClient.cc	(revision 7160)
+++ /code/branches/presentation3/src/orxonox/gamestates/GSClient.cc	(revision 7161)
@@ -44,5 +44,4 @@
     GSClient::GSClient(const GameStateInfo& info)
         : GameState(info)
-        , client_(0)
     {
     }
@@ -56,21 +55,21 @@
         GameMode::setIsClient(true);
 
-        this->client_ = new Client(CommandLineParser::getValue("dest").getString(), CommandLineParser::getValue("port"));
+//         this->client_ = new Client();
+//         this->client_->setDestination(CommandLineParser::getValue("dest").getString(), CommandLineParser::getValue("port") );
 
-        if(!client_->establishConnection())
+        if( !Client::getInstance()->establishConnection() )
         {
-            delete this->client_;
             ThrowException(InitialisationFailed, "Could not establish connection with server.");
         }
 
-        client_->update(Game::getInstance().getGameClock());
+        Client::getInstance()->update(Game::getInstance().getGameClock());
     }
 
     void GSClient::deactivate()
     {
-        client_->closeConnection();
+        Client::getInstance()->closeConnection();
 
         // destroy client
-        delete this->client_;
+//         delete this->client_;
 
         GameMode::setIsClient(false);
@@ -79,5 +78,5 @@
     void GSClient::update(const Clock& time)
     {
-        client_->update(time);
+        Client::getInstance()->update(time);
     }
 }
Index: /code/branches/presentation3/src/orxonox/gamestates/GSClient.h
===================================================================
--- /code/branches/presentation3/src/orxonox/gamestates/GSClient.h	(revision 7160)
+++ /code/branches/presentation3/src/orxonox/gamestates/GSClient.h	(revision 7161)
@@ -46,7 +46,4 @@
         void deactivate();
         void update(const Clock& time);
-
-    private:
-        Client* client_;
     };
 }
