Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 25, 2006, 9:44:53 PM (18 years ago)
Author:
bensch
Message:

adapted many more classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/util/multiplayer_team_deathmatch.cc

    r9704 r9705  
    5656 */
    5757MultiplayerTeamDeathmatch::MultiplayerTeamDeathmatch(const TiXmlElement* root)
    58   : NetworkGameRules(root)
     58    : NetworkGameRules(root)
    5959{
    6060  this->registerObject(this, MultiplayerTeamDeathmatch::_objectList);
     
    111111
    112112  LoadParam(root, "death-penalty-timeout", this, MultiplayerTeamDeathmatch, setDeathPenaltyTimeout)
    113       .describe("sets the time in seconds a player has to wait for respawn");
     113  .describe("sets the time in seconds a player has to wait for respawn");
    114114
    115115  LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills)
    116       .describe("sets the maximal kills for winning condition");
     116  .describe("sets the maximal kills for winning condition");
    117117
    118118  LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams)
    119       .describe("sets number of teams");
     119  .describe("sets number of teams");
    120120
    121121}
     
    189189  }
    190190
    191 //   if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) )
    192 //   {
    193 //     PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM);
    194 //   }
     191  //   if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) )
     192  //   {
     193  //     PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM);
     194  //   }
    195195
    196196  // check if the menu should be removed and the game state should be entered
     
    270270  if( unlikely( this->bLocalPlayerDead))
    271271  {
    272 
    273272  }
    274273}
     
    305304{
    306305  if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR )
    307     return CL_SPECTATOR;
     306    return NewObjectListBase::retrieveIdentity("Spectator");
    308307
    309308  if ( team == 0 || team == 1 )
    310     return CL_TURBINE_HOVER;
     309    return NewObjectListBase::retrieveIdentity("TurbineHover");
    311310
    312311  assert( false );
     
    314313
    315314
    316 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassID classId )
     315std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, const NewClassID& classId )
    317316{
    318317  if (classId == CL_TURBINE_HOVER)
    319    return "models/ships/hoverglider_mainbody.obj";
     318    return "models/ships/hoverglider_mainbody.obj";
    320319  if ( team == 0 )
    321320    return "models/creatures/doom_guy.md2";
     
    326325}
    327326
    328 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassID classId )
     327std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, const NewClassID& classId )
    329328{
    330329  if ( classId == CL_FPS_PLAYER )
     
    339338}
    340339
    341 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, ClassID classId )
    342 {
    343   if ( classId == CL_FPS_PLAYER )
     340float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, const NewClassID& classId )
     341{
     342  if ( classId == NewObjectListBase::retrieveIdentity(CL_FPS_PLAYER))
    344343  {
    345344    return 10.0f;
     
    359358    teamScore[i] = 0;
    360359
    361 
    362   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    363 
    364   if ( !list )
    365     return;
    366 
    367   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    368   {
    369     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     360  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     361       it != PlayerStats::objectList().end();
     362       ++it)
     363  {
     364    PlayerStats & stats = *(*it);
    370365
    371366    if ( stats.getTeamId() >= 0 )
     
    387382    playersInTeam[i] = 0;
    388383
    389   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    390 
    391   if ( !list )
    392     return 0;
    393 
    394   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    395   {
    396     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     384  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     385       it != PlayerStats::objectList().end();
     386       ++it)
     387  {
     388    PlayerStats & stats = *(*it);
    397389
    398390    if ( stats.getTeamId() >= 0 )
     
    450442void MultiplayerTeamDeathmatch::handleTeamChanges( )
    451443{
    452   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    453 
    454   if ( !list )
    455     return;
    456 
    457   //first server players with choices
    458   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    459   {
    460     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     444  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     445       it != PlayerStats::objectList().end();
     446       ++it)
     447  {
     448    PlayerStats & stats = *(*it);
    461449
    462450    if ( stats.getTeamId() != stats.getPreferedTeamId() )
     
    470458
    471459  //now serve player who want join a random team
    472   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    473   {
    474     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     460  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     461       it != PlayerStats::objectList().end();
     462       ++it)
     463  {
     464    PlayerStats & stats = *(*it);
    475465
    476466    if ( stats.getTeamId() != stats.getPreferedTeamId() )
     
    501491
    502492
    503   ClassID       playableClassId  = getPlayableClassId( userId, stats.getPreferedTeamId() );
     493  NewClassID       playableClassId  = getPlayableClassId( userId, stats.getPreferedTeamId() );
    504494  std::string   playableModel    = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
    505495  std::string   playableTexture  = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );
     
    584574    if ( event.bPressed )
    585575      this->bShowTeamChange = true;
    586   } else if ( event.type == SDLK_F1 )
     576  }
     577  else if ( event.type == SDLK_F1 )
    587578  {
    588579    if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed )
     
    680671void MultiplayerTeamDeathmatch::hideStats( )
    681672{
    682     if ( statsBox )
    683     {
    684       delete statsBox;
    685       statsBox = NULL;
    686     }
     673  if ( statsBox )
     674  {
     675    delete statsBox;
     676    statsBox = NULL;
     677  }
    687678}
    688679
     
    819810void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
    820811{
    821   const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    822 
    823   assert( list );
    824812
    825813  std::vector<SpawningPoint*> spList;
    826814
    827   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    828   {
    829     SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
     815  for (NewObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin();
     816       it != SpawningPoint::objectList().end();
     817       ++it)
     818  {
     819    SpawningPoint * sp = (*it);
    830820
    831821    if ( sp->getTeamId() == teamId )
     
    835825  if ( spList.size() == 0 )
    836826  {
    837     for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    838     {
    839       SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
     827    for (NewObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin();
     828         it != SpawningPoint::objectList().end();
     829         ++it)
     830    {
     831      SpawningPoint * sp = (*it);
    840832
    841833      if ( sp->getTeamId() < 0 )
Note: See TracChangeset for help on using the changeset viewer.