Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 14, 2010, 11:02:57 PM (14 years ago)
Author:
jo
Message:

Some cleanup. There's still a nasty bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc

    r7485 r7542  
    4848    }
    4949
     50    void LastManStanding::spawnDeadPlayersIfRequested()
     51    {
     52        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     53            if (it->second.state_ == PlayerState::Dead)
     54            {
     55                bool alive = (0<playerLives_[it->first]);
     56                if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
     57                    this->spawnPlayer(it->first);
     58             }
     59    }
     60
     61
    5062    void LastManStanding::setConfigValues()
    5163    {
     
    6678    bool LastManStanding::allowPawnDeath(Pawn* victim, Pawn* originator)
    6779    {
    68         if (!victim)// only for safety
     80        if (!victim||!victim->getPlayer())// only for safety
    6981            return true;
    70         playerLives_[victim->getPlayer()]--;
    71         if (!playerLives_[victim->getPlayer()])//if player lost all lives
     82        playerLives_[victim->getPlayer()]=playerLives_[victim->getPlayer()]-1;
     83        if (playerLives_[victim->getPlayer()]<=0)//if player lost all lives
    7284        {
    7385            this->playersAlive--;
     
    183195        if(!player)
    184196            return;
    185         std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
     197        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);//!!!!!!!!!!!
    186198        if (it != this->players_.end())
    187199        {
     
    189201            it->second.killed_++;
    190202
    191             playerLives_[player]--;//-----------datapart
    192             if (!playerLives_[player])//if player lost all lives
     203            playerLives_[player]=playerLives_[player]-1;//-----------datapart
     204            if (playerLives_[player]<=0)//if player lost all lives
    193205            {
    194206                this->playersAlive--;
    195                 const std::string& message = player->getName() + " has lost all lives";
     207                const std::string& message = player->getName() + " is out";
    196208                COUT(0) << message << std::endl;
    197209                Host::Broadcast(message);
    198210            }
     211            this->timeToAct_[player]=timeRemaining+3.0f;//reset timer
    199212        }
    200213    }
     
    215228                if (it->second<0.0f)
    216229                {
    217                     it->second=timeRemaining+3.0f;
    218                     this->killPlayer(it->first);
     230                    it->second=timeRemaining+3.0f;//reset timer
     231                    if (playerGetLives(it->first)>0)
     232                        this->killPlayer(it->first);
    219233                }
    220234            }
     
    222236    }
    223237
    224     void LastManStanding::spawnDeadPlayersIfRequested()
    225     {
    226         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    227             if (it->second.state_ == PlayerState::Dead)
    228             {
    229                 bool alive = (0<playerLives_[it->first]);
    230                 if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
    231                     this->spawnPlayer(it->first);
    232              }
    233     }
    234 
    235238}
Note: See TracChangeset for help on using the changeset viewer.