Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

network: implemented network cd system

Location:
branches/network/src/world_entities/space_ships
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.