Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gametypes/LastTeamStanding.cc

    r9941 r11071  
    145145    void LastTeamStanding::spawnDeadPlayersIfRequested()
    146146    {
    147         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    148             if (it->second.state_ == PlayerState::Dead)
    149             {
    150                 bool alive = (0 < playerLives_[it->first]&&(inGame_[it->first]));
    151                 if (alive&&(it->first->isReadyToSpawn() || this->bForceSpawn_))
    152                 {
    153                     this->spawnPlayer(it->first);
     147        for (const auto& mapEntry : this->players_)
     148            if (mapEntry.second.state_ == PlayerState::Dead)
     149            {
     150                bool alive = (0 < playerLives_[mapEntry.first]&&(inGame_[mapEntry.first]));
     151                if (alive&&(mapEntry.first->isReadyToSpawn() || this->bForceSpawn_))
     152                {
     153                    this->spawnPlayer(mapEntry.first);
    154154                }
    155155            }
     
    184184                this->end();
    185185            }
    186             for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
    187             {
    188                 if (playerGetLives(it->first) <= 0)//Players without lives shouldn't be affected by time.
     186            for (auto& mapEntry : this->timeToAct_)
     187            {
     188                if (playerGetLives(mapEntry.first) <= 0)//Players without lives shouldn't be affected by time.
    189189                    continue;
    190                 it->second -= dt;//Decreases punishment time.
    191                 if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
    192                 {
    193                     playerDelayTime_[it->first] -= dt;
    194                     if (playerDelayTime_[it->first] <= 0)
    195                     this->inGame_[it->first] = true;
    196 
    197                     if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
     190                mapEntry.second -= dt;//Decreases punishment time.
     191                if (!inGame_[mapEntry.first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
     192                {
     193                    playerDelayTime_[mapEntry.first] -= dt;
     194                    if (playerDelayTime_[mapEntry.first] <= 0)
     195                    this->inGame_[mapEntry.first] = true;
     196
     197                    if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
    198198                        continue;
    199                     int output = 1 + (int)playerDelayTime_[it->first];
     199                    int output = 1 + (int)playerDelayTime_[mapEntry.first];
    200200                    const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown
    201                     this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    202                 }
    203                 else if (it->second < 0.0f)
    204                 {
    205                     it->second = timeRemaining + 3.0f;//reset punishment-timer
    206                     if (playerGetLives(it->first) > 0)
     201                    this->gtinfo_->sendFadingMessage(message,mapEntry.first->getClientID());
     202                }
     203                else if (mapEntry.second < 0.0f)
     204                {
     205                    mapEntry.second = timeRemaining + 3.0f;//reset punishment-timer
     206                    if (playerGetLives(mapEntry.first) > 0)
    207207                    {
    208                         this->punishPlayer(it->first);
    209                         if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     208                        this->punishPlayer(mapEntry.first);
     209                        if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    210210                            return;
    211211                        const std::string& message = ""; // resets Camper-Warning-message
    212                         this->gtinfo_->sendFadingMessage(message, it->first->getClientID());
     212                        this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID());
    213213                    }
    214214                }
    215                 else if (it->second < timeRemaining/5)//Warning message
    216                 {
    217                   if (it->first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
     215                else if (mapEntry.second < timeRemaining/5)//Warning message
     216                {
     217                  if (mapEntry.first->getClientID()== NETWORK_PEER_ID_UNKNOWN)
    218218                        continue;
    219219                    const std::string& message = "Camper Warning! Don't forget to shoot.";
    220                     this->gtinfo_->sendFadingMessage(message, it->first->getClientID());
     220                    this->gtinfo_->sendFadingMessage(message, mapEntry.first->getClientID());
    221221                }
    222222            }
     
    229229        int party = -1;
    230230        //find a player who survived
    231         for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
    232         {
    233           if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
     231        for (const auto& mapEntry : this->playerLives_)
     232        {
     233          if (mapEntry.first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
    234234                continue;
    235235
    236             if (it->second > 0)//a player that is alive
     236            if (mapEntry.second > 0)//a player that is alive
    237237            {
    238238                //which party has survived?
    239                 std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(it->first);
     239                std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(mapEntry.first);
    240240                if (it2 != this->teamnumbers_.end())
    241241                {
     
    255255    {
    256256        int min = lives;
    257         for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
    258         {
    259             if (it->second <= 0)
     257        for (const auto& mapEntry : this->playerLives_)
     258        {
     259            if (mapEntry.second <= 0)
    260260                continue;
    261             if (it->second < lives)
    262                 min = it->second;
     261            if (mapEntry.second < lives)
     262                min = mapEntry.second;
    263263        }
    264264        return min;
Note: See TracChangeset for help on using the changeset viewer.