Merge phase 26 school seed.
ci / server (push) Failing after 3m34s
ci / client (push) Failing after 12s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 00:43:33 +03:00
co-authored by Cursor
18 changed files with 237 additions and 35 deletions
+6 -3
View File
@@ -55,6 +55,7 @@ internal static class SchoolEndpoints
request.Map,
request.NameSetId,
request.NativeLanguage,
request.Seed,
NewCompletion<SchoolCreationOutcome>());
commands.Enqueue(command);
@@ -508,7 +509,8 @@ internal sealed record CreateSchoolRequest(
IReadOnlyList<string>? ModIds,
MapLayout? Map,
string? NameSetId,
string? NativeLanguage);
string? NativeLanguage,
int? Seed);
internal sealed record SchoolResponse(
int Id,
@@ -516,10 +518,11 @@ internal sealed record SchoolResponse(
DateTime GameTime,
bool Running,
byte SpeedIndex,
IReadOnlyList<string> ModIds)
IReadOnlyList<string> ModIds,
int Seed)
{
public static SchoolResponse From(SchoolState school) =>
new(school.Id, school.Name, school.GameTime, school.Running, school.SpeedIndex, school.ModIds);
new(school.Id, school.Name, school.GameTime, school.Running, school.SpeedIndex, school.ModIds, school.Seed);
}
/// <summary>Everything the main menu needs in one request.</summary>
+1
View File
@@ -18,6 +18,7 @@ internal abstract record GameCommand
MapLayout? Map,
string? NameSetId,
string? NativeLanguage,
int? Seed,
TaskCompletionSource<SchoolCreationOutcome> Result) : GameCommand;
internal sealed record DeleteSchool(int SchoolId, TaskCompletionSource<bool> Result) : GameCommand;
+7 -3
View File
@@ -378,9 +378,10 @@ internal sealed class GameLoopService(
var id = _nextId++;
store.WriteNextId(_nextId);
var nativeLanguage = NativeLanguages.Pick(names, id, command.NativeLanguage, rollIfOmitted: true);
var seed = command.Seed ?? Random.Shared.Next();
var nativeLanguage = NativeLanguages.Pick(names, seed, command.NativeLanguage, rollIfOmitted: true);
var worker = SpawnWorker(id, normalized, command.StartDate, running: true, ClockSpeed.DefaultIndex, isNew: true, packIds, command.Map, nameSetId, nativeLanguage);
var worker = SpawnWorker(id, normalized, command.StartDate, running: true, ClockSpeed.DefaultIndex, isNew: true, packIds, command.Map, nameSetId, nativeLanguage, seed);
Track(worker);
worker.Start();
@@ -402,7 +403,7 @@ internal sealed class GameLoopService(
throw;
}
logger.LogInformation("School {SchoolId} \"{Name}\" created.", id, normalized);
logger.LogInformation("School {SchoolId} \"{Name}\" created with seed {Seed}.", id, normalized, seed);
command.Result.TrySetResult(new SchoolCreationOutcome(worker.Snapshot, SchoolCreationError.None));
}
catch (Exception ex)
@@ -549,6 +550,7 @@ internal sealed class GameLoopService(
save.Map,
save.NameSetId,
save.NativeLanguage,
createSeed: null,
save.Presence);
worker.Start();
@@ -598,6 +600,7 @@ internal sealed class GameLoopService(
MapLayout? map,
string? nameSetId,
string? nativeLanguage,
int? createSeed = null,
IReadOnlyList<PresenceSnapshot>? presence = null) =>
new(
id,
@@ -610,6 +613,7 @@ internal sealed class GameLoopService(
map,
nameSetId,
nativeLanguage,
createSeed,
presence,
_options,
clients,
+2 -1
View File
@@ -10,7 +10,8 @@ internal sealed record SchoolState(
DateTime GameTime,
bool Running,
byte SpeedIndex,
IReadOnlyList<string> ModIds);
IReadOnlyList<string> ModIds,
int Seed);
/// <summary>Everything the main menu needs in one read.</summary>
internal sealed record SchoolsState(int MaxSchools, IReadOnlyList<SchoolState> Schools);
+12 -3
View File
@@ -34,6 +34,7 @@ internal sealed class SchoolWorker
private readonly MapLayout? _savedMap;
private readonly string? _nameSetId;
private string? _nativeLanguage;
private readonly int? _createSeed;
private readonly IReadOnlyList<PresenceSnapshot>? _savedPresence;
private readonly Action<int> _onFailed;
@@ -67,6 +68,7 @@ internal sealed class SchoolWorker
MapLayout? savedMap,
string? nameSetId,
string? nativeLanguage,
int? createSeed,
IReadOnlyList<PresenceSnapshot>? savedPresence,
SimulationOptions options,
ClientRegistry clients,
@@ -86,6 +88,7 @@ internal sealed class SchoolWorker
_savedMap = savedMap;
_nameSetId = nameSetId;
_nativeLanguage = nativeLanguage;
_createSeed = createSeed;
_savedPresence = savedPresence;
_options = options;
_clients = clients;
@@ -94,7 +97,7 @@ internal sealed class SchoolWorker
_mods = mods;
_onFailed = onFailed;
_logger = logger;
_snapshot = new SchoolState(id, name, time, running, (byte)speedIndex, modIds ?? []);
_snapshot = new SchoolState(id, name, time, running, (byte)speedIndex, modIds ?? [], createSeed ?? 0);
}
public int Id => _id;
@@ -589,7 +592,8 @@ internal sealed class SchoolWorker
school.Clock.Time,
school.Clock.IsRunning,
(byte)school.Clock.SpeedIndex,
school.Catalog?.PackIds ?? _modIds ?? []));
school.Catalog?.PackIds ?? _modIds ?? [],
school.PeopleSeed));
Volatile.Write(ref _rosterSnapshot, school.Roster);
Volatile.Write(ref _applicantSnapshot, school.Applicants);
Volatile.Write(ref _timetableSnapshot, school.Timetable);
@@ -868,7 +872,12 @@ internal sealed class SchoolWorker
if (_isNew)
{
seed = school.Id;
if (_createSeed is not int createSeed)
{
throw new InvalidOperationException($"School {_id} was created without a people seed.");
}
seed = createSeed;
native = ResolveNative(catalog, nameSetId, seed, _nativeLanguage, generating: true);
_nativeLanguage = native;
roster = RosterGenerator.Generate(catalog, map, seed, nameSetId, school.Clock.Time, native);