- Timestamp:
- Nov 8, 2008, 10:05:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc
r2112 r2160 67 67 if (!this->bStarted_) 68 68 this->checkStart(); 69 else 70 this->spawnDeadPlayersIfRequested(); 69 71 70 72 this->assignDefaultPawnsIfNeeded(); 71 this->spawnDeadPlayersIfRequested();72 73 } 73 74 … … 88 89 void Gametype::playerEntered(PlayerInfo* player) 89 90 { 90 this->players_ .insert(player);91 this->players_[player] = PlayerState::Joined; 91 92 92 93 std::string message = player->getName() + " entered the game"; … … 97 98 void Gametype::playerLeft(PlayerInfo* player) 98 99 { 99 std:: set<PlayerInfo*>::iterator it = this->players_.find(player);100 std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(player); 100 101 if (it != this->players_.end()) 101 102 { … … 165 166 } 166 167 167 void Gametype::assignDefaultPawnsIfNeeded() const168 { 169 for (std:: set<PlayerInfo*>::const_iterator it = this->players_.begin(); it != this->players_.end(); ++it)170 { 171 if (! (*it)->getControllableEntity() && (!(*it)->isReadyToSpawn() || !this->bStarted_))172 { 173 SpawnPoint* spawn = this->getBestSpawnPoint( *it);168 void Gametype::assignDefaultPawnsIfNeeded() 169 { 170 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 171 { 172 if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_)) 173 { 174 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 174 175 if (spawn) 175 176 { … … 177 178 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 178 179 spawn->spawn(entity); 179 (*it)->startControl(entity); 180 it->first->startControl(entity); 181 it->second = PlayerState::Dead; 180 182 } 181 183 else … … 210 212 { 211 213 bool allplayersready = true; 212 for (std:: set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)214 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 213 215 { 214 if (! (*it)->isReadyToSpawn())216 if (!it->first->isReadyToSpawn()) 215 217 allplayersready = false; 216 218 } … … 227 229 void Gametype::spawnPlayersIfRequested() 228 230 { 229 for (std:: set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)230 if ( (*it)->isReadyToSpawn() || this->bForceSpawn_)231 this->spawnPlayer( *it);231 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 232 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 233 this->spawnPlayer(it->first); 232 234 } 233 235 234 236 void Gametype::spawnDeadPlayersIfRequested() 235 237 { 236 for (std:: set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)237 if ( !(*it)->getControllableEntity())238 if ( (*it)->isReadyToSpawn() || this->bForceSpawn_)239 this->spawnPlayer( *it);238 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 239 if (it->second == PlayerState::Dead) 240 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 241 this->spawnPlayer(it->first); 240 242 } 241 243 … … 246 248 { 247 249 player->startControl(spawnpoint->spawn()); 250 this->players_[player] = PlayerState::Alive; 248 251 } 249 252 else
Note: See TracChangeset
for help on using the changeset viewer.