Index: branches/proxy/src/lib/coord/p_node.cc
===================================================================
--- branches/proxy/src/lib/coord/p_node.cc	(revision 9624)
+++ branches/proxy/src/lib/coord/p_node.cc	(revision 9625)
@@ -54,6 +54,6 @@
     parent->addChild(this);
 
-  this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate" ) );
-  this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction" ) );
+  this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate", PERMISSION_SERVER ) );
+  this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction", PERMISSION_SERVER ) );
 }
 
Index: branches/proxy/src/lib/network/README.NETWORK
===================================================================
--- branches/proxy/src/lib/network/README.NETWORK	(revision 9624)
+++ branches/proxy/src/lib/network/README.NETWORK	(revision 9625)
@@ -1,2 +1,4 @@
+
+
 
 
@@ -8,6 +10,7 @@
 WORKING_STACK:
 ==============
- - it works to connecto to a master server which is connected to a proxy itself
-
+ - removed compiler warnings in some modules
+ - totaly rework of the permission system
+ - introduced a new PERMISSION layer: PERMISSION_SERVER which gives the nearest server the authority to handle
 
 
Index: branches/proxy/src/lib/network/monitor/network_monitor.cc
===================================================================
--- branches/proxy/src/lib/network/monitor/network_monitor.cc	(revision 9624)
+++ branches/proxy/src/lib/network/monitor/network_monitor.cc	(revision 9625)
@@ -10,5 +10,5 @@
 
 ### File Specific:
-   main-programmer: Patrick Boenzli
+   main-programmer: Patrick Boenzli (patrick@orxonox.ethz.ch)
 */
 
@@ -49,4 +49,5 @@
   this->networkStream = networkStream;
   this->playerNumber = 0;
+  this->connectionNumber = 0;
   // create the localnode, init it and add it to the nodes list
   this->localNode = new NetworkNode( this->networkStream->getPeerInfo());
@@ -69,6 +70,4 @@
       peer->userId = -1;
 
-      NetworkNode* node = new NetworkNode(peer);
-      this->addNode( node);
       this->addActiveProxyServer( this->localNode, peer);
     }
@@ -141,17 +140,24 @@
     return;
 
+  PRINTF(0)("^^^^^^^^^^^^^^^^^^^^^^^^^^ adding node: %i with type: %s\n\n", pInfo->userId, pInfo->getNodeTypeString().c_str());
+
   if( pInfo->isClient())
-    this->localNode->addClient(pInfo);
+  {
+    this->localNode->addClient(new NetworkNode(pInfo));
+  }
   else if( pInfo->isProxyServerActive())
   {
-    this->localNode->addActiveProxyServer(pInfo);
-    // create a new node, since a proxy can connect clients again
-    NetworkNode* node = new NetworkNode(pInfo);
-    this->nodeList.push_back(node);
+    this->localNode->addActiveProxyServer(new NetworkNode(pInfo));
+  }
+  else if( pInfo->isProxyServerActivePassive())
+  {
+    this->localNode->addPassiveProxyServer(new NetworkNode(pInfo));
   }
   else if( pInfo->isMasterServer())
   {
-    this->localNode->addMasterServer(pInfo);
-  }
+    this->localNode->addMasterServer(new NetworkNode(pInfo));
+  }
+  else
+    assert(false);
 }
 
@@ -168,9 +174,9 @@
 
   if( pInfo->isClient())
-    node->addClient(pInfo);
+    node->addClient(new NetworkNode(pInfo));
   else if( pInfo->isProxyServerActive())
-    node->addActiveProxyServer(pInfo);
+    node->addActiveProxyServer(new NetworkNode(pInfo));
   else if( pInfo->isMasterServer())
-    node->addMasterServer(pInfo);
+    node->addMasterServer(new NetworkNode(pInfo));
 }
 
@@ -198,9 +204,9 @@
 
   if( pInfo->isClient())
-    node->removeClient(pInfo);
+    node->removeClient(pInfo->userId);
   else if( pInfo->isProxyServerActive())
-    node->removeActiveProxyServer(pInfo);
+    node->removeActiveProxyServer(pInfo->userId);
   else if( pInfo->isMasterServer())
-    node->removeMasterServer(pInfo);
+    node->removeMasterServer(pInfo->userId);
 }
 
@@ -253,4 +259,5 @@
   for(; it != this->nodeList.end(); it++)
   {
+    PRINTF(0)("comparing %i to %i\n", (*it)->getPeerInfo()->userId, userId);
     if( (*it)->getPeerInfo()->userId == userId)
       return (*it);
@@ -308,5 +315,5 @@
   for(; it != this->nodeList.end(); it++)
   {
-    (*it)->debug(0);
+    (*it)->debug(1);
   }
 
Index: branches/proxy/src/lib/network/monitor/network_monitor.h
===================================================================
--- branches/proxy/src/lib/network/monitor/network_monitor.h	(revision 9624)
+++ branches/proxy/src/lib/network/monitor/network_monitor.h	(revision 9625)
@@ -42,19 +42,19 @@
 
     /** adds to @param node a network node @param pInfo a new client */
-    inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(pInfo); }
+    inline void addClient(NetworkNode* node, PeerInfo* pInfo) { node->addClient(new NetworkNode(pInfo)); }
     /** adds to @param node a network node @param pInfo a new proxy server */
-    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(pInfo); }
+    inline void addActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addActiveProxyServer(new NetworkNode(pInfo)); }
     /** adds to @param node a network node @param pInfo a new proxy server */
-    inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(pInfo); }
+    inline void addPassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->addPassiveProxyServer(new NetworkNode(pInfo)); }
     /** adds to @param node a network node @param pInfo a new master server*/
-    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(pInfo); }
+    inline void addMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->addMasterServer(new NetworkNode(pInfo)); }
 
     void removeNode(PeerInfo* pInfo);
     void removeNode(NetworkNode* node, PeerInfo* pInfo);
 
-    inline void removeClient(NetworkNode* node, PeerInfo* pInfo) { node->removeClient(pInfo); }
-    inline void removeActiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removeActiveProxyServer(pInfo); }
-    inline void removePassiveProxyServer(NetworkNode* node, PeerInfo* pInfo) { node->removePassiveProxyServer(pInfo); }
-    inline void removeMasterServer(NetworkNode* node, PeerInfo* pInfo) { node->removeMasterServer(pInfo); }
+    inline void removeClient(NetworkNode* node, int userId) { node->removeClient(userId); }
+    inline void removeActiveProxyServer(NetworkNode* node, int userId) { node->removeActiveProxyServer(userId); }
+    inline void removePassiveProxyServer(NetworkNode* node, int userId) { node->removePassiveProxyServer(userId); }
+    inline void removeMasterServer(NetworkNode* node, int userId) { node->removeMasterServer(userId); }
 
     PeerInfo* getFirstChoiceProxy() const;
@@ -64,5 +64,5 @@
 
     /** @returns the active proxy server list of the localnode */
-    inline std::list<PeerInfo*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); }
+    inline std::list<NetworkNode*> getActiveProxyServer() const { return this->localNode->getActiveProxyServer(); }
 
     /* slots admin and info interface */
Index: branches/proxy/src/lib/network/monitor/network_node.cc
===================================================================
--- branches/proxy/src/lib/network/monitor/network_node.cc	(revision 9624)
+++ 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);
+    }
+  }
+}
+
Index: branches/proxy/src/lib/network/monitor/network_node.h
===================================================================
--- branches/proxy/src/lib/network/monitor/network_node.h	(revision 9624)
+++ branches/proxy/src/lib/network/monitor/network_node.h	(revision 9625)
@@ -22,13 +22,19 @@
 
 
-    void addClient(PeerInfo* node);
-    void addActiveProxyServer(PeerInfo* node);
-    void addPassiveProxyServer(PeerInfo* node);
-    void addMasterServer(PeerInfo* node);
+    void addClient(NetworkNode* node);
+    void addActiveProxyServer(NetworkNode* node);
+    void addPassiveProxyServer(NetworkNode* node);
+    void addMasterServer(NetworkNode* node);
 
-    void removeClient(PeerInfo* node);
-    void removeActiveProxyServer(PeerInfo* node);
-    void removePassiveProxyServer(PeerInfo* node);
-    void removeMasterServer(PeerInfo* node);
+    void removeClient(NetworkNode* node);
+    void removeActiveProxyServer(NetworkNode* node);
+    void removePassiveProxyServer(NetworkNode* node);
+    void removeMasterServer(NetworkNode* node);
+
+    void removeClient(int userId);
+    void removeActiveProxyServer(int userId);
+    void removePassiveProxyServer(int userId);
+    void removeMasterServer(int userId);
+
 
     PeerInfo* getClient(int index) const;
@@ -38,11 +44,11 @@
 
     /** @returns the master server list */
-    inline std::list<PeerInfo*> getMasterServer() const { return this->masterServerList; }
+    inline std::list<NetworkNode*> getMasterServer() const { return this->masterServerList; }
     /** @returns the active proxy server list */
-    inline std::list<PeerInfo*> getActiveProxyServer() const { return this->activeProxyServerList; }
+    inline std::list<NetworkNode*> getActiveProxyServer() const { return this->activeProxyServerList; }
     /** @returns the passive proxy server list */
-    inline std::list<PeerInfo*> getPassiveProxyServer() const { return this->passiveProxyServerList; }
+    inline std::list<NetworkNode*> getPassiveProxyServer() const { return this->passiveProxyServerList; }
     /** @returns the client list */
-    inline std::list<PeerInfo*> getClient() const { return this->clientList; }
+    inline std::list<NetworkNode*> getClient() const { return this->clientList; }
 
     PeerInfo* getPeerByUserId( int userId);
@@ -64,8 +70,8 @@
 
     /* network nodes directly connected to this node */
-    std::list<PeerInfo*>         clientList;                   //!< list of all clients in the network
-    std::list<PeerInfo*>         activeProxyServerList;        //!< list of all proxy servers in the network
-    std::list<PeerInfo*>         passiveProxyServerList;       //!< list of all proxy servers in the network
-    std::list<PeerInfo*>         masterServerList;             //!< list of all master servers in the network (should be 1!! :D)
+    std::list<NetworkNode*>         clientList;                   //!< list of all clients in the network
+    std::list<NetworkNode*>         activeProxyServerList;        //!< list of all proxy servers in the network
+    std::list<NetworkNode*>         passiveProxyServerList;       //!< list of all proxy servers in the network
+    std::list<NetworkNode*>         masterServerList;             //!< list of all master servers in the network (should be 1!! :D)
 
 };
Index: branches/proxy/src/lib/network/nettypes.h
===================================================================
--- branches/proxy/src/lib/network/nettypes.h	(revision 9624)
+++ branches/proxy/src/lib/network/nettypes.h	(revision 9625)
@@ -10,6 +10,7 @@
   PERMISSION_MASTER_SERVER = 1,
   PERMISSION_PROXY_SERVER  = 2,
-  PERMISSION_OWNER         = 4,
-  PERMISSION_ALL           = 8
+  PERMISSION_SERVER        = 4,
+  PERMISSION_OWNER         = 8,
+  PERMISSION_ALL           = 16
 };
 
Index: branches/proxy/src/lib/network/network_game_manager.cc
===================================================================
--- branches/proxy/src/lib/network/network_game_manager.cc	(revision 9624)
+++ branches/proxy/src/lib/network/network_game_manager.cc	(revision 9625)
@@ -68,5 +68,5 @@
 
   this->gameState = 0;
-  registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );
+  registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState", PERMISSION_MASTER_SERVER ) );
 }
 
Index: branches/proxy/src/lib/network/network_manager.cc
===================================================================
--- branches/proxy/src/lib/network/network_manager.cc	(revision 9624)
+++ branches/proxy/src/lib/network/network_manager.cc	(revision 9625)
@@ -142,5 +142,5 @@
 
   // then start the server
-  this->networkStream->createServer( port, port + 1, port + 2);
+//   this->networkStream->createServer( port, port + 1, port + 2);
 
   // 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 9624)
+++ branches/proxy/src/lib/network/network_stream.cc	(revision 9625)
@@ -81,15 +81,23 @@
       // init the shared network data
       SharedNetworkData::getInstance()->setHostID(NET_ID_MASTER_SERVER);
+      this->pInfo->userId = NET_ID_MASTER_SERVER;
+      this->pInfo->nodeType = NET_MASTER_SERVER;
+
       break;
     case NET_PROXY_SERVER_ACTIVE:
       // init the shared network data
       SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01);
+      this->pInfo->nodeType = NET_PROXY_SERVER_ACTIVE;
+
       break;
     case NET_PROXY_SERVER_PASSIVE:
       // init the shared network data
       SharedNetworkData::getInstance()->setHostID(NET_ID_PROXY_SERVER_01);
+      this->pInfo->nodeType = NET_PROXY_SERVER_PASSIVE;
+
       break;
     case NET_CLIENT:
       SharedNetworkData::getInstance()->setHostID(NET_ID_UNASSIGNED);
+      this->pInfo->nodeType = NET_CLIENT;
       break;
   }
@@ -526,6 +534,4 @@
     it++;
   }
-
-
 }
 
@@ -685,5 +691,5 @@
 //               it->second.ip = it->second.socket->getRemoteAddress();
 
-              // it->second.nodeType = it->second.handshake->getRemoteNodeType();
+              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)
Index: branches/proxy/src/lib/network/player_stats.cc
===================================================================
--- branches/proxy/src/lib/network/player_stats.cc	(revision 9624)
+++ branches/proxy/src/lib/network/player_stats.cc	(revision 9625)
@@ -65,12 +65,12 @@
   this->oldNickName = "Player";
 
-  userId_handle = registerVarId( new SynchronizeableInt( &assignedUserId, &assignedUserId, "userId" ) );
-  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
-  preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId" ) );
-  score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score" ) );
-  playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId") );
-  playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) );
-  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
-  nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName" ) );
+  userId_handle = registerVarId( new SynchronizeableInt( &assignedUserId, &assignedUserId, "userId", PERMISSION_MASTER_SERVER ) );
+  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId", PERMISSION_MASTER_SERVER ) );
+  preferedTeamId_handle = registerVarId( new SynchronizeableInt( &preferedTeamId, &preferedTeamId, "preferedUserId", PERMISSION_MASTER_SERVER ) );
+  score_handle = registerVarId( new SynchronizeableInt( &score, &score, "score", PERMISSION_MASTER_SERVER ) );
+  playableClassId_handle = registerVarId( new SynchronizeableInt( &playableClassId, &playableClassId, "playableClassId", PERMISSION_MASTER_SERVER) );
+  playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId", PERMISSION_MASTER_SERVER ) );
+  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) );
+  nickName_handler = registerVarId( new SynchronizeableString( &nickName, &nickName, "nickName", PERMISSION_MASTER_SERVER ) );
 
   MessageManager::getInstance()->registerMessageHandler( MSGID_CHANGENICKNAME, changeNickHandler, NULL );
Index: branches/proxy/src/lib/network/proxy/proxy_control.cc
===================================================================
--- branches/proxy/src/lib/network/proxy/proxy_control.cc	(revision 9624)
+++ branches/proxy/src/lib/network/proxy/proxy_control.cc	(revision 9625)
@@ -39,7 +39,5 @@
 
 
-// SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell);
-SHELL_COMMAND(bla, ProxyControl, forceReconnectionShellThumb);
-
+SHELL_COMMAND(forceReconnect, ProxyControl, forceReconnectionShell);
 
 /**
@@ -250,4 +248,6 @@
 void ProxyControl::forceReconnectionShell(int userId, int serverId)
 {
+  PRINTF(0)("shell reconnectoin command: %i to %i\n", userId, serverId);
+
   this->forceReconnection(userId, serverId);
 }
@@ -264,10 +264,10 @@
   if( serverInfo == NULL)
   {
-    PRINTF(0)("There is no node with userId %i registered in this network. Check the uid again\n");
-    return;
-  }
-  else if( serverInfo->isMasterServer() || serverInfo->isProxyServerActive())
-  {
-    PRINTF(0)("You can't connecto to a client (userId %i)\n", serverId);
+    PRINTF(0)("There is no server with userId %i registered in this network. Check the uid again\n", serverId);
+    return;
+  }
+  else if( serverInfo->isClient())
+  {
+    PRINTF(0)("You can't connec to to a client (userId %i)\n", serverId);
     return;
   }
@@ -306,5 +306,5 @@
   if( pInfo == NULL)
   {
-    PRINTF(0)("There is no node with userId %i registered in this network. Check the uid again\n");
+    PRINTF(0)("There is no client with userId %i registered in this network. Check the uid again\n", userId);
     return;
   }
@@ -316,4 +316,5 @@
   assert( Converter::intToByteArray( newAddress.host(), data + 2 * INTSIZE, INTSIZE ) == INTSIZE );
 
+  PRINTF(0)("Sending reconnection command to: %i\n", userId);
   MessageManager::getInstance()->sendMessage( MSGID_PROXY_COMMAND, data, 3*INTSIZE, RT_ALL_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
 }
Index: branches/proxy/src/lib/network/proxy/proxy_control.h
===================================================================
--- branches/proxy/src/lib/network/proxy/proxy_control.h	(revision 9624)
+++ branches/proxy/src/lib/network/proxy/proxy_control.h	(revision 9625)
@@ -18,4 +18,7 @@
 typedef enum proxyCommand {
   PXY_RECONNECT              = 0,              //!< forces a reconnection of the node
+
+  PXY_WEAKUP,                                  //!< signal to weakup a sleeping proxy server (not impl. yet)
+  PXY_SLEEP,                                   //!< signal to sleep and disconnect clients
 
   PXY_NUMBER
Index: branches/proxy/src/lib/network/synchronizeable.cc
===================================================================
--- branches/proxy/src/lib/network/synchronizeable.cc	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable.cc	(revision 9625)
@@ -55,8 +55,8 @@
   /* make sure loadClassId is first synced var because this is read by networkStream */
   assert( syncVarList.size() == 0 );
-  mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
-
-  this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );
-  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
+  mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId", PERMISSION_MASTER_SERVER) );
+
+  this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner", PERMISSION_MASTER_SERVER ) );
+  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName", PERMISSION_MASTER_SERVER ) );
 }
 
@@ -127,5 +127,5 @@
 {
   //make sure this user has his history
-  if ( sentStates.size() <= userId )
+  if ( (int)sentStates.size() <= userId )
     sentStates.resize( userId+1 );
 
@@ -207,7 +207,9 @@
   for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
   {
+
     // DATA PERMISSIONS
     // check if this synchronizeable has the permissions to write the data
 
+#if 0
     //  MASTER_SERVER |====> *
     if( SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
@@ -243,4 +245,50 @@
       hasPermission = true;
 
+    else
+      hasPermission = false;
+#endif
+
+    ////////////////////////////////
+    // Data SENDING Permissions
+    ////////////////////////////////
+
+    // Permission   OWNER accept if:
+    // I am the owner
+    if(       (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID())
+      hasPermission = true;
+    // reciever != owner && owner is local
+    else if(  (*it)->checkPermission( PERMISSION_OWNER ) && userId != this->owner &&
+                (SharedNetworkData::getInstance()->isUserLocal(this->owner) || this->owner == SharedNetworkData::getInstance()->getHostID()))
+      hasPermission = true;
+
+
+    // Permission   MASTER_SERVER accept if:
+    // im MASTER_SERVER
+    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer())
+      hasPermission = true;
+    // im PROXY_SERVER && reciever == CLIENT
+    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isProxyServerActive() &&
+               SharedNetworkData::getInstance()->isUserClient( userId))
+      hasPermission = true;
+
+
+    // Pemission    SERVER accept if:
+    // i am server && reciever == CLIENT
+    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
+               SharedNetworkData::getInstance()->isUserClient( userId))
+      hasPermission = true;
+    // i am SERVER && reciever == SERVER && reciever != owner && ( owner is local || i am owner)
+    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
+               userId != this->owner &&
+               ( SharedNetworkData::getInstance()->isUserLocal( userId) || this->owner ==  SharedNetworkData::getInstance()->getHostID()))
+      hasPermission = true;
+
+
+    // Permission   ALL accept if:
+    else if( (*it)->checkPermission( PERMISSION_ALL ))
+      hasPermission = true;
+
+
+    // or else refuse sending data
     else
       hasPermission = false;
@@ -308,5 +356,5 @@
 {
   //make sure this user has his history
-  if ( recvStates.size() <= userId )
+  if ( (int)recvStates.size() <= userId )
     recvStates.resize( userId+1 );
 
@@ -367,32 +415,42 @@
 
 
-    //  *              <====|  MASTER_SERVER
-    if(  this->networkStream->isUserMasterServer( userId ) && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
-      hasPermission = true;
-    else if( this->networkStream->isUserMasterServer( userId ) &&
-             this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
-      hasPermission = true;
-
-    //  *              <====|  PROXY_SERVER
-    else if( this->networkStream->isUserProxyServerActive( userId ) &&
-             this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
-      hasPermission = true;
-    //  CLIENT         <====|  PROXY_SERVER
-    else if( this->networkStream->isUserProxyServerActive( userId )  && SharedNetworkData::getInstance()->isClient()
-             && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
-      hasPermission = true;
-    // MASTER_SERVER   <====|  PROXY_SERVER
-    else if( this->networkStream->isUserProxyServerActive( userId )  && SharedNetworkData::getInstance()->isMasterServer() &&
-             !this->networkStream->isUserLocal( userId ))
-      hasPermission = true;
-
-    //  *              <====|  OWNER
-    else if( this->owner == userId && (*it)->checkPermission( PERMISSION_OWNER ))
-      hasPermission = true;
-
-    //  *              <====|  ALL
-    else if( (*it)->checkPermission( PERMISSION_ALL ))
-      hasPermission = true;
-
+    ////////////////////////////////
+    // Data RECIEVING Permissions
+    ////////////////////////////////
+
+    // i should never ever receive a state update from a synchronizeable, that belongs to me! If it does somethings wrong with the send rules
+//     assert(   !((*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID()));
+
+
+    // Permission   OWNER accept if:
+    // sender == owner
+    if(      (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId)
+      hasPermission = true;
+    // sender == MASTER_SERVER
+    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
+      hasPermission = true;
+    // sender == PROXY_SERVER
+    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
+      hasPermission = true;
+
+    // Permission   MASTER_SERVER accept if:
+    // sender == MASTER_SERVER
+    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
+      hasPermission = true;
+    // sender == PROXY_SERVER && im not MASTER_SERVER && im not PROXY_SERVER
+    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isClient() &&
+               SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
+      hasPermission = true;
+
+    // Permission   SERVER accept if:
+    // sender == SERVER
+    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) )
+      hasPermission = true;
+
+    // Pemission    ALL accept if:
+    else if(  (*it)->checkPermission( PERMISSION_ALL ))
+      hasPermission = true;
+
+   // no rights to over-write local data
     else
       hasPermission = false;
@@ -466,5 +524,5 @@
 void Synchronizeable::cleanUpUser( int userId )
 {
-  if ( recvStates.size() > userId )
+  if ( (int)recvStates.size() > userId )
   {
     for ( std::list<StateHistoryEntry*>::iterator it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ )
@@ -481,5 +539,5 @@
   }
 
-  if ( sentStates.size() > userId )
+  if ( (int)sentStates.size() > userId )
   {
 
@@ -507,5 +565,5 @@
 {
    //make sure this user has his history
-  if ( recvStates.size() <= userId )
+  if ( (int)recvStates.size() <= userId )
     recvStates.resize( userId+1 );
 
@@ -597,5 +655,5 @@
 {
    //make sure this user has his history
-  if ( sentStates.size() <= userId )
+  if ( (int)sentStates.size() <= userId )
     sentStates.resize( userId+1 );
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_bool.h	(revision 9625)
@@ -12,5 +12,5 @@
 
   public:
-    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableBool();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_float.h	(revision 9625)
@@ -13,5 +13,5 @@
 
   public:
-    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableFloat();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_int.h	(revision 9625)
@@ -13,5 +13,5 @@
 
   public:
-    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableInt();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.h	(revision 9625)
@@ -15,5 +15,5 @@
 
   public:
-    SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableIP( IP *ptrIn, IP * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableIP();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h	(revision 9625)
@@ -14,5 +14,5 @@
 
   public:
-    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableQuaternion();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_string.h	(revision 9625)
@@ -14,5 +14,5 @@
 
   public:
-    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableString();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_uint.h	(revision 9625)
@@ -13,5 +13,5 @@
 
   public:
-    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableUInt();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 9625)
@@ -15,5 +15,5 @@
 
   public:
-    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission, int priority = 0 );
     virtual ~SynchronizeableVar();
 
Index: branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h
===================================================================
--- branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h	(revision 9624)
+++ branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_vector.h	(revision 9625)
@@ -14,5 +14,5 @@
 
   public:
-    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = PERMISSION_MASTER_SERVER, int priority = 0 );
+    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority = 0 );
     virtual ~SynchronizeableVector();
 
