mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* 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 ae1051e813, 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 316a7e4ac10100593202ff7f53dc2992611bbd1e, 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
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using Lidgren.Network;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Shared.Upload;
|
|
|
|
public sealed class NetworkResourceUploadMessage : NetMessage
|
|
{
|
|
public override MsgGroups MsgGroup => MsgGroups.String;
|
|
|
|
public byte[] Data { get; set; } = Array.Empty<byte>();
|
|
public ResPath RelativePath { get; set; } = ResPath.Self;
|
|
|
|
public NetworkResourceUploadMessage()
|
|
{
|
|
}
|
|
|
|
public NetworkResourceUploadMessage(byte[] data, ResPath relativePath)
|
|
{
|
|
Data = data;
|
|
RelativePath = relativePath;
|
|
}
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
|
{
|
|
var dataLength = buffer.ReadVariableInt32();
|
|
Data = buffer.ReadBytes(dataLength);
|
|
// What is the second argument here?
|
|
RelativePath = new ResPath(buffer.ReadString());
|
|
}
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
|
|
{
|
|
buffer.WriteVariableInt32(Data.Length);
|
|
buffer.Write(Data);
|
|
buffer.Write(RelativePath.ToString());
|
|
buffer.Write(ResPath.Separator);
|
|
}
|
|
}
|