Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6937 in orxonox.OLD for branches/network/src/world_entities


Ignore:
Timestamp:
Feb 1, 2006, 2:32:16 PM (19 years ago)
Author:
patrick
Message:

network: implemented network cd system

Location:
branches/network/src/world_entities
Files:
5 edited

Legend:

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

    r6868 r6937  
    101101void Playable::collidesWith(WorldEntity* entity, const Vector& location)
    102102{
    103   if (entity->isA(CL_PROJECTILE))
     103  if (entity->isA(CL_PROJECTILE) && !State::isOnline() )
    104104    this->decreaseHealth(entity->getHealth());
    105105
     
    253253{
    254254  SYNCHELP_READ_BEGIN();
    255  
     255
    256256  byte flags;
    257  
     257
    258258  SYNCHELP_READ_BYTE( flags, NWT_PL_FLAGS );
    259  
     259
    260260  bFire = (flags & FLAGS_bFire) != 0;
    261  
     261
    262262  return SYNCHELP_READ_N;
    263263}
     
    267267  SYNCHELP_WRITE_BEGIN();
    268268  byte flags = 0;
    269  
     269
    270270  if ( bFire )
    271271    flags |= FLAGS_bFire;
    272  
     272
    273273
    274274  SYNCHELP_WRITE_BYTE( flags, NWT_PL_FLAGS );
    275275  oldFlags = flags;
    276276
    277  
     277
    278278  return SYNCHELP_WRITE_N;
    279279}
     
    282282{
    283283  byte flags = 0;
    284  
     284
    285285  if ( bFire )
    286286    flags |= FLAGS_bFire;
    287  
     287
    288288  return flags!=oldFlags;
    289289}
  • branches/network/src/world_entities/space_ships/space_ship.cc

    r6930 r6937  
    9696  {
    9797    //this->loadModel("models/ships/reap_#.obj");
    98     this->loadModel( "models/ships/fighter.obj" );
     98    ///HACK this is only for network multiplayer games.
     99    if( this->getOwner()%2 == 0)
     100    {
     101      this->loadModel("models/ships/reap_#.obj");
     102      this->toList(OM_GROUP_00);
     103    }
     104    else
     105    {
     106      this->loadModel( "models/ships/fighter.obj" );
     107      this->toList(OM_GROUP_01);
     108    }
    99109  }
    100110
     
    275285{
    276286  Playable::collidesWith(entity, location);
     287
     288
    277289  if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)
    278290  {
    279291    this->ADDWEAPON();
    280292    ref = entity;
    281     }
     293  }
     294
     295  if( entity->isA(CL_PROJECTILE) && entity != ref)
     296  {
     297    if ( isServer() )
     298    {
     299      networkCollisionList.push_back( entity->getHealth() );
     300      doCollideNetwork( entity->getHealth() );
     301    }
     302  }
    282303//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    283304}
     
    323344    this->calculateVelocity(time);
    324345
    325  
     346
    326347  Vector move = velocity*time;
    327348
     
    528549#define DATA_velocity    5
    529550#define DATA_playables   6
     551#define DATA_collision   7
    530552
    531553int SpaceShip::writeBytes( const byte * data, int length, int sender )
     
    563585        bRollL = (flags & MASK_bRollL) != 0;
    564586        bRollR = (flags & MASK_bRollR) != 0;
    565        
     587
    566588      }
    567589      else
     
    605627        SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
    606628        SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
    607       }     
     629      }
    608630      else
    609631        assert(false);
    610      
     632
    611633      continue;
    612634    }
    613    
     635
    614636    if ( b == DATA_playables )
    615637    {
     
    620642      else
    621643        assert(false);
     644    }
     645
     646    if ( b == DATA_collision )
     647    {
     648      int n;
     649      float energy;
     650      SYNCHELP_READ_INT( n, NWT_SS_CO_N );
     651
     652      for ( int i = 0; i<n; i++ )
     653      {
     654        SYNCHELP_READ_FLOAT( energy, NWT_SS_CO_CLID );
     655        doCollideNetwork( energy );
     656      }
    622657    }
    623658  }
     
    725760      SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
    726761    }
    727    
     762
    728763    if ( Playable::needsReadSync() )
    729764    {
     
    735770
    736771  }
    737  
     772
    738773  if ( !sentSomething )
     774  {
    739775    *reciever = 0;
    740776
     777    if ( networkCollisionList.size()>0 )
     778    {
     779      SYNCHELP_WRITE_BYTE( DATA_collision, NWT_SS_B );
     780
     781      SYNCHELP_WRITE_INT( networkCollisionList.size(), NWT_SS_CO_N );
     782
     783      for ( std::list<float>::iterator it = networkCollisionList.begin(); it!=networkCollisionList.end(); it++ )
     784      {
     785        SYNCHELP_WRITE_FLOAT( *it, NWT_SS_CO_CLID );
     786      }
     787
     788      networkCollisionList.clear();
     789    }
     790  }
     791
    741792  return SYNCHELP_WRITE_N;
    742793}
    743794
    744 
     795void SpaceShip::doCollideNetwork( float energy )
     796{
     797  this->decreaseHealth( energy );
     798}
     799
     800
     801
  • branches/network/src/world_entities/space_ships/space_ship.h

    r6868 r6937  
    4747    void calculateVelocity(float time);
    4848
     49    void doCollideNetwork( float energy );
     50
    4951    // !! temporary !!
    5052    void ADDWEAPON();
     
    8486    ParticleEmitter*      burstEmitter;
    8587    ParticleSystem*       burstSystem;
     88
     89    std::list<float>        networkCollisionList;
    8690};
    8791
  • branches/network/src/world_entities/world_entity.cc

    r6815 r6937  
    280280
    281281/**
    282  *  this method is called by the world if the WorldEntity leaves valid gamespace
    283  *
    284  * For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
    285  * place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
    286  *
    287  * NOT YET IMPLEMENTED
    288  */
    289 void WorldEntity::leftWorld ()
     282 *  this method is called by the world if the WorldEntity leaves the game
     283 */
     284void WorldEntity::leaveWorld ()
    290285{}
    291286
  • branches/network/src/world_entities/world_entity.h

    r6700 r6937  
    5454
    5555  virtual void postSpawn ();
    56   virtual void leftWorld ();
     56  virtual void leaveWorld ();
    5757
    5858  virtual void tick (float time);
Note: See TracChangeset for help on using the changeset viewer.