Changeset 9869 in orxonox.OLD for trunk/src/lib/network/player_stats.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/player_stats.cc
r9656 r9869 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" … … 25 25 #include "converter.h" 26 26 27 #include "p references.h"27 #include "parser/preferences/preferences.h" 28 28 29 29 #include "debug.h" 30 30 #include "shell_command.h" 31 31 32 33 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS); 34 32 #include "class_id_DEPRECATED.h" 33 34 ObjectListDefinitionID(PlayerStats, CL_PLAYER_STATS); 35 CREATE_FACTORY(PlayerStats); 35 36 36 37 /** … … 54 55 void PlayerStats::init( ) 55 56 { 56 this-> setClassID( CL_PLAYER_STATS, "PlayerStats");57 this->registerObject(this, PlayerStats::_objectList); 57 58 58 59 this->assignedUserId = 0; … … 122 123 PlayerStats * PlayerStats::getStats( int userId ) 123 124 { 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 ) 139 130 { 140 return dynamic_cast<PlayerStats*>(*it);131 return (*it); 141 132 } 142 133 } … … 150 141 void PlayerStats::setPlayableUniqueId( int uniqueId ) 151 142 { 152 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );153 154 if ( !list )155 {156 this->playableUniqueId = uniqueId;157 return;158 }159 160 143 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 ) 168 149 { 169 this->playable = dynamic_cast<Playable*>(*it);150 this->playable = (*it); 170 151 //TODO when OM_PLAYERS is ticked add line: 171 152 //this->playable->toList( OM_PLAYERS ); … … 174 155 } 175 156 176 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance() 177 ->getHostID() ) 157 if ( this->playable && this->assignedUserId == SharedNetworkData::getInstance()->getHostID() ) 178 158 { 179 159 State::getPlayer()->setPlayable( this->playable ); … … 272 252 void PlayerStats::deleteAllPlayerStats( ) 273 253 { 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(); 278 257 } 279 258 … … 287 266 ScoreList result; 288 267 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); 302 273 303 274 TeamScoreList::iterator it = result[stats.getTeamId()].begin();
Note: See TracChangeset
for help on using the changeset viewer.