Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 2, 2006, 2:22:19 PM (18 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/util
Files:
5 edited

Legend:

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

    r8802 r9008  
    9090  if ( !SharedNetworkData::getInstance()->isGameServer() )
    9191    return;
     92
    9293  PRINTF(0)("Received Event: Kill\n");
    93   this->killList.push_back(kill);
     94
     95  this->killList.push_back( kill );
    9496}
    9597
  • trunk/src/util/game_rules.h

    r8802 r9008  
    99
    1010#include "base_object.h"
     11#include <list>
    1112#include <vector>
    1213
     
    5455    std::vector<MissionGoal*>   missionList;            //!< list of mission goals
    5556
    56     std::vector<Kill>          killList;               //!<  list of kills in the world
     57    std::list<Kill>             killList;               //!<  list of kills in the world
    5758};
    5859
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r8802 r9008  
    6868  this->numTeams = 2;
    6969  this->currentGameState = GAMESTATE_PRE_GAME;
    70   this->gameStateTimer = 10.0f;
     70  this->gameStateTimer = 3.0f;
    7171  this->bShowTeamChange = false;
    7272
     
    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
    223   for ( std::vector<Kill>::iterator it = this->killList.begin(); it != this->killList.end();  )
    224   {
    225     std::vector<Kill>::iterator delit = it;
    226    
    227     onKill( it->getKiller()->getOwner(), it->getVictim()->getOwner() );
    228    
    229     it++;
    230     killList.erase( delit );
     223  while ( this->killList.begin() != this->killList.end() )
     224  {
     225    onKill( this->killList.begin()->getVictim(), this->killList.begin()->getKiller() );
     226    this->killList.erase( this->killList.begin() );
    231227  }
    232228 
     229
     230
    233231  gameStateTimer -= dt;
    234232  //PRINTF(0)("TICK %f\n", gameStateTimer);
     
    488486  stats.setModelFileName( playableModel );
    489487
     488  this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f );
     489
    490490  if ( oldPlayable )
    491491  {
     
    558558  else if ( event.type == SDLK_TAB )
    559559  {
    560     if ( !event.bPressed )
     560    if ( currentGameState == GAMESTATE_GAME && event.bPressed && !EventHandler::getInstance()->isPressed( SDLK_RALT ) && !EventHandler::getInstance()->isPressed( SDLK_LALT ) )
    561561    {
    562562      EventHandler::getInstance()->pushState( ES_MENU );
     
    627627  statsBox = new OrxGui::GLGuiBox();
    628628  statsBox->setAbsCoor2D( 300, 100 );
    629  
     629
    630630  this->table = new OrxGui::GLGuiTable(0,0);
    631631
     
    645645      statsBox = NULL;
    646646    }
    647      
     647
    648648    EventHandler::getInstance()->popState();
    649649}
     
    664664  headers.push_back("");
    665665  this->table->setHeader(headers);
    666  
     666
    667667  std::map<int,std::string> fragsTeam0;
    668668  std::map<int,std::string> fragsTeam1;
    669  
     669
    670670  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    671  
     671
    672672  if ( !list )
    673673    return;
    674  
     674
    675675  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    676676  {
    677677    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
    678    
     678
    679679    if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 )
    680680    {
     
    685685    }
    686686  }
    687  
     687
    688688  char st[10];
    689689  int i = 0;
    690  
    691  
     690
     691
    692692  i = 2;
    693693  for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ )
     
    699699    i++;
    700700  }
    701  
     701
    702702  i = 2;
    703703  for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ )
     
    712712/**
    713713 * this function is called when a player kills another one or himself
    714  * @param killedUserId
    715  * @param userId
    716  */
    717 void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId )
    718 {
    719   assert( PlayerStats::getStats( killedUserId ) );
    720   assert( PlayerStats::getStats( userId ) );
     714 * @param killedUserId
     715 * @param userId
     716 */
     717void MultiplayerTeamDeathmatch::onKill( WorldEntity * victim, WorldEntity * killer )
     718{
     719  if ( !victim )
     720    return;
     721  if ( !killer )
     722    return;
    721723 
    722   PlayerStats & killedStats = *PlayerStats::getStats( killedUserId );
    723   PlayerStats & stats = *PlayerStats::getStats( userId );
     724  int killerUserId = killer->getOwner();
     725  int victimUserId = victim->getOwner();
     726
     727  PlayerStats & victimStats = *PlayerStats::getStats( victimUserId );
     728  PlayerStats & killerStats = *PlayerStats::getStats( killerUserId );
    724729 
    725   if ( killedUserId != userId )
    726     stats.setScore( stats.getScore() + 1 );
     730  if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim )
     731    return;
     732
     733  //check for suicide
     734  if ( killerUserId != victimUserId )
     735  {
     736    //check for teamkill
     737    if ( victimStats.getTeamId() != killerStats.getTeamId() )
     738    {
     739      killerStats.setScore( killerStats.getScore() + 1 );
     740    }
     741    else
     742    {
     743      killerStats.setScore( killerStats.getScore() - 1 );
     744    }
     745  }
    727746  else
    728     stats.setScore( stats.getScore() - 1 );
    729  
    730   if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )
     747    killerStats.setScore( killerStats.getScore() - 1 );
     748
     749  if ( victimUserId == SharedNetworkData::getInstance()->getHostID() )
    731750  {
    732751    this->bLocalPlayerDead = true;
    733752    this->showStats();
    734753  }
    735  
    736   const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    737  
    738   assert( list );
    739  
    740   std::vector<SpawningPoint*> spList;
    741  
    742   for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    743   {
    744     SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
    745    
    746     if ( sp->getTeamId() < 0 || sp->getTeamId() == killedStats.getTeamId() )
    747       spList.push_back( sp );
    748   }
    749  
    750   int n = spList.size()*rand();
    751  
    752   spList[n]->pushEntity( killedStats.getPlayable(), 3 );
     754
     755  this->respawnPlayable( victimStats.getPlayable(), victimStats.getTeamId(), 3.0f );
    753756}
    754757
    755758/**
    756759 * this function is called on player respawn
    757  * @param userId 
     760 * @param userId
    758761 */
    759762void MultiplayerTeamDeathmatch::onRespawn( int userId )
     
    768771/**
    769772 * this function is called on player respawn
    770  * @param we 
     773 * @param we
    771774 */
    772775void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we )
     
    775778}
    776779
     780
     781void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
     782{
     783  const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
     784
     785  assert( list );
     786
     787  std::vector<SpawningPoint*> spList;
     788
     789  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     790  {
     791    SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
     792
     793    if ( sp->getTeamId() == teamId )
     794      spList.push_back( sp );
     795  }
     796
     797  if ( spList.size() == 0 )
     798  {
     799    for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     800    {
     801      SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it);
     802
     803      if ( sp->getTeamId() < 0 )
     804        spList.push_back( sp );
     805    }
     806  }
     807
     808  assert( spList.size() != 0 );
     809
     810  int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX);
     811
     812  spList[n]->pushEntity( playable, delay );
     813}
     814
  • trunk/src/util/multiplayer_team_deathmatch.h

    r8802 r9008  
    5656    virtual void process(const Event &event);
    5757   
    58     void onKill( int killedUserId, int userId );
     58    void onKill( WorldEntity * victim, WorldEntity * killer );
    5959    void onRespawn( int userId );
    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:
  • trunk/src/util/object_manager.cc

    r8362 r9008  
    212212    "background",
    213213    "common",
     214
     215    "players",
     216    "players-proj",
    214217
    215218    "group00",
Note: See TracChangeset for help on using the changeset viewer.