Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 4, 2006, 11:01:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy bache back with no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r9494 r9656  
    138138  if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME )
    139139  {
    140     if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    141          && box == NULL
    142          &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
    143          || bShowTeamChange )
     140    if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) &&
     141         box == NULL &&
     142         (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM || bShowTeamChange )
    144143
    145144       )
     
    193192  }
    194193
    195   if ( box != NULL
    196        && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    197        && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM
    198        && !bShowTeamChange
     194//   if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) )
     195//   {
     196//     PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM);
     197//   }
     198
     199  // check if the menu should be removed and the game state should be entered
     200  if ( box != NULL &&
     201       PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) &&
     202       PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM &&
     203       !bShowTeamChange
    199204     )
    200205  {
     
    310315  assert( false );
    311316}
     317
    312318
    313319std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassID classId )
     
    442448}
    443449
     450/**
     451 *  this handles team changes but only on the master server
     452 */
    444453void MultiplayerTeamDeathmatch::handleTeamChanges( )
    445454{
     
    458467      if ( stats.getPreferedTeamId() == TEAM_SPECTATOR || ( stats.getPreferedTeamId() >= 0 && stats.getPreferedTeamId() < numTeams ) )
    459468      {
    460         teamChange( stats.getUserId() );
     469        teamChange( stats.getAssignedUserId() );
    461470      }
    462471    }
     
    473482      {
    474483        stats.setPreferedTeamId( getRandomTeam() );
    475         teamChange( stats.getUserId() );
     484        teamChange( stats.getAssignedUserId() );
    476485      }
    477486    }
     
    479488}
    480489
     490
     491
     492/**
     493 * changes the team
     494 * @param userId the user changing team (userId)
     495 */
    481496void MultiplayerTeamDeathmatch::teamChange( int userId )
    482497{
     
    489504
    490505
    491   ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );
    492   std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
    493   std::string playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );
    494   float       playableScale = getPlayableScale( userId, stats.getPreferedTeamId(), playableClassId );
     506  ClassID       playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );
     507  std::string   playableModel    = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
     508  std::string   playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );
     509  float         playableScale    = getPlayableScale( userId, stats.getPreferedTeamId(), playableClassId );
    495510
    496511  BaseObject * bo = Factory::fabricate( playableClassId );
     
    507522  playable.setSynchronized( true );
    508523
    509   stats.setTeamId( stats.getPreferedTeamId() );
    510524  stats.setPlayableClassId( playableClassId );
    511525  stats.setPlayableUniqueId( playable.getUniqueID() );
    512526  stats.setModelFileName( playableModel );
     527  stats.setTeamId( stats.getPreferedTeamId() );
     528
     529  playable.setTeam(stats.getPreferedTeamId());
     530
    513531
    514532  this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f );
     
    516534  if ( oldPlayable )
    517535  {
    518     //if ( userId == SharedNetworkData::getInstance()->getHostID() )
    519     //  State::getPlayer()->setPlayable( NULL );
    520536    delete oldPlayable;
    521537  }
    522538}
     539
    523540
    524541void MultiplayerTeamDeathmatch::onButtonExit( )
     
    558575}
    559576
    560   /**
    561    * function that processes events from the handler
    562    * @param event: the event
    563    * @todo replace SDLK_o with something from KeyMapper
    564    */
     577
     578/**
     579 * function that processes events from the handler
     580 * @param event: the event
     581 * @todo replace SDLK_o with something from KeyMapper
     582 */
    565583void MultiplayerTeamDeathmatch::process( const Event & event )
    566584{
     
    573591    if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed )
    574592    {
    575       PRINTF(0)("hide stats\n");
     593      PRINTF(5)("hide stats\n");
    576594      this->hideStats();
    577595    }
    578596    else if ( !this->statsBox && event.bPressed )
    579597    {
    580       PRINTF(0)("show stats\n");
     598      PRINTF(5)("show stats\n");
    581599      this->showStats();
    582600    }
     
    740758  PlayerStats & killerStats = *PlayerStats::getStats( killerUserId );
    741759
    742   if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim )
    743   {
    744     PRINTF(0)("killerStats.getPlayable() != killer || victimStats.getPlayable() != victim\n");
     760  if ( killerStats.getPlayable() == NULL || victimStats.getPlayable() == NULL)
     761  {
     762    PRINTF(0)("killerStats.getPlayable() != NULL || victimStats.getPlayable() != NULL\n");
    745763    PRINTF(0)("%x %x %x %x\n", killerStats.getPlayable(), killer, victimStats.getPlayable(), victim );
    746764    PRINTF(0)("%d %d %d %d\n", killerStats.getPlayable()->getUniqueID(), killer->getUniqueID(), victimStats.getPlayable()->getUniqueID(), victim->getUniqueID() );
     
    796814
    797815
     816/**
     817 * respawns a playable in the world via spawning points
     818 * @param playable the playable to respawn
     819 * @param teamId the teamId to use
     820 * @param delay time delay for delayed spawning
     821 */
    798822void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
    799823{
Note: See TracChangeset for help on using the changeset viewer.