Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6498 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Jan 11, 2006, 9:58:22 PM (19 years ago)
Author:
patrick
Message:

trunk: merged the network branche into the trunk

Location:
trunk/src/world_entities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r6424 r6498  
    138138    SYNCHELP_READ_INT( this->min_value );
    139139    SYNCHELP_READ_INT( this->max_value );
     140    respawn();
    140141  }
    141142
     
    162163    SYNCHELP_WRITE_FKT( PowerUp::readState );
    163164
    164     int i = this->type;
     165    int i = (int)this->type;
    165166    SYNCHELP_WRITE_INT( i );
    166167    SYNCHELP_WRITE_INT( this->value );
  • trunk/src/world_entities/power_ups/power_up.cc

    r6424 r6498  
    9696}
    9797
     98
     99
     100/********************************************************************************************
     101 NETWORK STUFF
     102 ********************************************************************************************/
     103
     104
    98105/**
    99106 * data copied in data will bee sent to another host
     
    108115  return SYNCHELP_WRITE_N;
    109116}
     117
    110118
    111119/**
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r6424 r6498  
    119119}
    120120
     121
     122
     123
     124/********************************************************************************************
     125 NETWORK STUFF
     126 ********************************************************************************************/
     127
     128
    121129int TurretPowerUp::writeBytes( const byte * data, int length, int sender )
    122130{
     
    130138  return SYNCHELP_READ_N;
    131139}
    132 
    133140
    134141
  • trunk/src/world_entities/skybox.cc

    r6470 r6498  
    270270  SYNCHELP_READ_STRINGM( textureName );
    271271
    272   PRINT(0)("GOT DATA: size=%f texture='%s'\n", size, textureName);
    273 
    274272  this->setSize( size );
    275273  this->setTextureAndType( textureName, "jpg" );
     
    292290  if ( rec > 0 )
    293291  {
    294     PRINT(0)("SEND DATA: size=%f texture='%s'\n", size, textureName);
    295292    *reciever = rec;
    296293
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6444 r6498  
    510510}
    511511
     512#define MASK_bUp         1
     513#define MASK_bDown       2
     514#define MASK_bLeft       4
     515#define MASK_bRight      8
     516#define MASK_bAscend    16
     517#define MASK_bDescend   32
     518#define MASK_bFire      64
     519#define MASK_bRollL    128
     520#define MASK_bRollR    256
     521
     522#define DATA_state       1
     523#define DATA_flags       2
     524#define DATA_mouse       3
    512525
    513526int SpaceShip::writeBytes( const byte * data, int length, int sender )
    514527{
    515   setRequestedSync( false );
    516   setIsOutOfSync( false );
    517 
    518528  SYNCHELP_READ_BEGIN();
    519529
    520   SYNCHELP_READ_FKT( WorldEntity::writeState );
     530  byte b;
     531  SYNCHELP_READ_BYTE( b );
     532
     533  if ( b == DATA_state && this->getHostID()!=this->getOwner() )
     534  {
     535    setRequestedSync( false );
     536    setIsOutOfSync( false );
     537    SYNCHELP_READ_FKT( WorldEntity::writeState );
     538    SYNCHELP_READ_FLOAT( cycle );
     539  }
     540
     541  if ( b == DATA_flags && this->getHostID()!=this->getOwner() )
     542  {
     543    int flags;
     544    SYNCHELP_READ_INT( flags );
     545
     546    bUp = flags & MASK_bUp != 0;
     547    bDown = flags & MASK_bDown != 0;
     548    bLeft = flags & MASK_bLeft != 0;
     549    bRight = flags & MASK_bRight != 0;
     550    bAscend = flags & MASK_bAscend != 0;
     551    bDescend = flags & MASK_bDescend != 0;
     552    bFire = flags & MASK_bFire != 0;
     553    bRollL = flags & MASK_bRollL != 0;
     554    bRollR = flags & MASK_bRollR != 0;
     555  }
     556
     557  if ( b == DATA_mouse && this->getHostID()!=this->getOwner() )
     558  {
     559    SYNCHELP_READ_FLOAT( xMouse );
     560    SYNCHELP_READ_FLOAT( yMouse );
     561    SYNCHELP_READ_FLOAT( mouseSensitivity );
     562    SYNCHELP_READ_FLOAT( cycle );
     563  }
    521564
    522565  return SYNCHELP_READ_N;
    523566}
    524567
     568
     569
    525570int SpaceShip::readBytes( byte * data, int maxLength, int * reciever )
    526571{
     572  SYNCHELP_WRITE_BEGIN();
     573
    527574  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    528575  {
     
    536583    *reciever = rec;
    537584
    538     SYNCHELP_WRITE_BEGIN();
     585    SYNCHELP_WRITE_BYTE( (byte)DATA_state );
    539586
    540587    SYNCHELP_WRITE_FKT( WorldEntity::readState );
     588    SYNCHELP_WRITE_FLOAT( cycle );
    541589
    542590    return SYNCHELP_WRITE_N;
    543591  }
    544592
     593
    545594  *reciever = 0;
    546   return 0;
    547 }
     595
     596  if ( this->getHostID()==this->getOwner() )
     597  {
     598    int mask = 0;
     599
     600    if ( bUp )
     601      mask |= MASK_bUp;
     602    if ( bDown )
     603      mask |= MASK_bDown;
     604    if ( bLeft )
     605      mask |= MASK_bLeft;
     606    if ( bRight )
     607      mask |= MASK_bRight;
     608    if ( bAscend )
     609      mask |= MASK_bAscend;
     610    if ( bFire )
     611      mask |= MASK_bFire;
     612    if ( bRollL )
     613      mask |= MASK_bRollL;
     614    if ( bRollR )
     615      mask |= MASK_bRollR;
     616
     617    static int oldMask = mask+1; //so it is different the first time!
     618    static float oldxMouse = xMouse + 1.0;
     619    static float oldyMouse = yMouse + 1.0;
     620
     621    if ( mask != oldMask )
     622    {
     623      oldMask = mask;
     624      SYNCHELP_WRITE_BYTE( DATA_flags );
     625      SYNCHELP_WRITE_INT( mask );
     626    }
     627
     628    if ( oldxMouse != xMouse || oldyMouse != yMouse )
     629    {
     630      oldxMouse = xMouse;
     631      oldyMouse = yMouse;
     632      SYNCHELP_WRITE_BYTE( DATA_mouse );
     633      SYNCHELP_WRITE_FLOAT( xMouse );
     634      SYNCHELP_WRITE_FLOAT( yMouse );
     635      SYNCHELP_WRITE_FLOAT( mouseSensitivity );
     636      SYNCHELP_WRITE_FLOAT( cycle );
     637    }
     638  }
     639
     640  return SYNCHELP_WRITE_N;
     641}
  • trunk/src/world_entities/world_entity.cc

    r6440 r6498  
    491491
    492492
     493
     494
     495/********************************************************************************************
     496 NETWORK STUFF
     497 ********************************************************************************************/
     498
     499
    493500/**
    494501 * Writes data from network containing information about the state
     
    523530
    524531  SYNCHELP_READ_STRINGM( modelFileName );
     532
    525533  if ( strcmp(modelFileName, "") )
    526     this->md2TextureFileName = modelFileName;
     534    if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) )
     535    {
     536      this->md2TextureFileName = new char[strlen(modelFileName)-strlen(ResourceManager::getInstance()->getDataDir())+1];
     537      strcpy((char*)this->md2TextureFileName, modelFileName+strlen(ResourceManager::getInstance()->getDataDir()));
     538    }
     539    else
     540    {
     541      this->md2TextureFileName = modelFileName;
     542    }
    527543
    528544  return SYNCHELP_READ_N;
    529545}
     546
    530547
    531548/**
  • trunk/src/world_entities/world_entity.h

    r6440 r6498  
    2828
    2929//! Basis-class all interactive stuff in the world is derived from
    30 class WorldEntity : public PNode, public Synchronizeable
     30class WorldEntity : public PNode
    3131{
    3232public:
Note: See TracChangeset for help on using the changeset viewer.