Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 15, 2011, 3:38:54 PM (14 years ago)
Author:
jo
Message:

Finally working as intended.

Location:
code/branches/lastmanstanding2/src/orxonox/gametypes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding2/src/orxonox/gametypes/Gametype.h

    r7284 r7901  
    150150              { this->timeLimit_ = t; }
    151151
     152            //inline bool getForceSpawn()
     153            //  { return this->bForceSpawn_; }       
     154
    152155            virtual void resetTimer();
    153156            virtual void resetTimer(float t);
  • code/branches/lastmanstanding2/src/orxonox/gametypes/LastTeamStanding.cc

    r7899 r7901  
    5858    LastTeamStanding::~LastTeamStanding()
    5959    {
    60         this->playerLives_.clear();
    61         this->eachTeamsPlayers.clear();
    62         this->timeToAct_.clear();
    63         this->inGame_.clear();
    64         this->playerDelayTime_.clear();
     60        //this->playerLives_.clear();
     61        //this->eachTeamsPlayers.clear();
     62        //this->timeToAct_.clear();
     63        //this->inGame_.clear();
     64        //this->playerDelayTime_.clear();
    6565    }   
    6666
     
    7575            playerLives_[player]=getMinLives();//new players only get minimum of lives */
    7676       
    77         if(this->eachTeamsPlayers[getTeam(player)]==0) //if a player is the first in his group, a new team is alive
    78             this->teamsAlive++;
    79         this->eachTeamsPlayers[getTeam(player)]++; //the number of player in this team is increased
    80 
    8177        if (teamsAlive>1) // Now the game is allowed to end, since there are at least two teams.
    8278            bMinTeamsReached = true; // since there are at least two teams, the game is allowed to end
     
    8480        this->playerDelayTime_[player] = respawnDelay;
    8581        this->inGame_[player] = true;
     82        int team = getTeam(player);
     83        if( team < 0|| team > teams_) // make sure getTeam returns a regular value
     84            return;
     85        if(this->eachTeamsPlayers[team]==0) //if a player is the first in his group, a new team is alive
     86            this->teamsAlive++;
     87        this->eachTeamsPlayers[team]++; //the number of player in this team is increased
    8688    }
    8789
     
    9193        if (valid_player)
    9294        {
    93             this->eachTeamsPlayers[getTeam(player)]--;       // a player left the team
    94             if(this->eachTeamsPlayers[getTeam(player)] == 0) // if it was the last player a team died
    95                  this->teamsAlive--;
    9695            this->playerLives_.erase(player);
    9796            this->timeToAct_.erase(player);
    9897            this->playerDelayTime_.erase(player);
    9998            this->inGame_.erase(player);
     99            int team = getTeam(player);
     100            if( team < 0|| team > teams_) // make sure getTeam returns a regular value
     101                return valid_player;
     102            this->eachTeamsPlayers[team]--;       // a player left the team
     103            if(this->eachTeamsPlayers[team] == 0) // if it was the last player a team died
     104                this->teamsAlive--;
    100105        }
    101106
     
    114119        if (playerLives_[victim->getPlayer()]<=0) //if player lost all lives
    115120        {
    116             this->eachTeamsPlayers[getTeam(victim->getPlayer())]--;
    117             if(eachTeamsPlayers[getTeam(victim->getPlayer())] == 0) //last team member died
     121            int team = getTeam(victim->getPlayer());
     122            if(team < 0|| team > teams_) // make sure getTeam returns a regular value
     123                return allow;
     124            this->eachTeamsPlayers[team]--;
     125            if(eachTeamsPlayers[team] == 0) //last team member died
    118126                this->teamsAlive--;
    119127            const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
     
    121129            Host::Broadcast(message);
    122130        }
    123 
    124131        return allow;
    125132    }
Note: See TracChangeset for help on using the changeset viewer.