fix(runtime,net): OP1 review fixes — server-seed gate, tick-wired auto-save/logout flush, fellowship mutual exclusion
Closes the two mechanism-lens and blast-lens dual reviews of Campaign OP
slice OP1 (86c0a7e0): docs/research/2026-08-10-op1-review-mechanism.md and
docs/research/2026-08-10-op1-review-blast.md.
MUST-FIX M1 (blast): RuntimeCharacterOptionsState gains a HasServerSeed
latch, set by Replace (the PlayerDescription seed) and cleared by
ResetSession. TryFlush/TryFlushIfAutoSaveDue now refuse before the seed
arrives — closing the window where a bot (or, after this commit, the
timer/logout triggers) could flush client-default option words over a
character's real server-side options before any PlayerDescription ever
landed.
MUST-FIX 1 (mechanism): the 480 s auto-save timer and the pre-logoff
flush are now wired into production, closing TS-71 (retired). Both ride
LiveSessionController's own tick/stop transaction via two new hooks
(ConfigureAutoSaveTick/ConfigurePreLogoffFlush), wired once by
GameRuntime's constructor — a Runtime-internal change requiring zero
host edits, exactly as the review identified. The flush body talks to
WorldSession directly rather than through App's LiveSessionCommandRouter,
which is what keeps this off the S2 lock-order hazard (below). Filed
TS-73 for the two OnChanged side-effect cases (weather/day/combat-
target/fog) TrySetOption still doesn't model — pre-anchored to OP4's
Group B consumer binds.
SHOULD-FIX S2 (blast, prerequisite for MUST-FIX 1): TryFlush/
TryFlushIfAutoSaveDue no longer invoke the flush callback while holding
_dirtyGate — the decision is made and cleared under the lock, but the
callback itself runs outside it, closing the lock-inversion hazard the
natural timer wiring would have hit (Runtime tick's _dirtyGate-then-
_gate vs the router's _gate-then-_dirtyGate).
SHOULD-FIX MF-2 (mechanism): TrySetOption now ports the two
PlayerModule-state-mutating cases of CPlayerModule::OnChanged's local
side-effect switch — turning ON IgnoreFellowshipRequests or
FellowshipAutoAcceptRequests clears the other through a real recursive
TrySetOption call, reproducing retail's second 0x0005 (the clear's send
reaches the wire before the primary option's own send, matching the
nested-call order in the decomp). The signature widened from
Action sendAutoSave to Action<uint,bool> so the recursion can send a
different (id, value) than the caller's own; every production call site
now passes WorldSession.SendSetSingleCharacterOption directly.
SHOULD-FIX MF-3 (mechanism): a hand-transcribed 53-row (id, isOptions1,
mask) theory in CharacterOptionTableTests, independently re-derived from
acclient.h's PlayerOption/CharacterOption/CharacterOptions2 enums rather
than copied from CharacterOptionTable.cs — closes the one column with no
id-by-id pin. Also added the pairwise-distinctness check blast NOTE N7
named.
SHOULD-FIX S1 (blast): LiveSessionCommandRouterTests' CH3/CH4 regression
test now drives the REAL TrySetOption binding instead of a hand-rolled
SetOptionBit substitute that had silently drifted from production after
OP1.
SHOULD-FIX S3 (blast): RuntimeCharacterOwnershipSnapshot gains
OptionsAreClean (!Options.IsDirty), included in IsConverged — a module
whose two words happen to cycle back to their default bit pattern while
still dirty is now caught by the combined ownership ledger, not just by
OptionsAreDefaults.
SHOULD-FIX S4 (blast): SaveOptions no longer encodes "did it actually
flush" as PrimaryObjectId 1u/0u (which read as object guid 0x00000001 in
the K2 event stream). Both host adapters now report the identical shape
(Accepted, objectId 0) — the graphical host never could report this
anyway (LiveCommandBus.Publish has no return channel).
SHOULD-FIX S5 (blast): Replace (the server-seed arrival) now also clears
IsDirty/FirstDirtiedAt — a wholesale re-seed supersedes any pending
batched-but-unflushed local intent (retail's own PlayerModule has no
partial-merge path either), documented at the member.
SHOULD-FIX S6 (blast): a cross-check theory asserting CharacterOptionTable's
masks equal PlayerDescriptionParser.CharacterOptions1/2's independently
(the write path vs the read path TurbineChatMembershipGate/
RuntimeSettingsController consume) — guards the exact CH3 failure class.
Also fixed a real allocation regression found while landing MUST-FIX 1:
the naive per-tick flush closure would have allocated on EVERY
LiveSessionController.Tick() call regardless of dirty state, which broke
the K4 headless 30-session resource-envelope gate. GameRuntime.
FlushCharacterOptions now pre-checks Options.IsDirty (itself retail-
faithful — CPlayerModule::UseTime opens with the identical m_bDirty byte
compare) before allocating the flush closure, so the allocation only
happens on the rare tick that might actually flush.
Dispositions on findings not changed this round:
- Mechanism NOTE 6 / not independently re-flagged: a re-entrant MarkDirty
from inside a flush callback can still be erased by the trailing
"_isDirty = false" — pre-existing, unchanged by the S2 lock restructure
(same outcome whether the callback runs inside or outside the lock),
not reachable from any current caller, not a one-liner to close
correctly (needs a per-dirty-period generation token). Left as documented
in the review; worth closing before the Options panel ever flushes from
inside a change handler.
- Mechanism NOTE 9, blast N2/N3/N4/N5/N6/N8: informational or require
touching files this round doesn't otherwise edit (SocialActions.cs,
CharacterOptionsBlobSource.cs, GameRuntimeContractTests.cs) — left per
the "one-liner in a file already being edited" instruction.
Register: TS-71 retired (both remaining SetCharacterOptions flush
triggers now production-wired); TS-73 filed (the two unmodeled OnChanged
presentation-binding cases, pre-anchored to OP4).
Quality bar: Release build green; full solution suite 12,853 passed / 4
skipped / 0 failed (baseline 12,770/4/0 post-OP2 — 83 new tests added,
zero regressions).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
26b119354d
commit
09029f9f4b
12 changed files with 1043 additions and 51 deletions
|
|
@ -266,6 +266,8 @@ public sealed class LiveSessionController
|
|||
private ulong _generation;
|
||||
private RuntimeTeardownStage _lastTeardownStages;
|
||||
private LiveSessionCharacterSelection? _activeSelection;
|
||||
private Action<WorldSession>? _autoSaveTickHook;
|
||||
private Action<WorldSession>? _preLogoffFlushHook;
|
||||
|
||||
public LiveSessionController()
|
||||
: this(ProductionLiveSessionOperations.Instance)
|
||||
|
|
@ -297,6 +299,38 @@ public sealed class LiveSessionController
|
|||
get { lock (_gate) return new RuntimeGenerationToken(_generation); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MUST-FIX 1 (Campaign OP OP1 review fix, 2026-08-11 — mechanism lens
|
||||
/// finding): reaches retail's <c>CPlayerModule::UseTime</c> (the 480 s
|
||||
/// batched character-option auto-save) from the SAME per-session tick
|
||||
/// both the graphical host (<c>RetailLiveFrameCoordinator</c>) and the
|
||||
/// no-window host (<c>HeadlessSessionHost.Tick</c>) already call —
|
||||
/// <see cref="Tick()"/> — with ZERO host edits. <c>GameRuntime</c> wires
|
||||
/// this once, after constructing <c>CharacterOwner</c>/
|
||||
/// <c>InventoryOwner</c>, with a flush body that talks to the
|
||||
/// <see cref="WorldSession"/> directly rather than through App's
|
||||
/// <c>LiveSessionCommandRouter</c>/<c>LiveCommandBus</c> — which is what
|
||||
/// keeps this wiring off the S2 lock-order hazard the blast-lens finding
|
||||
/// named (this hook never touches the router's own gate). A hook
|
||||
/// throwing is caught and logged (<see cref="Tick()"/>), never treated
|
||||
/// as a tick failure — a transient send error on a background auto-save
|
||||
/// must not tear down the whole live session.
|
||||
/// </summary>
|
||||
internal void ConfigureAutoSaveTick(Action<WorldSession> hook) =>
|
||||
_autoSaveTickHook = hook ?? throw new ArgumentNullException(nameof(hook));
|
||||
|
||||
/// <summary>
|
||||
/// MUST-FIX 1: reaches retail's <c>CPlayerSystem::LogOffCharacter</c> →
|
||||
/// <c>SaveToServer</c> ordering — flush the batched option module BEFORE
|
||||
/// the character-logoff wire request goes out — from Runtime's own
|
||||
/// Stop/teardown transaction (<see cref="StopCore"/>), using the
|
||||
/// CURRENT (not-yet-retired) session. Caught and logged rather than
|
||||
/// propagated: a failed flush must not block the graceful-shutdown
|
||||
/// sequence CLAUDE.md flags as ACE-timing-sensitive.
|
||||
/// </summary>
|
||||
internal void ConfigurePreLogoffFlush(Action<WorldSession> hook) =>
|
||||
_preLogoffFlushHook = hook ?? throw new ArgumentNullException(nameof(hook));
|
||||
|
||||
public bool IsDisposalComplete
|
||||
{
|
||||
get { lock (_gate) return _disposed; }
|
||||
|
|
@ -440,10 +474,31 @@ public sealed class LiveSessionController
|
|||
throw;
|
||||
throw error;
|
||||
}
|
||||
|
||||
// MUST-FIX 1: TS-71's 480 s auto-save timer half. Runs after
|
||||
// the protocol pump above and only when the scope/generation
|
||||
// are still current — a reconnect that happened mid-tick
|
||||
// must not flush against a retired session.
|
||||
InvokeAutoSaveTick(scope.Session);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void InvokeAutoSaveTick(WorldSession session)
|
||||
{
|
||||
if (_autoSaveTickHook is not { } hook)
|
||||
return;
|
||||
try
|
||||
{
|
||||
hook(session);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"live: auto-save character-options tick failed: {error.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (_gate)
|
||||
|
|
@ -621,6 +676,16 @@ public sealed class LiveSessionController
|
|||
|
||||
private void StopCore()
|
||||
{
|
||||
// MUST-FIX 1: TS-71's logout-flush half — retail's
|
||||
// CPlayerSystem::LogOffCharacter calls SaveToServer BEFORE the
|
||||
// character-logoff wire request, so this runs before anything below
|
||||
// touches the scope (teardown, generation bump). Gated on _inWorld
|
||||
// so a failed/never-entered-world Stop (still connecting, no
|
||||
// character session) never fires it — matching retail's own call
|
||||
// site, which only exists on an actual in-world character.
|
||||
if (_inWorld && _scope is { } activeScope)
|
||||
InvokePreLogoffFlush(activeScope.Session);
|
||||
|
||||
++_generation;
|
||||
_inWorld = false;
|
||||
_activeSelection = null;
|
||||
|
|
@ -638,6 +703,21 @@ public sealed class LiveSessionController
|
|||
_lastTeardownStages = RuntimeTeardownStage.Complete;
|
||||
}
|
||||
|
||||
private void InvokePreLogoffFlush(WorldSession session)
|
||||
{
|
||||
if (_preLogoffFlushHook is not { } hook)
|
||||
return;
|
||||
try
|
||||
{
|
||||
hook(session);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"live: pre-logoff character-options flush failed: {error.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void DrainRetiredScope()
|
||||
{
|
||||
if (_retiredScope is not { } retired)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue