-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strongly order network prototypes and resources. (#5293)
* Strongly order network prototypes and resources. When a new client connects, both the uploaded prototypes and resources get sent at once. There was no ordering here, which means that prototypes could easily load before resources. This would then obviously give load errors at runtime. In practice though this seemed fine because the RSI or something would just load fine after when spawned or something. This was then broken by ae1051e, which made ResourceCache start caching "that RSI doesn't exist" so it never really tried again. I originally tried to fix this by adding an API to IResourceManager that allows content to invalidate the aforementioned cache (commit 316a7e4, for however GitHub will track that) but then realized resource uploading isn't part of content like I first thought. Lol whoops. That API might still be useful for other dynamic content use cases, but I'm not committing it for now. That fix still caused errors to be spammed if the prototype was loaded before the resources were ready. The new fix is to just load resources before prototypes. This is done by making them both ordered relative to each other, and running resources first. Fixes #5291 * Release notes
- Loading branch information
Showing
6 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Network; | ||
|
||
namespace Robust.Server.Upload; | ||
|
||
/// <summary> | ||
/// Responsible for sending uploaded content to clients when they connect. | ||
/// </summary> | ||
internal sealed class UploadedContentManager | ||
{ | ||
[Dependency] private readonly IServerNetManager _netManager = default!; | ||
[Dependency] private readonly GamePrototypeLoadManager _prototypeLoadManager = default!; | ||
[Dependency] private readonly NetworkResourceManager _networkResourceManager = default!; | ||
|
||
public void Initialize() | ||
{ | ||
_netManager.Connected += NetManagerOnConnected; | ||
} | ||
|
||
private void NetManagerOnConnected(object? sender, NetChannelArgs e) | ||
{ | ||
// This just shells out to the other managers, ensuring they are ordered properly. | ||
// Resources must be done before prototypes. | ||
// Note: both net messages sent here are on the same group and are therefore ordered. | ||
_networkResourceManager.SendToNewUser(e.Channel); | ||
_prototypeLoadManager.SendToNewUser(e.Channel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters