Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6937 in orxonox.OLD for branches/network


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

network: implemented network cd system

Location:
branches/network/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_game_manager.cc

    r6917 r6937  
    576576    {
    577577      assert((*it)->isA(CL_WORLD_ENTITY));
     578      dynamic_cast<WorldEntity*>(*it)->leaveWorld();
    578579      dynamic_cast<WorldEntity*>(*it)->toList(OM_DEAD);
    579580      break;
  • branches/network/src/lib/network/synchronizeable.h

    r6868 r6937  
    3434  NWT_SS_VELZ,
    3535  NWT_SS_PL_SYNC,
    36  
     36  NWT_SS_CO_N,
     37  NWT_SS_CO_CLID,
     38
    3739  NWT_HS_HOST_ID,
    3840  NWT_HS_NGM_ID,
    39  
     41
    4042  NWT_PL_FLAGS,
    41  
     43
    4244  NWT_PN_BO_WRITESTATE,
    4345  NWT_PN_PARENTMODE,
     
    4951  NWT_PN_ROTZ,
    5052  NWT_PN_ROTV,
    51  
     53
    5254  NWT_PN_FLAGS,
    5355  NWT_PN_SCOORX,
     
    5860  NWT_PN_SROTZ,
    5961  NWT_PN_SROTV,
    60  
     62
    6163  NWT_BO_NAME,
    62  
     64
    6365  NWT_WE_PN_WRITESTATE,
    6466  NWT_WE_PN_MODELFILENAME,
    6567  NWT_WE_PN_SCALING,
    66  
     68
    6769  NWT_GT_WE_STATE,
    68  
     70
    6971  NWT_SB_WE_STATE,
    7072  NWT_SB_SIZE,
    7173  NWT_SB_TEXTURENAME,
    72  
     74
    7375  NWT_TER_WE_STATE,
    74  
     76
    7577  NWT_PU_WE_STATE,
    76  
     78
    7779  NWT_TPU_WE_STATE,
    78  
     80
    7981  NWT_LPU_WE_STATE,
    80  
     82
    8183  NWT_WPU_WE_STATE,
    82  
     84
    8385  NWT_PPU_WE_STATE,
    8486  NWT_PPU_TYPE,
     
    133135 *  delete[] textureName;
    134136 *  textureName = NULL;
    135  *  SYNCHELP_READ_STRINGM( texturename );      //this will call new char[strlen()+1] 
     137 *  SYNCHELP_READ_STRINGM( texturename );      //this will call new char[strlen()+1]
    136138 *
    137139 * Example 2:
     
    142144 *
    143145 */
    144  
     146
    145147#define SYNCHELP_WRITE_DEBUG(n) {\
    146148  __synchelp_write_n = Converter::intToByteArray( n, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
  • 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.