Enhance school creation and map management features by updating the API to support mod packs and map layouts. Introduce a new map snapshot protocol for efficient data handling during school sessions. Revise documentation to reflect these changes, including updates to the protocol and architecture documents. Improve UI components for mod selection and map editing, ensuring a better user experience. Update tests to validate new functionalities and ensure robustness.
ci / server (push) Failing after 3m31s
ci / client (push) Successful in 14s

This commit is contained in:
Leonid Pershin
2026-08-18 15:15:49 +03:00
parent 1bc75244e8
commit 30cc937069
36 changed files with 1876 additions and 171 deletions
+23
View File
@@ -1,4 +1,5 @@
using System.Buffers.Binary;
using System.Text;
namespace HSchool.Protocol;
@@ -22,6 +23,13 @@ public ref struct PacketWriter(Span<byte> buffer)
public void WriteMessageType(MessageType value) => WriteByte((byte)value);
public void WriteUInt16(ushort value)
{
EnsureRoom(sizeof(ushort));
BinaryPrimitives.WriteUInt16LittleEndian(_buffer[_position..], value);
_position += sizeof(ushort);
}
public void WriteUInt32(uint value)
{
EnsureRoom(sizeof(uint));
@@ -29,6 +37,21 @@ public ref struct PacketWriter(Span<byte> buffer)
_position += sizeof(uint);
}
/// <summary><c>u16</c> byte length, then UTF-8. Empty string is a zero length.</summary>
public void WriteString(string value)
{
var byteCount = Encoding.UTF8.GetByteCount(value);
if (byteCount > ushort.MaxValue)
{
throw new ProtocolException($"String is {byteCount} bytes; u16 length cannot hold it.");
}
WriteUInt16((ushort)byteCount);
EnsureRoom(byteCount);
Encoding.UTF8.GetBytes(value, _buffer[_position..]);
_position += byteCount;
}
public void WriteInt32(int value)
{
EnsureRoom(sizeof(int));