Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/network/player_stats.cc


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/player_stats.cc

    r9656 r9869  
    1616#include "player_stats.h"
    1717
    18 #include "class_list.h"
    1918#include "src/lib/util/loading/factory.h"
    2019
    2120#include "player.h"
     21#include "playable.h"
    2222#include "state.h"
    2323#include "shared_network_data.h"
     
    2525#include "converter.h"
    2626
    27 #include "preferences.h"
     27#include "parser/preferences/preferences.h"
    2828
    2929#include "debug.h"
    3030#include "shell_command.h"
    3131
    32 
    33 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS);
    34 
     32#include "class_id_DEPRECATED.h"
     33
     34ObjectListDefinitionID(PlayerStats, CL_PLAYER_STATS);
     35CREATE_FACTORY(PlayerStats);
    3536
    3637/**
     
    5455void PlayerStats::init( )
    5556{
    56   this->setClassID( CL_PLAYER_STATS, "PlayerStats" );
     57  this->registerObject(this, PlayerStats::_objectList);
    5758
    5859  this->assignedUserId = 0;
     
    122123PlayerStats * PlayerStats::getStats( int userId )
    123124{
    124   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    125 
    126   if ( !list )
    127   {
    128     return NULL;
    129   }
    130 
    131   for ( std::list<BaseObject*>::const_iterator it = list->
    132         begin();
    133         it != list->end();
    134         it++ )
    135   {
    136 
    137 
    138     if ( dynamic_cast<PlayerStats*>(*it)->getAssignedUserId() == userId )
     125  for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     126       it != PlayerStats::objectList().end();
     127       ++it)
     128  {
     129    if ( (*it)->getAssignedUserId() == userId )
    139130    {
    140       return dynamic_cast<PlayerStats*>(*it);
     131      return (*it);
    141132    }
    142133  }
     
    150141void PlayerStats::setPlayableUniqueId( int uniqueId )
    151142{
    152   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    153 
    154   if ( !list )
    155   {
    156     this->playableUniqueId = uniqueId;
    157     return;
    158   }
    159 
    160143  this->playable = NULL;
    161   for ( std::list<BaseObject*>::const_iterator it = list->
    162         begin();
    163         it != list->end();
    164         it++ )
    165   {
    166     if ( dynamic_cast<Playable*>(*it)->
    167          getUniqueID() == uniqueId )
     144  for (ObjectList<Playable>::const_iterator it = Playable::objectList().begin();
     145       it != Playable::objectList().end();
     146       ++it)
     147  {
     148    if ( (*it)->getUniqueID() == uniqueId )
    168149    {
    169       this->playable = dynamic_cast<Playable*>(*it);
     150      this->playable = (*it);
    170151      //TODO when OM_PLAYERS is ticked add line:
    171152      //this->playable->toList( OM_PLAYERS );
     
    174155  }
    175156
    176   if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()
    177        ->getHostID() )
     157  if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() )
    178158  {
    179159    State::getPlayer()->setPlayable( this->playable );
     
    272252void PlayerStats::deleteAllPlayerStats( )
    273253{
    274   const std::list<BaseObject*> * list;
    275 
    276   while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
    277     delete *list->begin();
     254
     255  while(!PlayerStats::objectList().empty())
     256    delete PlayerStats::objectList().front();
    278257}
    279258
     
    287266  ScoreList result;
    288267
    289   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    290 
    291   if ( !list )
    292   {
    293     return result;
    294   }
    295 
    296   for ( std::list<BaseObject*>::const_iterator it = list->
    297         begin();
    298         it != list->end();
    299         it++ )
    300   {
    301     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     268  for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     269       it != PlayerStats::objectList().end();
     270       ++it)
     271  {
     272    PlayerStats& stats = *(*it);
    302273
    303274    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
Note: See TracChangeset for help on using the changeset viewer.