Skip to content
70 changes: 34 additions & 36 deletions Robust.Server/Prototypes/ServerPrototypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,56 @@
using Robust.Server.Console;
using Robust.Server.Player;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Network.Messages;
using Robust.Shared.Prototypes;

namespace Robust.Server.Prototypes
namespace Robust.Server.Prototypes;

public sealed partial class ServerPrototypeManager : PrototypeManager
{
public sealed partial class ServerPrototypeManager : PrototypeManager
{
#if TOOLS
[Dependency] private IPlayerManager _playerManager = default!;
[Dependency] private IConGroupController _conGroups = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

@slarticodefast slarticodefast May 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependencies should no longer be readonly, see #6549
So revert this

[Dependency] private readonly IConGroupController _conGroups = default!;
#endif
[Dependency] private INetManager _netManager = default!;
[Dependency] private IBaseServerInternal _server = default!;
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IBaseServerInternal _server = default!;

public ServerPrototypeManager()
{
RegisterIgnore("shader");
RegisterIgnore("uiTheme");
RegisterIgnore("font");
}
public ServerPrototypeManager()
{
RegisterIgnore("shader");
RegisterIgnore("uiTheme");
RegisterIgnore("font");
}

public override void Initialize()
{
base.Initialize();
public override void Initialize()
{
base.Initialize();

_netManager.RegisterNetMessage<MsgReloadPrototypes>(HandleReloadPrototypes, NetMessageAccept.Server);
}
_netManager.RegisterNetMessage<MsgReloadPrototypes>(HandleReloadPrototypes, NetMessageAccept.Server);
}

private void HandleReloadPrototypes(MsgReloadPrototypes msg)
{
private void HandleReloadPrototypes(MsgReloadPrototypes msg)
{
#if TOOLS
if (!_playerManager.TryGetSessionByChannel(msg.MsgChannel, out var player) ||
!_conGroups.CanAdminReloadPrototypes(player))
{
return;
}
if (!_playerManager.TryGetSessionByChannel(msg.MsgChannel, out var player) ||
!_conGroups.CanAdminReloadPrototypes(player))
{
return;
}

var sw = Stopwatch.StartNew();
var sw = Stopwatch.StartNew();

ReloadPrototypes(msg.Paths);
ReloadPrototypes(msg.Paths);

Sawmill.Info($"Reloaded prototypes in {sw.ElapsedMilliseconds} ms");
Sawmill.Info($"Reloaded prototypes in {sw.ElapsedMilliseconds} ms");
#endif
}
}

public override void LoadDefaultPrototypes(Dictionary<Type, HashSet<string>>? changed = null)
{
LoadDirectory(new("/EnginePrototypes/"), changed: changed);
LoadDirectory(_server.Options.PrototypeDirectory, changed: changed);
ResolveResults();
}
public override void LoadDefaultPrototypes(Dictionary<Type, HashSet<string>>? changed = null)
{
LoadDirectory(new("/EnginePrototypes/"), changed: changed);
LoadDirectory(_server.Options.PrototypeDirectory, changed: changed);
ResolveResults();
}
}
Loading
Loading