Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 2, 2006, 2:22:19 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network bak to the trunk
merged with command:
svn merge -r8804:HEAD https://svn.orxonox.net/orxonox/branches/multi_player_map .

conflicts all resolved in favour of the branche

Location:
trunk/src/world_entities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/playable.cc

    r8724 r9008  
    6565
    6666  this->bDead = false;
    67  
     67
    6868  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    6969
     
    392392    State::getGameRules()->onPlayerSpawn();
    393393
    394 
    395   if( this->getOwner() % 2 == 0)
    396   {
    397     //     this->toList(OM_GROUP_00);
    398     this->setAbsCoor(213.37, 57.71, -47.98);
    399     this->setAbsDir(0, 0, 1, 0);
    400   }
    401   else
    402   { // red team
    403     //     this->toList(OM_GROUP_01);
    404     this->setAbsCoor(-314.450, 40.701, 83.554);
    405     this->setAbsDir(1.0, -0.015, -0.012, 0.011);
    406   }
    407394  this->reset();
    408395  this->bDead = false;
  • trunk/src/world_entities/space_ships/space_ship.cc

    r8708 r9008  
    220220  this->burstSystem->setColor(0.5, .5,.5,.8,.8);
    221221  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
    222  
     222
    223223  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity" ) );
    224224  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) );
     
    384384  this->shiftCoor(move);
    385385
     386//   PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());
    386387
    387388}
     
    504505}
    505506
    506 
    507 
    508 
     507void SpaceShip::destroy( )
     508{
     509  PRINTF(0)("spaceship destroy\n");
     510}
     511
     512void SpaceShip::respawn( )
     513{
     514  toList( OM_PLAYERS );
     515}
     516
     517
     518
     519
  • trunk/src/world_entities/space_ships/space_ship.h

    r7954 r9008  
    3636    virtual void postSpawn();
    3737    virtual void leftWorld();
     38   
     39    virtual void destroy();
     40    virtual void respawn();
    3841
    3942    virtual void collidesWith(WorldEntity* entity, const Vector& location);
  • trunk/src/world_entities/spawning_point.cc

    r8802 r9008  
    2222#include "world_entity.h"
    2323
     24#include "class_list.h"
     25
    2426#include "compiler.h"
    2527
     
    2729#include "game_rules.h"
    2830
     31#include "shared_network_data.h"
     32
     33CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT );
    2934
    3035/**
    3136 *  constructor
    3237 */
    33 SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
    34 {
    35   this->setAbsCoor(position);
    36   this->classid = classid;
    37   this->mode = SPT_ALL_AT_ONCE;
    38   this->delay = 0;
     38SpawningPoint::SpawningPoint( const TiXmlElement * root )
     39{
     40  this->setAbsCoor( 0, 0, 0 );
    3941
    4042  this->init();
    41 }
    42 
    43 
    44 /**
    45  *  standard constructor
    46  */
    47 SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay)
    48 {
    49   this->setAbsCoor(position);
    50   this->classid = classid;
    51   this->mode = mode;
    52   this->delay = delay;
    53 
    54   this->init();
    55 }
    56 
    57 
     43 
     44  if (root != NULL)
     45    this->loadParams(root);
     46}
    5847
    5948void SpawningPoint::init()
    6049{
    6150  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
     51  PRINTF(0)("Created SpawningPoint\n");
    6252 
    6353  this->teamId = -1;
     54  this->localTimer = 0.0f;
     55 
     56  this->toList( OM_DEAD_TICK );
     57 
     58  MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
    6459}
    6560
     
    8176  WorldEntity::loadParams(root);
    8277
    83   /* now load the frequency */
    84   LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
    85       .describe("sets the delay of the spawning point");
    86      
    8778  /* load teamId */
    8879  LoadParam(root, "teamId", this, SpawningPoint, setTeamId)
    8980      .describe("sets teamId");
    90 
    91 
    92   /* now load the seed */
    93 //   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
    94 //       .describe("sets the spawning entity");
    95 
    96   /* now load the seed */
    97 /*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
    98       .describe("sets the class id of the entity to spawn")
    99       .defaultValues(CL_WORLD_ENTITY);*/
    10081}
    10182
     
    10687 *  @param entity WorldEntity to be added
    10788 */
    108 void SpawningPoint::pushEntity(WorldEntity* entity, float delay)
     89void SpawningPoint::pushEntity(Playable* entity, float delay)
    10990{
    11091  QueueEntry qe;
    11192  qe.entity = entity;
    112   qe.list = entity->getOMListNumber();
    11393  qe.respawnTime = this->localTimer + delay;
    11494 
     
    120100 *  spawn the entity
    121101 */
    122 void SpawningPoint::spawn(WorldEntity* entity)
    123 {
    124   PRINTF(1)("Spawningpoint spawns new Entity (%s)\n", entity->getClassName());
     102void SpawningPoint::spawn(Playable* entity)
     103{
     104  PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassName());
    125105
    126106
     
    129109 
    130110  //TODO set camera (not smooth)
     111 
     112  if ( State::getGameRules() )
     113  {
     114    (State::getGameRules())->registerSpawn( entity );
     115  }
     116 
     117  entity->respawn();
    131118}
    132119
     
    141128{
    142129  this->localTimer += dt;
    143 
    144130  std::list<QueueEntry>::iterator it = this->queue.begin();
    145131  for( ; it != this->queue.end(); )
    146132  {
    147    
     133    //PRINTF(0)("%f <= %f\n", it->respawnTime, this->localTimer);
    148134    if( it->respawnTime <= this->localTimer)
    149135    {
     
    151137      this->spawn(it->entity);
    152138     
    153       it->entity->toList( it->list );
    154      
    155       if ( State::getGameRules() )
    156       {
    157         (State::getGameRules())->registerSpawn( it->entity );
    158       }
    159      
     139      if ( SharedNetworkData::getInstance()->isGameServer() )
     140        this->sendRespawnMessage( it->entity->getUniqueID() );
     141
    160142      std::list<QueueEntry>::iterator delit = it;
    161143      it++;
     
    179161 */
    180162void SpawningPoint::draw()
    181 {}
     163{
     164}
     165
     166void SpawningPoint::sendRespawnMessage( int uniqueId )
     167{
     168  byte * buf = new byte[2*INTSIZE];
     169 
     170  assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE );
     171  assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
     172 
     173  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
     174}
     175
     176bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
     177{
     178  if ( SharedNetworkData::getInstance()->isGameServer() )
     179  {
     180    PRINTF(2)("server received spawn message!\n");
     181    return true;
     182  }
     183   
     184  int spUniqueId;
     185  int uniqueId;
     186 
     187  if ( dataLength != 2*INTSIZE )
     188  {
     189    PRINTF(2)("spawn message has wrong size: %d\n", dataLength );
     190    return true;
     191  }
     192 
     193  assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE );
     194  assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
     195 
     196  SpawningPoint * sp = NULL;
     197  Playable      * playable = NULL;
     198 
     199  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
     200 
     201  if ( list )
     202  {
     203    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     204    {
     205      if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == uniqueId )
     206      {
     207        sp = dynamic_cast<SpawningPoint*>(*it);
     208        break;
     209      }
     210    }
     211  }
     212 
     213  if ( !sp )
     214  {
     215    PRINTF(2)("could not find spawning point\n");
     216    return false;
     217  }
     218 
     219  list = ClassList::getList( CL_PLAYABLE );
     220 
     221  if ( list )
     222  {
     223    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     224    {
     225      if ( dynamic_cast<Playable*>(*it)->getUniqueID() == uniqueId )
     226      {
     227        playable = dynamic_cast<Playable*>(*it);
     228        break;
     229      }
     230    }
     231  }
     232 
     233  if ( !playable )
     234  {
     235    PRINTF(2)("could not find playable\n");
     236    return false;
     237  }
     238 
     239  sp->spawn( playable );
     240 
     241  return true;
     242}
     243
  • trunk/src/world_entities/spawning_point.h

    r8802 r9008  
    1010#include "playable.h"
    1111
     12#include "message_manager.h"
     13
    1214#include <list>
    1315
     
    1820{
    1921  float respawnTime;
    20   WorldEntity * entity;
    21   OM_LIST list;
     22  Playable * entity;
    2223};
    2324
     
    4344
    4445  public:
    45     SpawningPoint (ClassID classID, const Vector& position = Vector(0.0, 0.0, 0.0));
    46     SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode type, float delay);
     46    SpawningPoint(const TiXmlElement* root = NULL);
    4747    virtual ~SpawningPoint ();
    4848    void init();
     
    5050    virtual void loadParams(const TiXmlElement* root);
    5151
    52     /**  sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */
    53     void SpawningPoint::setSpawningEntity(ClassID classid) { this->classid = classid; }
    54     /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */
    55     void SpawningPoint::setSpawningDelay(float delay) { this->delay = delay; }
    56     /** sets the spawning point mode @param mode: the mode */
    57     void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; }
    58    
    5952    inline int getTeamId(){ return this->teamId; }
    6053    inline void setTeamId( int teamId ){ this->teamId = teamId; }
    6154
    62     void pushEntity(WorldEntity* entity, float delay = 0);
     55    void pushEntity(Playable* entity, float delay = 0);
    6356
    6457    /** activates the spawning point */
     
    7467
    7568  private:
    76     void spawn(WorldEntity* entity);
     69    void spawn(Playable* entity);
     70   
     71    void sendRespawnMessage( int uniqueId );
     72    static bool respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    7773
    7874
    7975  private:
    80     float                           delay;                          //!< the timer that counts down until the next spawn
    8176    float                           localTimer;                     //!< the local timer
    82     float                           seed;                           //!< the random seed of the position
    8377    int                             teamId;                         //!< only spawn players of this team
    84     ClassID                         classid;                        //!< the classid of the entity to spawn
    85     SpawningPointMode               mode;                           //!< the mode of the spawning point
    8678    std::list<QueueEntry>           queue;                          //!< queue of waiting WorldEntities to be spawned
    8779    bool                            bSpawning;                      //!< flag to indicate if this spawning point is active or not
  • trunk/src/world_entities/world_entity.cc

    r9003 r9008  
    8888  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    8989  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
     90  list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
    9091}
    9192
     
    733734 *  @param damage damage to be dealt
    734735 */
    735 void WorldEntity::hit(float damage)
     736void WorldEntity::hit(float damage, WorldEntity* killer)
    736737{
    737738  this->decreaseHealth(damage);
     
    748749
    749750    if( State::getGameRules() != NULL)
    750       State::getGameRules()->registerKill(Kill(NULL, this));
     751      State::getGameRules()->registerKill(Kill(killer, this));
    751752  }
    752753}
     
    832833  }
    833834
     835  if ( std::find( id.begin(), id.end(), list_handle ) != id.end() )
     836  {
     837    this->toList( (OM_LIST)list_write );
     838  }
     839
    834840  PNode::varChangeHandler( id );
    835841}
  • trunk/src/world_entities/world_entity.h

    r9003 r9008  
    9999  void setOnGround(bool flag) { this->bOnGround = flag; }
    100100
    101   virtual void hit(float damage);
     101  virtual void hit(float damage, WorldEntity* killer);
     102
    102103  virtual void destroy();
    103104
     
    195196  int                     modelFileName_handle;            //!< handle for syncing var
    196197
     198  int                     list_write;                      //!< entity's list
     199  int                     list_handle;                     //!< handle for list changes
     200
    197201  CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
    198202  bool                    bReactive;                              //!< true if there is at least one collision reaction subscibed
Note: See TracChangeset for help on using the changeset viewer.