Update wire protocol to version 5, introducing pupil slots and item counts in map snapshots. Enhance UI components to display pupil slots and item counts in game screens and map editors. Revise localization strings for improved user guidance. Update tests to validate new functionalities and ensure robustness in handling room and item data.
ci / server (push) Failing after 3m37s
ci / client (push) Successful in 28s

This commit is contained in:
Leonid Pershin
2026-08-18 17:21:16 +03:00
parent f000b128f6
commit 38afbcad36
26 changed files with 349 additions and 64 deletions
+7 -1
View File
@@ -44,15 +44,21 @@ public readonly record struct ServerSchoolGoneMessage(int SchoolId);
/// <summary>
/// Tree node in a map snapshot. Kind is <c>0</c> territory, <c>1</c> building, <c>2</c> floor, <c>3</c> room.
/// <paramref name="ParentId"/> is empty for the yard.
/// <paramref name="PupilSlots"/> is how many pupils can take a lesson here — summed from things
/// on the server, not by the client.
/// </summary>
public sealed record MapSnapshotNode(
byte Kind,
string Id,
string ParentId,
string Name,
IReadOnlyList<string> Items,
ushort PupilSlots,
IReadOnlyList<MapSnapshotItem> Items,
IReadOnlyList<string> Positions);
/// <summary>One stacked thing in a room. <paramref name="Count"/> is 1255.</summary>
public sealed record MapSnapshotItem(string Name, byte Count);
/// <summary>
/// One school's map, labelled in the Hello locale. Sent once when that school is opened, not every tick.
/// People and in-place activities are omitted — the client keeps those sections empty.
+11 -5
View File
@@ -116,11 +116,12 @@ public static class ProtocolCodec
{
size += sizeof(byte);
size += StringSize(node.Id) + StringSize(node.ParentId) + StringSize(node.Name);
size += sizeof(ushort);
size += sizeof(byte);
foreach (var item in node.Items)
{
size += StringSize(item);
size += StringSize(item.Name) + sizeof(byte);
}
size += sizeof(byte);
@@ -156,10 +157,12 @@ public static class ProtocolCodec
writer.WriteString(node.Id);
writer.WriteString(node.ParentId);
writer.WriteString(node.Name);
writer.WriteUInt16(node.PupilSlots);
writer.WriteByte((byte)node.Items.Count);
foreach (var item in node.Items)
{
writer.WriteString(item);
writer.WriteString(item.Name);
writer.WriteByte(item.Count);
}
writer.WriteByte((byte)node.Positions.Count);
@@ -263,11 +266,14 @@ public static class ProtocolCodec
var id = reader.ReadString();
var parentId = reader.ReadString();
var name = reader.ReadString();
var pupilSlots = reader.ReadUInt16();
var itemCount = reader.ReadByte();
var items = new string[itemCount];
var items = new MapSnapshotItem[itemCount];
for (var item = 0; item < itemCount; item++)
{
items[item] = reader.ReadString();
var itemName = reader.ReadString();
var count = reader.ReadByte();
items[item] = new MapSnapshotItem(itemName, count);
}
var positionCount = reader.ReadByte();
@@ -277,7 +283,7 @@ public static class ProtocolCodec
positions[position] = reader.ReadString();
}
nodes[i] = new MapSnapshotNode(kind, id, parentId, name, items, positions);
nodes[i] = new MapSnapshotNode(kind, id, parentId, name, pupilSlots, items, positions);
}
return new ServerMapSnapshotMessage(schoolId, nodes);
+1 -1
View File
@@ -4,7 +4,7 @@ namespace HSchool.Protocol;
public static class ProtocolConstants
{
/// <summary>Bumped on every breaking change to the binary layout.</summary>
public const byte Version = 4;
public const byte Version = 5;
/// <summary>Upper bound for a single WebSocket frame accepted by the server.</summary>
public const int MaxMessageSize = 8 * 1024;