Index: branches/proxy/src/lib/network/monitor/network_node.cc
===================================================================
--- branches/proxy/src/lib/network/monitor/network_node.cc	(revision 9583)
+++ branches/proxy/src/lib/network/monitor/network_node.cc	(revision 9625)
@@ -39,5 +39,5 @@
  * adds a client
  */
-void NetworkNode::addClient(PeerInfo* node)
+void NetworkNode::addClient(NetworkNode* node)
 {
   this->clientList.push_back(node);
@@ -49,5 +49,5 @@
  * adds a proxy server
  */
-void NetworkNode::addActiveProxyServer(PeerInfo* node)
+void NetworkNode::addActiveProxyServer(NetworkNode* node)
 {
   this->activeProxyServerList.push_back(node);
@@ -58,5 +58,5 @@
  * adds a proxy server
  */
-void NetworkNode::addPassiveProxyServer(PeerInfo* node)
+void NetworkNode::addPassiveProxyServer(NetworkNode* node)
 {
   this->passiveProxyServerList.push_back(node);
@@ -66,5 +66,5 @@
  * adds a master server
  */
-void NetworkNode::addMasterServer(PeerInfo* node)
+void NetworkNode::addMasterServer(NetworkNode* node)
 {
   this->masterServerList.push_back(node);
@@ -75,7 +75,7 @@
  * removes a client
  */
-void NetworkNode::removeClient(PeerInfo* node)
-{
-  std::list<PeerInfo*>::iterator it = this->clientList.begin();
+void NetworkNode::removeClient(NetworkNode* node)
+{
+  std::list<NetworkNode*>::iterator it = this->clientList.begin();
   for(; it != this->clientList.end(); it++)
   {
@@ -94,7 +94,7 @@
  * removes a proxy server
  */
-void NetworkNode::removeActiveProxyServer(PeerInfo* node)
-{
-  std::list<PeerInfo*>::iterator it = this->activeProxyServerList.begin();
+void NetworkNode::removeActiveProxyServer(NetworkNode* node)
+{
+  std::list<NetworkNode*>::iterator it = this->activeProxyServerList.begin();
   for(; it != this->activeProxyServerList.end(); it++)
   {
@@ -113,7 +113,7 @@
  * removes a proxy server
  */
-void NetworkNode::removePassiveProxyServer(PeerInfo* node)
-{
-  std::list<PeerInfo*>::iterator it = this->passiveProxyServerList.begin();
+void NetworkNode::removePassiveProxyServer(NetworkNode* node)
+{
+  std::list<NetworkNode*>::iterator it = this->passiveProxyServerList.begin();
   for(; it != this->passiveProxyServerList.end(); it++)
   {
@@ -131,7 +131,7 @@
  * removes a master server
  */
-void NetworkNode::removeMasterServer(PeerInfo* node)
-{
-  std::list<PeerInfo*>::iterator it = this->masterServerList.begin();
+void NetworkNode::removeMasterServer(NetworkNode* node)
+{
+  std::list<NetworkNode*>::iterator it = this->masterServerList.begin();
   for(; it != this->masterServerList.end(); it++)
   {
@@ -146,4 +146,84 @@
   PRINTF(2)("Could not remove client from the list, very strange...");
 }
+
+
+
+
+/**
+ * removes a client
+ */
+void NetworkNode::removeClient(int userId)
+{
+  std::list<NetworkNode*>::iterator it = this->clientList.begin();
+  for(; it != this->clientList.end(); it++)
+  {
+    if( (*it)->getPeerInfo()->userId == userId)
+    {
+      this->clientList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove client from the list, very strange...");
+}
+
+/**
+ * removes a proxy server
+ */
+void NetworkNode::removeActiveProxyServer(int userId)
+{
+  std::list<NetworkNode*>::iterator it = this->activeProxyServerList.begin();
+  for(; it != this->activeProxyServerList.end(); it++)
+  {
+    if( (*it)->getPeerInfo()->userId == userId)
+    {
+      this->activeProxyServerList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove proxy server from the list, very strange...");
+}
+
+/**
+ * removes a proxy server
+ */
+void NetworkNode::removePassiveProxyServer(int userId)
+{
+  std::list<NetworkNode*>::iterator it = this->passiveProxyServerList.begin();
+  for(; it != this->passiveProxyServerList.end(); it++)
+  {
+    if( (*it)->getPeerInfo()->userId == userId)
+    {
+      this->passiveProxyServerList.erase(it);
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove proxy server from the list, very strange...");
+}
+
+/**
+ * removes a master server
+ */
+void NetworkNode::removeMasterServer(int userId)
+{
+  std::list<NetworkNode*>::iterator it = this->masterServerList.begin();
+  for(; it != this->masterServerList.end(); it++)
+  {
+    if( (*it)->getPeerInfo()->userId == userId)
+    {
+      this->masterServerList.erase(it);
+      this->playerNumber--;
+      return;
+    }
+  }
+
+  PRINTF(2)("Could not remove client from the list, very strange...");
+}
+
+
 
 
@@ -157,9 +237,9 @@
 {
   // look through the master server lists
-  std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
+  std::list<NetworkNode*>::const_iterator it = this->masterServerList.begin();
   for( ;it != this->masterServerList.end(); it++)
   {
-    if( (*it)->userId == userId)
-      return (*it);
+    if( (*it)->getPeerInfo()->userId == userId)
+      return (*it)->getPeerInfo();
   }
 
@@ -168,6 +248,6 @@
   for( ; it != this->activeProxyServerList.end(); it++)
   {
-    if( (*it)->userId == userId)
-      return (*it);
+    if( (*it)->getPeerInfo()->userId == userId)
+      return (*it)->getPeerInfo();
   }
 
@@ -176,6 +256,6 @@
   for( ; it != this->passiveProxyServerList.end(); it++)
   {
-    if( (*it)->userId == userId)
-      return (*it);
+    if( (*it)->getPeerInfo()->userId == userId)
+      return (*it)->getPeerInfo();
   }
 
@@ -184,6 +264,6 @@
   for( ; it != this->clientList.end(); it++)
   {
-    if( (*it)->userId == userId)
-      return (*it);
+    if( (*it)->getPeerInfo()->userId == userId)
+      return (*it)->getPeerInfo();
   }
 
@@ -201,9 +281,9 @@
     return NULL;
 
-  std::list<PeerInfo*>::const_iterator it = this->clientList.begin();
+  std::list<NetworkNode*>::const_iterator it = this->clientList.begin();
   for(int i = 0; it != this->clientList.end(); it++, i++)
   {
   if( i == index)
-    return (*it);
+    return (*it)->getPeerInfo();
   }
 
@@ -221,9 +301,9 @@
     return NULL;
 
-  std::list<PeerInfo*>::const_iterator it = this->activeProxyServerList.begin();
+  std::list<NetworkNode*>::const_iterator it = this->activeProxyServerList.begin();
   for(int i = 0; it != this->activeProxyServerList.end(); it++, i++)
   {
     if( i == index)
-      return (*it);
+      return (*it)->getPeerInfo();
   }
 
@@ -241,9 +321,9 @@
     return NULL;
 
-  std::list<PeerInfo*>::const_iterator it = this->passiveProxyServerList.begin();
+  std::list<NetworkNode*>::const_iterator it = this->passiveProxyServerList.begin();
   for(int i = 0; it != this->passiveProxyServerList.end(); it++, i++)
   {
     if( i == index)
-      return (*it);
+      return (*it)->getPeerInfo();
   }
 
@@ -261,9 +341,9 @@
     return NULL;
 
-  std::list<PeerInfo*>::const_iterator it = this->masterServerList.begin();
+  std::list<NetworkNode*>::const_iterator it = this->masterServerList.begin();
   for(int i = 0; it != this->masterServerList.end(); it++, i++)
   {
     if( i == index)
-      return (*it);
+      return (*it)->getPeerInfo();
   }
 
@@ -278,37 +358,62 @@
 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*>::const_iterator it = this->masterServerList.begin();
-  for(; it != this->masterServerList.end(); it++)
-  {
-    IP* ip = &(*it)->ip;
-    PRINT(0)("     - ms, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
-  }
-
-  PRINT(0)("    proxy servers active: %i\n", this->activeProxyServerList.size());
-  it = this->activeProxyServerList.begin();
-  for(; it != this->activeProxyServerList.end(); it++)
-  {
-    IP* ip = &(*it)->ip;
-    PRINT(0)("     - ps-a, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
-  }
-
-  PRINT(0)("    proxy servers passive: %i\n", this->passiveProxyServerList.size());
-  it = this->passiveProxyServerList.begin();
-  for(; it != this->passiveProxyServerList.end(); it++)
-  {
-    IP* ip = &(*it)->ip;
-    PRINT(0)("     - ps-p, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
-  }
-
-  PRINT(0)("    clients: %i\n", this->clientList.size());
-  it = this->clientList.begin();
-  for(; it != this->clientList.end(); it++)
-  {
-    IP* ip = &(*it)->ip;
-    PRINT(0)("     - client, id: %i (%s)\n", (*it)->userId, ip->ipString().c_str());
-  }
-}
-
+  char indent[depth +1];
+  for( int i = 0; i < depth; i++) {     indent[i] = ' ';  }
+  indent[depth] = '\0';
+
+  PRINT(0)("%s + %s, with ip: %s\n", indent,  this->peerInfo->getNodeTypeString().c_str(), this->peerInfo->ip.ipString().c_str());
+  std::list<NetworkNode*>::const_iterator it;
+  if( !this->masterServerList.empty())
+  {
+//     PRINT(0)("%s + master servers: %i\n", indent, this->masterServerList.size());
+    it = this->masterServerList.begin();
+
+    for(; it != this->masterServerList.end(); it++)
+    {
+//       IP* ip = &(*it)->getPeerInfo()->ip;
+//       PRINT(0)("%s     - ms, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
+      (*it)->debug(depth+1);
+    }
+  }
+
+  if( !this->activeProxyServerList.empty())
+  {
+//     PRINT(0)("%s + proxy servers active: %i\n", indent, this->activeProxyServerList.size());
+    it = this->activeProxyServerList.begin();
+
+    for(; it != this->activeProxyServerList.end(); it++)
+    {
+//       IP* ip = &(*it)->getPeerInfo()->ip;
+//       PRINT(0)("%s     - ps-a, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
+      (*it)->debug(depth+1);
+    }
+  }
+
+
+  if( !this->passiveProxyServerList.empty())
+  {
+//     PRINT(0)("%s proxy servers passive: %i\n", indent, this->passiveProxyServerList.size());
+    it = this->passiveProxyServerList.begin();
+
+    for(; it != this->passiveProxyServerList.end(); it++)
+    {
+//       IP* ip = &(*it)->getPeerInfo()->ip;
+//       PRINT(0)("%s     - ps-p, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
+      (*it)->debug(depth+1);
+    }
+  }
+
+  if( !this->clientList.empty())
+  {
+//     PRINT(0)("%s clients: %i\n", indent, this->clientList.size());
+    it = this->clientList.begin();
+
+    for(; it != this->clientList.end(); it++)
+    {
+//       IP* ip = &(*it)->getPeerInfo()->ip;
+//       PRINT(0)("%s     - client, id: %i (%s)\n", indent, (*it)->getPeerInfo()->userId, ip->ipString().c_str());
+      (*it)->debug(depth+1);
+    }
+  }
+}
+
