Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7954 in orxonox.OLD for trunk/src/world_entities/playable.cc


Ignore:
Timestamp:
May 29, 2006, 3:28:41 PM (19 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/playable.cc

    r7868 r7954  
    6262
    6363  this->score = 0;
    64   this->oldScore = 0;
    6564  this->collider = NULL;
    6665
    6766  this->bDead = false;
     67
     68  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
     69  registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER));
    6870}
    6971
     
    484486
    485487
    486 #define DATA_FLAGS    1
    487 #define DATA_SCORE    2
    488 
    489 #define FLAGS_bFire   1
    490 
    491 int Playable::writeSync( const byte * data, int length, int sender )
    492 {
    493   SYNCHELP_READ_BEGIN();
    494 
    495   byte b;
    496   SYNCHELP_READ_BYTE( b, NWT_PL_B );
    497 
    498   byte flags;
    499 
    500   if ( b == DATA_FLAGS )
    501   {
    502     SYNCHELP_READ_BYTE( flags, NWT_PL_FLAGS );
    503 
    504     bFire = (flags & FLAGS_bFire) != 0;
    505 
    506     return SYNCHELP_READ_N;
    507   }
    508 
    509   if ( b == DATA_SCORE )
    510   {
    511     int newScore;
    512     SYNCHELP_READ_BYTE( newScore, NWT_PL_SCORE );
    513     setScore( newScore );
    514 
    515     return SYNCHELP_READ_N;
    516   }
    517 
    518   return SYNCHELP_READ_N;
    519 }
    520 
    521 int Playable::readSync( byte * data, int maxLength )
    522 {
    523   SYNCHELP_WRITE_BEGIN();
    524 
    525   if ( score != oldScore && isServer() )
    526   {
    527     SYNCHELP_WRITE_BYTE( DATA_SCORE, NWT_PL_B);
    528     SYNCHELP_WRITE_INT( score, NWT_PL_SCORE );
    529     oldScore = score;
    530 
    531     return SYNCHELP_WRITE_N;
    532   }
    533 
    534   byte flags = 0;
    535 
    536   if ( bFire )
    537     flags |= FLAGS_bFire;
    538 
    539 
    540   SYNCHELP_WRITE_BYTE( DATA_FLAGS, NWT_PL_B);
    541   SYNCHELP_WRITE_BYTE( flags, NWT_PL_FLAGS );
    542   oldFlags = flags;
    543 
    544 
    545   return SYNCHELP_WRITE_N;
    546 }
    547 
    548 bool Playable::needsReadSync( )
    549 {
    550   if ( score != oldScore && isServer() )
    551     return true;
    552 
    553   byte flags = 0;
    554 
    555   if ( bFire )
    556     flags |= FLAGS_bFire;
    557 
    558   return flags!=oldFlags;
    559 }
    560 
    561488
    562489/**
Note: See TracChangeset for help on using the changeset viewer.