Changeset 9627 in orxonox.OLD for branches/proxy/src/lib/network/synchronizeable.cc
- Timestamp:
- Jul 31, 2006, 1:14:06 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/synchronizeable.cc
r9626 r9627 201 201 int n; 202 202 203 bool hasPermission = false;204 203 bool sizeChanged = false; 205 204 … … 207 206 for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ ) 208 207 { 209 210 // DATA PERMISSIONS211 // check if this synchronizeable has the permissions to write the data212 213 #if 0214 // 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_SERVER228 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 |====> CLIENT232 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 else248 hasPermission = false;249 #endif250 208 251 209 //////////////////////////////// 252 210 // Data SENDING Permissions 253 211 //////////////////////////////// 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 254 216 255 217 // Permission OWNER accept if: 256 218 // 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; } 259 221 // reciever != owner && owner is local 260 222 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; } 263 225 264 226 265 227 // Permission MASTER_SERVER accept if: 266 228 // 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; } 269 231 // im PROXY_SERVER && reciever == CLIENT 270 232 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; } 273 235 274 236 … … 276 238 // i am server && reciever == CLIENT 277 239 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; } 280 242 // i am SERVER && reciever == SERVER && reciever != owner && ( owner is local || i am owner) 281 243 else if( (*it)->checkPermission( PERMISSION_SERVER ) && !SharedNetworkData::getInstance()->isClient() && 282 244 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; } 285 247 286 248 287 249 // 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; } 292 252 // or else refuse sending data 293 253 else … … 296 256 297 257 298 299 258 if ( sizeIter == stateFrom->sizeList.end() || *sizeIter != (*it)->getSize() ) 300 259 sizeChanged = true; … … 305 264 //NETPRINTF(0)("getvar %s %d\n", (*it)->getName().c_str(), n); 306 265 // 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 307 279 stateTo->sizeList.push_back( n ); 308 280 // this is only for very hardcore debug sessions … … 408 380 int n = 0; 409 381 std::list<int> changes; 410 bool hasPermission = false;411 382 412 383 // extract the new state for every client … … 416 387 // check if this synchronizeable has the permissions to write the data 417 388 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; 418 392 419 393 //////////////////////////////// … … 427 401 // Permission OWNER accept if: 428 402 // 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; } 431 405 // 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; } 434 409 // 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; } 437 412 438 413 // Permission MASTER_SERVER accept if: 439 414 // 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; } 442 417 // sender == PROXY_SERVER && im not MASTER_SERVER && im not PROXY_SERVER 443 418 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; } 446 421 447 422 // Permission SERVER accept if: 448 423 // 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; } 451 426 452 427 // 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; } 455 430 456 431 // no rights to over-write local data … … 468 443 // PRINTF(0)("recieving: %s %d\n", (*it)->getName().c_str(), n); 469 444 //(*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 470 458 if ( (*it)->getHasChanged() ) 471 459 {
Note: See TracChangeset
for help on using the changeset viewer.