Changeset 9691 in orxonox.OLD for branches/new_class_id/src/lib/network/player_stats.cc
- Timestamp:
- Aug 22, 2006, 11:45:21 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/network/player_stats.cc
r9690 r9691 16 16 #include "player_stats.h" 17 17 18 #include "class_list.h"19 18 #include "src/lib/util/loading/factory.h" 20 19 21 20 #include "player.h" 21 #include "playable.h" 22 22 #include "state.h" 23 23 #include "shared_network_data.h" … … 55 55 void PlayerStats::init( ) 56 56 { 57 this-> setClassID( CL_PLAYER_STATS, "PlayerStats");57 this->registerObject(this, PlayerStats::_objectList); 58 58 59 59 this->assignedUserId = 0; … … 123 123 PlayerStats * PlayerStats::getStats( int userId ) 124 124 { 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 ) 140 130 { 141 return dynamic_cast<PlayerStats*>(*it);131 return (*it); 142 132 } 143 133 } … … 151 141 void PlayerStats::setPlayableUniqueId( int uniqueId ) 152 142 { 153 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );154 155 if ( !list )156 {157 this->playableUniqueId = uniqueId;158 return;159 }160 161 143 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 ) 169 149 { 170 this->playable = dynamic_cast<Playable*>(*it);150 this->playable = (*it); 171 151 //TODO when OM_PLAYERS is ticked add line: 172 152 //this->playable->toList( OM_PLAYERS ); … … 175 155 } 176 156 177 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance() 178 ->getHostID() ) 157 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() ) 179 158 { 180 159 State::getPlayer()->setPlayable( this->playable ); … … 273 252 void PlayerStats::deleteAllPlayerStats( ) 274 253 { 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(); 279 257 } 280 258 … … 288 266 ScoreList result; 289 267 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); 303 273 304 274 TeamScoreList::iterator it = result[stats.getTeamId()].begin();
Note: See TracChangeset
for help on using the changeset viewer.