Refuse newer save formats and add a gated dump of a live school.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 00:30:39 +03:00
co-authored by Cursor
parent 0ae633995f
commit a7955a0dce
13 changed files with 479 additions and 11 deletions
@@ -0,0 +1,45 @@
using Arch.Core;
using HSchool.Schedule;
using HSchool.Simulation;
namespace HSchool.Server.Game;
/// <summary>
/// Live slice of one school for a diagnostic dump. Built on the worker thread; HTTP never sees
/// the <c>World</c>.
/// </summary>
internal sealed record SchoolLiveDump(
DateTime GameTime,
bool Running,
IReadOnlyList<PresenceSnapshot> Presence,
IReadOnlyDictionary<string, IReadOnlyDictionary<string, float>> Needs,
IReadOnlyList<LessonPlacement> Now);
/// <summary>Reads presence and needs from the live school. Call only on that school's worker.</summary>
internal static class SchoolDumpReader
{
private static readonly QueryDescription IdentityAndNeeds =
new QueryDescription().WithAll<PersonIdentity, PersonNeeds>();
public static SchoolLiveDump Read(School school, int weekDays)
{
var needs = new Dictionary<string, IReadOnlyDictionary<string, float>>(StringComparer.Ordinal);
school.World.Query(in IdentityAndNeeds, (ref PersonIdentity identity, ref PersonNeeds live) =>
{
needs[identity.Id] = new Dictionary<string, float>(live.Values, StringComparer.Ordinal);
});
IReadOnlyList<LessonPlacement> now = [];
if (school.Timetable is not null && school.Catalog is not null)
{
now = TimetableClock.OccurringAt(school.Timetable, school.Catalog, school.Clock.Time, weekDays);
}
return new SchoolLiveDump(
school.Clock.Time,
school.Clock.IsRunning,
school.CapturePresence(),
needs,
now);
}
}