Appraisals - RequestId slot merges a pending request for the same object (PendingIdQueue), as the QueryHealth slot does. - AutoId: per-object last-sent time kept across client releases; no re-appraisal within 10 min while the data is cached, unless the server deleted the object (0xF747). Map bounded at 8192 with a prune off the create path. The sent mark is set at the real send in DrainRequestIds, not at queue time. - The selected-target priority appraisal is skipped when its data is cached and fresh. Main thread frozen - Plugin ticks pause while AC's main thread is frozen (a main-thread message box, or no beat for the hang watchdog's threshold); events keep flowing. Exposed through GetEngineStatusJson (mainThreadFrozen, mainThreadStallMs, pluginTicksPausedMs) and the heartbeat (pump=paused). Crashes - AC's OUT OF MEMORY box: one full-memory dump to <install>\Dumps before the box shows, newest 3 kept. - Native crash logger: pid, tid and date per entry; once per address; .NET Framework AVs never charged to the limit; last-chance handler; stack overflow and heap corruption codes. Build-SehTrampoline gains -NoDeploy. - ProcessExitHooks: dead fail-fast detours removed; crash exit codes pass straight through TerminateProcess/NtTerminateProcess. - CoreCLR's own crash dump is left to the loader's existing ConfigureCrashDumps (Loader.c, Logs\dumps\clr_*.dmp) and Publish-EngineCoreClr's createdump/DAC handling; this change adds no second setup. World transitions - AcMainThreadQueue holds queued game-mutating work while the player is dead, in portal space, or within 5 s after either or after a non-adjacent landblock jump. When the window ends, stale casts, uses, selects and appraisals are dropped and stops and cancels run in order. Walking across an adjacent landblock border never gates. State is re-sampled after AC's tick, before the post-tick drain. - Inventory panel actions are held during a transition too. Diagnostics - Heartbeat valargest= (largest free VA block); free and largest logged before and after each plugin load and unload. - CastSpell comments corrected to the actual main-thread paths. Tests - tools\EngineRobustnessTests and native\SehTrampoline\tests\CrashLogFilterTests.c. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
99 lines
5 KiB
C#
99 lines
5 KiB
C#
// ============================================================================
|
|
// RynthCore.Engine - Compatibility/PlayerLifecycleLog.cs
|
|
// One log line per player lifecycle edge: death (health reaches 0), revival,
|
|
// portal space entered/exited, and landblock jumps (a teleport, not walking
|
|
// into the next landblock), each with the landblock.
|
|
//
|
|
// Why: 2026-09-28 a client crashed in AC's own teardown code
|
|
// (acclient+0x18712F, null read in a hash-table clear) during the death
|
|
// portal to the lifestone, and nothing in the log recorded the death or the
|
|
// teleport. With these lines a crash can be lined up with what the character
|
|
// was doing.
|
|
//
|
|
// Also the world-transition gate (WorldTransitionState): while the player is dead,
|
|
// portaling, or settling after either or after a landblock jump, AcMainThreadQueue
|
|
// holds every queued game-mutating call instead of running it into a world AC is
|
|
// tearing down (a client died right after a death recall's landblock jump).
|
|
//
|
|
// Sampled from GameTickHooks.UseTimeDetour on AC's main thread, before AC's
|
|
// tick and before the cast drain, so the reads see a consistent world and the gate
|
|
// knows about a death in the same tick. Alloc-free except on an edge.
|
|
// ============================================================================
|
|
|
|
using System;
|
|
using System.Threading;
|
|
|
|
namespace RynthCore.Engine.Compatibility;
|
|
|
|
internal static class PlayerLifecycleLog
|
|
{
|
|
// Main thread only (the UseTime sample and both main-thread drains).
|
|
private static readonly WorldTransitionState _state = new();
|
|
private static long _settleUntil; // published copy for other threads
|
|
private static volatile bool _portaling, _dead;
|
|
private static long _portalEnteredAt, _diedAt;
|
|
|
|
/// <summary>
|
|
/// Dead, in portal space, or within 5 s after either or after a landblock jump: AC is
|
|
/// tearing down and loading the world, so nothing should poke at its state
|
|
/// (BusyCountHooks' force-clear). As of the last game tick; any thread.
|
|
/// </summary>
|
|
public static bool InWorldTransition =>
|
|
_dead || _portaling || Environment.TickCount64 < Interlocked.Read(ref _settleUntil);
|
|
|
|
/// <summary>
|
|
/// AC main thread only (the queue drains): true = hold everything queued now (see
|
|
/// WorldTransitionState for the rule).
|
|
/// </summary>
|
|
public static bool HoldQueuedWork(long nowMs) => _state.CheckHolding(nowMs);
|
|
|
|
/// <summary>AC main thread only: what a drain does with one queued item (WorldTransitionState.Decide).</summary>
|
|
public static WorldTransitionState.Verdict DecideQueued(long nowMs, long queuedAtMs, bool teardown) =>
|
|
_state.Decide(nowMs, queuedAtMs, teardown);
|
|
|
|
/// <summary>AC main thread, once per game tick.</summary>
|
|
public static void SampleOnGameThread(bool portaling)
|
|
{
|
|
bool dead = false;
|
|
uint health = 0, maxHealth = 0;
|
|
if (PlayerVitalsHooks.TryGetSnapshot(out PlayerVitalsSnapshot v))
|
|
{
|
|
health = v.Health;
|
|
maxHealth = v.MaxHealth;
|
|
dead = v.MaxHealth > 0 && v.Health == 0;
|
|
}
|
|
uint cell = 0;
|
|
if (PlayerPhysicsHooks.TryGetPlayerPose(out uint c, out _, out _, out _, out _, out _, out _, out _))
|
|
cell = c;
|
|
uint landblock = cell >> 16;
|
|
|
|
long now = Environment.TickCount64;
|
|
WorldTransitionState.Edge edges = _state.Sample(now, dead, portaling, landblock);
|
|
_dead = _state.Dead;
|
|
_portaling = _state.Portaling;
|
|
Interlocked.Exchange(ref _settleUntil, _state.SettleUntilMs);
|
|
if (edges == WorldTransitionState.Edge.None)
|
|
return;
|
|
|
|
if ((edges & WorldTransitionState.Edge.Died) != 0)
|
|
{
|
|
_diedAt = now;
|
|
RynthLog.Info($"[Lifecycle] player DIED (health 0/{maxHealth}) in landblock 0x{landblock:X4} (cell 0x{cell:X8}).");
|
|
}
|
|
if ((edges & WorldTransitionState.Edge.Revived) != 0)
|
|
RynthLog.Info($"[Lifecycle] player alive again (health {health}/{maxHealth}) {Ago(_diedAt, now)} after death, landblock 0x{landblock:X4}.");
|
|
if ((edges & WorldTransitionState.Edge.PortalEntered) != 0)
|
|
{
|
|
_portalEnteredAt = now;
|
|
string why = _diedAt != 0 && now - _diedAt < 30_000 ? " (death portal)" : "";
|
|
RynthLog.Info($"[Lifecycle] portal space ENTERED{why} from landblock 0x{landblock:X4} (cell 0x{cell:X8}).");
|
|
}
|
|
if ((edges & WorldTransitionState.Edge.PortalExited) != 0)
|
|
RynthLog.Info($"[Lifecycle] portal space EXITED into landblock 0x{landblock:X4} (cell 0x{cell:X8}) after {Ago(_portalEnteredAt, now)}.");
|
|
if ((edges & WorldTransitionState.Edge.LandblockJump) != 0)
|
|
RynthLog.Info($"[Lifecycle] landblock jump 0x{_state.PreviousLandblock:X4} -> 0x{landblock:X4}{(portaling ? " (in portal space)" : "")}; queued game actions held off for {WorldTransitionState.SettleMs / 1000} s.");
|
|
}
|
|
|
|
private static string Ago(long since, long now) =>
|
|
since == 0 ? "?" : $"{(now - since) / 1000.0:0.0}s";
|
|
}
|