Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 10, 2008, 12:05:03 AM (15 years ago)
Author:
landauf
Message:

merged revisions 2111-2170 from objecthierarchy branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/gametypes/Gametype.cc

    r2087 r2171  
    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";
    9394        COUT(0) << message << std::endl;
    94         network::Host::Broadcast(message);
     95        Host::Broadcast(message);
    9596    }
    9697
    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        {
     
    104105            std::string message = player->getName() + " left the game";
    105106            COUT(0) << message << std::endl;
    106             network::Host::Broadcast(message);
     107            Host::Broadcast(message);
    107108        }
    108109    }
     
    124125                std::string message = player->getOldName() + " changed name to " + player->getName();
    125126                COUT(0) << message << std::endl;
    126                 network::Host::Broadcast(message);
     127                Host::Broadcast(message);
    127128            }
    128129        }
     
    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.