Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 29, 2006, 1:57:48 PM (18 years ago)
Author:
rennerc
Message:

new network system implemented. yet with a lot of empty function bodys

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/world_entities/playable.cc

    r7356 r7444  
    6060
    6161  this->score = 0;
    62   this->oldScore = 0;
    6362
    6463  this->bDead = false;
     64 
     65  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
    6566}
    6667
     
    480481
    481482
    482 #define DATA_FLAGS    1
    483 #define DATA_SCORE    2
    484 
    485 #define FLAGS_bFire   1
    486 
    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 
    557483
    558484/**
Note: See TracChangeset for help on using the changeset viewer.