AutoId review fixes: tag before send, pack waits out combat, sweep retries
- The flight tag is registered BEFORE _requestId again, so a 0xC8 that AC puts on the wire inside the call is still tagged. EngineSend returns a token; a call that returns false or throws hands it to EngineSendFailed, which retires the entry (a no-op once it was matched, or when the slot now holds another id). FlightRecorderTests: a synchronous send is tagged, a failed send leaves no live entry, a retire for another id or a bad token is a no-op. - Inventory sends wait (WaitCombat, kept, counted once) while a target is selected, a cast is in flight (CastGate.GetCastBusyState) or an attack runs (ClientActionGates.TryReadAttacking). Each 0xC8 raises AC's busy count, which plugins gate casts on. The selected target and an open container are not held; All mode is unchanged. combat= in the minute line, combat in /rc autoid status. - The login sweep looks into containers only (ItemsCapacity > 0 in the PWD snapshot, the engine's own pack rule), skips a tick while the pending list is full, and is marked done only when nothing overflowed; otherwise it runs again once there is room. - CollectOwnedIdsFromSnapshot has its doc comment back; HasPwdSnapshot and the new IsContainerInSnapshot have their own. LiveWorld's send is renamed QueueIdentify and block-bodied, so check_offthread_mutators.py scans it and its allow-list entry no longer also covers the create-path Enqueue. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c9bbafbfb4
commit
8668f2a3ca
11 changed files with 224 additions and 50 deletions
|
|
@ -94,7 +94,14 @@ internal static class AutoIdService
|
|||
// native 0xC8 send directly (off-thread heap alloc + non-atomic UI-counter increment).
|
||||
// The appraisal counts as sent only when the main thread sends it (OnSent, from
|
||||
// AcMainThreadQueue.DrainRequestIds): a queued request dropped there leaves it due again.
|
||||
public bool Enqueue(uint id, IdRequester who) => AcMainThreadQueue.EnqueueRequestId(id, who);
|
||||
// Block-bodied, and named apart from the create-path Enqueue, so
|
||||
// tools/check_offthread_mutators.py scans it and its allow-list entry covers only this.
|
||||
public bool QueueIdentify(uint id, IdRequester who)
|
||||
{
|
||||
return AcMainThreadQueue.EnqueueRequestId(id, who);
|
||||
}
|
||||
|
||||
public bool IsContainer(uint id) => ClientObjectHooks.IsContainerInSnapshot(id);
|
||||
}
|
||||
|
||||
/// <summary>Re-creates not appraised because a recent appraisal is still cached.</summary>
|
||||
|
|
@ -305,6 +312,10 @@ internal static class AutoIdService
|
|||
? Interlocked.Read(ref _openedAtMs) : 0,
|
||||
SettleUntilMs = PlayerLifecycleLog.SettleUntilMs,
|
||||
LoginCompleteAtMs = LoginLifecycleHooks.LoginCompleteAtMs,
|
||||
// Each 0xC8 raises AC's busy count, which plugins gate their casts on: the
|
||||
// pack waits while a target is selected, a cast is in flight or an attack runs.
|
||||
CombatBusy = target != 0 || CastGate.GetCastBusyState() != 0
|
||||
|| (ClientActionGates.TryReadAttacking(out bool attacking) && attacking),
|
||||
};
|
||||
_drain.Tick(ctx, sent);
|
||||
|
||||
|
|
@ -354,7 +365,7 @@ internal static class AutoIdService
|
|||
IdRequester.Plugin, IdRequester.Self, IdRequester.Ui, IdRequester.None,
|
||||
};
|
||||
private static readonly long[] _lastSent = new long[IdRequesters.Count];
|
||||
private static long _lastForeign, _lastSkipMode, _lastSkipAge, _lastSkipDefer, _lastSkipFresh, _lastSkipRate;
|
||||
private static long _lastForeign, _lastSkipMode, _lastSkipAge, _lastSkipDefer, _lastSkipFresh, _lastSkipRate, _lastSkipCombat;
|
||||
|
||||
/// <summary>
|
||||
/// The last minute's IdentifyObject counts (heartbeat thread, once a minute): sent per
|
||||
|
|
@ -365,7 +376,7 @@ internal static class AutoIdService
|
|||
public static string TakeMinuteLine()
|
||||
{
|
||||
long foreign = FlightRecorder.ForeignIdentifyTotal;
|
||||
long sm = _drain.SkipMode, sa = _drain.SkipAge, sd = _drain.SkipDefer, sf = _drain.SkipFresh, sr = _drain.SkipRate;
|
||||
long sm = _drain.SkipMode, sa = _drain.SkipAge, sd = _drain.SkipDefer, sf = _drain.SkipFresh, sr = _drain.SkipRate, sc = _drain.SkipCombat;
|
||||
var sb = new System.Text.StringBuilder(176);
|
||||
sb.Append("autoid 60s: mode=").Append(AutoIdPolicy.Name(Mode)).Append(" sent");
|
||||
long total = 0;
|
||||
|
|
@ -392,9 +403,9 @@ internal static class AutoIdService
|
|||
sb.Append(" tot=").Append(total);
|
||||
sb.Append(" skip mode=").Append(sm - _lastSkipMode).Append(" age=").Append(sa - _lastSkipAge)
|
||||
.Append(" defer=").Append(sd - _lastSkipDefer).Append(" fresh=").Append(sf - _lastSkipFresh)
|
||||
.Append(" rate=").Append(sr - _lastSkipRate);
|
||||
.Append(" rate=").Append(sr - _lastSkipRate).Append(" combat=").Append(sc - _lastSkipCombat);
|
||||
sb.Append(" pend=").Append(_drain.PendingCount);
|
||||
_lastSkipMode = sm; _lastSkipAge = sa; _lastSkipDefer = sd; _lastSkipFresh = sf; _lastSkipRate = sr;
|
||||
_lastSkipMode = sm; _lastSkipAge = sa; _lastSkipDefer = sd; _lastSkipFresh = sf; _lastSkipRate = sr; _lastSkipCombat = sc;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +436,7 @@ internal static class AutoIdService
|
|||
{
|
||||
AutoIdMode.All => "all (every created object, the old behaviour)",
|
||||
AutoIdMode.Off => "off (no background appraisals, not even the selected target)",
|
||||
_ => $"limited (selected target; open container and own inventory after {AutoIdPolicy.MinAgeMs / 1000} s, {AutoIdPolicy.DeferMs / 1000} s after login or a portal/death/teleport; inventory at most {1000 / AutoIdPolicy.InventoryMinIntervalMs}/s)",
|
||||
_ => $"limited (selected target; open container and own inventory after {AutoIdPolicy.MinAgeMs / 1000} s, {AutoIdPolicy.DeferMs / 1000} s after login or a portal/death/teleport; inventory at most {1000 / AutoIdPolicy.InventoryMinIntervalMs}/s, and not while a target is selected or a cast or attack is in flight)",
|
||||
};
|
||||
string extra = "";
|
||||
if (_drain.Overflow > 0) extra += $", overflow {_drain.Overflow}";
|
||||
|
|
@ -435,7 +446,7 @@ internal static class AutoIdService
|
|||
$"AutoId: {modeText}. Saved in engine.json; /rc autoid all|limited|off switches it now. Plugins' own identifies are never limited.",
|
||||
$"Identifies sent since start: {sent}; by AC or Decal: {(foreign >= 0 ? foreign.ToString() : "? (flight recorder off)")}.",
|
||||
$"AutoId skipped: mode {_drain.SkipMode}, fresh {_drain.SkipFresh}, recent re-create {SkippedRecentCount}; " +
|
||||
$"waited: age {_drain.SkipAge}, defer {_drain.SkipDefer}, rate {_drain.SkipRate}; refused {_drain.Refused} (kept); " +
|
||||
$"waited: age {_drain.SkipAge}, defer {_drain.SkipDefer}, rate {_drain.SkipRate}, combat {_drain.SkipCombat}; refused {_drain.Refused} (kept); " +
|
||||
$"login sweep {_drain.Swept}; pending now {_drain.PendingCount}{extra}.",
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue