Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8170


Ignore:
Timestamp:
Apr 3, 2011, 1:01:28 PM (14 years ago)
Author:
jo
Message:

Removed lock that triggered a bug. (the game didn't end) Implemented win/loose message. Somehow the loose message isn't send though.

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

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding3/src/orxonox/gametypes/LastTeamStanding.cc

    r7903 r8170  
    4747        this->eachTeamsPlayers.resize(teams_,0);
    4848        this->teamsAlive = 0;
    49         this->bMinTeamsReached = false;
    5049        this->bNoPunishment = false;
    5150        this->bHardPunishment = false;
     
    7574            playerLives_[player]=getMinLives();//new players only get minimum of lives */
    7675       
    77         if (teamsAlive>1) // Now the game is allowed to end, since there are at least two teams.
    78             bMinTeamsReached = true; // since there are at least two teams, the game is allowed to end
    7976        this->timeToAct_[player] = timeRemaining;
    8077        this->playerDelayTime_[player] = respawnDelay;
    8178        this->inGame_[player] = true;
    82         int team = getTeam(player);
     79        unsigned int team = getTeam(player);
    8380        if( team < 0|| team > teams_) // make sure getTeam returns a regular value
    8481            return;
     
    9794            this->playerDelayTime_.erase(player);
    9895            this->inGame_.erase(player);
    99             int team = getTeam(player);
     96            unsigned int team = getTeam(player);
    10097            if( team < 0|| team > teams_) // make sure getTeam returns a regular value
    10198                return valid_player;
     
    119116        if (playerLives_[victim->getPlayer()]<=0) //if player lost all lives
    120117        {
    121             int team = getTeam(victim->getPlayer());
     118            unsigned int team = getTeam(victim->getPlayer());
    122119            if(team < 0|| team > teams_) // make sure getTeam returns a regular value
    123120                return allow;
     
    189186        if(this->hasStarted()&&(!this->hasEnded()))
    190187        {
    191             if (bMinTeamsReached &&(this->hasStarted()&&(teamsAlive<=1)))//last team remaining -> game will end
     188            if ( this->hasStarted()&&(teamsAlive<=1) )//last team remaining -> game will end
    192189            {
    193190                this->end();
     
    236233    {
    237234        Gametype::end();
    238        
     235        int party = -1;
     236        //find a player who survived
    239237        for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
    240238        {
     
    243241
    244242            if (it->second > 0)
    245                 this->gtinfo_->sendAnnounceMessage("You have won the match!", it->first->getClientID());
    246             else
    247                 this->gtinfo_->sendAnnounceMessage("You have lost the match!", it->first->getClientID());
    248         }
    249 
     243            {
     244             //which party has survived?
     245                std::map<PlayerInfo*, int>::iterator it2 = this->teamnumbers_.find(it->first);
     246                if (it2 != this->teamnumbers_.end())
     247                {
     248                    party = it2->second;
     249                }
     250                //if (party < 0) return; //if search failed
     251             //victory message to all team members
     252                for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3)
     253                {
     254                    if (it3->first->getClientID() == CLIENTID_UNKNOWN)
     255                        continue;
     256                    if (it3->second == party)
     257                        this->gtinfo_->sendAnnounceMessage("You have won the match!", it3->first->getClientID());
     258                    else
     259                        this->gtinfo_->sendAnnounceMessage("You have lost the match!", it3->first->getClientID());
     260                }
     261                return;
     262            }
     263        }
    250264    }
    251265
  • code/branches/lastmanstanding3/src/orxonox/gametypes/LastTeamStanding.h

    r7903 r8170  
    6767            std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state.
    6868
    69             bool bMinTeamsReached; //!< Lock. Game shouldn't end right at the beginning.
    70 
    7169            virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn.
    7270            virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped;
Note: See TracChangeset for help on using the changeset viewer.