mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Miscellaneous replay related changes (#4354)
This commit is contained in:
@@ -388,6 +388,11 @@ namespace Robust.Server
|
||||
_protoLoadMan.Initialize();
|
||||
_netResMan.Initialize();
|
||||
|
||||
// String serializer has to be locked before PostInit as content can depend on it (e.g., replays that start
|
||||
// automatically recording on startup).
|
||||
AddFinalStringsToSerializer();
|
||||
_stringSerializer.LockStrings();
|
||||
|
||||
_modLoader.BroadcastRunLevel(ModRunLevel.PostInit);
|
||||
|
||||
_statusHost.Start();
|
||||
@@ -397,9 +402,6 @@ namespace Robust.Server
|
||||
|
||||
_watchdogApi.Initialize();
|
||||
|
||||
AddFinalStringsToSerializer();
|
||||
_stringSerializer.LockStrings();
|
||||
|
||||
if (OperatingSystem.IsWindows() && _config.GetCVar(CVars.SysWinTickPeriod) >= 0)
|
||||
{
|
||||
WindowsTickPeriod.TimeBeginPeriod((uint) _config.GetCVar(CVars.SysWinTickPeriod));
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Robust.Shared.ContentPack
|
||||
{
|
||||
if (directory.Children.TryGetValue(segment, out var child))
|
||||
{
|
||||
if (!(child is DirectoryNode childDir))
|
||||
if (child is not DirectoryNode childDir)
|
||||
{
|
||||
throw new ArgumentException("A file already exists at that location.");
|
||||
}
|
||||
@@ -55,6 +55,7 @@ namespace Robust.Shared.ContentPack
|
||||
var newDir = new DirectoryNode();
|
||||
|
||||
directory.Children.Add(segment, newDir);
|
||||
directory = newDir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +206,28 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
public void Rename(ResPath oldPath, ResPath newPath)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (!oldPath.IsRooted)
|
||||
throw new ArgumentException("Path must be rooted", nameof(oldPath));
|
||||
|
||||
if (!newPath.IsRooted)
|
||||
throw new ArgumentException("Path must be rooted", nameof(newPath));
|
||||
|
||||
if (!TryGetNodeAt(oldPath.Directory, out var parent) || parent is not DirectoryNode sourceDir)
|
||||
throw new ArgumentException("Source directory does not exist.");
|
||||
|
||||
if (!TryGetNodeAt(newPath.Directory, out var target) || target is not DirectoryNode targetDir)
|
||||
throw new ArgumentException("Target directory does not exist.");
|
||||
|
||||
var newFile = newPath.Filename;
|
||||
if (targetDir.Children.ContainsKey(newFile))
|
||||
throw new ArgumentException("Target node already exists");
|
||||
|
||||
var oldFile = oldPath.Filename;
|
||||
if (!sourceDir.Children.TryGetValue(oldFile, out var node))
|
||||
throw new ArgumentException("Node does not exist in original directory.");
|
||||
|
||||
sourceDir.Children.Remove(oldFile);
|
||||
targetDir.Children.Add(newFile, node);
|
||||
}
|
||||
|
||||
public void OpenOsWindow(ResPath path)
|
||||
|
||||
@@ -124,6 +124,11 @@ public interface IReplayRecordingManager
|
||||
/// Thrown if we are currently recording (<see cref="IsRecording"/> true).
|
||||
/// </exception>
|
||||
Task WaitWriteTasks();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there are any currently running write tasks.
|
||||
/// </summary>
|
||||
bool IsWriting();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -187,6 +187,12 @@ internal abstract partial class SharedReplayRecordingManager
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsWriting()
|
||||
{
|
||||
UpdateWriteTasks();
|
||||
return _finalizingWriteTasks.Count > 0;
|
||||
}
|
||||
|
||||
public Task WaitWriteTasks()
|
||||
{
|
||||
if (IsRecording)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Robust.UnitTesting
|
||||
|
||||
public (byte[] mapHash, byte[] package) GeneratePackage()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
return (Array.Empty<byte>(), Array.Empty<byte>());
|
||||
}
|
||||
|
||||
public void SetPackage(byte[] hash, byte[] package)
|
||||
|
||||
Reference in New Issue
Block a user