Index: /trunk/src/lib/collision_detection/aabb_tree_node.cc
===================================================================
--- /trunk/src/lib/collision_detection/aabb_tree_node.cc	(revision 9493)
+++ /trunk/src/lib/collision_detection/aabb_tree_node.cc	(revision 9494)
@@ -66,4 +66,6 @@
 {
   this->depth = depth;
+
+  this->init();
 }
 
@@ -87,10 +89,4 @@
 
   this->owner = NULL;
-
-  /* debug ids */
-  if( this->nodePrev)
-    this->treeIndex = 100 * this->depth + this->nodePrev->getID();
-  else
-    this->treeIndex = 0;
 }
 
Index: /trunk/src/lib/network/Makefile.am
===================================================================
--- /trunk/src/lib/network/Makefile.am	(revision 9493)
+++ /trunk/src/lib/network/Makefile.am	(revision 9494)
@@ -28,7 +28,8 @@
 		      proxy/network_settings.cc \
 		      \
-				  monitor/connection_monitor.cc \
+		      monitor/connection_monitor.cc \
 		      monitor/network_monitor.cc \
 		      monitor/network_node.cc \
+		      monitor/network_stats_widget.cc \
 		      \
 		      synchronizeable_var/synchronizeable_var.cc \
@@ -77,7 +78,8 @@
 		proxy/network_settings.cc \
 		\
-                monitor/connection_monitor.h \
-                monitor/network_monitor.h \
-                monitor/network_node.h \
+		monitor/connection_monitor.h \
+		monitor/network_monitor.h \
+		monitor/network_node.h \
+		monitor/network_stats_widget.h \
 		\
 		synchronizeable_var/synchronizeable_var.h \
Index: /trunk/src/lib/network/README.NETWORK
===================================================================
--- /trunk/src/lib/network/README.NETWORK	(revision 9493)
+++ /trunk/src/lib/network/README.NETWORK	(revision 9494)
@@ -1,2 +1,17 @@
+
+
+
+WORKING_STACK:
+==============
+ - it works to connecto to a master server which is connected to a proxy itself
+
+
+
+UNSOLVED:
+=========
+ - what if the proxy server gets a new client and wants to add it to the game? There are some problems waiting in the network game manager
+ - actualy the whole message sending system won't work in this network topic. proxys have to relay messages to clients
+ - the clients cant get its ip in the handleHandshakes without throuwing sigseg
+
 
 
@@ -8,13 +23,51 @@
 
 UserId:
+=======
 containing the id of a user (==client). This id must be unique within a orxonox network its used especialy in the NetworkStream for node identification and also in the Synchronizeable base class for permissions checking (PERMISSION_OWNER)
-WARNING:
-There is some correlation between userids and the maxplayer, do not touch this.
+
+the connections belonging tu toe userId's are stored in the NetworkStream::peers std::map. As a keyvalue the userId's are used. Therefore the usage of this peers map is very delicate. Don't ever try to add anything you are not sure about the id stuff.
+
+There are some reserved id's, don't mess with them:
+0 :                  Master Server
+1 :                  First Proxy Server
+2 :                  Second Proxy Server
+3 :                  Third Proxy Server
+4 :                  Fourth Proxy Server
+.
+.
+.
+NET_MAX_PROXY        The maximal number of proxy servers
+NET_MAX... + 1       First Client
+NET_MAX... + 2       Second Client
+.
+.
+.
+NET_MAX_CONNECTION   Last client
+
+The proxy server ids are assigned as stated in the data/trunk/config/network_settings.conf, the first proxy server in the list gets the id NET_ID_PROXY_01 and so on.
+
 
 
 uniqueId:
+=========
 uniqueId is an id (unique :D) for each synchronizeable to be identified in a network. the number space for uniqueIds goes from 0 to maxplayers - 1
 
 
+permissions:
+============
+Each synchronizeable variable has some write permissions. this permission systems allows to manage which network nodes are able to write the variables.
+PERMISSION_MASTER_SERVER       : only the master server can write this variable
+PERMISSION_PROXY_SERVER        : only the proxy server can write this variable
+PERMISSION_OWNER               : only the owner can write this variable
+PERMISSION_ALL                 : all clients can write this variable
+
+
+
+
+
 NetworkStream PeerInfo list: (peers)
+=====================================
 The network node with the offset 0 is always the server to which the client must connect to (in case there are connections to other hosts at the same time).
+
+
+
Index: /trunk/src/lib/network/handshake.cc
===================================================================
--- /trunk/src/lib/network/handshake.cc	(revision 9493)
+++ /trunk/src/lib/network/handshake.cc	(revision 9494)
@@ -76,5 +76,5 @@
   remoteState.orxId = 0;
   remoteState.version = 0;
-  remoteState.nodeType = NET_CLIENT;
+  remoteState.nodeType = NET_UNASSIGNED;
   remoteState.canDel = 0;
 
Index: /trunk/src/lib/network/handshake.h
===================================================================
--- /trunk/src/lib/network/handshake.h	(revision 9493)
+++ /trunk/src/lib/network/handshake.h	(revision 9494)
@@ -49,34 +49,34 @@
     /* functions indicating states of the handshake */
     /** @returns true if the handshake is completed */
-    inline bool completed(){ return localState.completed != 0 && remoteState.completed != 0; }
+    inline bool completed() const { return localState.completed != 0 && remoteState.completed != 0; }
     /** @returns true if no error has occured until now */
-    inline bool ok(){ return localState.error == 0 && remoteState.error == 0; }
+    inline bool ok() const { return localState.error == 0 && remoteState.error == 0; }
     /** stops the handshake and reject the other side with @param reason: string describing the reason */
     inline void doReject( std::string reason ){ localState.error = 1; localState.errorString = "the server rejected your connection ["+ reason +"]"; }
     /** @returns true if the handshake is finished and the instances can be deleted */
-    inline bool canDel(){ return localState.canDel == 1 && remoteState.canDel == 1; }
+    inline bool canDel() const { return localState.canDel == 1 && remoteState.canDel == 1; }
     /** @returns true if the local state can be removed*/
-    inline bool allowDel(){ return localState.canDel == 1; }
+    inline bool allowDel() const { return localState.canDel == 1; }
     /** marks the handshake to be deleted */
-    inline void del(){ localState.canDel = 1; }
+    inline void del() { localState.canDel = 1; }
 
 
     /* the actual informations exchanged in the handshake */
     /** @returns the host id of the remote host */
-    inline int  getHostId(){ return remoteState.hostId; }
+    inline int  getHostId() const { return remoteState.hostId; }
     /** @returns the unique id of the network game manager*/
-    inline int  getNetworkGameManagerId(){ return remoteState.networkManagerId; }
+    inline int  getNetworkGameManagerId() const { return remoteState.networkManagerId; }
     /** @returns the unique id of the message manager */
-    inline int  getMessageManagerId(){ return remoteState.messageManagerId; }
+    inline int  getMessageManagerId() const { return remoteState.messageManagerId; }
     /** @returns the node type of the remote host */
-    inline int getRemoteNodeType() { return this->remoteState.nodeType; }
+    inline int getRemoteNodeType() const { return this->remoteState.nodeType; }
 
     /** sets @param nick the prefereded nick name */
     inline void setPreferedNickName( const std::string & nick ){ localState.preferedNickName = nick; }
     /** @returns the prefered nick name */
-    inline std::string getPreferedNickName(){ return remoteState.preferedNickName; }
+    inline const std::string& getPreferedNickName() const { return remoteState.preferedNickName; }
 
     /** @returns if true the local client should reconnect to a proxy server from the proxy server list */
-    inline bool redirect() { return this->redirectProxy;}
+    inline bool redirect() const  { return this->redirectProxy; }
     /** @param flag: indicating if the client should be redirected */
     inline void setRedirect(bool flag) { if( SharedNetworkData::getInstance()->isClient()) return; this->redirectProxy = (int)flag; }
@@ -85,9 +85,9 @@
     inline void setProxy1Address(IP address) { if( SharedNetworkData::getInstance()->isClient()) return; this->proxy1 = address; }
     /** @returns the address of the proxy server 1 if any */
-    inline IP getProxy1Address() { return this->proxy1; }
+    inline IP getProxy1Address() const { return this->proxy1; }
     /** @param address: the address of the proxy server 2 if any */
     inline void setProxy2Address(IP address) { if( SharedNetworkData::getInstance()->isClient()) return; this->proxy2 = address; }
     /** @returns the address of the proxy server 2 if any */
-    inline IP getProxy2Address() { return this->proxy2; }
+    inline IP getProxy2Address() const { return this->proxy2; }
 
 
Index: /trunk/src/lib/network/ip.cc
===================================================================
--- /trunk/src/lib/network/ip.cc	(revision 9493)
+++ /trunk/src/lib/network/ip.cc	(revision 9494)
@@ -111,8 +111,8 @@
 IP::IP(unsigned int first, unsigned int second, unsigned int third, unsigned int fourth, int port)
 {
-  this->_host = (first << 24) +
-                (second << 16) +
-                (third <<  8) +
-                fourth;
+  this->_host = (fourth << 24) +
+                (third << 16) +
+                (second <<  8) +
+                (first);
   this->_port = port;
 }
@@ -185,7 +185,7 @@
     IPaddress ipaddr;
 
-    SDLNet_ResolveHost(&ipaddr, NULL, 2000);
-
-    return IP(ipaddr.host, port);
+    SDLNet_ResolveHost(&ipaddr, ip.c_str(), port);
+
+    return IP(ipaddr);
   }
   else
@@ -255,20 +255,18 @@
 /**
  * @brief converts a IP into a String (without port).
- * @param ip the IP to put into the string.
+ * @param host the IP to put into the string.
  * @param port -1 if not wanted
  * @return the string of the ip.
  */
-std::string IP::ipToString(int ip, int port)
-{
-  MultiType part0((int) (ip & 0xFF000000) >> 24);
-  MultiType part1((int) (ip & 0x00FF0000) >> 16);
-  MultiType part2((int) (ip & 0x0000FF00) >>  8);
-  MultiType part3((int) (ip & 0x000000FF) );
+std::string IP::ipToString(int host, int port)
+{
+  MultiType part0((int) ((host & 0xFF000000) >> 24));
+  MultiType part1((int) ((host & 0x00FF0000) >> 16));
+  MultiType part2((int) ((host & 0x0000FF00) >>  8));
+  MultiType part3((int) ((host & 0x000000FF) ));
 
   std::string addr = part3.getString() + "." + part2.getString() + "." +
                      part1.getString() + "." + part0.getString();
 
-  if (port != -1)
-    addr += ":" + MultiType(port).getString();
   return addr;
 }
Index: /trunk/src/lib/network/ip.h
===================================================================
--- /trunk/src/lib/network/ip.h	(revision 9493)
+++ /trunk/src/lib/network/ip.h	(revision 9494)
@@ -54,5 +54,5 @@
 
     static std::string ipToString(const IPaddress& ipaddr);
-    static std::string ipToString(int ip, int port = -1);
+    static std::string ipToString(int host, int port = -1);
 
     static void setDefaultPort(int defaultPort);
Index: /trunk/src/lib/network/message_manager.cc
===================================================================
--- /trunk/src/lib/network/message_manager.cc	(revision 9493)
+++ /trunk/src/lib/network/message_manager.cc	(revision 9494)
@@ -320,8 +320,9 @@
     if (
          recieverType == RT_ALL_ME ||
-         recieverType == RT_ALL_NOT_ME ||
+         recieverType == RT_ALL_BUT_ME ||
          recieverType == RT_USER && it->first == reciever ||
          recieverType == RT_NOT_USER && it->first != reciever ||
-         recieverType == RT_SERVER && getNetworkStream()->isUserMasterServer( it->first )
+         recieverType == RT_SERVER && getNetworkStream()->isUserMasterServer( it->first ) ||
+         recieverType == RT_SERVER && getNetworkStream()->isUserProxyServerActive( it->first )
        )
     {
Index: /trunk/src/lib/network/message_manager.h
===================================================================
--- /trunk/src/lib/network/message_manager.h	(revision 9493)
+++ /trunk/src/lib/network/message_manager.h	(revision 9494)
@@ -26,5 +26,5 @@
 
 
-enum MessageId 
+enum MessageId
 {
   TESTMESSAGEID = 1,
@@ -40,5 +40,5 @@
 enum RecieverType
 {
-  RT_ALL_NOT_ME = 1,   //!< message is sent to all users
+  RT_ALL_BUT_ME = 1,   //!< message is sent to all users but myself
   RT_ALL_ME,           //!< message is sent to all users
   RT_USER,             //!< message is only sent to reciever
@@ -52,5 +52,5 @@
   MP_HIGHBANDWIDTH = 1,  //!< fast and reliable but uses a lot of bandwidth
   MP_LOWBANDWIDTH,       //!< may take a long time to arrive. reliable
-  MP_UNRELIABLE          //!< unreliable. low bandwidth 
+  MP_UNRELIABLE          //!< unreliable. low bandwidth
 };
 
@@ -88,9 +88,9 @@
  public:
    inline static MessageManager * getInstance(){ if (!singletonRef) singletonRef = new MessageManager();  return singletonRef; }
-   
+
    virtual ~MessageManager();
-   
+
    bool registerMessageHandler( MessageId messageId, MessageCallback cb, void * someData );
-   
+
    void sendMessage( MessageId messageId, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority );
 
@@ -100,5 +100,5 @@
    virtual void handleSentState( int userId, int stateId, int fromStateId ){}
    virtual void handleRecvState( int userId, int stateId, int fromStateId ){}
-   
+
    void initUser( int userId );
 
@@ -110,5 +110,5 @@
 
    int                       newNumber;              //!< used to create unique message numbers
-   std::list<NetworkMessage> incomingMessageBuffer; 
+   std::list<NetworkMessage> incomingMessageBuffer;
 
 };
Index: /trunk/src/lib/network/monitor/connection_monitor.cc
===================================================================
--- /trunk/src/lib/network/monitor/connection_monitor.cc	(revision 9493)
+++ /trunk/src/lib/network/monitor/connection_monitor.cc	(revision 9494)
@@ -32,5 +32,5 @@
   /* set the class id for the base object and add ist to class list*/
   this->setClassID(CL_CONNECTION_MONITOR, "ConnectionMonitor");
-  
+
   this->userId = userId;
   this->ping = 0;
@@ -43,5 +43,5 @@
   this->nZIncomingPackets = 0;
   this->nZOutgoingPackets = 0;
-  
+
   this->lastPacketTick = 0;
   this->lastPrintTick = 0;
@@ -64,21 +64,21 @@
 {
   nOutgoingPackets++;
-  
+
   // for ping calculation
   sentStateTicks[stateId] = tick;
-  
+
   // calculate bandwidth
   outgoingUnzippedPacketHistory[tick] = length;
   outgoingUnzippedBandWidth = calculateBandWidth( outgoingUnzippedPacketHistory, tick );
-  
+
   //NETPRINTF(n)("UNZIPPED UPSTREAM: user: %d bandwidth %f\n", userId, outgoingUnzippedBandWidth );
-  
+
   // count zero bytes
   //int nZeroBytes = 0;
-  
+
   //for ( int i = 0; i < length; i++ )
   //  if ( data[i] == '\0' )
   //    nZeroBytes++;
-  
+
   //NETPRINTF(n)( "ZEROBYTES: %d (%f%%)\n", nZeroBytes, ((float)100)*nZeroBytes/length );
 }
@@ -94,7 +94,7 @@
 {
   nIncomingPackets++;
-  
+
   lastPacketTick = tick;
-  
+
   // calculate ping
   if ( sentStateTicks.find( ackedState ) != sentStateTicks.end() )
@@ -102,35 +102,35 @@
     ackDelay.push_back( tick - sentStateTicks[ackedState] );
   }
-  
+
   while ( sentStateTicks.begin() != sentStateTicks.end() && sentStateTicks.begin()->first <= ackedState )
     sentStateTicks.erase( sentStateTicks.begin() );
-      
+
   while ( ackDelay.size() > N_PACKETS_FOR_PING )
     ackDelay.erase( ackDelay.begin() );
-      
+
   ping = 0;
-      
+
   for ( std::list<int>::iterator it = ackDelay.begin(); it != ackDelay.end(); it++ )
     ping += *it;
-      
+
   if ( ackDelay.size() == 0 )
     ping = -1;
   else
     ping /= ackDelay.size();
-      
+
   //NETPRINTF(n)("PING: user: %d ping: %d\n", userId, ping );
-  
+
   // calculate bandwidth
   incomingUnzippedPacketHistory[tick] = length;
   incomingUnzippedBandWidth = calculateBandWidth( incomingUnzippedPacketHistory, tick );
-  
+
   //NETPRINTF(n)("UNZIPPED DOWNSTREAM: user: %d bandwidth %f\n", userId, incomingUnzippedBandWidth );
-  
+
 }
 
 /**
  * remove old packets
- * @param packetHistory 
- * @param tick 
+ * @param packetHistory
+ * @param tick
  */
 void ConnectionMonitor::removeOldPackets( std::map< int, int > & packetHistory, int tick )
@@ -149,5 +149,5 @@
 {
   removeOldPackets( packetHistory, tick );
-  
+
   float res = 0.0f;
 #if 0
@@ -157,23 +157,23 @@
       res += it->second;
   }
-  
+
   if ( packetHistory.size() <= 1 || tick - packetHistory.begin()->first == 0 )
     res = 0.0f;
   else
     res /= (float)(tick - packetHistory.begin()->first);
-  
+
   res *= 1000.0f;
 #endif
 
-  for ( std::map<int,int>::iterator it = packetHistory.begin(); it != packetHistory.end(); it++ )
+  for ( std::map<int,int>::const_iterator it = packetHistory.begin(); it != packetHistory.end(); it++ )
   {
     res += it->second;
   }
-  
+
   if ( packetHistory.size() <= 1 )
     res = 0.0f;
   else
     res /= (float)(tick - packetHistory.begin()->first);
-  
+
   res *= 1000.0f;
 
@@ -191,9 +191,9 @@
 {
   nZOutgoingPackets++;
-  
+
   // calculate bandwidth
   outgoingZippedPacketHistory[tick] = length;
   outgoingZippedBandWidth = calculateBandWidth( outgoingZippedPacketHistory, tick );
-  
+
   //NETPRINTF(n)("UPSTREAM: user: %d bandwidth %f nOutgoingPackets %d\n", userId, outgoingZippedBandWidth, nOutgoingPackets );
 
@@ -216,11 +216,11 @@
 {
   nZIncomingPackets++;
-  
+
   // calculate bandwidth
   incomingZippedPacketHistory[tick] = length;
   incomingZippedBandWidth = calculateBandWidth( incomingZippedPacketHistory, tick );
-  
+
   //NETPRINTF(n)("DOWNSTREAM: user: %d bandwidth %f nIncomingPackets %d\n", userId, incomingZippedBandWidth, nIncomingPackets );
-  
+
 }
 
@@ -230,12 +230,12 @@
  * @return true if last packet recieved \< NOW() - SECS_TO_TIMEOUT
  */
-bool ConnectionMonitor::hasTimedOut( )
+bool ConnectionMonitor::hasTimedOut( ) const
 {
   if ( lastPacketTick + SECS_TO_TIMEOUT*1000 < SDL_GetTicks() && nIncomingPackets > 0 )
     return true;
-  
+
   if ( nIncomingPackets == 0 && nOutgoingPackets >= NETWORK_FREQUENCY*SECS_TO_TIMEOUT )
     return true;
-  
+
   return false;
 }
@@ -246,5 +246,5 @@
  * prints bandwith usage, ping and other important things to telnet-console
  */
-void ConnectionMonitor::printStatis( )
+void ConnectionMonitor::printStatis( ) const
 {
   NETPRINT(n)("============NETWORKSTATS FOR USER %d============\n", userId);
Index: /trunk/src/lib/network/monitor/connection_monitor.h
===================================================================
--- /trunk/src/lib/network/monitor/connection_monitor.h	(revision 9493)
+++ /trunk/src/lib/network/monitor/connection_monitor.h	(revision 9494)
@@ -31,7 +31,11 @@
     void calculatePing();
 
-    bool hasTimedOut();
+    bool hasTimedOut() const;
 
-    void printStatis();
+    void printStatis() const;
+    float getIncomingUnzippedBandWidth() const { return incomingUnzippedBandWidth; }
+    float getOutgoingUnzippedBandWidth() const { return outgoingUnzippedBandWidth; }
+    float getIncomingZippedBandWidth() const { return incomingZippedBandWidth; }
+    float getOutgoingZippedBandWidth() const { return outgoingZippedBandWidth; }
 
   private:
Index: /trunk/src/lib/network/monitor/network_monitor.cc
===================================================================
--- /trunk/src/lib/network/monitor/network_monitor.cc	(revision 9493)
+++ /trunk/src/lib/network/monitor/network_monitor.cc	(revision 9494)
@@ -31,6 +31,8 @@
 
 
-SHELL_COMMAND(showGUI, NetworkMonitor, showGUI);
-SHELL_COMMAND(hideGUI, NetworkMonitor, hideGUI);
+#include "network_stats_widget.h"
+
+SHELL_COMMAND(gui, NetworkMonitor, toggleGUI)
+ ->setAlias("ProxyGui");
 SHELL_COMMAND(debug, NetworkMonitor, debug);
 
@@ -57,11 +59,11 @@
   {
     // assuming that the config files are already read we get the proxy servers
-    std::vector<IPaddress*>* proxyList = NetworkSettings::getInstance()->getProxyList();
-    std::vector<IPaddress*>::iterator it = proxyList->begin();
+    std::vector<IP>* proxyList = NetworkSettings::getInstance()->getProxyList();
+    std::vector<IP>::iterator it = proxyList->begin();
     // create a peer info class and a network node class for each new proxy and add them to the passive list
     for(; it < proxyList->end(); it++)
     {
       PeerInfo* peer = new PeerInfo();
-      peer->ip = *(*it);
+      peer->ip = (*it);
       peer->nodeType = NET_PROXY_SERVER_ACTIVE;
       peer->userId = -1;
@@ -72,4 +74,5 @@
     }
   }
+  this->box = NULL;
 }
 
@@ -119,5 +122,5 @@
  * @param ip ip of the new node
  */
-void NetworkMonitor::addNode(IP ip, int nodeType)
+void NetworkMonitor::addNode(const IP& ip, int nodeType)
 {
   PeerInfo* pInfo = new PeerInfo();
@@ -140,5 +143,5 @@
   if( pInfo->isClient())
     this->localNode->addClient(pInfo);
-  else if( pInfo->isProxyServer())
+  else if( pInfo->isProxyServerActive())
   {
     this->localNode->addActiveProxyServer(pInfo);
@@ -166,5 +169,5 @@
   if( pInfo->isClient())
     node->addClient(pInfo);
-  else if( pInfo->isProxyServer())
+  else if( pInfo->isProxyServerActive())
     node->addActiveProxyServer(pInfo);
   else if( pInfo->isMasterServer())
@@ -176,5 +179,5 @@
  * @returns the proxy server of the first choice
  */
-PeerInfo* NetworkMonitor::getFirstChoiceProxy()
+PeerInfo* NetworkMonitor::getFirstChoiceProxy() const
 {
   // return the fist proxy in the list
@@ -186,5 +189,5 @@
  * @returns the proxy server of second choice
  */
-PeerInfo* NetworkMonitor::getSecondChoiceProxy()
+PeerInfo* NetworkMonitor::getSecondChoiceProxy() const
 {
   // return the second server in the list
@@ -196,5 +199,5 @@
  * this displays the network monitor gui
  */
-void NetworkMonitor::showGUI()
+void NetworkMonitor::toggleGUI()
 {
   if (this->box == NULL)
@@ -202,36 +205,18 @@
     this->box = new OrxGui::GLGuiBox(OrxGui::Vertical);
     {
-      OrxGui::GLGuiBox* waterColorBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
-      {
-        OrxGui::GLGuiText* waterColorText = new OrxGui::GLGuiText();
-        waterColorText->setText("NetworkMonitor");
-        waterColorBox->pack(waterColorText);
-      }
-      this->box->pack(waterColorBox);
+      NetworkStatsWidget* netStats = new NetworkStatsWidget(this);
+      this->box->pack(netStats);
+
     }
 
     this->box->showAll();
     this->box->setAbsCoor2D(300, 40);
-    OrxGui::GLGuiHandler::getInstance()->activate();
-//     OrxGui::GLGuiHandler::getInstance()->activateCursor();
-  }
-}
-
-
-/**
- * hides the network monitor gui again
- */
-void NetworkMonitor::hideGUI()
-{
-  if( this->box == NULL)
-    return;
-
-  OrxGui::GLGuiHandler::getInstance()->deactivate();
-//   OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
-
-  delete this->box;
-  this->box = NULL;
-}
-
+  }
+  else
+  {
+    delete this->box;
+    this->box = NULL;
+  }
+}
 
 /**
@@ -255,12 +240,13 @@
  * prints out the debug informations
  */
-void NetworkMonitor::debug()
+void NetworkMonitor::debug() const
 {
   PRINT(0)("================================= Network Monitor::debug() =====\n");
   PRINT(0)(" I am: %s\n", this->localNode->getPeerInfo()->getNodeTypeString().c_str());
-  PRINT(0)(" Total count of network connections: %i\n", this->playerNumber);
+  PRINT(0)(" Total count of network connections: %i\n", this->connectionNumber);
+  PRINT(0)(" Total count of players: %i\n", this->playerNumber);
   PRINT(0)(" Max players on this server: %i\n", SharedNetworkData::getInstance()->getMaxPlayer());
 
-  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
+  std::list<NetworkNode*>::const_iterator it = this->nodeList.begin();
   for(; it != this->nodeList.end(); it++)
   {
Index: /trunk/src/lib/network/monitor/network_monitor.h
===================================================================
--- /trunk/src/lib/network/monitor/network_monitor.h	(revision 9493)
+++ /trunk/src/lib/network/monitor/network_monitor.h	(revision 9494)
@@ -37,5 +37,5 @@
 
     void addNode(PeerInfo* pInfo);
-    void addNode(IP ip, int nodeType);
+    void addNode(const IP& ip, int nodeType);
     void addNode(NetworkNode* node) { this->nodeList.push_back(node); }
     void addNode(NetworkNode* node, PeerInfo* pInfo);
@@ -55,28 +55,30 @@
     inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
 
-    PeerInfo* getFirstChoiceProxy();
-    PeerInfo* getSecondChoiceProxy();
+    PeerInfo* getFirstChoiceProxy() const;
+    PeerInfo* getSecondChoiceProxy() const;
+    /** @returns the local node */
+    inline NetworkNode* getLocalNode() const { return this->localNode; };
 
     /** @returns the active proxy server list of the localnode */
-    inline std::list<PeerInfo*> getActiveProxyServer() { return this->localNode->getActiveProxyServer(); }
+    inline std::list<PeerInfo*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); }
 
     /* slots admin and info interface */
     /** @returns the total number of players in this game (including all proxy servers etc)*/
-    inline int getPlayerNumber() { return this->playerNumber; }
+    inline int getPlayerNumber() const { return this->playerNumber; }
 
     /** @returns true if there are still free network slots available at the local node*/
-    inline bool gotFreeSlots() { return (this->localNode->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
+    inline bool gotFreeSlots() const { return (this->localNode->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer()); }
     /** @param node node to be checked for slots @returns true if there are still free network slots available at this node */
-    inline bool gotFreeSlots(NetworkNode* node) { return (node->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
+    inline bool gotFreeSlots(NetworkNode* node) const { return (node->getPlayerNumber() < SharedNetworkData::getInstance()->getMaxPlayer()); }
 
     /** @returns true if the next client should be reconnected to some other proxy server with more connections */
-    inline bool isReconnectNextClient() { return (this->localNode->getPlayerNumber() >= SharedNetworkData::getInstance()->getMaxPlayer())?true:false; }
+    inline bool isReconnectNextClient() const { return (this->localNode->getPlayerNumber() >= SharedNetworkData::getInstance()->getMaxPlayer()); }
 
+    inline const std::list<NetworkNode*>& getNodeList() const { return this->nodeList; };
 
-    void showGUI();
-    void hideGUI();
+    void toggleGUI();
 
     void process();
-    void debug();
+    void debug() const;
 
 
Index: /trunk/src/lib/network/monitor/network_node.cc
===================================================================
--- /trunk/src/lib/network/monitor/network_node.cc	(revision 9493)
+++ /trunk/src/lib/network/monitor/network_node.cc	(revision 9494)
@@ -152,10 +152,10 @@
  * @return the client in the list or NULL if none
  */
-PeerInfo* NetworkNode::getClient(int index)
+PeerInfo* NetworkNode::getClient(int index) const
 {
   if( this->clientList.size() < index)
     return NULL;
 
-  std::list<PeerInfo*>::iterator it = this->clientList.begin();
+  std::list<PeerInfo*>::const_iterator it = this->clientList.begin();
   for(int i = 0; it != this->clientList.end(); it++, i++)
   {
@@ -172,10 +172,10 @@
  * @return the active proxy server in the list or NULL if none
  */
-PeerInfo* NetworkNode::getActiveProxyServer(int index)
+PeerInfo* NetworkNode::getActiveProxyServer(int index) const
 {
   if( this->activeProxyServerList.size() < index)
     return NULL;
 
-  std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
+  std::list<PeerInfo*>::const_iterator it = this->activeProxyServerList.begin();
   for(int i = 0; it != this->activeProxyServerList.end(); it++, i++)
   {
@@ -192,10 +192,10 @@
  * @return the passive proxy server in the list or NULL if none
  */
-PeerInfo* NetworkNode::getPassiveProxyServer(int index)
+PeerInfo* NetworkNode::getPassiveProxyServer(int index) const
 {
   if( this->passiveProxyServerList.size() < index)
     return NULL;
 
-  std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
+  std::list<PeerInfo*>::const_iterator it = this->passiveProxyServerList.begin();
   for(int i = 0; it != this->passiveProxyServerList.end(); it++, i++)
   {
@@ -212,10 +212,10 @@
  * @return the master server in the list or NULL if none
  */
-PeerInfo* NetworkNode::getMasterServer(int index)
+PeerInfo* NetworkNode::getMasterServer(int index) const
 {
   if( this->masterServerList.size() < index)
     return NULL;
 
-  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
+  std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
   for(int i = 0; it != this->masterServerList.end(); it++, i++)
   {
@@ -232,10 +232,10 @@
  * @param depth: depth in the tree
  */
-void NetworkNode::debug(int depth)
+void NetworkNode::debug(int depth) const
 {
   PRINT(0)(" = %s\n", this->peerInfo->getNodeTypeString().c_str());
 
   PRINT(0)("    master servers: %i\n", this->masterServerList.size());
-  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
+  std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
   for(; it != this->masterServerList.end(); it++)
   {
Index: /trunk/src/lib/network/monitor/network_node.h
===================================================================
--- /trunk/src/lib/network/monitor/network_node.h	(revision 9493)
+++ /trunk/src/lib/network/monitor/network_node.h	(revision 9494)
@@ -32,27 +32,27 @@
     void removeMasterServer(PeerInfo* node);
 
-    PeerInfo* getClient(int index);
-    PeerInfo* getActiveProxyServer(int index);
-    PeerInfo* getPassiveProxyServer(int index);
-    PeerInfo* getMasterServer(int index);
+    PeerInfo* getClient(int index) const;
+    PeerInfo* getActiveProxyServer(int index) const;
+    PeerInfo* getPassiveProxyServer(int index) const;
+    PeerInfo* getMasterServer(int index) const;
 
     /** @returns the master server list */
-    inline std::list<PeerInfo*> getMasterServer() { return this->masterServerList; }
+    inline std::list<PeerInfo*> getMasterServer() const { return this->masterServerList; }
     /** @returns the active proxy server list */
-    inline std::list<PeerInfo*> getActiveProxyServer() { return this->activeProxyServerList; }
+    inline std::list<PeerInfo*> getActiveProxyServer() const { return this->activeProxyServerList; }
     /** @returns the passive proxy server list */
-    inline std::list<PeerInfo*> getPassiveProxyServer() { return this->passiveProxyServerList; }
+    inline std::list<PeerInfo*> getPassiveProxyServer() const { return this->passiveProxyServerList; }
     /** @returns the client list */
-    inline std::list<PeerInfo*> getClient() { return this->clientList; }
+    inline std::list<PeerInfo*> getClient() const { return this->clientList; }
 
 
     /** @returns the number of players */
-    inline int getPlayerNumber() { return this->playerNumber; }
+    inline int getPlayerNumber() const { return this->playerNumber; }
     /** @returns the node type of this node */
-    inline int getNodeType() { return this->peerInfo->nodeType; }
+    inline int getNodeType() const { return this->peerInfo->nodeType; }
     /** @returns the peer info of this node */
-    inline PeerInfo* getPeerInfo() { return this->peerInfo; }
+    inline PeerInfo* getPeerInfo() const { return this->peerInfo; }
 
-    void debug(int depth);
+    void debug(int depth) const;
 
 
@@ -60,5 +60,5 @@
     int                          playerNumber;                 //!< localy direct connected player number
     int                          connectionNumber;             //!< number of connections ( can but musn't be equal players)
-    PeerInfo*                    peerInfo;                     //!< the peer informationa about this node
+    PeerInfo*                    peerInfo;                     //!< the peer information about this node
 
     /* network nodes directly connected to this node */
Index: /trunk/src/lib/network/monitor/network_stats_widget.cc
===================================================================
--- /trunk/src/lib/network/monitor/network_stats_widget.cc	(revision 9494)
+++ /trunk/src/lib/network/monitor/network_stats_widget.cc	(revision 9494)
@@ -0,0 +1,230 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
+
+#include "network_stats_widget.h"
+#include "network_monitor.h"
+
+#include "multi_type.h"
+
+#include "shell_command.h"
+
+// SHELL_COMMAND(gui, NetworkMonitor, toggleGUI)
+//  ->setAlias("ProxyGui");
+
+
+HostWidget::HostWidget(const std::string& name, const IP& ip)
+    : GLGuiBox(OrxGui::Horizontal)
+{
+  this->setName(name);
+  this->setIP(ip);
+
+  this->pack(&this->_name);
+  this->pack(&this->_ip);
+}
+
+void HostWidget::showing()
+{
+  this->_name.show();
+  this->_ip.show();
+}
+
+void HostWidget::hiding()
+{
+  this->_name.hide();
+  this->_ip.hide();
+}
+
+
+
+//======================================================//
+
+
+ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
+    : _proxyWidget(proxyName, ip)
+{
+  this->_clientNameWidth = 100.0f;
+  this->pack(&_proxyWidget);
+}
+
+void ProxyWidget::addClient(const std::string& name, const IP& ip)
+{
+  HostWidget* newClient = new HostWidget(name, ip);
+  newClient->setNameWidth(this->_clientNameWidth);
+
+  this->pack(newClient);
+
+  if (this->isVisible())
+    newClient->show();
+}
+
+bool ProxyWidget::removeClient(const IP& ip)
+{
+  std::vector<HostWidget*>::iterator rmIt;
+  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
+  {
+    if (*(*rmIt) == ip)
+    {
+      delete (*rmIt);
+      this->_clients.erase(rmIt);
+      return true;
+    }
+  }
+  return false;
+}
+
+bool ProxyWidget::removeClient(const std::string& name)
+{
+  std::vector<HostWidget*>::iterator rmIt;
+  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
+  {
+    if (*(*rmIt) == name)
+    {
+      delete (*rmIt);
+      this->_clients.erase(rmIt);
+      return true;
+    }
+  }
+  return false;
+
+}
+
+bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
+{
+  std::vector<HostWidget*>::iterator rmIt;
+  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
+  {
+    if (*(*rmIt) == ip && *(*rmIt) == name)
+    {
+      delete (*rmIt);
+      this->_clients.erase(rmIt);
+      return true;
+    }
+  }
+  return false;
+}
+
+
+void ProxyWidget::setClientNameWidths(float width)
+{
+  this->_clientNameWidth = width;
+  for (unsigned int i = 0; i < this->_clients.size(); ++i)
+    this->_clients[i]->setNameWidth(width);
+}
+
+void ProxyWidget::hiding()
+{
+  this->_proxyWidget.hide();
+  for (unsigned int i = 0; i < this->_clients.size(); ++i)
+    this->_clients[i]->hide();
+}
+
+void ProxyWidget::showing()
+{
+  this->_proxyWidget.show();
+  for (unsigned int i = 0; i < this->_clients.size(); ++i)
+    this->_clients[i]->show();
+}
+
+
+//======================================================//
+
+/**
+ * @brief standard constructor
+ */
+NetworkStatsWidget::NetworkStatsWidget(const NetworkMonitor* monitor)
+    : GLGuiBox(OrxGui::Vertical), _thisHost("myName", IP(127, 0, 0 , 1))
+{
+  this->_monitor = monitor;
+
+  /*
+  this->_bar.setSize2D(100, 30);
+  this->pack(&this->_valueText);
+  this->_bar.setParent2D(&this->_valueText);
+
+  this->_valueText.setChangedTextColor(Color::white);
+
+  //this->setBackgroundTexture("maps/gui_element_background_2.png");
+  this->setBackgroundColor(Color(.5,.5,.5,1));
+
+  //this->_name.setBackgroundTexture(Texture());
+  //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
+  this->_bar.setBackgroundTexture(Texture());
+  this->_bar.setBackgroundColor(Color(0,0,0,0));
+  this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
+  this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
+  this->_bar.setChangedValueColor(Color::black);
+  */
+  this->pack(&this->_thisHost);
+
+  this->pack(&this->_upstreamText);
+  this->pack(&this->_downstreamText);
+
+  this->pack(&this->_serverIP);
+}
+
+
+/**
+ * @brief standard deconstructor
+ */
+NetworkStatsWidget::~NetworkStatsWidget ()
+{}
+
+
+void NetworkStatsWidget::setMaximum(float max)
+{
+  // this->_bar.setMaximum(max);
+}
+
+void NetworkStatsWidget::setValue(float value)
+{
+  MultiType val(value);
+  val.setType(MT_INT);
+  /*
+
+  this->_bar.setValue(value);
+  this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
+  this->_bar.setFrontColor(Color(1,1,1,1), true);
+  this->_valueText.setText(val.getString());
+  */
+}
+
+
+void NetworkStatsWidget::tick(float dt)
+{
+  assert (this->_monitor->getLocalNode() != NULL);
+  assert(this->_monitor->getLocalNode()->getPeerInfo() != NULL);
+
+  if(this->_monitor->getLocalNode()->getPeerInfo()->connectionMonitor != NULL)
+  {
+    ConnectionMonitor* mon = this->_monitor->getLocalNode()->getPeerInfo()->connectionMonitor;
+
+    this->_upstreamText.setText(MultiType(mon->getOutgoingZippedBandWidth()).getString());
+    this->_downstreamText.setText(MultiType(mon->getIncomingZippedBandWidth()).getString());
+  }
+}
+
+void NetworkStatsWidget::resize()
+{
+  GLGuiBox::resize();
+}
+
+
+void NetworkStatsWidget::showing()
+{}
+
+void NetworkStatsWidget::hiding()
+{}
Index: /trunk/src/lib/network/monitor/network_stats_widget.h
===================================================================
--- /trunk/src/lib/network/monitor/network_stats_widget.h	(revision 9494)
+++ /trunk/src/lib/network/monitor/network_stats_widget.h	(revision 9494)
@@ -0,0 +1,117 @@
+/*!
+ * @file network_stats_widget.h
+ * @brief Definition of an EnergyWidget, that displays a bar and a Text
+*/
+
+#ifndef _NETWORK_STATS_WIDGET_H
+#define _NETWORK_STATS_WIDGET_H
+
+#include "glgui_box.h"
+#include "glgui_bar.h"
+#include "glgui_text.h"
+
+#include "network/ip.h"
+
+class NetworkMonitor;
+
+
+class HostWidget : public OrxGui::GLGuiBox
+{
+  public:
+    HostWidget(const std::string& name, const IP& ip);
+    ~HostWidget() {};
+
+    void setName(const std::string& name) { this->_name.setText(name); };
+    void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; };
+
+    void setNameWidth(float width) { this->_name.setLineWidth(width); };
+
+    bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
+    bool operator==(const std::string& name) const { return (this->_name == name); };
+
+  protected:
+    virtual void showing();
+    virtual void hiding();
+
+  private:
+    OrxGui::GLGuiText _name;           //!< The Name of the Proxy server to be displayed.
+    OrxGui::GLGuiText _ip;             //!< The IP of the proxy server.
+    IP                _storedIP;       //!< The ip to compare.
+};
+
+
+class ProxyWidget : public OrxGui::GLGuiBox
+{
+  public:
+    ProxyWidget(const std::string& proxyName, const IP& ip);
+
+    void addClient(const std::string& name, const IP& ip);
+
+    bool removeClient(const IP& ip);
+    bool removeClient(const std::string& name);
+    bool removeClient(const std::string& name, const IP& ip);
+
+    void setClientNameWidths(float width);
+
+
+  protected:
+    virtual void hiding();
+    virtual void showing();
+
+
+  private:
+    HostWidget                _proxyWidget;
+
+    std::vector<HostWidget*>  _clients;
+    float                     _clientNameWidth;
+};
+
+
+
+
+//! A class to display network Statistics.
+class NetworkStatsWidget : public OrxGui::GLGuiBox
+{
+  public:
+    NetworkStatsWidget(const NetworkMonitor* monitor);
+    virtual ~NetworkStatsWidget();
+
+    void setUpstream(unsigned int upstream);
+    void setDownstream(unsigned int upstream);
+    void setIP(const IP& ip);
+
+
+
+    void addProxy(const std::string& name, const IP& proxy);
+
+
+    //void rebuildConnectedHosts(std::vector<hosts> hosts);
+
+    void setMaximum(float max);
+    void setValue(float value);
+
+    virtual void tick(float dt);
+
+  protected:
+    virtual void resize();
+    virtual void showing();
+    virtual void hiding();
+
+  private:
+    const NetworkMonitor*  _monitor;
+
+    HostWidget             _thisHost;
+
+    OrxGui::GLGuiText      _upstreamText;
+    OrxGui::GLGuiText      _downstreamText;
+
+    std::vector<HostWidget*>_connectedProxies;
+
+    OrxGui::GLGuiText       _serverIP;
+
+
+    //OrxGui::GLGuiText       _valueText;
+    //OrxGui::GLGuiBar        _bar;
+};
+
+#endif /* _NETWORK_STATS_WIDGET_H */
Index: /trunk/src/lib/network/netdefs.h
===================================================================
--- /trunk/src/lib/network/netdefs.h	(revision 9493)
+++ /trunk/src/lib/network/netdefs.h	(revision 9494)
@@ -43,7 +43,11 @@
 
 
+
+
 //!< enum indicating the type of the node
 typedef enum {
-  NET_MASTER_SERVER,
+  NET_UNASSIGNED              = -1,
+
+  NET_MASTER_SERVER           =  0,
   NET_PROXY_SERVER_ACTIVE,
   NET_PROXY_SERVER_PASSIVE,
@@ -54,4 +58,5 @@
 } NodeType;
 
+
 //!< enum indicating the type of the network connection (2 protocols supported)
 typedef enum ConnectionType {
@@ -60,10 +65,75 @@
 };
 
-//!< the type of the user id (special number never used elsewhere)
+
+//!< the type of the unique id (special number never used elsewhere)
 typedef enum {
   NET_UID_UNASSIGNED = -1,
+
+  NET_UID_HANDSHAKE  =  0,
+
 
   NET_UID_NUMBER
 } UidType;
 
+
+//!< the network id list
+typedef enum nodeId {
+  NET_ID_UNASSIGNED       =-1,
+
+  NET_ID_MASTER_SERVER    = 0,
+
+  NET_ID_PROXY_SERVER_01  = 1,
+  NET_ID_PROXY_SERVER_02,
+  NET_ID_PROXY_SERVER_03,
+  NET_ID_PROXY_SERVER_04,
+  NET_ID_PROXY_SERVER_05,
+  NET_ID_PROXY_SERVER_06,
+  NET_ID_PROXY_SERVER_07,
+  NET_ID_PROXY_SERVER_08  = 8,
+
+  NET_ID_PROXY_MAX        = 8,
+
+  NET_ID_CLIENT_01        = 9,
+  NET_ID_CLIENT_02,
+  NET_ID_CLIENT_03,
+  NET_ID_CLIENT_04,
+  NET_ID_CLIENT_05,
+  NET_ID_CLIENT_06,
+  NET_ID_CLIENT_07,
+  NET_ID_CLIENT_08,
+  NET_ID_CLIENT_09,
+  NET_ID_CLIENT_10,
+  NET_ID_CLIENT_11,
+  NET_ID_CLIENT_12,
+  NET_ID_CLIENT_13,
+  NET_ID_CLIENT_14,
+  NET_ID_CLIENT_15,
+  NET_ID_CLIENT_16,
+  NET_ID_CLIENT_17,
+  NET_ID_CLIENT_18,
+  NET_ID_CLIENT_19,
+  NET_ID_CLIENT_20,
+  NET_ID_CLIENT_21,
+  NET_ID_CLIENT_22,
+  NET_ID_CLIENT_23,
+  NET_ID_CLIENT_24,
+  NET_ID_CLIENT_25,
+  NET_ID_CLIENT_26,
+  NET_ID_CLIENT_27,
+  NET_ID_CLIENT_28,
+  NET_ID_CLIENT_29,
+  NET_ID_CLIENT_30,
+  NET_ID_CLIENT_31,
+  NET_ID_CLIENT_32,
+  NET_ID_CLIENT_33,
+  NET_ID_CLIENT_34,
+  NET_ID_CLIENT_35,
+  NET_ID_CLIENT_36,
+  NET_ID_CLIENT_37,
+  NET_ID_CLIENT_38,
+  NET_ID_CLIENT_39,
+  NET_ID_CLIENT_40,
+
+  NET_ID_CLIENT_MAX        = 40
+};
 #endif /* _NETDEFS_H */
Index: /trunk/src/lib/network/nettypes.h
===================================================================
--- /trunk/src/lib/network/nettypes.h	(revision 9493)
+++ /trunk/src/lib/network/nettypes.h	(revision 9494)
@@ -5,3 +5,13 @@
 typedef unsigned char byte;
 
+
+//!< this are the network write variable permissions
+typedef enum netPermissions {
+  PERMISSION_MASTER_SERVER = 1,
+  PERMISSION_PROXY_SERVER  = 2,
+  PERMISSION_OWNER         = 4,
+  PERMISSION_ALL           = 8
+};
+
+
 #endif /* __NET_TYPES_H */
Index: /trunk/src/lib/network/network_game_manager.cc
===================================================================
--- /trunk/src/lib/network/network_game_manager.cc	(revision 9493)
+++ /trunk/src/lib/network/network_game_manager.cc	(revision 9494)
@@ -91,5 +91,5 @@
 bool NetworkGameManager::signalNewPlayer( int userId )
 {
-  assert( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServer());
+  assert( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServerActive());
   assert( State::getGameRules() );
   assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
@@ -168,7 +168,11 @@
 bool NetworkGameManager::delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
 {
-  if ( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServer())
-  {
-    PRINTF(2)("Recieved DeleteSynchronizeable message from client %d!\n", userId);
+
+  PRINTF(0)(" del synchronizeable\n");
+
+  if ( SharedNetworkData::getInstance()->isMasterServer() ||
+       SharedNetworkData::getInstance()->isProxyServerActive() && SharedNetworkData::getInstance()->isUserClient(userId))
+  {
+    PRINTF(0)("Recieved DeleteSynchronizeable message from client %d!\n", userId);
     return true;
   }
@@ -213,5 +217,5 @@
   assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE );
 
-  MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+  MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
 }
 
@@ -229,5 +233,5 @@
 bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
 {
-  assert( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServer());
+  assert( SharedNetworkData::getInstance()->isMasterServer() ||  SharedNetworkData::getInstance()->isProxyServerActive());
 
   int teamId = 0;
@@ -261,5 +265,5 @@
 void NetworkGameManager::prefereTeam( int teamId )
 {
-  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+  if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
     setPreferedTeam( SharedNetworkData::getInstance()->getHostID(), teamId );
   else
@@ -305,7 +309,7 @@
 {
   PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", userId, SharedNetworkData::getInstance()->getHostID() );
-  if ( (SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()) && userId !=  SharedNetworkData::getInstance()->getHostID() )
-  {
-    MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+  if ( (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/) && userId !=  SharedNetworkData::getInstance()->getHostID() )
+  {
+    MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
   }
 
@@ -347,8 +351,8 @@
   assert( Converter::stringToByteArray(message, buf+2*INTSIZE, message.length()+INTSIZE) == message.length()+INTSIZE );
 
-  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+  if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
     MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH );
   else
-    MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+    MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
 
 
Index: /trunk/src/lib/network/network_manager.cc
===================================================================
--- /trunk/src/lib/network/network_manager.cc	(revision 9493)
+++ /trunk/src/lib/network/network_manager.cc	(revision 9494)
@@ -101,5 +101,6 @@
 /**
  *  creates a new NetworkStream of server type
- * @param port: number of the TCP port
+ * @param clientPort: number of the TCP/UDP port for client connections
+ * @param proxyPort: number of the TCP/UDP port for proxy connections
  */
 int NetworkManager::createMasterServer(unsigned int port)
@@ -110,5 +111,5 @@
   // create the network stream
   this->networkStream = new NetworkStream(NET_MASTER_SERVER);
-  this->networkStream->createServer( port);
+  this->networkStream->createServer( port, port + 1);
 
   // start the network game manager
@@ -129,15 +130,20 @@
   NetworkSettings::getInstance()->loadData();
 
-  // create the network stream
-  this->networkStream = new NetworkStream(NET_PROXY_SERVER_ACTIVE);
-  this->networkStream->createServer( port);
-  // and connect to the master server for synchronization
-//   this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr());
-  // and to the other proxy servers
-
+  // create the network stream af
+  this->networkStream = new NetworkStream(NET_PROXY_SERVER_ACTIVE );
+  // first connect to the master server for synchronization
+  this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 10000);
+  // start the handshake with the master server
+  this->networkStream->startHandshake(NET_ID_MASTER_SERVER);
+
+  // then start the server
+  this->networkStream->createServer( port, port +1);
+
+
+  // and to the other proxy servers also, this would be very nice if its works
 
 
   // start the network game manager
-  this->networkStream->createNetworkGameManager();
+  //this->networkStream->createNetworkGameManager();
 
 
@@ -165,5 +171,5 @@
   this->networkStream->startHandshake();
 
-  PRINTF(0)("Created Network Client");
+  PRINTF(0)("Created Network Client\n");
   return 1;
 }
Index: /trunk/src/lib/network/network_manager.h
===================================================================
--- /trunk/src/lib/network/network_manager.h	(revision 9493)
+++ /trunk/src/lib/network/network_manager.h	(revision 9494)
@@ -17,9 +17,8 @@
 
 
-/* forward declarations for the header file (include the header via #include "bla.h" in the source file) */
+
 class NetworkStream;
 class Synchronizeable;
-template<typename>
-class tList;
+
 
 /* and here is the class itsself*/
Index: /trunk/src/lib/network/network_stream.cc
===================================================================
--- /trunk/src/lib/network/network_stream.cc	(revision 9493)
+++ /trunk/src/lib/network/network_stream.cc	(revision 9494)
@@ -65,5 +65,5 @@
   this->init();
   /* initialize the references */
-  this->pInfo->nodeType = NET_CLIENT;
+  this->pInfo->nodeType = NET_UNASSIGNED;
 }
 
@@ -79,20 +79,16 @@
     case NET_MASTER_SERVER:
       // init the shared network data
-      SharedNetworkData::getInstance()->setHostID(0);
-//       SharedNetworkData::getInstance()->setNodeType(NET_MASTER_SERVER);
+      SharedNetworkData::getInstance()->setHostID(NET_ID_MASTER_SERVER);
       break;
-
     case NET_PROXY_SERVER_ACTIVE:
       // init the shared network data
-      SharedNetworkData::getInstance()->setHostID(0);
-//       SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_ACTIVE);
+      SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01);
       break;
     case NET_PROXY_SERVER_PASSIVE:
-            // init the shared network data
-      SharedNetworkData::getInstance()->setHostID(0);
-//       SharedNetworkData::getInstance()->setNodeType(NET_PROXY_SERVER_PASSIVE);
+      // init the shared network data
+      SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01);
       break;
     case NET_CLIENT:
-//       SharedNetworkData::getInstance()->setNodeType(NET_CLIENT);
+      SharedNetworkData::getInstance()->setHostID(NET_ID_UNASSIGNED);
       break;
   }
@@ -115,5 +111,6 @@
   /* set the class id for the base object */
   this->setClassID(CL_NETWORK_STREAM, "NetworkStream");
-  this->serverSocket = NULL;
+  this->clientSocket = NULL;
+  this->proxySocket = NULL;
   this->networkGameManager = NULL;
   this->networkMonitor = NULL;
@@ -124,4 +121,5 @@
   this->pInfo->lastRecvedState = 0;
 
+  this->bRedirect = false;
 
   this->currentState = 0;
@@ -142,9 +140,15 @@
 NetworkStream::~NetworkStream()
 {
-  if ( this->serverSocket )
-  {
-    serverSocket->close();
-    delete serverSocket;
-    serverSocket = NULL;
+  if ( this->clientSocket )
+  {
+    clientSocket->close();
+    delete clientSocket;
+    clientSocket = NULL;
+  }
+  if ( this->proxySocket)
+  {
+    proxySocket->close();
+    delete proxySocket;
+    proxySocket = NULL;
   }
   for ( PeerList::iterator i = peers.begin(); i!=peers.end(); i++)
@@ -187,10 +191,11 @@
 void NetworkStream::connectToMasterServer(std::string host, int port)
 {
-  int node = this->peers.size();
+  int node = NET_ID_MASTER_SERVER;
+  // this create the new node in the peers map
   this->peers[node].socket = new UdpSocket( host, port );
-  this->peers[node].userId = 0;
+  this->peers[node].userId = NET_ID_MASTER_SERVER;
 
   this->peers[node].nodeType = NET_MASTER_SERVER;
-  this->peers[node].connectionMonitor = new ConnectionMonitor( 0 );
+  this->peers[node].connectionMonitor = new ConnectionMonitor( NET_ID_MASTER_SERVER );
   this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
 }
@@ -202,13 +207,15 @@
  * @param port: the port number
  */
-void NetworkStream::connectToProxyServer(std::string host, int port)
-{
-  int node = this->peers.size();
-  this->peers[node].socket = new UdpSocket( host, port );
-  this->peers[node].userId = 0;
-
-  this->peers[node].nodeType = NET_PROXY_SERVER_ACTIVE;
-  this->peers[node].connectionMonitor = new ConnectionMonitor( 0 );
-  this->peers[node].ip = this->peers[node].socket->getRemoteAddress();
+void NetworkStream::connectToProxyServer(int proxyId, std::string host, int port)
+{
+  PRINTF(0)("connect to proxy %s, this is proxyId %i\n", host.c_str(), proxyId);
+
+  // this creates the new proxyId in the peers map
+  this->peers[proxyId].socket = new UdpSocket( host, port );
+  this->peers[proxyId].userId = proxyId;
+
+  this->peers[proxyId].nodeType = NET_PROXY_SERVER_ACTIVE;
+  this->peers[proxyId].connectionMonitor = new ConnectionMonitor( proxyId );
+  this->peers[proxyId].ip = this->peers[proxyId].socket->getRemoteAddress();
 }
 
@@ -218,7 +225,9 @@
  * @param port: interface port for all clients
  */
-void NetworkStream::createServer(int port)
-{
-  this->serverSocket = new UdpServerSocket(port);
+void NetworkStream::createServer(int clientPort, int proxyPort)
+{
+  PRINTF(0)(" Creating new Server: listening for clients on port %i and for proxies on port %i", clientPort, proxyPort);
+  this->clientSocket= new UdpServerSocket(clientPort);
+  this->proxySocket = new UdpServerSocket(proxyPort);
 }
 
@@ -240,11 +249,13 @@
  * handsakes are always initialized from the client side first. this starts the handshake and therefore is only
  * executed as client
- */
-void NetworkStream::startHandshake()
+ * @param userId: start handshake for this user id (optional, default == 0)
+ */
+void NetworkStream::startHandshake(int userId)
 {
   Handshake* hs = new Handshake(this->pInfo->nodeType);
-  hs->setUniqueID( 0 );
-  assert( peers[0].handshake == NULL );
-  peers[0].handshake = hs;
+  // fake the unique id
+  hs->setUniqueID( NET_UID_HANDSHAKE );
+  assert( peers[userId].handshake == NULL );
+  peers[userId].handshake = hs;
 
   // set the preferred nick name
@@ -259,4 +270,5 @@
  * it all over the network and creating it on the other platforms (if and only if it is a
  * server
+ * @param sync: the synchronizeable to add
  */
 void NetworkStream::connectSynchronizeable(Synchronizeable& sync)
@@ -264,6 +276,4 @@
   this->synchronizeables.push_back(&sync);
   sync.setNetworkStream( this );
-
-//   this->bActive = true;
 }
 
@@ -271,4 +281,5 @@
 /**
  * removes the synchronizeable from the list of synchronized entities
+ * @param sync: the syncronizeable to remove
  */
 void NetworkStream::disconnectSynchronizeable(Synchronizeable& sync)
@@ -302,43 +313,45 @@
   }
 
-  if ( this->pInfo->isMasterServer())
+  if ( SharedNetworkData::getInstance()->isMasterServer())
   {
     // execute everytthing the master server shoudl do
-    if ( serverSocket )
-      serverSocket->update();
+    if ( this->clientSocket )
+      this->clientSocket->update();
+    if( this->proxySocket)
+      this->proxySocket->update();
 
     this->updateConnectionList();
   }
-  else if( this->pInfo->isProxyServer())
-  {
-    // execute everything the proxy server should do
-    if ( serverSocket )
-      serverSocket->update();
+  else if( SharedNetworkData::getInstance()->isProxyServerActive())
+  {
+    //execute everything the proxy server should do
+    if ( this->clientSocket )
+      this->clientSocket->update();
+    if( this->proxySocket)
+      this->proxySocket->update();
 
     this->updateConnectionList();
   }
-  else
+
+#warning make this more modular: every proxy/master server connection should be watched for termination
+  if( !SharedNetworkData::getInstance()->isMasterServer())
   {
     // check if the connection is ok else terminate and remove
-    if ( peers[0].socket && ( !peers[0].socket->isOk() || peers[0].connectionMonitor->hasTimedOut() ) )
-    {
+    if ( !peers.empty() && peers[NET_ID_MASTER_SERVER].socket &&
+          ( !peers[NET_ID_MASTER_SERVER].socket->isOk() ||
+          peers[NET_ID_MASTER_SERVER].connectionMonitor->hasTimedOut() ) )
+    {
+      this->handleDisconnect( NET_ID_MASTER_SERVER);
       PRINTF(1)("lost connection to server\n");
-
-      peers[0].socket->disconnectServer();
-      delete peers[0].socket;
-      peers[0].socket = NULL;
-
-      if ( peers[0].handshake )
-        delete peers[0].handshake;
-      peers[0].handshake = NULL;
-
-      if ( peers[0].connectionMonitor )
-        delete peers[0].connectionMonitor;
-      peers[0].connectionMonitor = NULL;
-    }
-  }
-
-  cleanUpOldSyncList();
-  handleHandshakes();
+    }
+    // check if there is a redirection command
+    if( this->bRedirect)
+    {
+      this->handleReconnect( NET_ID_MASTER_SERVER);
+    }
+  }
+
+  this->cleanUpOldSyncList();
+  this->handleHandshakes();
 
   // update the network monitor
@@ -347,12 +360,14 @@
   // order of up/downstream is important!!!!
   // don't change it
-  handleDownstream( tick );
-  handleUpstream( tick );
-}
-
-
-/**
- * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new
- * connections (clients) also start the handsake for the new clients
+  this->handleDownstream( tick );
+  this->handleUpstream( tick );
+}
+
+
+/**
+ * @brief handles incoming connections
+ *
+ * if we are a NET_MASTER_SERVER or NET_PROXY_SERVER_ACTIVE update the connection list to accept new connections (clients)
+ * start and initialize the handsake for the new clients
  */
 void NetworkStream::updateConnectionList( )
@@ -360,72 +375,72 @@
   //check for new connections
 
-  NetworkSocket* tempNetworkSocket = serverSocket->getNewSocket();
-
-  // we got new network node
-  if ( tempNetworkSocket )
-  {
-    int clientId;
-    // if there is a list of free client id slots, take these
-    if ( freeSocketSlots.size() > 0 )
-    {
-      clientId = freeSocketSlots.back();
-      freeSocketSlots.pop_back();
-    }
-    else
-    {
-      clientId = 1;
-
-      for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )
-        if ( it->first >= clientId )
-          clientId = it->first + 1;
-    }
-    peers[clientId].socket = tempNetworkSocket;
-
-
-    // create new handshake and init its variables
-    peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
-    peers[clientId].handshake->setUniqueID(clientId);
-
-    peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
-    peers[clientId].userId = clientId;
-
-    PRINTF(0)("num sync: %d\n", synchronizeables.size());
-
-    // get the proxy server informations and write them to the handshake, if any (proxy)
-    assert( this->networkMonitor != NULL);
-    PeerInfo* pi = this->networkMonitor->getFirstChoiceProxy();
-    if( pi != NULL)
-    {
-      peers[clientId].handshake->setProxy1Address( pi->ip);
-    }
-    pi = this->networkMonitor->getSecondChoiceProxy();
-    if( pi != NULL)
-      peers[clientId].handshake->setProxy2Address( pi->ip);
-
-    // check if the connecting client should reconnect to a proxy server
-    peers[clientId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);
-
-    // the connecting node of course is a client
-    peers[clientId].nodeType = NET_CLIENT;
-    peers[clientId].ip = peers[clientId].socket->getRemoteAddress();
-
-
-    // check if there are too many clients connected (DEPRECATED: new: the masterserver sends a list of proxy servers)
-//     if ( clientId > SharedNetworkData::getInstance()->getMaxPlayer() )
-//     {
-// //       peers[clientId].handshake->setRedirect(true);
-// //
-// //       peers[clientId].handshake->doReject( "too many connections" );
-//       PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId);
-//     }
-//     else
-//     {
-//       PRINTF(0)("New Client: %d\n", clientId);
-//     }
-    PRINTF(0)("New Client: %d\n", clientId);
-
-
-  }
-
+  NetworkSocket* tempNetworkSocket = NULL;
+  int userId;
+
+  if( this->clientSocket != NULL)
+  {
+    tempNetworkSocket = this->clientSocket->getNewSocket();
+
+    // we got new NET_CLIENT connecting
+    if ( tempNetworkSocket )
+    {
+      // determine the network node id
+      if ( freeSocketSlots.size() > 0 )
+      {
+        userId = freeSocketSlots.back();
+        freeSocketSlots.pop_back();
+      }
+      else
+      {
+        userId = 1;
+
+        for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )
+          if ( it->first >= userId )
+            userId = it->first + 1;
+      }
+      // this creates a new entry in the peers list
+      peers[userId].socket = tempNetworkSocket;
+      peers[userId].nodeType = NET_CLIENT;
+
+      // handle the newly connected client
+      this->handleConnect(userId);
+
+      PRINTF(0)("New Client: %d\n", userId);
+    }
+  }
+
+
+  if( this->proxySocket != NULL)
+  {
+    tempNetworkSocket = this->proxySocket->getNewSocket();
+
+    // we got new NET_PROXY_SERVER_ACTIVE connecting
+    if ( tempNetworkSocket )
+    {
+      // determine the network node id
+      if ( freeSocketSlots.size() > 0 )
+      {
+        userId = freeSocketSlots.back();
+        freeSocketSlots.pop_back();
+      }
+      else
+      {
+        userId = 1;
+
+        for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )
+          if ( it->first >= userId )
+            userId = it->first + 1;
+      }
+
+      // this creates a new entry in the peers list
+      peers[userId].socket = tempNetworkSocket;
+      peers[userId].nodeType = NET_PROXY_SERVER_ACTIVE;
+
+      // handle the newly connected proxy server
+      this->handleConnect(userId);
+
+      PRINTF(0)("New proxy connected: %d\n", userId);
+    }
+  }
 
 
@@ -446,35 +461,7 @@
       PRINTF(0)("Client is gone: %d (%s)\n", it->second.userId, reason.c_str());
 
-
-      // clean up the network data
-      it->second.socket->disconnectServer();
-      delete it->second.socket;
-      it->second.socket = NULL;
-
-      // remove the old connectin monitor
-      if ( it->second.connectionMonitor )
-        delete it->second.connectionMonitor;
-      it->second.connectionMonitor = NULL;
-
-      // remove the handshake
-      if ( it->second.handshake )
-        delete it->second.handshake;
-      it->second.handshake = NULL;
-
-      // and cleanup the user infos
-      for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )
-      {
-        (*it2)->cleanUpUser( it->second.userId );
-      }
-
-      NetworkGameManager::getInstance()->signalLeftPlayer(it->second.userId);
-
-      freeSocketSlots.push_back( it->second.userId );
-
-      PeerList::iterator delit = it;
+      this->handleDisconnect( it->second.userId);
+
       it++;
-
-      peers.erase( delit );
-
       continue;
     }
@@ -487,4 +474,43 @@
 
 
+/**
+ * this handles new connections
+ * @param userId: the id of the new user node
+ */
+void NetworkStream::handleConnect( int userId)
+{
+  // create new handshake and init its variables
+  peers[userId].handshake = new Handshake(this->pInfo->nodeType, userId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
+  peers[userId].handshake->setUniqueID(userId);
+
+  peers[userId].connectionMonitor = new ConnectionMonitor( userId );
+  peers[userId].userId = userId;
+
+  PRINTF(0)("num sync: %d\n", synchronizeables.size());
+
+  // get the proxy server informations and write them to the handshake, if any (proxy)
+  assert( this->networkMonitor != NULL);
+  PeerInfo* pi = this->networkMonitor->getFirstChoiceProxy();
+  if( pi != NULL)
+  {
+    peers[userId].handshake->setProxy1Address( pi->ip);
+  }
+  pi = this->networkMonitor->getSecondChoiceProxy();
+  if( pi != NULL)
+    peers[userId].handshake->setProxy2Address( pi->ip);
+
+  // check if the connecting client should reconnect to a proxy server
+  if( SharedNetworkData::getInstance()->isMasterServer())
+    peers[userId].handshake->setRedirect(/*this->networkMonitor->isReconnectNextClient()*/false);
+
+  // the connecting node of course is a client
+  peers[userId].ip = peers[userId].socket->getRemoteAddress();
+}
+
+
+
+/**
+ * some debug output
+ */
 void NetworkStream::debug()
 {
@@ -492,5 +518,5 @@
     PRINT(0)(" Host ist Master Server with ID: %i\n", this->pInfo->userId);
   }
-  else if( SharedNetworkData::getInstance()->isProxyServer()) {
+  else if( SharedNetworkData::getInstance()->isProxyServerActive()) {
     PRINT(0)(" Host ist Proxy Server with ID: %i\n", this->pInfo->userId);
   }
@@ -541,15 +567,25 @@
         if ( it->second.handshake->ok() )
         {
-          // the server gave it free for deletion
+          // write the first informations into the node so they can be read from there for case differentiation
+          it->second.nodeType = it->second.handshake->getRemoteNodeType();
+
+          // the counter part didn't mark it free for deletion yet
           if ( !it->second.handshake->allowDel() )
           {
-
-            if ( this->pInfo->isClient() )
+            // make sure this is a connection:
+            // - client       <==> master server
+            // - proxy server <==> master server
+            if(  SharedNetworkData::getInstance()->isClient() || SharedNetworkData::getInstance()->isProxyServerActive() && it->second.isMasterServer())
             {
+              PRINTF(0)("Handshake: i am in client role\n");
+
               SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
               this->pInfo->userId = SharedNetworkData::getInstance()->getHostID();
 
-              it->second.nodeType = it->second.handshake->getRemoteNodeType();
-              it->second.ip = it->second.socket->getRemoteAddress();
+#warning the ip address is not set here because it results in a segfault when connecting to a proxy server => trace this later
+//               it->second.ip = it->second.socket->getRemoteAddress();
+
+              // it->second.nodeType = it->second.handshake->getRemoteNodeType();
+              // it->second.ip = it->second.socket->getRemoteAddress();
               // add the new server to the nodes list (it can be a NET_MASTER_SERVER or NET_PROXY_SERVER)
               this->networkMonitor->addNode(&it->second);
@@ -560,6 +596,8 @@
 
               // now check if the server accepted the connection
-              if( it->second.handshake->redirect())
-                this->handleReconnect( it->second.userId);
+              if( SharedNetworkData::getInstance()->isClient() && it->second.handshake->redirect() )
+              {
+                this->bRedirect = true;
+              }
 
               // create the new network game manager and init it
@@ -570,7 +608,7 @@
             }
 
-
             PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
             it->second.handshake->del();
+
           }
           else
@@ -580,7 +618,6 @@
             {
 
-              if ( this->pInfo->isMasterServer() )
+              if (  SharedNetworkData::getInstance()->isMasterServer() )
               {
-                it->second.nodeType = it->second.handshake->getRemoteNodeType();
                 it->second.ip = it->second.socket->getRemoteAddress();
 
@@ -594,7 +631,8 @@
                 }
               }
-              else if ( this->pInfo->isProxyServer() )
+              else if ( SharedNetworkData::getInstance()->isProxyServerActive() && it->second.isClient() )
               {
-                it->second.nodeType = it->second.handshake->getRemoteNodeType();
+                PRINTF(0)("Handshake: i am in server role\n");
+
                 it->second.ip = it->second.socket->getRemoteAddress();
 
@@ -632,32 +670,66 @@
 void NetworkStream::handleReconnect(int userId)
 {
+  this->bRedirect = false;
+  PeerInfo* pInfo = &this->peers[userId];
+
   PRINTF(0)("===============================================\n");
   PRINTF(0)("Client is redirected to the other proxy servers\n");
+  PRINTF(0)("  user id: %i\n", userId);
+  PRINTF(0)("  connecting to: %s\n", this->networkMonitor->getFirstChoiceProxy()->ip.ipString().c_str());
   PRINTF(0)("===============================================\n");
-
-  return;
-
-  PeerInfo* pInfo = &this->peers[userId];
-
-  // reject the server
-  pInfo->handshake->doReject( "redirected to different server");
 
   // flush the old synchronization states, since the numbering could be completely different
   pInfo->lastAckedState = 0;
   pInfo->lastRecvedState = 0;
-  // not sure if this works as expected
-  if( pInfo->handshake)
-    delete pInfo->handshake;
+
+  // temp save the ip address here
+  IP proxyIP = pInfo->handshake->getProxy1Address();
 
   // disconnect from the current server and reconnect to proxy server
-  pInfo->socket->reconnectToServer( pInfo->handshake->getProxy1Address().ipString(), pInfo->handshake->getProxy1Address().port());
+  this->handleDisconnect( userId);
+  this->connectToProxyServer(NET_ID_PROXY_SERVER_01, proxyIP.ipString(), 9999);
+  #warning the ports are not yet integrated correctly in the ip class
 
   // and restart the handshake
-  this->startHandshake();
-}
+  this->startHandshake( userId);
+}
+
+
+/**
+ * handles the disconnect event
+ * @param userId id of the user to remove
+ */
+void NetworkStream::handleDisconnect( int userId )
+{
+  peers[userId].socket->disconnectServer();
+  delete peers[userId].socket;
+  peers[userId].socket = NULL;
+
+  if ( peers[userId].handshake )
+    delete peers[userId].handshake;
+  peers[userId].handshake = NULL;
+
+  if ( peers[userId].connectionMonitor )
+    delete peers[userId].connectionMonitor;
+  peers[userId].connectionMonitor = NULL;
+
+
+  for ( SynchronizeableList::iterator it2 = synchronizeables.begin(); it2 != synchronizeables.end(); it2++ )  {
+    (*it2)->cleanUpUser( userId );
+  }
+
+  if( SharedNetworkData::getInstance()->isMasterServer())
+    NetworkGameManager::getInstance()->signalLeftPlayer(userId);
+
+  this->freeSocketSlots.push_back( userId );
+
+  peers.erase( userId);
+}
+
 
 
 /**
  * handle upstream network traffic
+ * @param tick: seconds elapsed since last update
  */
 void NetworkStream::handleUpstream( int tick )
@@ -698,5 +770,5 @@
 
       // do not include synchronizeables with uninit id and syncs that don't want to be synchronized
-      if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
+      if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED )
         continue;
 
@@ -706,5 +778,7 @@
 
       // if we are a server (both master and proxy servers) and this is not our handshake
-      if ( ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
+      if ( ( SharedNetworkData::getInstance()->isMasterServer() ||
+             SharedNetworkData::getInstance()->isProxyServerActive() &&  peer->second.isClient())
+             && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
         continue;
 
@@ -720,5 +794,6 @@
 
       // server fakes uniqueid == 0 for handshake
-      if ( ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() ) &&
+      if ( ( SharedNetworkData::getInstance()->isMasterServer() ||
+             SharedNetworkData::getInstance()->isProxyServerActive() &&  peer->second.isClient() ) &&
              sync.getUniqueID() <= SharedNetworkData::getInstance()->getMaxPlayer() + 1) // plus one to handle one client more than the max to redirect it
         n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset );
@@ -760,5 +835,6 @@
       Synchronizeable & sync = **it;
 
-      if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
+      // again exclude all unwanted syncs
+      if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED)
         continue;
 
@@ -771,5 +847,6 @@
     // now compress the data with the zip library
     int compLength = 0;
-    if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+    if ( SharedNetworkData::getInstance()->isMasterServer() ||
+         SharedNetworkData::getInstance()->isProxyServerActive())
       compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer );
     else
@@ -888,6 +965,10 @@
           }
 
-          // if the node we got this unknown sync from is a client we ignore it (since it has no rights to create a new sync)
-          if ( peers[peer->second.userId].isClient() )
+          // if the node we got this unknown sync we ignore it if:
+          //  - the remote host is a client
+          //  - the remote host is a proxy server and we are master server
+          // (since it has no rights to create a new sync)
+          if ( peers[peer->second.userId].isClient() ||
+               (peers[peer->second.userId].isProxyServerActive() && SharedNetworkData::getInstance()->isMasterServer()))
           {
             offset += syncDataLength;
@@ -960,5 +1041,5 @@
         Synchronizeable & sync = **it;
 
-        if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
+        if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED )
           continue;
 
Index: /trunk/src/lib/network/network_stream.h
===================================================================
--- /trunk/src/lib/network/network_stream.h	(revision 9493)
+++ /trunk/src/lib/network/network_stream.h	(revision 9494)
@@ -42,9 +42,9 @@
 
     void connectToMasterServer(std::string host, int port);
-    void connectToProxyServer(std::string host, int port);
-    void createServer(int port);
+    void connectToProxyServer(int proxyId, std::string host, int port);
+    void createServer(int clientPort, int proxyPort);
 
     void createNetworkGameManager();
-    void startHandshake();
+    void startHandshake(int userId = NET_ID_MASTER_SERVER);
 
     /* synchronizeable interface */
@@ -55,7 +55,13 @@
 
     /* functions for the peerInfo information retreival */
+    /** @returns true if this userId is activated at this client false if not*/
     inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
+    /** @returns true if this userId is a local client */
+    inline bool isUserLocal( int userID) { return this->isUserIdActive(userID); }
+    /** @returns true if this user is a master server */
     inline bool isUserMasterServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isMasterServer(); }
-    inline bool isUserProxyServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isProxyServer(); }
+    /** @returns true if this user is a proxy server */
+    inline bool isUserProxyServerActive( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isProxyServerActive(); }
+    /** @returns true if this user is a client */
     inline bool isUserClient( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isClient(); }
 
@@ -80,4 +86,5 @@
 
     void updateConnectionList();
+
     /* handle processes */
     void handleHandshakes();
@@ -87,5 +94,8 @@
     /* handle events*/
     void handleNewClient( int userId );
+
+    void handleConnect( int userId);
     void handleReconnect( int userId );
+    void handleDisconnect( int userId );
 
     void writeToNewDict( byte * data, int length, bool upstream );
@@ -102,5 +112,6 @@
     NetworkMonitor*            networkMonitor;              //!< the network monitor
     NetworkGameManager*        networkGameManager;          //!< reference to the network game manager
-    ServerSocket*              serverSocket;                //!< the listening socket of the server
+    ServerSocket*              clientSocket;                //!< the listening socket of the server
+    ServerSocket*              proxySocket;                 //!< socket for proxy connections
 
     std::map<int,int>          oldSynchronizeables;         //!< used to save recently deleted sync ids to not recreate them
@@ -113,4 +124,6 @@
     int                        dictServer;                  //!< the zip dict for the server
     int                        dictClient;                  //!< the zip dict for the client
+
+    bool                       bRedirect;                   //!< true if the master server sent a redirect command
 };
 #endif /* _NETWORK_STREAM */
Index: /trunk/src/lib/network/peer_info.cc
===================================================================
--- /trunk/src/lib/network/peer_info.cc	(revision 9493)
+++ /trunk/src/lib/network/peer_info.cc	(revision 9494)
@@ -54,18 +54,23 @@
 
 
-std::string PeerInfo::getNodeTypeString()
+const std::string& PeerInfo::getNodeTypeString() const
 {
-  switch( this->nodeType)
-  {
-    case NET_CLIENT:
-      return std::string("client");
-    case NET_PROXY_SERVER_ACTIVE:
-      return std::string("proxy server active");
-    case NET_PROXY_SERVER_PASSIVE:
-      return std::string("proxy server passive");
-    case NET_MASTER_SERVER:
-      return std::string("master server");
-  }
+  return PeerInfo::nodeTypeToString( this->nodeType );
+  // the above does the same, and is faster in it. (there is no case where node is uninit i hope!)
+}
 
-  return std::string("node is uninit");
+const std::string& PeerInfo::nodeTypeToString(unsigned int type)
+{
+  return PeerInfo::nodeNames[type];
 }
+
+
+const std::string PeerInfo::nodeNames[] =
+{
+
+  "maser server",
+  "proxy server active",
+  "proxy server passive",
+  "client",
+  "node is not initialized"
+};
Index: /trunk/src/lib/network/peer_info.h
===================================================================
--- /trunk/src/lib/network/peer_info.h	(revision 9493)
+++ /trunk/src/lib/network/peer_info.h	(revision 9494)
@@ -22,10 +22,12 @@
 
 
-    inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
-    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
-    inline bool isProxyServerPassive() { return this->nodeType == NET_PROXY_SERVER_PASSIVE; }
-    inline bool isClient() { return this->nodeType == NET_CLIENT; }
+    inline bool isMasterServer() const { return this->nodeType == NET_MASTER_SERVER; }
+    inline bool isProxyServerActive() const { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
+    inline bool isProxyServerActivePassive() const { return this->nodeType == NET_PROXY_SERVER_PASSIVE; }
+    inline bool isClient() const { return this->nodeType == NET_CLIENT; }
 
-    std::string getNodeTypeString();
+    const std::string& getNodeTypeString() const;
+    static const std::string& nodeTypeToString(unsigned int type);
+
 
 
@@ -41,4 +43,7 @@
     int                 lastAckedState;          //!< last acked state synchronized state
     int                 lastRecvedState;         //!< last received state
+
+    static const std::string nodeNames[];
+
 };
 
Index: /trunk/src/lib/network/player_stats.cc
===================================================================
--- /trunk/src/lib/network/player_stats.cc	(revision 9493)
+++ /trunk/src/lib/network/player_stats.cc	(revision 9494)
@@ -191,5 +191,5 @@
 void PlayerStats::setNickName( std::string nick )
 {
-  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() )
+  if ( SharedNetworkData::getInstance()->isMasterServer())
   {
     this->nickName = nick;
Index: /trunk/src/lib/network/proxy/network_settings.cc
===================================================================
--- /trunk/src/lib/network/proxy/network_settings.cc	(revision 9493)
+++ /trunk/src/lib/network/proxy/network_settings.cc	(revision 9494)
@@ -40,6 +40,4 @@
   // suggest a good standard max players value
   this->maxPlayer = 10;
-
-//   this->loadData();
 }
 
@@ -53,9 +51,8 @@
 
   // remove all unused proxy data again
-  for( int i = 0; i < this->proxies.size(); i++)
+  for(unsigned int i = 0; i < this->proxies.size(); i++)
   {
-    IPaddress* ip = this->proxies.back();
+    IP ip = this->proxies.back();
     this->proxies.pop_back();
-    delete ip;
   }
 }
@@ -104,4 +101,5 @@
 
   LoadParam(root, "max-player", this, NetworkSettings, setMaxPlayer);
+  LoadParam(root, "max-player-saturation", this, NetworkSettings, setMaxPlayerSaturation);
 
 
@@ -140,9 +138,5 @@
     return;
 
-  IPaddress *ip = new IPaddress;
-
-  SDLNet_ResolveHost( ip, proxyAddr.c_str(), 9999 );
-
-  this->proxies.push_back(ip);
+  this->proxies.push_back(IP(proxyAddr, 9999));
 }
 
Index: /trunk/src/lib/network/proxy/network_settings.h
===================================================================
--- /trunk/src/lib/network/proxy/network_settings.h	(revision 9493)
+++ /trunk/src/lib/network/proxy/network_settings.h	(revision 9494)
@@ -37,13 +37,16 @@
     inline void setMaxPlayer(int number) { this->maxPlayer = number; }
     /** @returns teh max number of players */
-    int getMaxPlayer() { return this->maxPlayer; }
+    int getMaxPlayer() const { return this->maxPlayer; }
+    /** sets the @param saturation: a threshold in percente when the proxy servers should be activated to be able to redirect the clients */
+    inline void setMaxPlayerSaturation(float saturation) { this->maxPlayerSaturation = saturation; }
+
 
     void setMasterAddr(const std::string& masterAddr);
     /** @returns the address of the master server read from the network config file */
-    inline IP getMasterAddr() { return this->masterServer; }
+    inline const IP& getMasterAddr() const { return this->masterServer; }
 
     void setProxyAddr(const std::string& proxyAddr);
     /** @returns the list of proxy servers from the init file */
-    inline std::vector<IPaddress*>* getProxyList() { return &this->proxies; }
+    inline std::vector<IP>* getProxyList() { return &this->proxies; }
 
 
@@ -53,7 +56,10 @@
 
   private:
-    static NetworkSettings*        singletonRef;            //!< Pointer to the only instance of this Class
+    static NetworkSettings*      singletonRef;            //!< Pointer to the only instance of this Class
+
     int                          maxPlayer;               //!< maximal number of players
-    std::vector<IPaddress*>      proxies;                 //!< all registered proxies
+    float                        maxPlayerSaturation;     //!< the saturation level from where on the proxy server should be activated
+
+    std::vector<IP>              proxies;                 //!< all registered proxies
     IP                           masterServer;            //!< master server ip address
 
Index: /trunk/src/lib/network/shared_network_data.cc
===================================================================
--- /trunk/src/lib/network/shared_network_data.cc	(revision 9493)
+++ /trunk/src/lib/network/shared_network_data.cc	(revision 9494)
@@ -20,4 +20,6 @@
 #include "state.h"
 
+#include "network_stream.h"
+
 #include "debug.h"
 
@@ -34,5 +36,5 @@
   this->setClassID(CL_SHARED_NETWORK_DATA, "SharedNetworkData");
 
-  this->nodeType = NET_CLIENT;
+  this->nodeType = NET_MASTER_SERVER;
   this->hostID = -1;
   this->defaultSyncStream = NULL;
@@ -51,2 +53,31 @@
   SharedNetworkData::singletonRef = NULL;
 }
+
+
+
+/** @return true if this user is connected to the local host */
+bool SharedNetworkData::isUserLocal( int userID)
+{
+  return this->defaultSyncStream->isUserLocal(userID);
+}
+
+
+/** @returns true if this user is a master server */
+bool SharedNetworkData::isUserMasterServer( int userID )
+{
+  return this->defaultSyncStream->isUserMasterServer(userID);
+}
+
+
+/** @returns true if this user is a proxy server */
+bool SharedNetworkData::isUserProxyServerActive( int userID )
+{
+   return this->defaultSyncStream->isUserProxyServerActive(userID);
+}
+
+
+/** @returns true if this user is a client */
+bool SharedNetworkData::isUserClient( int userID )
+{
+  return this->defaultSyncStream->isUserClient(userID);
+}
Index: /trunk/src/lib/network/shared_network_data.h
===================================================================
--- /trunk/src/lib/network/shared_network_data.h	(revision 9493)
+++ /trunk/src/lib/network/shared_network_data.h	(revision 9494)
@@ -14,5 +14,5 @@
 #define NET_MAX_CONNECTIONS 2
 
-class NetworkStream;
+
 class Synchronizeable;
 
@@ -28,16 +28,26 @@
 
     /** @returns the next uniqueID free for an object */
-    inline int getNewUniqueID() { return ( this->nodeType != NET_CLIENT)?this->newUniqueID++:-1; }
+    inline int getNewUniqueID() { return ( isMasterServer())?this->newUniqueID++:-1; }
     /** sets the @param newUniqueID: the new offset for the next unique id */
     inline void setNewUniqueID(int newUniqueID) { this->newUniqueID = newUniqueID; }
 
+    /** sets the game server flag @param bGameServer true if it is a game server */
+    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
     /** @returns true is this node is a master server */
     inline bool isMasterServer() { return this->nodeType == NET_MASTER_SERVER; }
     /** @returns true is this node is a proxy server */
-    inline bool isProxyServer() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
+    inline bool isProxyServerActive() { return this->nodeType == NET_PROXY_SERVER_ACTIVE; }
     /** @returns true is this node is a client*/
     inline bool isClient() { return this->nodeType == NET_CLIENT; }
-    /** sets the game server flag @param bGameServer true if it is a game server */
-    inline void setNodeType(int nodeType) { this->nodeType = nodeType; }
+
+    /** @return true if this user is connected to the local host */
+    bool isUserLocal( int userID);
+    /** @returns true if this user is a master server */
+    bool isUserMasterServer( int userID );
+    /** @returns true if this user is a proxy server */
+    bool isUserProxyServerActive( int userID );
+    /** @returns true if this user is a client */
+    bool isUserClient( int userID );
+
 
     /** @returns the maximum number of players for this server */
Index: /trunk/src/lib/network/synchronizeable.cc
===================================================================
--- /trunk/src/lib/network/synchronizeable.cc	(revision 9493)
+++ /trunk/src/lib/network/synchronizeable.cc	(revision 9494)
@@ -72,5 +72,6 @@
     this->networkStream->disconnectSynchronizeable(*this);
 
-    if ( (SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer() )
+    // remove the message manager only by the server
+    if ( (SharedNetworkData::getInstance()->isMasterServer() )
            && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
       NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
@@ -213,5 +214,5 @@
       hasPermission = true;
     // now check PROXY_SERVER permissions
-    else if( SharedNetworkData::getInstance()->isProxyServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
+    else if( SharedNetworkData::getInstance()->isProxyServerActive() && (*it)->checkPermission( PERMISSION_PROXY_SERVER ))
       hasPermission = true;
     // now check OWNER permissions
@@ -222,8 +223,10 @@
       hasPermission = true;
     // SPECIAL: get write permissions if i am master server and i am able to overwrite the client stuff
+#warning this could probably override also clients that are connected to another proxy: the master server overwrites it
     else if( SharedNetworkData::getInstance()->isMasterServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
       hasPermission = true;
     // SPECIAL: get write permissions if i am proxy server and i am able to overwrite the client stuff
-    else if( SharedNetworkData::getInstance()->isProxyServer()  && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
+    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
+             && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) )
       hasPermission = true;
     else
@@ -354,5 +357,6 @@
       hasPermission = true;
     // now check PROXY_SERVER permissions
-    else if( this->networkStream->isUserProxyServer( userId )  && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
+    else if( this->networkStream->isUserProxyServerActive( userId )  && (*it)->checkPermission( PERMISSION_MASTER_SERVER )
+             && SharedNetworkData::getInstance()->isClient())
       hasPermission = true;
     // now check OWNER permissions
@@ -366,5 +370,6 @@
       hasPermission = true;
     // SPECIAL: get write permissions if im sending to a proxy server that does not own this sync
-    else if( this->networkStream->isUserProxyServer( userId )  && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
+    else if( this->networkStream->isUserProxyServerActive( userId ) && SharedNetworkData::getInstance()->isClient()
+              && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
       hasPermission = true;
     else
@@ -388,5 +393,5 @@
     else
     {
-//      PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s %d %d %d %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_MASTER_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserServer( userId ), this->owner, userId );
+//       PRINTF(0)("DONT SET VAR BECAUSE OF PERMISSION: %s perm: %d %d %d - %d %d %d\n", (*it)->getName().c_str(), (*it)->checkPermission( PERMISSION_MASTER_SERVER ), (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_ALL ), networkStream->isUserMasterServer( userId ), this->owner, userId );
       n = (*it)->getSizeFromBuf( stateTo->data + i, stateTo->dataLength - i );
       //NETPRINTF(0)("%s::setvar %s %d\n", getClassCName(), (*it)->getName().c_str(), n);
@@ -416,5 +421,4 @@
 void Synchronizeable::registerVar( SynchronizeableVar * var )
 {
-  //PRINTF(0)("ADDING VAR: %s\n", var->getName().c_str());
   syncVarList.push_back( var );
 }
@@ -428,5 +432,4 @@
 int Synchronizeable::registerVarId( SynchronizeableVar * var )
 {
-  //PRINTF(0)("ADDING VAR: %s\n", var->getName().c_str());
   syncVarList.push_back( var );
   var->setWatched( true );
Index: /trunk/src/lib/network/synchronizeable_var/synchronizeable_var.h
===================================================================
--- /trunk/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 9493)
+++ /trunk/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 9494)
@@ -10,10 +10,5 @@
 #include <string>
 
-enum {
-  PERMISSION_MASTER_SERVER = 1,
-  PERMISSION_PROXY_SERVER  = 2,
-  PERMISSION_OWNER         = 4,
-  PERMISSION_ALL           = 8
-};
+
 
 class SynchronizeableVar {
Index: /trunk/src/lib/network/tcp_server_socket.cc
===================================================================
--- /trunk/src/lib/network/tcp_server_socket.cc	(revision 9493)
+++ /trunk/src/lib/network/tcp_server_socket.cc	(revision 9494)
@@ -126,4 +126,6 @@
 }
 
+
+
 void TcpServerSocket::close( )
 {
Index: /trunk/src/lib/network/udp_server_socket.cc
===================================================================
--- /trunk/src/lib/network/udp_server_socket.cc	(revision 9493)
+++ /trunk/src/lib/network/udp_server_socket.cc	(revision 9494)
@@ -94,4 +94,5 @@
 }
 
+
 /**
  * stop listening on server
@@ -220,5 +221,5 @@
   if ( !socket )
     return false;
-  
+
   assert( networkPacket.length <= UDP_PACKET_SIZE );
 
@@ -232,5 +233,5 @@
     return false;
   }
-  
+
   return true;
 }
@@ -244,4 +245,5 @@
   int newConn = 0;
 
+  // iterate through all newly received packets and assign them to the users packet buffer
   for ( res = SDLNet_UDP_Recv( socket, packet ); res == 1; res = SDLNet_UDP_Recv( socket, packet ) )
   {
@@ -250,10 +252,16 @@
 
     if ( packet->len <= 0 )
-      continue; 
-        
-    for ( userId =0; userId < (int)userList.size(); userId++ )
-      if ( userList[userId].addr.host == packet->address.host && userList[userId].addr.port == packet->address.port && userList[userId].randomByte == ( packet->data[0] & 0xFC ) )
+      continue;
+
+    // search the user id this backet belongs to
+    for ( userId = 0; userId < (int)userList.size(); userId++ )
+    {
+      if ( userList[userId].addr.host == packet->address.host &&
+           userList[userId].addr.port == packet->address.port &&
+           userList[userId].randomByte == ( packet->data[0] & 0xFC ) )
         break;
-
+    }
+
+    // is it a new packet initializing a new connecion?
     if ( userId >= (int)userList.size() )
     {
@@ -271,5 +279,5 @@
           break;
 
-      initUser( userId, packet->address, packet->data[0] & 0xFC );
+      this->initUser( userId, packet->address, packet->data[0] & 0xFC );
       UdpSocket * sock = new UdpSocket( this, packet->address, userId, packet->data[0] & 0xFC );
       newSocketList.push_back( sock );
@@ -277,6 +285,6 @@
     }
 
-    //add new packet to packetbuffer
-
+
+    // add new packet to packetbuffer
     NetworkPacket networkPacket;
     networkPacket.length = packet->len;
Index: /trunk/src/lib/network/udp_server_socket.h
===================================================================
--- /trunk/src/lib/network/udp_server_socket.h	(revision 9493)
+++ /trunk/src/lib/network/udp_server_socket.h	(revision 9494)
@@ -33,9 +33,12 @@
 typedef std::vector<NetworkPacketList> PacketBuffer;
 
+
+//!< informations struct for each user
 struct UserInfo
 {
-  IPaddress addr;
-  byte randomByte;
+  IPaddress     addr;            //!< ip address of this user
+  byte          randomByte;      //!< random byte of this user
 };
+
 
 typedef std::vector<UserInfo> UserList;
@@ -43,4 +46,6 @@
 typedef std::list<UdpSocket*> UdpSocketList;
 
+
+//!< the upd server socket listening for incoming connections
 class UdpServerSocket : public ServerSocket
 {
@@ -49,25 +54,29 @@
     virtual ~UdpServerSocket();
 
+    /* server socket manipulations */
     virtual bool listen( unsigned int port );
-
     virtual NetworkSocket* getNewSocket( void );
-
     virtual void close();
 
     virtual void update();
 
+    /* network traffic interface */
+    NetworkPacket getPacket( int userId );
+    void removeUser( int userId );
+    bool sendPacket( NetworkPacket networkPacket, int userId );
+
+
+  private:
     void removeUserPackets( int userId );
-    void removeUser( int userId );
-    NetworkPacket getPacket( int userId );
-    bool sendPacket( NetworkPacket networkPacket, int userId );
     int getPacketCount( int childId );
     void initUser( int childId, IPaddress ip, byte randomByte );
 
+
   private:
-    UDPsocket     socket;           //!< will be uses to send/recieve data
-    UDPpacket *   packet;           //!< packet structure to recieve packet
-    PacketBuffer  packetBuffer;     //!< will store recieved packets for UdpSockets
-    UserList      userList;         //!< contains information about clients
-    UdpSocketList newSocketList;    //!< contains new socket
+    UDPsocket          socket;           //!< will be used to send/recieve data to/from clients
+    UDPpacket *        packet;           //!< packet structure to recieve packet
+    PacketBuffer       packetBuffer;     //!< will store recieved packets for UdpSockets
+    UserList           userList;         //!< contains information about clients
+    UdpSocketList      newSocketList;    //!< contains new socket
 
 };
Index: /trunk/src/lib/network/zip.h
===================================================================
--- /trunk/src/lib/network/zip.h	(revision 9493)
+++ /trunk/src/lib/network/zip.h	(revision 9494)
@@ -21,5 +21,5 @@
 
 //! A class for compressing/uncompressing packes.
-class Zip 
+class Zip
 {
   public:
@@ -27,9 +27,9 @@
     /** @returns a Pointer to the only object of this Class */
     inline static Zip* getInstance(void) { if (!singletonRef) singletonRef = new Zip();  return singletonRef; };
-    
+
     int loadDictionary( std::string name );
     int zip( byte * from, int fromLength, byte * to, int maxLength, int dict = 0 );
     int unZip( byte * from, int fromLength, byte * to, int maxLength );
-    
+
     int getDictCount(){ return dicts.size(); }
 
@@ -37,7 +37,7 @@
     Zip();
     static Zip* singletonRef;
-    
+
     std::vector<DictionaryEntry> dicts;
 };
 
-#endif /* _PROTO_SINGLETON_H */
+#endif /* _ZIP_H */
Index: /trunk/src/story_entities/game_world.cc
===================================================================
--- /trunk/src/story_entities/game_world.cc	(revision 9493)
+++ /trunk/src/story_entities/game_world.cc	(revision 9494)
@@ -414,4 +414,11 @@
     double currentFrame = Timer::getNow();
 
+    if (currentFrame - this->lastFrame < .01)
+    {
+      SDL_Delay(1000.0 * (0.01 - (currentFrame - lastFrame)));
+      currentFrame = Timer::getNow();
+    }
+
+
     frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE;
     this->frameTimes[frameTimesIndex] = currentFrame - this->lastFrame;
@@ -469,10 +476,10 @@
       this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ));
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
-    this->dataTank->objectManager->getObjectList(OM_GROUP_00));
+      this->dataTank->objectManager->getObjectList(OM_GROUP_00));
 
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
-  this->dataTank->objectManager->getObjectList(OM_GROUP_02));
+      this->dataTank->objectManager->getObjectList(OM_GROUP_02));
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_02),
-  this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
+      this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ));
 
 
@@ -513,11 +520,11 @@
 {
 
-    // if this server is a dedicated server the game workd does not need to be drawn
+  // if this server is a dedicated server the game workd does not need to be drawn
   if( !GraphicsEngine::getInstance()->isDedicated())
   {
-  // render the reflection texture
-  this->renderPassReflection();
-  // redner the refraction texture
-  this->renderPassRefraction();
+    // render the reflection texture
+    this->renderPassReflection();
+    // redner the refraction texture
+    this->renderPassRefraction();
   }
   // render all
Index: /trunk/src/story_entities/multi_player_world_data.cc
===================================================================
--- /trunk/src/story_entities/multi_player_world_data.cc	(revision 9493)
+++ /trunk/src/story_entities/multi_player_world_data.cc	(revision 9494)
@@ -112,5 +112,5 @@
   const TiXmlElement* element = NULL;
 
-  if( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+  if( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
   {
     /* load the spawning points */
@@ -148,5 +148,5 @@
     element = element->FirstChildElement();
 
-    if( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+    if( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
     {
       while( element != NULL)
@@ -206,5 +206,5 @@
 
 
-    if( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+    if( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
     {
       this->localPlayer = new Player();
@@ -284,5 +284,5 @@
 
   // create server playable
-  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+  if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
   {
     NetworkGameManager::getInstance()->signalNewPlayer( 0 );
Index: /trunk/src/subprojects/network/network_unit_test.cc
===================================================================
--- /trunk/src/subprojects/network/network_unit_test.cc	(revision 9493)
+++ /trunk/src/subprojects/network/network_unit_test.cc	(revision 9494)
@@ -276,5 +276,5 @@
   for(;;)
   {
-    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"server to client", 18, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"server to client", 18, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     netMan->synchronize( 100 );
     SDL_Delay(100);
@@ -323,5 +323,5 @@
   {
     netMan->synchronize( 100 );
-    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"client to server", 18, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"client to server", 18, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     ss = dynamic_cast<SimpleSync*>(ClassList::getObject( "Server", CL_SIMPLE_SYNC ) );
     SDL_Delay(100);
Index: /trunk/src/util/Makefile.am
===================================================================
--- /trunk/src/util/Makefile.am	(revision 9493)
+++ /trunk/src/util/Makefile.am	(revision 9494)
@@ -26,7 +26,5 @@
 			animation/animation_player.cc \
 			\
-			track/pilot_node.cc \
-			\
-			network_stats_widget.cc
+			track/pilot_node.cc
 
 #			track/track_manager.cc \
@@ -54,8 +52,5 @@
 			animation/t_animation.h \
 			\
-			track/pilot_node.h \
-			\
-			network_stats_widget.h
-
+			track/pilot_node.h
 
 #			track/track_manager.h \
Index: /trunk/src/util/game_rules.cc
===================================================================
--- /trunk/src/util/game_rules.cc	(revision 9493)
+++ /trunk/src/util/game_rules.cc	(revision 9494)
@@ -87,5 +87,5 @@
 void GameRules::registerKill(const Kill& kill)
 {
-  if ( SharedNetworkData::getInstance()->isClient() )
+  if ( SharedNetworkData::getInstance()->isClient() || SharedNetworkData::getInstance()->isProxyServerActive())
     return;
 
Index: /trunk/src/util/multiplayer_team_deathmatch.cc
===================================================================
--- /trunk/src/util/multiplayer_team_deathmatch.cc	(revision 9493)
+++ /trunk/src/util/multiplayer_team_deathmatch.cc	(revision 9494)
@@ -152,19 +152,29 @@
       box->setAbsCoor2D( 300, 100 );
 
-      OrxGui::GLGuiPushButton * buttonSpectator = new OrxGui::GLGuiPushButton("Spectator");
-      box->pack( buttonSpectator );
-      buttonSpectator->released.connect(this, &MultiplayerTeamDeathmatch::onButtonSpectator);
-
-      OrxGui::GLGuiPushButton * buttonRandom = new OrxGui::GLGuiPushButton("Random");
-      box->pack( buttonRandom );
-      buttonRandom->released.connect(this, &MultiplayerTeamDeathmatch::onButtonRandom);
-
-      OrxGui::GLGuiPushButton * buttonTeam0 = new OrxGui::GLGuiPushButton("Blue Team");
-      box->pack( buttonTeam0 );
-      buttonTeam0->released.connect(this, &MultiplayerTeamDeathmatch::onButtonTeam0);
-
-      OrxGui::GLGuiPushButton * buttonTeam1 = new OrxGui::GLGuiPushButton("Red Team");
-      box->pack( buttonTeam1 );
-      buttonTeam1->released.connect(this, &MultiplayerTeamDeathmatch::onButtonTeam1);
+      if( SharedNetworkData::getInstance()->isClient() ||  SharedNetworkData::getInstance()->isProxyServerActive())
+      {
+        OrxGui::GLGuiPushButton * buttonSpectator = new OrxGui::GLGuiPushButton("Spectator");
+        box->pack( buttonSpectator );
+        buttonSpectator->released.connect(this, &MultiplayerTeamDeathmatch::onButtonSpectator);
+
+        OrxGui::GLGuiPushButton * buttonRandom = new OrxGui::GLGuiPushButton("Random");
+        box->pack( buttonRandom );
+        buttonRandom->released.connect(this, &MultiplayerTeamDeathmatch::onButtonRandom);
+
+        OrxGui::GLGuiPushButton * buttonTeam0 = new OrxGui::GLGuiPushButton("Blue Team");
+        box->pack( buttonTeam0 );
+        buttonTeam0->released.connect(this, &MultiplayerTeamDeathmatch::onButtonTeam0);
+
+        OrxGui::GLGuiPushButton * buttonTeam1 = new OrxGui::GLGuiPushButton("Red Team");
+        box->pack( buttonTeam1 );
+        buttonTeam1->released.connect(this, &MultiplayerTeamDeathmatch::onButtonTeam1);
+      }
+      else
+      {
+        OrxGui::GLGuiText* text = new OrxGui::GLGuiText();
+        text->setText("Server Mode: not able to play at this node");
+        box->pack( text);
+      }
+
 
       if ( bShowTeamChange )
@@ -204,5 +214,5 @@
   assignPlayable();
 
-  if ( SharedNetworkData::getInstance()->isClient() )
+  if ( SharedNetworkData::getInstance()->isClient() || SharedNetworkData::getInstance()->isProxyServerActive())
     return;
 
@@ -268,5 +278,5 @@
 void MultiplayerTeamDeathmatch::checkGameRules()
 {
-  if ( SharedNetworkData::getInstance()->isClient() )
+  if ( SharedNetworkData::getInstance()->isClient() || SharedNetworkData::getInstance()->isProxyServerActive())
     return;
 
@@ -296,5 +306,5 @@
 
   if ( team == 0 || team == 1 )
-    return CL_FPS_PLAYER;
+    return CL_TURBINE_HOVER;
 
   assert( false );
@@ -303,4 +313,6 @@
 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassID classId )
 {
+  if (classId == CL_TURBINE_HOVER)
+   return "models/ships/hoverglider_mainbody.obj";
   if ( team == 0 )
     return "models/creatures/doom_guy.md2";
Index: unk/src/util/network_stats_widget.cc
===================================================================
--- /trunk/src/util/network_stats_widget.cc	(revision 9493)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/*
-   orxonox - the future of 3D-vertical-scrollers
-
-   Copyright (C) 2004 orx
-
-   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, or (at your option)
-   any later version.
-
-   ### File Specific:
-   main-programmer: Benjamin Grauer
-   co-programmer: ...
-*/
-
-//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
-
-#include "network_stats_widget.h"
-
-#include "multi_type.h"
-
-namespace OrxGui
-{
-  HostWidget::HostWidget(const std::string& name, const IP& ip)
-      : GLGuiBox(Horizontal)
-  {
-    this->setName(name);
-    this->setIP(ip);
-
-    this->pack(&this->_name);
-    this->pack(&this->_ip);
-  }
-
-  void HostWidget::showing()
-  {
-    this->_name.show();
-    this->_ip.show();
-  }
-
-  void HostWidget::hiding()
-  {
-    this->_name.hide();
-    this->_ip.hide();
-  }
-
-
-
-  //======================================================//
-
-
-  ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
-  : _proxyWidget(proxyName, ip)
-  {
-    this->_clientNameWidth = 100.0f;
-    this->pack(&_proxyWidget);
-  }
-
-  void ProxyWidget::addClient(const std::string& name, const IP& ip)
-  {
-    HostWidget* newClient = new HostWidget(name, ip);
-    newClient->setNameWidth(this->_clientNameWidth);
-
-    this->pack(newClient);
-
-    if (this->isVisible())
-      newClient->show();
-  }
-
-  bool ProxyWidget::removeClient(const IP& ip)
-  {
-    std::vector<HostWidget*>::iterator rmIt;
-    for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
-    {
-      if (*(*rmIt) == ip)
-      {
-        delete (*rmIt);
-        this->_clients.erase(rmIt);
-        return true;
-      }
-    }
-    return false;
-  }
-
-  bool ProxyWidget::removeClient(const std::string& name)
-  {
-    std::vector<HostWidget*>::iterator rmIt;
-    for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
-    {
-      if (*(*rmIt) == name)
-      {
-        delete (*rmIt);
-        this->_clients.erase(rmIt);
-        return true;
-      }
-    }
-    return false;
-
-  }
-
-  bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
-  {
-    std::vector<HostWidget*>::iterator rmIt;
-    for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
-    {
-      if (*(*rmIt) == ip && *(*rmIt) == name)
-      {
-        delete (*rmIt);
-        this->_clients.erase(rmIt);
-        return true;
-      }
-    }
-    return false;
-  }
-
-
-  void ProxyWidget::setClientNameWidths(float width)
-  {
-    this->_clientNameWidth = width;
-    for (unsigned int i = 0; i < this->_clients.size(); ++i)
-      this->_clients[i]->setNameWidth(width);
-  }
-
-  void ProxyWidget::hiding()
-  {
-    this->_proxyWidget.hide();
-    for (unsigned int i = 0; i < this->_clients.size(); ++i)
-      this->_clients[i]->hide();
-  }
-
-  void ProxyWidget::showing()
-  {
-    this->_proxyWidget.show();
-    for (unsigned int i = 0; i < this->_clients.size(); ++i)
-      this->_clients[i]->show();
-  }
-
-
-  //======================================================//
-
-
-
-  /**
-   * @brief standard constructor
-   */
-  NetworkStatsWidget::NetworkStatsWidget ()
-  : GLGuiBox(Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
-  {
-    //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
-
-    this->_bar.setSize2D(100, 30);
-    this->pack(&this->_valueText);
-    this->_bar.setParent2D(&this->_valueText);
-
-    this->_valueText.setChangedTextColor(Color::white);
-
-    //this->setBackgroundTexture("maps/gui_element_background_2.png");
-    this->setBackgroundColor(Color(.5,.5,.5,1));
-
-    //this->_name.setBackgroundTexture(Texture());
-    //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
-    this->_bar.setBackgroundTexture(Texture());
-    this->_bar.setBackgroundColor(Color(0,0,0,0));
-    this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
-    this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
-    this->_bar.setChangedValueColor(Color::black);
-  }
-
-
-  /**
-   * @brief standard deconstructor
-   */
-  NetworkStatsWidget::~NetworkStatsWidget ()
-  {}
-
-
-  void NetworkStatsWidget::setMaximum(float max)
-  {
-    this->_bar.setMaximum(max);
-  }
-
-  void NetworkStatsWidget::setValue(float value)
-  {
-    MultiType val(value);
-    val.setType(MT_INT);
-
-
-    this->_bar.setValue(value);
-    this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
-    this->_bar.setFrontColor(Color(1,1,1,1), true);
-    this->_valueText.setText(val.getString());
-  }
-
-  void NetworkStatsWidget::resize()
-  {
-    GLGuiBox::resize();
-  }
-
-
-  void NetworkStatsWidget::showing()
-  {
-    this->_valueText.show();
-    this->_bar.show();
-  }
-
-  void NetworkStatsWidget::hiding()
-  {
-    this->_valueText.hide();
-    this->_bar.hide();
-  }
-}
Index: unk/src/util/network_stats_widget.h
===================================================================
--- /trunk/src/util/network_stats_widget.h	(revision 9493)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*!
- * @file network_stats_widget.h
- * @brief Definition of an EnergyWidget, that displays a bar and a Text
-*/
-
-#ifndef _NETWORK_STATS_WIDGET_H
-#define _NETWORK_STATS_WIDGET_H
-
-#include "glgui_box.h"
-#include "glgui_bar.h"
-#include "glgui_text.h"
-
-#include "network/ip.h"
-
-
-namespace OrxGui
-{
-
-  class HostWidget : public GLGuiBox
-  {
-    public:
-      HostWidget(const std::string& name, const IP& ip);
-      ~HostWidget() {};
-
-      void setName(const std::string& name) { this->_name.setText(name); };
-      void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; };
-
-      void setNameWidth(float width) { this->_name.setLineWidth(width); };
-
-      bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
-      bool operator==(const std::string& name) const { return (this->_name == name); };
-
-    protected:
-      virtual void showing();
-      virtual void hiding();
-
-    private:
-      GLGuiText        _name;           //!< The Name of the Proxy server to be displayed.
-      GLGuiText        _ip;             //!< The IP of the proxy server.
-      IP               _storedIP;       //!< The ip to compare.
-  };
-
-
-  class ProxyWidget : public GLGuiBox
-  {
-    public:
-      ProxyWidget(const std::string& proxyName, const IP& ip);
-
-      void addClient(const std::string& name, const IP& ip);
-
-      bool removeClient(const IP& ip);
-      bool removeClient(const std::string& name);
-      bool removeClient(const std::string& name, const IP& ip);
-
-      void setClientNameWidths(float width);
-
-
-    protected:
-      virtual void hiding();
-      virtual void showing();
-
-
-    private:
-      HostWidget       _proxyWidget;
-
-      std::vector<HostWidget*>  _clients;
-      float            _clientNameWidth;
-  };
-
-
-
-
-  //! A class to display network Statistics.
-  class NetworkStatsWidget : public GLGuiBox
-  {
-    public:
-      NetworkStatsWidget();
-      virtual ~NetworkStatsWidget();
-
-      void setUpstream(unsigned int upstream);
-      void setDownstream(unsigned int upstream);
-      void setIP(const IP& ip);
-
-
-
-      void addProxy(const std::string& name, const IP& proxy);
-
-
-      //void rebuildConnectedHosts(std::vector<hosts> hosts);
-
-      void setMaximum(float max);
-      void setValue(float value);
-
-    protected:
-      virtual void resize();
-      virtual void showing();
-      virtual void hiding();
-
-    private:
-      HostWidget             _thisHost;
-
-      GLGuiText              _upstreamText;
-      GLGuiText              _downstreamText;
-
-      std::vector<HostWidget*>_connectedProxies;
-
-      GLGuiText              _serverIP;
-
-
-      GLGuiText              _valueText;
-      GLGuiBar               _bar;
-  };
-}
-#endif /* _NETWORK_STATS_WIDGET_H */
Index: /trunk/src/world_entities/creatures/fps_player.cc
===================================================================
--- /trunk/src/world_entities/creatures/fps_player.cc	(revision 9493)
+++ /trunk/src/world_entities/creatures/fps_player.cc	(revision 9494)
@@ -287,5 +287,5 @@
   //dealing damage
 
-  if ( State::isOnline() && (SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer()))
+  if ( State::isOnline() && (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/))
   {
     this->damageTicker -= time;
Index: /trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- /trunk/src/world_entities/space_ships/space_ship.cc	(revision 9493)
+++ /trunk/src/world_entities/space_ships/space_ship.cc	(revision 9494)
@@ -310,14 +310,5 @@
 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
 {
-  Playable::collidesWith(entity, location);
-
-  if( entity->isA(CL_PROJECTILE) && entity != ref)
-  {
-    if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
-    {
-      //TODO handle this
-    }
-  }
-  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassCName(), entity->getClassCName(), location.x, location.y, location.z);
+
 }
 
Index: /trunk/src/world_entities/space_ships/turbine_hover.cc
===================================================================
--- /trunk/src/world_entities/space_ships/turbine_hover.cc	(revision 9493)
+++ /trunk/src/world_entities/space_ships/turbine_hover.cc	(revision 9494)
@@ -126,5 +126,6 @@
   this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
   //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
-  //this->cameraNode.setParent(this);
+  this->cameraNode.setParent(this);
+  this->cameraNode.setRelCoor(0,5,0);
 
   // rotors
@@ -211,5 +212,5 @@
   this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
   this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
-  
+
   registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
   registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
@@ -218,5 +219,5 @@
   registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
   registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
-  //registerVar( new SynchronizeableQuaternion( &direction, &direction, "direction", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableQuaternion( &direction, &direction, "direction", PERMISSION_OWNER ) );
   registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
   registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
@@ -294,11 +295,15 @@
 
   // spaceship controlled movement
+
+  // TRYING TO FIX PNode.
+  //this->cameraNode.setRelCoor(Vector(0.0f, 5.0f, 0.0f));//, 30.0f);
+  //this->cameraNode.setRelDir(Quaternion(this->smoothRotator  *10.0, Vector(0,1,0)));
+
   this->movement(dt);
   this->rotorCycle += this->rotorSpeed * dt;
-
-  // TRYING TO FIX PNode.
-  this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
-  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
-}
+}
+
+
+#include "shared_network_data.h"
 
 /**
@@ -349,5 +354,6 @@
 
         this->velocity += (accelerationDir - damping)* dt;
-        this->shiftCoor (this->velocity * dt);
+        //if (this->getOwner() != SharedNetworkData::getInstance()->getHostID())
+          this->shiftCoor (this->velocity * dt);
 
         // limit the maximum rotation speed.
@@ -362,5 +368,6 @@
         }
 
-        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
+        //if (this->getOwner() != SharedNetworkData::getInstance()->getHostID())
+          this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
 
         this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
@@ -407,24 +414,24 @@
 
     case Playable::Vertical:
-    {
-      accel.z = 0;
-      Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
-      accelerationDir.z=0;
+      {
+        accel.z = 0;
+        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
+        accelerationDir.z=0;
 
         // this is the air friction (necessary for a smooth control)
-      Vector damping = (this->velocity * this->airFriction);
-
-      this->velocity += (accelerationDir - damping)* dt;
-      this->shiftCoor (this->velocity * dt);
-
-      this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
-
-      this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
-      this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
-
-      this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
-      this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
-    }
-    break;
+        Vector damping = (this->velocity * this->airFriction);
+
+        this->velocity += (accelerationDir - damping)* dt;
+        this->shiftCoor (this->velocity * dt);
+
+        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
+
+        this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
+        this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
+
+        this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
+        this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
+      }
+      break;
     default:
       PRINTF(2)("Playmode %s Not Implemented\n", Playable::playmodeToString(this->getPlaymode()).c_str());
Index: /trunk/src/world_entities/spawning_point.cc
===================================================================
--- /trunk/src/world_entities/spawning_point.cc	(revision 9493)
+++ /trunk/src/world_entities/spawning_point.cc	(revision 9494)
@@ -178,5 +178,5 @@
       }
 
-      if ( found && SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+      if ( found && SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
         this->sendRespawnMessage( it->entity->getUniqueID() );
 
@@ -201,5 +201,5 @@
  * Just override this function with whatever you want to be drawn.
  */
-void SpawningPoint::draw()
+void SpawningPoint::draw() const
 {
 }
@@ -213,10 +213,10 @@
   assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
 
-  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
+  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
 }
 
 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
 {
-  if ( SharedNetworkData::getInstance()->isMasterServer() || SharedNetworkData::getInstance()->isProxyServer())
+  if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
   {
     PRINTF(2)("server received spawn message!\n");
Index: /trunk/src/world_entities/spawning_point.h
===================================================================
--- /trunk/src/world_entities/spawning_point.h	(revision 9493)
+++ /trunk/src/world_entities/spawning_point.h	(revision 9494)
@@ -50,6 +50,6 @@
     virtual void loadParams(const TiXmlElement* root);
 
-    inline int getTeamId(){ return this->teamId; }
-    inline void setTeamId( int teamId ){ this->teamId = teamId; }
+    inline int getTeamId() const { return this->teamId; }
+    inline void setTeamId( int teamId ) { this->teamId = teamId; }
 
     void pushEntity(Playable* entity, float delay = 0);
@@ -63,10 +63,10 @@
 
     virtual void tick(float dt);
-    virtual void draw();
+    virtual void draw() const;
 
 
   private:
     void spawn(Playable* entity);
-    
+
     void sendRespawnMessage( int uniqueId );
     static bool respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
Index: /trunk/src/world_entities/world_entity.cc
===================================================================
--- /trunk/src/world_entities/world_entity.cc	(revision 9493)
+++ /trunk/src/world_entities/world_entity.cc	(revision 9494)
@@ -257,6 +257,9 @@
 bool WorldEntity::buildObbTree(int depth)
 {
-  if (this->obbTree)
+  if( this->obbTree != NULL)
+  {
     delete this->obbTree;
+    this->obbTree = NULL;
+  }
 
   if (this->models[0] != NULL)
@@ -280,4 +283,10 @@
     this->aabbNode = new AABBTreeNode();
     this->aabbNode->spawnBVTree(this->models[0]);
+  }
+  else
+  {
+    PRINTF(1)("could not create aabb bounding box, because no model was loaded yet\n");
+    this->aabbNode = NULL;
+    return false;
   }
   return true;
