Catch replay start and end errors on round restarts (#20565)
This commit is contained in:
@@ -23,38 +23,45 @@ public sealed partial class GameTicker
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ReplayStartRound()
|
private void ReplayStartRound()
|
||||||
{
|
{
|
||||||
if (!_cfg.GetCVar(CCVars.ReplayAutoRecord))
|
try
|
||||||
return;
|
|
||||||
|
|
||||||
if (_replays.IsRecording)
|
|
||||||
{
|
{
|
||||||
_sawmillReplays.Warning("Already an active replay recording before the start of the round, not starting automatic recording.");
|
if (!_cfg.GetCVar(CCVars.ReplayAutoRecord))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_replays.IsRecording)
|
||||||
|
{
|
||||||
|
_sawmillReplays.Warning("Already an active replay recording before the start of the round, not starting automatic recording.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_sawmillReplays.Debug($"Starting replay recording for round {RoundId}");
|
||||||
|
|
||||||
|
var finalPath = GetAutoReplayPath();
|
||||||
|
var recordPath = finalPath;
|
||||||
|
var tempDir = _cfg.GetCVar(CCVars.ReplayAutoRecordTempDir);
|
||||||
|
ResPath? moveToPath = null;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(tempDir))
|
||||||
|
{
|
||||||
|
var baseReplayPath = new ResPath(_cfg.GetCVar(CVars.ReplayDirectory)).ToRootedPath();
|
||||||
|
moveToPath = baseReplayPath / finalPath;
|
||||||
|
|
||||||
|
var fileName = finalPath.Filename;
|
||||||
|
recordPath = new ResPath(tempDir) / fileName;
|
||||||
|
|
||||||
|
_sawmillReplays.Debug($"Replay will record in temporary position: {recordPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var recordState = new ReplayRecordState(moveToPath);
|
||||||
|
|
||||||
|
if (!_replays.TryStartRecording(_resourceManager.UserData, recordPath.ToString(), state: recordState))
|
||||||
|
{
|
||||||
|
_sawmillReplays.Error("Can't start automatic replay recording!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
_sawmillReplays.Debug($"Starting replay recording for round {RoundId}");
|
|
||||||
|
|
||||||
var finalPath = GetAutoReplayPath();
|
|
||||||
var recordPath = finalPath;
|
|
||||||
var tempDir = _cfg.GetCVar(CCVars.ReplayAutoRecordTempDir);
|
|
||||||
ResPath? moveToPath = null;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(tempDir))
|
|
||||||
{
|
{
|
||||||
var baseReplayPath = new ResPath(_cfg.GetCVar(CVars.ReplayDirectory)).ToRootedPath();
|
Log.Error($"Error while starting an automatic replay recording:\n{e}");
|
||||||
moveToPath = baseReplayPath / finalPath;
|
|
||||||
|
|
||||||
var fileName = finalPath.Filename;
|
|
||||||
recordPath = new ResPath(tempDir) / fileName;
|
|
||||||
|
|
||||||
_sawmillReplays.Debug($"Replay will record in temporary position: {recordPath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var recordState = new ReplayRecordState(moveToPath);
|
|
||||||
|
|
||||||
if (!_replays.TryStartRecording(_resourceManager.UserData, recordPath.ToString(), state: recordState))
|
|
||||||
{
|
|
||||||
_sawmillReplays.Error("Can't start automatic replay recording!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +70,16 @@ public sealed partial class GameTicker
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ReplayEndRound()
|
private void ReplayEndRound()
|
||||||
{
|
{
|
||||||
if (_replays.ActiveRecordingState is ReplayRecordState)
|
try
|
||||||
{
|
{
|
||||||
_replays.StopRecording();
|
if (_replays.ActiveRecordingState is ReplayRecordState)
|
||||||
|
{
|
||||||
|
_replays.StopRecording();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error($"Error while stopping replay recording:\n{e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user