Changeset 7444 in orxonox.OLD for branches/network/src/world_entities/playable.cc
- Timestamp:
- Apr 29, 2006, 1:57:48 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/playable.cc
r7356 r7444 60 60 61 61 this->score = 0; 62 this->oldScore = 0;63 62 64 63 this->bDead = false; 64 65 registerVar( new SynchronizeableInt( &score, &score, "score" ) ); 65 66 } 66 67 … … 480 481 481 482 482 #define DATA_FLAGS 1483 #define DATA_SCORE 2484 485 #define FLAGS_bFire 1486 487 int Playable::writeSync( const byte * data, int length, int sender )488 {489 SYNCHELP_READ_BEGIN();490 491 byte b;492 SYNCHELP_READ_BYTE( b, NWT_PL_B );493 494 byte flags;495 496 if ( b == DATA_FLAGS )497 {498 SYNCHELP_READ_BYTE( flags, NWT_PL_FLAGS );499 500 bFire = (flags & FLAGS_bFire) != 0;501 502 return SYNCHELP_READ_N;503 }504 505 if ( b == DATA_SCORE )506 {507 int newScore;508 SYNCHELP_READ_BYTE( newScore, NWT_PL_SCORE );509 setScore( newScore );510 511 return SYNCHELP_READ_N;512 }513 514 return SYNCHELP_READ_N;515 }516 517 int Playable::readSync( byte * data, int maxLength )518 {519 SYNCHELP_WRITE_BEGIN();520 521 if ( score != oldScore && isServer() )522 {523 SYNCHELP_WRITE_BYTE( DATA_SCORE, NWT_PL_B);524 SYNCHELP_WRITE_INT( score, NWT_PL_SCORE );525 oldScore = score;526 527 return SYNCHELP_WRITE_N;528 }529 530 byte flags = 0;531 532 if ( bFire )533 flags |= FLAGS_bFire;534 535 536 SYNCHELP_WRITE_BYTE( DATA_FLAGS, NWT_PL_B);537 SYNCHELP_WRITE_BYTE( flags, NWT_PL_FLAGS );538 oldFlags = flags;539 540 541 return SYNCHELP_WRITE_N;542 }543 544 bool Playable::needsReadSync( )545 {546 if ( score != oldScore && isServer() )547 return true;548 549 byte flags = 0;550 551 if ( bFire )552 flags |= FLAGS_bFire;553 554 return flags!=oldFlags;555 }556 557 483 558 484 /**
Note: See TracChangeset
for help on using the changeset viewer.