Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8838 in orxonox.OLD for branches/multi_player_map/src/util


Ignore:
Timestamp:
Jun 28, 2006, 12:44:07 AM (19 years ago)
Author:
patrick
Message:

mulitplayer: debuggin session

File:
1 edited

Legend:

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

    r8827 r8838  
    8585  subscribeEvent( ES_MENU, SDLK_F1 );
    8686  subscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 );
    87  
     87
    8888  this->notifier = new OrxGui::GLGuiNotifier();
    8989  this->notifier->show();
     
    106106  unsubscribeEvent( ES_MENU, SDLK_F1 );
    107107  unsubscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 );
    108  
     108
    109109  if ( this->notifier )
    110110  {
     
    219219  if ( !SharedNetworkData::getInstance()->isGameServer() )
    220220    return;
    221    
     221
    222222  //handle kills
    223223  for ( std::vector<Kill>::iterator it = this->killList.begin(); it != this->killList.end();  )
    224224  {
    225225    std::vector<Kill>::iterator delit = it;
    226    
     226
    227227    onKill( it->getKiller()->getOwner(), it->getVictim()->getOwner() );
    228    
     228
    229229    it++;
    230230    killList.erase( delit );
    231231  }
    232  
     232
    233233  gameStateTimer -= dt;
    234234  //PRINTF(0)("TICK %f\n", gameStateTimer);
     
    482482  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    483483  playable.setSynchronized( true );
    484  
     484
    485485  stats.setTeamId( stats.getPreferedTeamId() );
    486486  stats.setPlayableClassId( playableClassId );
    487487  stats.setPlayableUniqueId( playable.getUniqueID() );
    488488  stats.setModelFileName( playableModel );
    489  
     489
    490490  this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f );
    491491
     
    629629  statsBox = new OrxGui::GLGuiBox();
    630630  statsBox->setAbsCoor2D( 300, 100 );
    631  
     631
    632632  this->table = new OrxGui::GLGuiTable(0,0);
    633633
     
    647647      statsBox = NULL;
    648648    }
    649      
     649
    650650    EventHandler::getInstance()->popState();
    651651}
     
    666666  headers.push_back("");
    667667  this->table->setHeader(headers);
    668  
     668
    669669  std::map<int,std::string> fragsTeam0;
    670670  std::map<int,std::string> fragsTeam1;
    671  
     671
    672672  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    673  
     673
    674674  if ( !list )
    675675    return;
    676  
     676
    677677  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    678678  {
    679679    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
    680    
     680
    681681    if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 )
    682682    {
     
    687687    }
    688688  }
    689  
     689
    690690  char st[10];
    691691  int i = 0;
    692  
    693  
     692
     693
    694694  i = 2;
    695695  for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ )
     
    701701    i++;
    702702  }
    703  
     703
    704704  i = 2;
    705705  for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ )
     
    714714/**
    715715 * this function is called when a player kills another one or himself
    716  * @param killedUserId 
    717  * @param userId 
     716 * @param killedUserId
     717 * @param userId
    718718 */
    719719void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId )
     
    721721  assert( PlayerStats::getStats( killedUserId ) );
    722722  assert( PlayerStats::getStats( userId ) );
    723  
     723
    724724  PlayerStats & killedStats = *PlayerStats::getStats( killedUserId );
    725725  PlayerStats & stats = *PlayerStats::getStats( userId );
    726  
     726
    727727  if ( killedUserId != userId )
    728728    stats.setScore( stats.getScore() + 1 );
    729729  else
    730730    stats.setScore( stats.getScore() - 1 );
    731  
     731
    732732  if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )
    733733  {
     
    735735    this->showStats();
    736736  }
    737  
     737
    738738  this->respawnPlayable( killedStats.getPlayable(), killedStats.getTeamId(), 3.0f );
    739739}
     
    741741/**
    742742 * this function is called on player respawn
    743  * @param userId 
     743 * @param userId
    744744 */
    745745void MultiplayerTeamDeathmatch::onRespawn( int userId )
     
    754754/**
    755755 * this function is called on player respawn
    756  * @param we 
     756 * @param we
    757757 */
    758758void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
     
    761761}
    762762
     763
    763764void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
    764765{
    765766  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    766  
     767
    767768  assert( list );
    768  
     769
    769770  std::vector<SpawningPoint*> spList;
    770  
     771
    771772  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    772773  {
    773774    SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
    774    
     775
    775776    if ( sp->getTeamId() == teamId )
    776777      spList.push_back( sp );
    777778  }
    778  
     779
    779780  if ( spList.size() == 0 )
    780781  {
     
    782783    {
    783784      SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
    784    
     785
    785786      if ( sp->getTeamId() < 0 )
    786787        spList.push_back( sp );
    787788    }
    788789  }
    789  
     790
    790791  assert( spList.size() != 0 );
    791  
     792
    792793  int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX);
    793  
     794
    794795  spList[n]->pushEntity( playable, delay );
    795796}
Note: See TracChangeset for help on using the changeset viewer.