Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 8, 2008, 10:05:06 PM (15 years ago)
Author:
landauf
Message:

respawn of late joined clients works now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc

    r2112 r2160  
    6767        if (!this->bStarted_)
    6868            this->checkStart();
     69        else
     70            this->spawnDeadPlayersIfRequested();
    6971
    7072        this->assignDefaultPawnsIfNeeded();
    71         this->spawnDeadPlayersIfRequested();
    7273    }
    7374
     
    8889    void Gametype::playerEntered(PlayerInfo* player)
    8990    {
    90         this->players_.insert(player);
     91        this->players_[player] = PlayerState::Joined;
    9192
    9293        std::string message = player->getName() + " entered the game";
     
    9798    void Gametype::playerLeft(PlayerInfo* player)
    9899    {
    99         std::set<PlayerInfo*>::iterator it = this->players_.find(player);
     100        std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(player);
    100101        if (it != this->players_.end())
    101102        {
     
    165166    }
    166167
    167     void Gametype::assignDefaultPawnsIfNeeded() const
    168     {
    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);
    174175                if (spawn)
    175176                {
     
    177178                    ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
    178179                    spawn->spawn(entity);
    179                     (*it)->startControl(entity);
     180                    it->first->startControl(entity);
     181                    it->second = PlayerState::Dead;
    180182                }
    181183                else
     
    210212                {
    211213                    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)
    213215                    {
    214                         if (!(*it)->isReadyToSpawn())
     216                        if (!it->first->isReadyToSpawn())
    215217                            allplayersready = false;
    216218                    }
     
    227229    void Gametype::spawnPlayersIfRequested()
    228230    {
    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);
    232234    }
    233235
    234236    void Gametype::spawnDeadPlayersIfRequested()
    235237    {
    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);
    240242    }
    241243
     
    246248        {
    247249            player->startControl(spawnpoint->spawn());
     250            this->players_[player] = PlayerState::Alive;
    248251        }
    249252        else
Note: See TracChangeset for help on using the changeset viewer.