Index: /branches/proxy/src/lib/network/README.NETWORK
===================================================================
--- /branches/proxy/src/lib/network/README.NETWORK	(revision 9449)
+++ /branches/proxy/src/lib/network/README.NETWORK	(revision 9450)
@@ -29,4 +29,6 @@
 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.
+
 
 
Index: /branches/proxy/src/lib/network/netdefs.h
===================================================================
--- /branches/proxy/src/lib/network/netdefs.h	(revision 9449)
+++ /branches/proxy/src/lib/network/netdefs.h	(revision 9450)
@@ -62,7 +62,10 @@
 };
 
-//!< 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
@@ -70,5 +73,5 @@
 
 
-//!< the id of the node
+//!< the network id list
 typedef enum nodeId {
   NET_ID_UNASSIGNED       =-1,
Index: /branches/proxy/src/lib/network/network_manager.cc
===================================================================
--- /branches/proxy/src/lib/network/network_manager.cc	(revision 9449)
+++ /branches/proxy/src/lib/network/network_manager.cc	(revision 9450)
@@ -133,5 +133,5 @@
   this->networkStream->createServer( port);
   // and connect to the master server for synchronization
-  int userId = this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 9999);
+  this->networkStream->connectToMasterServer(NetworkSettings::getInstance()->getMasterAddr().ipString(), 9999);
   // and to the other proxy servers also, this would be very nice if its works
 
Index: /branches/proxy/src/lib/network/network_stream.cc
===================================================================
--- /branches/proxy/src/lib/network/network_stream.cc	(revision 9449)
+++ /branches/proxy/src/lib/network/network_stream.cc	(revision 9450)
@@ -182,16 +182,14 @@
  * @param port: the port number
  */
-int NetworkStream::connectToMasterServer(std::string host, int port)
-{
-  int node = this->peers.size();
+void NetworkStream::connectToMasterServer(std::string host, int port)
+{
+  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();
-
-  return node;
 }
 
@@ -202,18 +200,15 @@
  * @param port: the port number
  */
-int NetworkStream::connectToProxyServer(std::string host, int port)
-{
-  int node = this->peers.size();
-  PRINTF(0)("connect to proxy %s, this is node %i\n", host.c_str(), node);
-
-  // this creates the new node in the peers map
-  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();
-
-  return node;
+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();
 }
 
@@ -250,5 +245,6 @@
 {
   Handshake* hs = new Handshake(this->pInfo->nodeType);
-  hs->setUniqueID( 0 );
+  // fake the unique id
+  hs->setUniqueID( NET_UID_HANDSHAKE );
   assert( peers[userId].handshake == NULL );
   peers[userId].handshake = hs;
@@ -327,7 +323,10 @@
   {
     // check if the connection is ok else terminate and remove
-    if ( !peers.empty() && peers[0].socket && ( !peers[0].socket->isOk() || peers[0].connectionMonitor->hasTimedOut() ) )
-    {
-      this->handleDisconnect( 0);
+#warning make this more modular: every proxy/master server connection should be watched for termination
+    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");
     }
@@ -335,5 +334,5 @@
     if( this->bRedirect)
     {
-      this->handleReconnect( 0);
+      this->handleReconnect( NET_ID_MASTER_SERVER);
     }
   }
@@ -625,5 +624,5 @@
   // disconnect from the current server and reconnect to proxy server
   this->handleDisconnect( userId);
-  this->connectToProxyServer(proxyIP.ipString(), 9999);
+  this->connectToProxyServer(NET_ID_PROXY_SERVER_01, proxyIP.ipString(), 9999);
   #warning the ports are not yet integrated correctly in the ip class
 
@@ -707,5 +706,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;
 
@@ -769,5 +768,6 @@
       Synchronizeable & sync = **it;
 
-      if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
+      // again exclude all unwanted syncs
+      if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED)
         continue;
 
@@ -969,5 +969,5 @@
         Synchronizeable & sync = **it;
 
-        if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
+        if ( !sync.beSynchronized() || sync.getUniqueID() <= NET_UID_UNASSIGNED )
           continue;
 
Index: /branches/proxy/src/lib/network/network_stream.h
===================================================================
--- /branches/proxy/src/lib/network/network_stream.h	(revision 9449)
+++ /branches/proxy/src/lib/network/network_stream.h	(revision 9450)
@@ -41,10 +41,10 @@
     void init();
 
-    int connectToMasterServer(std::string host, int port);
-    int connectToProxyServer(std::string host, int port);
+    void connectToMasterServer(std::string host, int port);
+    void connectToProxyServer(int proxyId, std::string host, int port);
     void createServer(int port);
 
     void createNetworkGameManager();
-    void startHandshake(int userId = 0);
+    void startHandshake(int userId = NET_ID_MASTER_SERVER);
 
     /* synchronizeable interface */
