//***************************************************************************** // void LASTMANSTANDING_TimeExpired( void ) { LONG lHighestHealth = 0; bool bTie = false; bool bFoundPlayer = false; LONG lWinner = -1; DHUDMessageFadeOut *pMsg; char szString[64]; // Don't end the level if we're not in a game. if ( LASTMANSTANDING_GetState( ) != LMSS_INPROGRESS ) return; // Try to find the player with the highest health. if ( lastmanstanding ) { TArray<ULONG> possibleWinners; for ( unsigned int i = 0; i < MAXPLAYERS; ++i ) possibleWinners.Push ( i ); // [BB] Find the player with the most lives left. PLAYER_SelectPlayersWithHighestValue ( PLAYER_GetLivesLeft, possibleWinners ); // [BB] If more than one player has the most lives left, select the player with the highest lives. if ( possibleWinners.Size() != 1 ) PLAYER_SelectPlayersWithHighestValue ( PLAYER_GetHealth, possibleWinners ); // [BB] If more then one player have the most lives and also the same health, then the game it a tie. if ( possibleWinners.Size() == 1 ) lWinner = possibleWinners[0]; else { lWinner = MAXPLAYERS; bTie = true; } } else if ( teamlms ) { if ( LASTMANSTANDING_TeamsWithAlivePlayersOn( ) == 1 ) { for ( ULONG i = 0; i < teams.Size( ); i++ ) { if ( TEAM_CountLivingAndRespawnablePlayers( i ) ) lWinner = i; } } else { lWinner = teams.Size( ); bTie = true; } } // If for some reason we don't have any players, just end the map like normal. if ( lWinner == -1 ) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_Printf( PRINT_HIGH, "%s\n", GStrings( "TXT_TIMELIMIT" )); else Printf( "%s\n", GStrings( "TXT_TIMELIMIT" )); GAME_SetEndLevelDelay( 5 * TICRATE ); return; } // If there was a tie, then go into sudden death! if ( bTie ) { // Only print the message the instant we reach sudden death. if ( level.time == (int)( timelimit * TICRATE * 60 )) { sprintf( szString, "\\cdSUDDEN DEATH!" ); V_ColorizeString( szString ); if ( NETWORK_GetState( ) != NETSTATE_SERVER ) { // Display the HUD message. pMsg = new DHUDMessageFadeOut( BigFont, szString, 160.4f, 75.0f, 320, 200, CR_RED, 3.0f, 2.0f ); StatusBar->AttachMessage( pMsg, MAKE_ID('C','N','T','R') ); } else { SERVERCOMMANDS_PrintHUDMessageFadeOut( szString, 160.4f, 75.0f, 320, 200, CR_RED, 3.0f, 2.0f, "BigFont", false, MAKE_ID('C','N','T','R') ); } } return; } // Also, do the win sequence for the player. LASTMANSTANDING_DoWinSequence( lWinner ); // Give the winner a win. if ( lastmanstanding ) PLAYER_SetWins( &players[lWinner], players[lWinner].ulWins + 1 ); // [BB] In a team game of course give the win to the winning team. if ( teamlms ) TEAM_SetWinCount( lWinner, TEAM_GetWinCount( lWinner ) + 1, false ); if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_Printf( PRINT_HIGH, "%s\n", GStrings( "TXT_TIMELIMIT" )); else Printf( "%s\n", GStrings( "TXT_TIMELIMIT" )); GAME_SetEndLevelDelay( 5 * TICRATE ); }
//***************************************************************************** // void JOINQUEUE_PlayerLeftGame( bool bWantPop ) { bool bPop = true; // If we're in a duel, revert to the "waiting for players" state. // [BB] But only do so if there are less then two duelers left (probably JOINQUEUE_PlayerLeftGame was called mistakenly). if ( duel && ( DUEL_CountActiveDuelers( ) < 2 ) ) DUEL_SetState( DS_WAITINGFORPLAYERS ); // If only one (or zero) person is left, go back to "waiting for players". if ( lastmanstanding ) { // Someone just won by default! if (( GAME_CountLivingAndRespawnablePlayers( ) == 1 ) && ( LASTMANSTANDING_GetState( ) == LMSS_INPROGRESS )) { LONG lWinner; lWinner = LASTMANSTANDING_GetLastManStanding( ); if ( lWinner != -1 ) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_Printf( PRINT_HIGH, "%s \\c-wins!\n", players[lWinner].userinfo.netname ); else { Printf( "%s \\c-wins!\n", players[lWinner].userinfo.netname ); if ( lWinner == consoleplayer ) ANNOUNCER_PlayEntry( cl_announcer, "YouWin" ); } // Give the winner a win. PLAYER_SetWins( &players[lWinner], players[lWinner].ulWins + 1 ); // Pause for five seconds for the win sequence. LASTMANSTANDING_DoWinSequence( lWinner ); } // Join queue will be popped upon state change. bPop = false; GAME_SetEndLevelDelay( 5 * TICRATE ); } else if ( SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ) <= 1 ) LASTMANSTANDING_SetState( LMSS_WAITINGFORPLAYERS ); } if ( teamlms ) { // Someone just won by default! if (( LASTMANSTANDING_GetState( ) == LMSS_INPROGRESS ) && LASTMANSTANDING_TeamsWithAlivePlayersOn( ) <= 1) { LONG lWinner; lWinner = LASTMANSTANDING_TeamGetLastManStanding( ); if ( lWinner != -1 ) { if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVER_Printf( PRINT_HIGH, "%s \\c-wins!\n", TEAM_GetName( lWinner )); else { Printf( "%s \\c-wins!\n", TEAM_GetName( lWinner )); if ( players[consoleplayer].bOnTeam && ( lWinner == (LONG)players[consoleplayer].ulTeam )) ANNOUNCER_PlayEntry( cl_announcer, "YouWin" ); } // Give the team a win. TEAM_SetWinCount( lWinner, TEAM_GetWinCount( lWinner ) + 1, false ); // Pause for five seconds for the win sequence. LASTMANSTANDING_DoWinSequence( lWinner ); } // Join queue will be popped upon state change. bPop = false; GAME_SetEndLevelDelay( 5 * TICRATE ); } else if ( TEAM_TeamsWithPlayersOn( ) <= 1 ) LASTMANSTANDING_SetState( LMSS_WAITINGFORPLAYERS ); } // If we're in possession mode, revert to the "waiting for players" state // [BB] when there are less than two players now. if ( possession && ( SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ) < 2 )) POSSESSION_SetState( PSNS_WAITINGFORPLAYERS ); if ( teampossession && ( TEAM_TeamsWithPlayersOn( ) <= 1 ) ) POSSESSION_SetState( PSNS_WAITINGFORPLAYERS ); // If we're in invasion mode, revert to the "waiting for players" state. if ( invasion && ( SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ) < 1 )) INVASION_SetState( IS_WAITINGFORPLAYERS ); // If we're in survival co-op mode, revert to the "waiting for players" state. if ( survival && ( SERVER_CalcNumNonSpectatingPlayers( MAXPLAYERS ) < 1 )) SURVIVAL_SetState( SURVS_WAITINGFORPLAYERS ); // Potentially let one person join the game. if ( bPop && bWantPop ) JOINQUEUE_PopQueue( 1 ); }