Index: branches/proxy/src/lib/network/network_stream.cc
===================================================================
--- branches/proxy/src/lib/network/network_stream.cc	(revision 9248)
+++ branches/proxy/src/lib/network/network_stream.cc	(revision 9249)
@@ -75,5 +75,5 @@
   this->peers[0].socket = new UdpSocket( host, port );
   this->peers[0].userId = 0;
-  this->peers[0].isServer = true;
+  this->peers[0].isMasterServer = true;
   this->peers[0].connectionMonitor = new ConnectionMonitor( 0 );
 }
@@ -222,5 +222,5 @@
   currentState++;
 
-  if ( this->type == NET_SERVER )
+  if ( this->type == NET_MASTER_SERVER )
   {
     if ( serverSocket )
@@ -284,5 +284,5 @@
       peers[clientId].handshake->setUniqueID(clientId);
       peers[clientId].userId = clientId;
-      peers[clientId].isServer = false;
+      peers[clientId].isMasterServer = false;
     }
     else
@@ -299,5 +299,5 @@
       peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
       peers[clientId].userId = clientId;
-      peers[clientId].isServer = false;
+      peers[clientId].isMasterServer = false;
 
       PRINTF(0)("num sync: %d\n", synchronizeables.size());
@@ -423,5 +423,5 @@
           if ( !it->second.handshake->allowDel() )
           {
-            if ( type != NET_SERVER )
+            if ( type != NET_MASTER_SERVER )
             {
               SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
@@ -442,5 +442,5 @@
             if ( it->second.handshake->canDel() )
             {
-              if ( type == NET_SERVER )
+              if ( type == NET_MASTER_SERVER )
               {
                 handleNewClient( it->second.userId );
@@ -516,5 +516,5 @@
 
       // if we are a server and this is not our handshake
-      if ( isServer() && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
+      if ( isMasterServer() && sync.getLeafClassID() == CL_HANDSHAKE && sync.getUniqueID() != peer->second.userId )
         continue;
 
@@ -576,5 +576,5 @@
     // now compress the data with the zip library
     int compLength = 0;
-    if ( this->isServer() )
+    if ( this->isMasterServer() )
       compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer );
     else
@@ -691,5 +691,5 @@
           }
 
-          if ( !peers[peer->second.userId].isServer )
+          if ( !peers[peer->second.userId].isMasterServer )
           {
             offset += syncDataLength;
Index: branches/proxy/src/lib/network/network_stream.h
===================================================================
--- branches/proxy/src/lib/network/network_stream.h	(revision 9248)
+++ branches/proxy/src/lib/network/network_stream.h	(revision 9249)
@@ -27,10 +27,12 @@
   public:
     PeerInfo() { clear(); }
-    void clear() { userId = 0; isServer = false; socket = NULL; handshake = NULL; lastAckedState = 0; lastRecvedState = 0; connectionMonitor = NULL; }
+    void clear() { userId = 0; isMasterServer = false; socket = NULL; handshake = NULL; lastAckedState = 0; lastRecvedState = 0; connectionMonitor = NULL; }
 
 
   public:
     int                 userId;
-    bool                isServer;
+    bool                isMasterServer;
+    bool                isProxyServer;
+    bool                isClient;
     NetworkSocket *     socket;
     Handshake *         handshake;
@@ -75,5 +77,7 @@
 
     inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
-    inline bool isUserServer( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isServer; }
+    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; }
+    inline bool isUserClient( int userID ){ if ( !isUserIdActive(userID) ) return false; return peers[userID].isClient; }
 
     void debug();
Index: branches/proxy/src/lib/network/synchronizeable.cc
===================================================================
--- branches/proxy/src/lib/network/synchronizeable.cc	(revision 9248)
+++ branches/proxy/src/lib/network/synchronizeable.cc	(revision 9249)
@@ -42,5 +42,5 @@
   this->networkStream = NULL;
   this->bSynchronize = false;
-  
+
   if( State::isOnline())
   {
@@ -54,5 +54,5 @@
   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" ) );
@@ -69,9 +69,9 @@
   {
     this->networkStream->disconnectSynchronizeable(*this);
-  
+
     if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
       NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
   }
-    
+
   for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
   {
@@ -79,5 +79,5 @@
   }
   syncVarList.clear();
-  
+
   for ( UserStateHistory::iterator it = recvStates.begin(); it != recvStates.end(); it++ )
   {
@@ -93,5 +93,5 @@
 
   }
-  
+
   for ( UserStateHistory::iterator it = sentStates.begin(); it != sentStates.end(); it++ )
   {
@@ -169,5 +169,5 @@
         (*it2)->data = NULL;
       }
-      
+
       delete *it2;
     }
@@ -181,5 +181,5 @@
   while ( it != sentStates[userId].end() && (*it)->stateId != fromStateId )
     it++;
-  
+
 //  if ( getLeafClassID() == CL_SPACE_SHIP )
 //  {
@@ -196,5 +196,5 @@
 
     stateFrom = initialEntry;
-    
+
     sentStates[userId].push_back( stateFrom );
   }
@@ -205,5 +205,5 @@
 
   sentStates[userId].push_back( stateTo );
-  
+
   stateTo->stateId = stateId;
   stateTo->dataLength = neededSize;
@@ -214,5 +214,5 @@
   int i = 0;
   int n;
-  
+
   bool hasPermission;
   bool sizeChanged = false;
@@ -225,10 +225,10 @@
         this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
             this->isServer() && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) ||
-            (*it)->checkPermission( PERMISSION_ALL ) 
+            (*it)->checkPermission( PERMISSION_ALL )
                     );
-    
-    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() ) 
+
+    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
       sizeChanged = true;
-    
+
     if ( ( hasPermission && (*it)->getPriority() >= priorityTH ) || sizeChanged )
     {
@@ -303,5 +303,5 @@
     it++;
 
-  
+
 //  if ( getLeafClassID() == CL_SPACE_SHIP )
 //  {
@@ -318,10 +318,10 @@
 
     stateFrom = initialEntry;
-    
+
     recvStates[userId].push_back( stateFrom );
   }
   else
     stateFrom = (*it);
-  
+
   //apply diff
   for ( int i = 0; i<length; i++ )
@@ -331,21 +331,21 @@
     else
       stateTo->data[i] = data[i];
-    
-  }
-  
+
+  }
+
   //add state to state history
   recvStates[userId].push_back( stateTo );
-  
+
   int i = 0;
   int n = 0;
   std::list<int> changes;
-  
+
   for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
   {
     if (
-        (*it)->checkPermission( PERMISSION_SERVER ) && networkStream->isUserServer( userId ) ||
+        (*it)->checkPermission( PERMISSION_SERVER ) && networkStream->isUserMasterServer( userId ) ||
         (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId ||
-        networkStream->isUserServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
-        (*it)->checkPermission( PERMISSION_ALL ) 
+        networkStream->isUserMasterServer( userId ) && this->owner != SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ) ||
+        (*it)->checkPermission( PERMISSION_ALL )
        )
     {
@@ -370,5 +370,5 @@
 
   this->varChangeHandler( changes );
-  
+
   return i;
 }
@@ -423,13 +423,13 @@
         (*it)->data = NULL;
       }
-    
+
       delete *it;
     }
     recvStates[userId].clear();
   }
- 
+
   if ( sentStates.size() > userId )
   {
-    
+
     for ( std::list<StateHistoryEntry*>::iterator it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ )
     {
@@ -439,5 +439,5 @@
         (*it)->data = NULL;
       }
-    
+
       delete *it;
     }
@@ -448,7 +448,7 @@
 /**
  * this function is called after recieving a state.
- * @param userId 
- * @param stateId 
- * @param fromStateId 
+ * @param userId
+ * @param stateId
+ * @param fromStateId
  */
 void Synchronizeable::handleRecvState( int userId, int stateId, int fromStateId )
@@ -457,5 +457,5 @@
   if ( recvStates.size() <= userId )
     recvStates.resize( userId+1 );
-  
+
   //remove old states
   StateHistory::iterator it = recvStates[userId].begin();
@@ -485,5 +485,5 @@
       StateHistory::iterator delIt = it;
       it ++;
-      
+
       if ( (*delIt)->data )
       {
@@ -493,13 +493,13 @@
       delete *delIt;
       recvStates[userId].erase( delIt );
-      
+
       continue;
     }
     it++;
   }
-  
+
   StateHistory::iterator fromState = recvStates[userId].end();
   StateHistory::iterator toState = recvStates[userId].end();
-  
+
   for ( it = recvStates[userId].begin(); it != recvStates[userId].end(); it++ )
   {
@@ -508,19 +508,19 @@
     if ( (*it)->stateId == fromStateId )
       fromState = it;
-    
+
     if ( fromState != recvStates[userId].end() && toState != recvStates[userId].end() )
       break;
   }
-  
+
   // setStateDiff was not called and i know fromStateId
   if ( fromState != recvStates[userId].end() && toState == recvStates[userId].end() )
   {
     StateHistoryEntry * entry = new StateHistoryEntry;
-    
+
     entry->dataLength = (*fromState)->dataLength;
     if ( entry->dataLength > 0 )
     {
       entry->data = new byte[entry->dataLength];
-          
+
       assert( (*fromState)->data );
       memcpy( entry->data, (*fromState)->data, entry->dataLength );
@@ -528,8 +528,8 @@
     else
       entry->data = NULL;
-    
+
     entry->sizeList = (*fromState)->sizeList;
     entry->stateId = stateId;
-    
+
     recvStates[userId].push_back(entry);
   }
@@ -538,7 +538,7 @@
 /**
  * this function is called after sending a state
- * @param userId 
- * @param stateId 
- * @param fromStateId 
+ * @param userId
+ * @param stateId
+ * @param fromStateId
  */
 void Synchronizeable::handleSentState( int userId, int stateId, int fromStateId )
@@ -557,5 +557,5 @@
       StateHistory::iterator delIt = it;
       it ++;
-      
+
       if ( (*delIt)->data )
       {
@@ -565,5 +565,5 @@
       delete *delIt;
       sentStates[userId].erase( delIt );
-      
+
       continue;
     }
@@ -571,8 +571,8 @@
   }
 
-  
+
   StateHistory::iterator fromState = sentStates[userId].end();
   StateHistory::iterator toState = sentStates[userId].end();
-  
+
   for ( it = sentStates[userId].begin(); it != sentStates[userId].end(); it++ )
   {
@@ -581,20 +581,20 @@
     if ( (*it)->stateId == fromStateId )
       fromState = it;
-    
+
     if ( fromState != sentStates[userId].end() && toState != sentStates[userId].end() )
       break;
   }
 
-  
+
   // getStateDiff was not called and i know fromStateId
   if ( fromState != sentStates[userId].end() && toState == sentStates[userId].end() )
   {
     StateHistoryEntry * entry = new StateHistoryEntry;
-    
+
     entry->dataLength = (*fromState)->dataLength;
     if ( entry->dataLength > 0 )
     {
       entry->data = new byte[entry->dataLength];
-      
+
       assert( (*fromState)->data );
       memcpy( entry->data, (*fromState)->data, entry->dataLength );
@@ -602,13 +602,13 @@
     else
       entry->data = NULL;
-    
+
     entry->sizeList = (*fromState)->sizeList;
     entry->stateId = stateId;
-    
+
     sentStates[userId].push_back(entry);
   }
-  
-}
-
-
-
+
+}
+
+
+
