Save round information into replay_final.yml (#23013)
* Save round information into the replay * Add round end text too * This is way better * Get actual job * oop * OK THERE * Fake line endings to make life easier * I was told this yaml is legal * I just realised this will make my life easier * REVIEWS BABY IM A PROGRAMMER MOMMY * Live pjb reaction * Live pjb reaction 2 * Reviews 2 * Dont need this * Please no more have mercy on my soul * Oh frick
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Replays;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Markdown;
|
||||
using Robust.Shared.Serialization.Markdown.Mapping;
|
||||
using Robust.Shared.Serialization.Markdown.Value;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.GameTicking;
|
||||
@@ -10,12 +14,15 @@ public sealed partial class GameTicker
|
||||
{
|
||||
[Dependency] private readonly IReplayRecordingManager _replays = default!;
|
||||
[Dependency] private readonly IResourceManager _resourceManager = default!;
|
||||
[Dependency] private readonly ISerializationManager _serialman = default!;
|
||||
|
||||
|
||||
private ISawmill _sawmillReplays = default!;
|
||||
|
||||
private void InitializeReplays()
|
||||
{
|
||||
_replays.RecordingFinished += ReplaysOnRecordingFinished;
|
||||
_replays.RecordingStopped += ReplaysOnRecordingStopped;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,6 +115,20 @@ public sealed partial class GameTicker
|
||||
data.Directory.Rename(data.Path, state.MoveToPath.Value);
|
||||
}
|
||||
|
||||
private void ReplaysOnRecordingStopped(MappingDataNode metadata)
|
||||
{
|
||||
// Write round info like map and round end summery into the replay_final.yml file. Useful for external parsers.
|
||||
|
||||
metadata["map"] = new ValueDataNode(_gameMapManager.GetSelectedMap()?.MapName);
|
||||
metadata["gamemode"] = new ValueDataNode(CurrentPreset != null ? Loc.GetString(CurrentPreset.ModeTitle) : string.Empty);
|
||||
metadata["roundEndPlayers"] = _serialman.WriteValue(_replayRoundPlayerInfo);
|
||||
metadata["roundEndText"] = new ValueDataNode(_replayRoundText);
|
||||
metadata["server_id"] = new ValueDataNode(_configurationManager.GetCVar(CCVars.ServerId));
|
||||
// These should be set to null to prepare them for the next round.
|
||||
_replayRoundPlayerInfo = null;
|
||||
_replayRoundText = null;
|
||||
}
|
||||
|
||||
private ResPath GetAutoReplayPath()
|
||||
{
|
||||
var cfgValue = _cfg.GetCVar(CCVars.ReplayAutoRecordName);
|
||||
|
||||
Reference in New Issue
Block a user