Skip to content

[TF2] Readymode countdown logic fixes #1316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/game/shared/tf/tf_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ bool CTFGameRules::BInMatchStartCountdown() const
if ( IsCompetitiveMode() )
{
float flTime = GetRoundRestartTime();
if ( ( flTime > 0.f ) && ( (int)( flTime - gpGlobals->curtime ) <= mp_tournament_readymode_countdown.GetInt() ) )
if ( ( flTime > 0.f ) && ( (int)ceil( flTime - gpGlobals->curtime ) <= mp_tournament_readymode_countdown.GetInt() ) )
{
return true;
}
Expand Down Expand Up @@ -2833,6 +2833,9 @@ bool CTFGameRules::PlayerReadyStatus_HaveMinPlayersToEnable( void )
if ( playerVector[i]->IsReplay() )
continue;

if ( playerVector[i]->IsDisconnecting() )
continue;

nNumPlayers++;
}

Expand Down Expand Up @@ -2939,7 +2942,7 @@ bool CTFGameRules::PlayerReadyStatus_ShouldStartCountdown( void )

if ( IsMannVsMachineMode() )
{
if ( !IsTeamReady( TF_TEAM_PVE_DEFENDERS ) && m_flRestartRoundTime >= gpGlobals->curtime + mp_tournament_readymode_countdown.GetInt() )
if ( !IsTeamReady( TF_TEAM_PVE_DEFENDERS ) && m_flRestartRoundTime >= (int)ceil( gpGlobals->curtime + mp_tournament_readymode_countdown.GetInt() ) )
{
bool bIsTeamReady = PlayerReadyStatus_ArePlayersOnTeamReady( TF_TEAM_PVE_DEFENDERS );
if ( bIsTeamReady )
Expand Down Expand Up @@ -3003,7 +3006,11 @@ void CTFGameRules::PlayerReadyStatus_UpdatePlayerState( CTFPlayer *pTFPlayer, bo

// Make sure we have enough to allow ready mode commands
if ( !PlayerReadyStatus_HaveMinPlayersToEnable() )
{
// Reset ready state if we do not have enough players anymore.
PlayerReadyStatus_ResetState();
return;
}

int nEntIndex = pTFPlayer->entindex();
if ( !IsIndexIntoPlayerArrayValid(nEntIndex) )
Expand Down Expand Up @@ -13207,6 +13214,8 @@ void CTFGameRules::ClientDisconnected( edict_t *pClient )
CTFPlayer *pPlayer = ToTFPlayer( GetContainingEntity( pClient ) );
if ( pPlayer )
{
pPlayer->SetConnected( PlayerDisconnecting );

// ACHIEVEMENT_TF_PYRO_DOMINATE_LEAVESVR - Pyro causes a dominated player to leave the server
for ( int i = 1; i <= gpGlobals->maxClients ; i++ )
{
Expand Down Expand Up @@ -13249,6 +13258,11 @@ void CTFGameRules::ClientDisconnected( edict_t *pClient )
{
PlayerReadyStatus_ResetState();
}
// For MvM, we don't want to stop the countdown if others are ready so reset only the leaving player's ready state.
else if ( IsPlayerReady( pPlayer->entindex() ) )
{
PlayerReadyStatus_UpdatePlayerState( pPlayer, false );
}
}
else if ( !IsTeamReady( pPlayer->GetTeamNumber() ) )
{
Expand Down Expand Up @@ -20749,14 +20763,13 @@ void CTFGameRules::BetweenRounds_Think( void )
if ( UsePlayerReadyStatusMode() )
{
// Everyone is ready, or the drop-dead timer naturally ticked down to mp_tournament_readymode_countdown
bool bStartFinalCountdown = ( PlayerReadyStatus_ShouldStartCountdown() || ( m_flRestartRoundTime > 0 && (int)( m_flRestartRoundTime - gpGlobals->curtime ) == mp_tournament_readymode_countdown.GetInt() ) );
bool bStartFinalCountdown = ( PlayerReadyStatus_ShouldStartCountdown() || ( m_flRestartRoundTime > 0 && (int)ceil( m_flRestartRoundTime - gpGlobals->curtime ) == mp_tournament_readymode_countdown.GetInt() ) );

// It's the FINAL COUNTDOOOWWWNNnnnnnnnnn
float flDropDeadTime = gpGlobals->curtime + mp_tournament_readymode_countdown.GetFloat() + 0.1f;
if ( bStartFinalCountdown && ( m_flRestartRoundTime < 0 || m_flRestartRoundTime >= flDropDeadTime ) )
{
float flDelay = IsMannVsMachineMode() ? 10.f : mp_tournament_readymode_countdown.GetFloat();
m_flRestartRoundTime.Set( gpGlobals->curtime + flDelay );
m_flRestartRoundTime.Set( gpGlobals->curtime + mp_tournament_readymode_countdown.GetFloat() );
ShouldResetScores( true, true );
ShouldResetRoundsPlayed( true );

Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/tf/tf_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12986,7 +12986,7 @@ bool CTFPlayer::CanMoveDuringTaunt()

if ( TFGameRules() && TFGameRules()->IsCompetitiveMode() )
{
if ( ( TFGameRules()->GetRoundRestartTime() > -1.f ) && ( (int)( TFGameRules()->GetRoundRestartTime() - gpGlobals->curtime ) <= mp_tournament_readymode_countdown.GetInt() ) )
if ( ( TFGameRules()->GetRoundRestartTime() > -1.f ) && ( (int)ceil( TFGameRules()->GetRoundRestartTime() - gpGlobals->curtime ) <= mp_tournament_readymode_countdown.GetInt() ) )
return false;

if ( TFGameRules()->PlayersAreOnMatchSummaryStage() )
Expand Down