Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8827 in orxonox.OLD


Ignore:
Timestamp:
Jun 27, 2006, 2:46:40 PM (18 years ago)
Author:
rennerc
Message:

SpawningPoint works now

Location:
branches/multi_player_map/src
Files:
8 edited

Legend:

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

    r8708 r8827  
    3939
    4040#include "network_game_manager.h"
     41
     42#include "multiplayer_team_deathmatch.h"
    4143
    4244
     
    118120  stats->setPlayableUniqueId( playable.getUniqueID() );
    119121  stats->setModelFileName( playableModel );
     122 
     123  if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) )
     124    dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f );
    120125 
    121126  return true;
  • branches/multi_player_map/src/util/multiplayer_team_deathmatch.cc

    r8809 r8827  
    487487  stats.setPlayableUniqueId( playable.getUniqueID() );
    488488  stats.setModelFileName( playableModel );
     489 
     490  this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f );
    489491
    490492  if ( oldPlayable )
     
    734736  }
    735737 
     738  this->respawnPlayable( killedStats.getPlayable(), killedStats.getTeamId(), 3.0f );
     739}
     740
     741/**
     742 * this function is called on player respawn
     743 * @param userId
     744 */
     745void MultiplayerTeamDeathmatch::onRespawn( int userId )
     746{
     747  if ( userId == SharedNetworkData::getInstance()->getHostID() )
     748  {
     749    this->bLocalPlayerDead = false;
     750    this->hideStats();
     751  }
     752}
     753
     754/**
     755 * this function is called on player respawn
     756 * @param we
     757 */
     758void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
     759{
     760  onRespawn( we->getOwner() );
     761}
     762
     763void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
     764{
    736765  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    737766 
     
    744773    SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
    745774   
    746     if ( sp->getTeamId() < 0 || sp->getTeamId() == killedStats.getTeamId() )
     775    if ( sp->getTeamId() == teamId )
    747776      spList.push_back( sp );
    748777  }
     778 
     779  if ( spList.size() == 0 )
     780  {
     781    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     782    {
     783      SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
     784   
     785      if ( sp->getTeamId() < 0 )
     786        spList.push_back( sp );
     787    }
     788  }
     789 
     790  assert( spList.size() != 0 );
    749791 
    750   int n = spList.size()*rand();
    751  
    752   spList[n]->pushEntity( killedStats.getPlayable(), 3 );
    753 }
    754 
    755 /**
    756  * this function is called on player respawn
    757  * @param userId
    758  */
    759 void MultiplayerTeamDeathmatch::onRespawn( int userId )
    760 {
    761   if ( userId == SharedNetworkData::getInstance()->getHostID() )
    762   {
    763     this->bLocalPlayerDead = false;
    764     this->hideStats();
    765   }
    766 }
    767 
    768 /**
    769  * this function is called on player respawn
    770  * @param we
    771  */
    772 void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
    773 {
    774   onRespawn( we->getOwner() );
    775 }
    776 
     792  int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX);
     793 
     794  spList[n]->pushEntity( playable, delay );
     795}
     796
  • branches/multi_player_map/src/util/multiplayer_team_deathmatch.h

    r8802 r8827  
    6060   
    6161    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
     62   
     63    void respawnPlayable( Playable * playable, int teamId, float delay );
    6264
    6365  protected:
  • branches/multi_player_map/src/world_entities/playable.cc

    r8724 r8827  
    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;
  • branches/multi_player_map/src/world_entities/space_ships/space_ship.cc

    r8708 r8827  
    504504}
    505505
    506 
    507 
    508 
     506void SpaceShip::destroy( )
     507{
     508  PRINTF(0)("spaceship destroy\n");
     509}
     510
     511void SpaceShip::respawn( )
     512{
     513  toList( OM_PLAYERS );
     514}
     515
     516
     517
     518
  • branches/multi_player_map/src/world_entities/space_ships/space_ship.h

    r7954 r8827  
    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);
  • branches/multi_player_map/src/world_entities/spawning_point.cc

    r8820 r8827  
    2222#include "world_entity.h"
    2323
     24#include "class_list.h"
     25
    2426#include "compiler.h"
    2527
     
    3436 *  constructor
    3537 */
    36 SpawningPoint::SpawningPoint (ClassID classid, const Vector& position)
    37 {
    38   this->setAbsCoor(position);
    39 
    40   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 
    51   this->init();
    52 }
    53 
    54 
    5538SpawningPoint::SpawningPoint( const TiXmlElement * root )
    5639{
     
    6952 
    7053  this->teamId = -1;
     54  this->localTimer = 0.0f;
     55 
     56  this->toList( OM_DEAD_TICK );
    7157 
    7258  MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL );
     
    10187 *  @param entity WorldEntity to be added
    10288 */
    103 void SpawningPoint::pushEntity(WorldEntity* entity, float delay)
     89void SpawningPoint::pushEntity(Playable* entity, float delay)
    10490{
    10591  QueueEntry qe;
     
    114100 *  spawn the entity
    115101 */
    116 void SpawningPoint::spawn(WorldEntity* entity)
    117 {
    118   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());
    119105
    120106
     
    128114    (State::getGameRules())->registerSpawn( entity );
    129115  }
     116 
     117  entity->respawn();
    130118}
    131119
     
    140128{
    141129  this->localTimer += dt;
    142 
    143130  std::list<QueueEntry>::iterator it = this->queue.begin();
    144131  for( ; it != this->queue.end(); )
    145132  {
    146    
     133    //PRINTF(0)("%f <= %f\n", it->respawnTime, this->localTimer);
    147134    if( it->respawnTime <= this->localTimer)
    148135    {
     
    207194  assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE );
    208195 
    209   //TODO find Playable and SpawningPoint and spawn Playable
     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 );
    210240 
    211241  return true;
  • branches/multi_player_map/src/world_entities/spawning_point.h

    r8820 r8827  
    2020{
    2121  float respawnTime;
    22   WorldEntity * entity;
     22  Playable * entity;
    2323};
    2424
     
    4545  public:
    4646    SpawningPoint(const TiXmlElement* root = NULL);
    47     SpawningPoint(ClassID classID, const Vector& position = Vector(0.0, 0.0, 0.0));
    48     SpawningPoint(const Vector& position, ClassID classID, SpawningPointMode type, float delay);
    4947    virtual ~SpawningPoint ();
    5048    void init();
     
    5553    inline void setTeamId( int teamId ){ this->teamId = teamId; }
    5654
    57     void pushEntity(WorldEntity* entity, float delay = 0);
     55    void pushEntity(Playable* entity, float delay = 0);
    5856
    5957    /** activates the spawning point */
     
    6967
    7068  private:
    71     void spawn(WorldEntity* entity);
     69    void spawn(Playable* entity);
    7270   
    7371    void sendRespawnMessage( int uniqueId );
Note: See TracChangeset for help on using the changeset viewer.