Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 22, 2006, 11:45:21 PM (18 years ago)
Author:
bensch
Message:

new_class_id: adapted Network

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/network/player_stats.cc

    r9690 r9691  
    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"
     
    5555void PlayerStats::init( )
    5656{
    57   this->setClassID( CL_PLAYER_STATS, "PlayerStats" );
     57  this->registerObject(this, PlayerStats::_objectList);
    5858
    5959  this->assignedUserId = 0;
     
    123123PlayerStats * PlayerStats::getStats( int userId )
    124124{
    125   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    126 
    127   if ( !list )
    128   {
    129     return NULL;
    130   }
    131 
    132   for ( std::list<BaseObject*>::const_iterator it = list->
    133         begin();
    134         it != list->end();
    135         it++ )
    136   {
    137 
    138 
    139     if ( dynamic_cast<PlayerStats*>(*it)->getAssignedUserId() == userId )
     125  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     126       it != PlayerStats::objectList().end();
     127       ++it)
     128  {
     129    if ( (*it)->getAssignedUserId() == userId )
    140130    {
    141       return dynamic_cast<PlayerStats*>(*it);
     131      return (*it);
    142132    }
    143133  }
     
    151141void PlayerStats::setPlayableUniqueId( int uniqueId )
    152142{
    153   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    154 
    155   if ( !list )
    156   {
    157     this->playableUniqueId = uniqueId;
    158     return;
    159   }
    160 
    161143  this->playable = NULL;
    162   for ( std::list<BaseObject*>::const_iterator it = list->
    163         begin();
    164         it != list->end();
    165         it++ )
    166   {
    167     if ( dynamic_cast<Playable*>(*it)->
    168          getUniqueID() == uniqueId )
     144  for (NewObjectList<Playable>::const_iterator it = Playable::objectList().begin();
     145       it != Playable::objectList().end();
     146       ++it)
     147  {
     148    if ( (*it)->getUniqueID() == uniqueId )
    169149    {
    170       this->playable = dynamic_cast<Playable*>(*it);
     150      this->playable = (*it);
    171151      //TODO when OM_PLAYERS is ticked add line:
    172152      //this->playable->toList( OM_PLAYERS );
     
    175155  }
    176156
    177   if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()
    178        ->getHostID() )
     157  if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() )
    179158  {
    180159    State::getPlayer()->setPlayable( this->playable );
     
    273252void PlayerStats::deleteAllPlayerStats( )
    274253{
    275   const std::list<BaseObject*> * list;
    276 
    277   while ( (list  = ClassList::getList( CL_PLAYER_STATS )) != NULL && list->begin() != list->end() )
    278     delete *list->begin();
     254
     255  while(!PlayerStats::objectList().empty())
     256    delete PlayerStats::objectList().front();
    279257}
    280258
     
    288266  ScoreList result;
    289267
    290   const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    291 
    292   if ( !list )
    293   {
    294     return result;
    295   }
    296 
    297   for ( std::list<BaseObject*>::const_iterator it = list->
    298         begin();
    299         it != list->end();
    300         it++ )
    301   {
    302     PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
     268  for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     269       it != PlayerStats::objectList().end();
     270       ++it)
     271  {
     272    PlayerStats& stats = *(*it);
    303273
    304274    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
Note: See TracChangeset for help on using the changeset viewer.