Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 31, 2006, 1:14:06 AM (18 years ago)
Author:
patrick
Message:

intrudoced very much debug information into the permission system since it seems to be THE critical part in this framework. found a bug in the variable setting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/synchronizeable.cc

    r9626 r9627  
    201201  int n;
    202202
    203   bool hasPermission = false;
    204203  bool sizeChanged = false;
    205204
     
    207206  for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
    208207  {
    209 
    210     // DATA PERMISSIONS
    211     // check if this synchronizeable has the permissions to write the data
    212 
    213 #if 0
    214     //  MASTER_SERVER |====> *
    215     if( SharedNetworkData::getInstance()->isMasterServer() && (*it)->checkPermission( PERMISSION_MASTER_SERVER ))
    216       hasPermission = true;
    217     else if( SharedNetworkData::getInstance()->isMasterServer()  && this->networkStream->isUserLocal(userId) &&
    218              this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
    219       hasPermission = true;
    220 
    221     // PROXY_SERVER  |====> *
    222     else if( SharedNetworkData::getInstance()->isProxyServerActive() && (*it)->checkPermission( PERMISSION_PROXY_SERVER ))
    223       hasPermission = true;
    224     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserLocal(userId) &&
    225              this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ))
    226       hasPermission = true;
    227     // PROXY_SERVER  |====> MASTER_SERVER
    228     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserMasterServer(userId)
    229              && this->networkStream->isUserLocal(userId) && (*it)->checkPermission( PERMISSION_MASTER_SERVER))
    230       hasPermission = true;
    231     // PROXY_SERVER  |====> CLIENT
    232     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
    233              && this->owner != userId && (*it)->checkPermission( PERMISSION_OWNER ) )
    234       hasPermission = true;
    235     else if( SharedNetworkData::getInstance()->isProxyServerActive() && this->networkStream->isUserClient(userId)
    236              && (*it)->checkPermission( PERMISSION_MASTER_SERVER) )
    237       hasPermission = true;
    238 
    239     // OWNER         |====> *
    240     else if( this->owner == SharedNetworkData::getInstance()->getHostID() && (*it)->checkPermission( PERMISSION_OWNER ))
    241       hasPermission = true;
    242 
    243     // ALL           |====> *
    244     else if( (*it)->checkPermission( PERMISSION_ALL ))
    245       hasPermission = true;
    246 
    247     else
    248       hasPermission = false;
    249 #endif
    250208
    251209    ////////////////////////////////
    252210    // Data SENDING Permissions
    253211    ////////////////////////////////
     212    bool hasPermission = false;
     213    bool b1, b2, b3, b4, b5, b6, b7, b8, b9;
     214    b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = b9 = false;
     215
    254216
    255217    // Permission   OWNER accept if:
    256218    // I am the owner
    257     if(       (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID())
    258       hasPermission = true;
     219    if(       (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == SharedNetworkData::getInstance()->getHostID()) {
     220      hasPermission = true; b1 = true; }
    259221    // reciever != owner && owner is local
    260222    else if(  (*it)->checkPermission( PERMISSION_OWNER ) && userId != this->owner &&
    261                 (SharedNetworkData::getInstance()->isUserLocal(this->owner) || this->owner == SharedNetworkData::getInstance()->getHostID()))
    262       hasPermission = true;
     223                (SharedNetworkData::getInstance()->isUserLocal(this->owner) || this->owner == SharedNetworkData::getInstance()->getHostID())) {
     224      hasPermission = true; b2 = true; }
    263225
    264226
    265227    // Permission   MASTER_SERVER accept if:
    266228    // im MASTER_SERVER
    267     else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer())
    268       hasPermission = true;
     229    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isMasterServer()) {
     230      hasPermission = true; b3 = true; }
    269231    // im PROXY_SERVER && reciever == CLIENT
    270232    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER ) && SharedNetworkData::getInstance()->isProxyServerActive() &&
    271                SharedNetworkData::getInstance()->isUserClient( userId))
    272       hasPermission = true;
     233               SharedNetworkData::getInstance()->isUserClient( userId)) {
     234      hasPermission = true;  b4 = true; }
    273235
    274236
     
    276238    // i am server && reciever == CLIENT
    277239    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
    278                SharedNetworkData::getInstance()->isUserClient( userId))
    279       hasPermission = true;
     240               SharedNetworkData::getInstance()->isUserClient( userId)) {
     241      hasPermission = true; b5 = true; }
    280242    // i am SERVER && reciever == SERVER && reciever != owner && ( owner is local || i am owner)
    281243    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() &&
    282244               userId != this->owner &&
    283                ( SharedNetworkData::getInstance()->isUserLocal( userId) || this->owner ==  SharedNetworkData::getInstance()->getHostID()))
    284       hasPermission = true;
     245               ( SharedNetworkData::getInstance()->isUserLocal( userId) || this->owner ==  SharedNetworkData::getInstance()->getHostID())) {
     246      hasPermission = true; b6 = true; }
    285247
    286248
    287249    // Permission   ALL accept if:
    288     else if( (*it)->checkPermission( PERMISSION_ALL ))
    289       hasPermission = true;
    290 
    291 
     250    else if( (*it)->checkPermission( PERMISSION_ALL )) {
     251      hasPermission = true; b7 = true; }
    292252    // or else refuse sending data
    293253    else
     
    296256
    297257
    298 
    299258    if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() )
    300259      sizeChanged = true;
     
    305264      //NETPRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n);
    306265//       PRINTF(0)("sending %s %d\n", (*it)->getName().c_str(), n);
     266
     267//       if( this->isA(CL_PLAYABLE))
     268//       {
     269//         PRINTF(0)("ms: %i, ps: %i, c: %i, sender: %i, reciever: %i, owner: %i, perm: (ow %i, ms %i, s %i, a %i)\n",
     270//         SharedNetworkData::getInstance()->isMasterServer(), SharedNetworkData::getInstance()->isProxyServerActive(), SharedNetworkData::getInstance()->isClient(),
     271//         SharedNetworkData::getInstance()->getHostID(), userId, this->owner,
     272//         (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_MASTER_SERVER ),
     273//         (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_ALL ));
     274//         PRINTF(0)("hasPermission: %i, sizeChanged: %i, eval: %i, %i, %i, %i, %i, %i, %i\n", hasPermission, sizeChanged, b1, b2, b3, b4, b5, b6, b7);
     275//         PRINTF(0)("sending %s %s %d\n", this->getClassCName(), (*it)->getName().c_str(), n);
     276//       }
     277
     278
    307279      stateTo->sizeList.push_back( n );
    308280      // this is only for very hardcore debug sessions
     
    408380  int n = 0;
    409381  std::list<int> changes;
    410   bool hasPermission = false;
    411382
    412383  // extract the new state for every client
     
    416387    // check if this synchronizeable has the permissions to write the data
    417388
     389    bool hasPermission = false;
     390    bool b1, b2, b3, b4, b5, b6, b7, b8, b9;
     391    b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = b9 = false;
    418392
    419393    ////////////////////////////////
     
    427401    // Permission   OWNER accept if:
    428402    // sender == owner
    429     if(      (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId)
    430       hasPermission = true;
     403    if(      (*it)->checkPermission( PERMISSION_OWNER ) && this->owner == userId) {
     404      hasPermission = true; b1 = true; }
    431405    // sender == MASTER_SERVER
    432     else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
    433       hasPermission = true;
     406    else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserMasterServer( userId)
     407               && this->owner != SharedNetworkData::getInstance()->getHostID()) {
     408      hasPermission = true; b2 = true; }
    434409    // sender == PROXY_SERVER
    435     else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
    436       hasPermission = true;
     410      else if( (*it)->checkPermission( PERMISSION_OWNER ) && SharedNetworkData::getInstance()->isUserProxyServerActive( userId)) {
     411        hasPermission = true; b3 = true; }
    437412
    438413    // Permission   MASTER_SERVER accept if:
    439414    // sender == MASTER_SERVER
    440     else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId))
    441       hasPermission = true;
     415    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isUserMasterServer( userId)) {
     416      hasPermission = true; b4 = true; }
    442417    // sender == PROXY_SERVER && im not MASTER_SERVER && im not PROXY_SERVER
    443418    else if( (*it)->checkPermission( PERMISSION_MASTER_SERVER) && SharedNetworkData::getInstance()->isClient() &&
    444                SharedNetworkData::getInstance()->isUserProxyServerActive( userId))
    445       hasPermission = true;
     419               SharedNetworkData::getInstance()->isUserProxyServerActive( userId)) {
     420      hasPermission = true; b5 = true; }
    446421
    447422    // Permission   SERVER accept if:
    448423    // sender == SERVER
    449     else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) )
    450       hasPermission = true;
     424    else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isUserClient( userId) ) {
     425      hasPermission = true; b6 = true; }
    451426
    452427    // Pemission    ALL accept if:
    453     else if(  (*it)->checkPermission( PERMISSION_ALL ))
    454       hasPermission = true;
     428    else if(  (*it)->checkPermission( PERMISSION_ALL )) {
     429      hasPermission = true; b7 = true; }
    455430
    456431   // no rights to over-write local data
     
    468443//       PRINTF(0)("recieving: %s %d\n",  (*it)->getName().c_str(), n);
    469444      //(*it)->debug();
     445
     446//       if( this->isA(CL_PLAYABLE))
     447//       {
     448//         PRINTF(0)("ms: %i, ps: %i, c: %i, sender: %i, reciever: %i, owner: %i, perm: (ow %i, ms %i, s %i, a %i)\n",
     449//         SharedNetworkData::getInstance()->isMasterServer(), SharedNetworkData::getInstance()->isProxyServerActive(), SharedNetworkData::getInstance()->isClient(),
     450//         userId, SharedNetworkData::getInstance()->getHostID(), this->owner,
     451//         (*it)->checkPermission( PERMISSION_OWNER ), (*it)->checkPermission( PERMISSION_MASTER_SERVER ),
     452//         (*it)->checkPermission( PERMISSION_SERVER ), (*it)->checkPermission( PERMISSION_ALL ));
     453//         PRINTF(0)("hasPermission: %i, eval: %i, %i, %i, %i, %i, %i, %i\n", hasPermission, b1, b2, b3, b4, b5, b6, b7);
     454//         PRINTF(0)("rec %s %s %d\n", this->getClassCName(), (*it)->getName().c_str(), n);
     455//       }
     456
     457
    470458      if ( (*it)->getHasChanged() )
    471459      {
Note: See TracChangeset for help on using the changeset viewer.