Skip to content

Commit

Permalink
Match restore issues (#652)
Browse files Browse the repository at this point in the history
* Fixed match restore issues

* Removed duplicate Pause

* Fixed timing issues with Pause match
  • Loading branch information
arildboifot authored Apr 10, 2022
1 parent 598acb1 commit 5afc25b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
6 changes: 6 additions & 0 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,12 @@ public Action Timer_CheckReady(Handle timer) {
if (g_GameState == Get5State_None) {
return Plugin_Continue;
}

if (g_DoingBackupRestoreNow) {
LogDebug("Timer_CheckReady: Waiting for restore");
return Plugin_Continue;
}


CheckTeamNameStatus(MatchTeam_Team1);
CheckTeamNameStatus(MatchTeam_Team2);
Expand Down
29 changes: 21 additions & 8 deletions scripting/get5/backups.sp
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,20 @@ public bool RestoreFromBackup(const char[] path) {
}

public void RestoreGet5Backup() {
// This variable is reset on a timer since the implementation of the
// mp_backup_restore_load_file doesn't do everything in one frame.
g_DoingBackupRestoreNow = true;
ExecCfg(g_LiveCfgCvar);

if (g_SavedValveBackup) {
// This variable is reset ona timer since the implementation of the
// mp_backup_restore_load_file doesn't do everything in one frame.
char tempValveBackup[PLATFORM_MAX_PATH];
GetTempFilePath(tempValveBackup, sizeof(tempValveBackup), TEMP_VALVE_BACKUP_PATTERN);
g_DoingBackupRestoreNow = true;
ServerCommand("mp_backup_restore_load_file \"%s\"", tempValveBackup);
Pause();
CreateTimer(0.1, Timer_FinishBackup);
ChangeState(Get5State_Live);
SetMatchTeamCvars();
ExecuteMatchConfigCvars();
SetMatchRestartDelay();

// There are some timing issues leading to incorrect score when restoring matches in second half.
// Doing the restore on a timer
CreateTimer(1.0, Time_StartRestore);
} else {
SetStartingTeams();
SetMatchTeamCvars();
Expand All @@ -352,9 +354,20 @@ public void RestoreGet5Backup() {
} else {
EnsurePausedWarmup();
}

g_DoingBackupRestoreNow = false;
}
}

public Action Time_StartRestore(Handle timer) {
Pause();

char tempValveBackup[PLATFORM_MAX_PATH];
GetTempFilePath(tempValveBackup, sizeof(tempValveBackup), TEMP_VALVE_BACKUP_PATTERN);
ServerCommand("mp_backup_restore_load_file \"%s\"", tempValveBackup);
CreateTimer(0.1, Timer_FinishBackup);
}

public Action Timer_FinishBackup(Handle timer) {
g_DoingBackupRestoreNow = false;
}
Expand Down
9 changes: 7 additions & 2 deletions scripting/get5/goinglive.sp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public Action MatchLive(Handle timer) {

// We force the match end-delay to extend for the duration of the GOTV broadcast here.
g_PendingSideSwap = false;
ConVar mp_match_restart_delay = FindConVar("mp_match_restart_delay");
SetConVarInt(mp_match_restart_delay, GetTvDelay() + MATCH_END_DELAY_AFTER_TV + 5);
SetMatchRestartDelay();

for (int i = 0; i < 5; i++) {
Get5_MessageToAll("%t", "MatchIsLiveInfoMessage");
Expand All @@ -69,3 +68,9 @@ public Action MatchLive(Handle timer) {

return Plugin_Handled;
}

public void SetMatchRestartDelay() {
ConVar mp_match_restart_delay = FindConVar("mp_match_restart_delay");
int delay = GetTvDelay() + MATCH_END_DELAY_AFTER_TV + 5;
SetConVarInt(mp_match_restart_delay, delay);
}

0 comments on commit 5afc25b

Please sign in to comment.