Index: branches/proxy/src/lib/network/synchronizeable.cc
===================================================================
--- branches/proxy/src/lib/network/synchronizeable.cc	(revision 9626)
+++ branches/proxy/src/lib/network/synchronizeable.cc	(revision 9627)
@@ -201,5 +201,4 @@
   int n;
 
-  bool hasPermission = false;
   bool sizeChanged = false;
 
@@ -207,68 +206,31 @@
   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 ))
-      hasPermission = true;
-    else if( SharedNetworkData::getInstance()->isMasterServer()  && this->networkStream->isUserLocal(userId) &&
-             this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
-      hasPermission = true;
-
-    // PROXY_SERVER  |====> *
-    else if( SharedNetworkData::getInstance()->isProxyServerActive() && (*it)->checkPermission( PERMISSION_PROXY_SERVER ))
-      hasPermission = true;
-    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserLocal(userId) &&
-             this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
-      hasPermission = true;
-    // PROXY_SERVER  |====> MASTER_SERVER
-    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserMasterServer(userId)
-             && this->networkStream->isUserLocal(userId) && (*it)->checkPermission( PERMISSION_MASTER_SERVER))
-      hasPermission = true;
-    // PROXY_SERVER  |====> CLIENT
-    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
-             && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) )
-      hasPermission = true;
-    else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
-             && (*it)->checkPermission( PERMISSION_MASTER_SERVER) )
-      hasPermission = true;
-
-    // OWNER         |====> *
-    else if( this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
-      hasPermission = true;
-
-    // ALL           |====> *
-    else if( (*it)->checkPermission( PERMISSION_ALL ))
-      hasPermission = true;
-
-    else
-      hasPermission = false;
-#endif
 
     ////////////////////////////////
     // Data SENDING Permissions
     ////////////////////////////////
+    bool hasPermission = false;
+    bool b1, b2, b3, b4, b5, b6, b7, b8, b9;
+    b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = b9 = false;
+
 
     // Permission   OWNER accept if:
     // I am the owner
-    if(       (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID())
-      hasPermission = true;
+    if(       (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID()) {
+      hasPermission = true; b1 = 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;
+                (SharedNetworkData::getInstance()->isUserLocal(this->owner) || this->owner == SharedNetworkData::getInstance()->getHostID())) {
+      hasPermission = true; b2 = true; }
 
 
     // Permission   MASTER_SERVER accept if:
     // im MASTER_SERVER
-    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer())
-      hasPermission = true;
+    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer()) {
+      hasPermission = true; b3 = true; }
     // im PROXY_SERVER && reciever == CLIENT
     else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isProxyServerActive() &&
-               SharedNetworkData::getInstance()->isUserClient( userId))
-      hasPermission = true;
+               SharedNetworkData::getInstance()->isUserClient( userId)) {
+      hasPermission = true;  b4 = true; }
 
 
@@ -276,18 +238,16 @@
     // i am server && reciever == CLIENT
     else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
-               SharedNetworkData::getInstance()->isUserClient( userId))
-      hasPermission = true;
+               SharedNetworkData::getInstance()->isUserClient( userId)) {
+      hasPermission = true; b5 = 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;
+               ( SharedNetworkData::getInstance()->isUserLocal( userId) || this->owner ==  SharedNetworkData::getInstance()->getHostID())) {
+      hasPermission = true; b6 = true; }
 
 
     // Permission   ALL accept if:
-    else if( (*it)->checkPermission( PERMISSION_ALL ))
-      hasPermission = true;
-
-
+    else if( (*it)->checkPermission( PERMISSION_ALL )) {
+      hasPermission = true; b7 = true; }
     // or else refuse sending data
     else
@@ -296,5 +256,4 @@
 
 
-
     if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
       sizeChanged = true;
@@ -305,4 +264,17 @@
       //NETPRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n);
 //       PRINTF(0)("sending %s %d\n", (*it)->getName().c_str(), n);
+
+//       if( this->isA(CL_PLAYABLE))
+//       {
+//         PRINTF(0)("ms: %i, ps: %i, c: %i, sender: %i, reciever: %i, owner: %i, perm: (ow %i, ms %i, s %i, a %i)\n",
+//         SharedNetworkData::getInstance()->isMasterServer(), SharedNetworkData::getInstance()->isProxyServerActive(), SharedNetworkData::getInstance()->isClient(),
+//         SharedNetworkData::getInstance()->getHostID(), userId, this->owner,
+//         (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_MASTER_SERVER ),
+//         (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_ALL ));
+//         PRINTF(0)("hasPermission: %i, sizeChanged: %i, eval: %i, %i, %i, %i, %i, %i, %i\n", hasPermission, sizeChanged, b1, b2, b3, b4, b5, b6, b7);
+//         PRINTF(0)("sending %s %s %d\n", this->getClassCName(), (*it)->getName().c_str(), n);
+//       }
+
+
       stateTo->sizeList.push_back( n );
       // this is only for very hardcore debug sessions
@@ -408,5 +380,4 @@
   int n = 0;
   std::list<int> changes;
-  bool hasPermission = false;
 
   // extract the new state for every client
@@ -416,4 +387,7 @@
     // check if this synchronizeable has the permissions to write the data
 
+    bool hasPermission = false;
+    bool b1, b2, b3, b4, b5, b6, b7, b8, b9;
+    b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = b9 = false;
 
     ////////////////////////////////
@@ -427,30 +401,31 @@
     // Permission   OWNER accept if:
     // sender == owner
-    if(      (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId)
-      hasPermission = true;
+    if(      (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId) {
+      hasPermission = true; b1 = true; }
     // sender == MASTER_SERVER
-    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
-      hasPermission = true;
+    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId)
+               && this->owner != SharedNetworkData::getInstance()->getHostID()) {
+      hasPermission = true; b2 = true; }
     // sender == PROXY_SERVER
-    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
-      hasPermission = true;
+      else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId)) {
+        hasPermission = true; b3 = true; }
 
     // Permission   MASTER_SERVER accept if:
     // sender == MASTER_SERVER
-    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
-      hasPermission = true;
+    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId)) {
+      hasPermission = true; b4 = 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;
+               SharedNetworkData::getInstance()->isUserProxyServerActive( userId)) {
+      hasPermission = true; b5 = true; }
 
     // Permission   SERVER accept if:
     // sender == SERVER
-    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) )
-      hasPermission = true;
+    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) ) {
+      hasPermission = true; b6 = true; }
 
     // Pemission    ALL accept if:
-    else if(  (*it)->checkPermission( PERMISSION_ALL ))
-      hasPermission = true;
+    else if(  (*it)->checkPermission( PERMISSION_ALL )) {
+      hasPermission = true; b7 = true; }
 
    // no rights to over-write local data
@@ -468,4 +443,17 @@
 //       PRINTF(0)("recieving: %s %d\n",  (*it)->getName().c_str(), n);
       //(*it)->debug();
+
+//       if( this->isA(CL_PLAYABLE))
+//       {
+//         PRINTF(0)("ms: %i, ps: %i, c: %i, sender: %i, reciever: %i, owner: %i, perm: (ow %i, ms %i, s %i, a %i)\n",
+//         SharedNetworkData::getInstance()->isMasterServer(), SharedNetworkData::getInstance()->isProxyServerActive(), SharedNetworkData::getInstance()->isClient(),
+//         userId, SharedNetworkData::getInstance()->getHostID(), this->owner,
+//         (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_MASTER_SERVER ),
+//         (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_ALL ));
+//         PRINTF(0)("hasPermission: %i, eval: %i, %i, %i, %i, %i, %i, %i\n", hasPermission, b1, b2, b3, b4, b5, b6, b7);
+//         PRINTF(0)("rec %s %s %d\n", this->getClassCName(), (*it)->getName().c_str(), n);
+//       }
+
+
       if ( (*it)->getHasChanged() )
       {
