feat: port aelrynth 2026.9.27.2 snapshot onto GitHub history

Overlay upstream/main (9b5e276) onto BlankenshipG main without rewriting
history. Keep origin-only Decal/plugin/docs trees. Re-apply aelrynth.com
and sibling-fork URL fixes that aelrynth git still has as tombohar links.

Co-authored-by: BlankenshipG <BlankenshipG@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-10-04 15:43:50 +00:00
commit 4ddbb52eb2
No known key found for this signature in database
244 changed files with 59710 additions and 3067 deletions

View file

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using RynthCore.Engine.Hooking;
using RynthCore.Engine.Plugins;
@ -16,7 +16,6 @@ internal static class SmartBoxHooks
private const uint PlayerPositionUpdateOpcode = 0x0000F74B;
private const uint VectorUpdateOpcode = 0x0000F74E;
private const uint UpdateObjectOpcode = 0x0000F7DB;
private const uint GameEventOpcode = 0x0000F7B0;
// ACSmartBox::DispatchSmartBoxEvent
// 83 EC 08 53 8B 5C 24 10 8B 53 30 83 FA 04 8B 43 2C 56 8B F1 89 44 24 14 89 54 24 08 72 ?? 8B 08
@ -28,14 +27,20 @@ internal static class SmartBoxHooks
0x89, 0x54, 0x24, 0x08, 0x72, null, 0x8B, 0x08
];
// ACGame::DispatchGameEvent
// 83 EC 08 53 8B 5C 24 10 8B 53 30 83 FA 04 8B 43 2C 56 8B F1 89 44 24 14 89 54 24 08 72 ?? 8B 08
// UIQueueManager::ProcessNetBlobData @ 0x0055BCD0 — the real inbound GameEvent
// dispatcher (switches on inner event type: 0x1B1/0x1B2 attack, 0x1AC/0x1AD
// victim/killer, 0x1C0 health, …). thiscall(this, uint* data, int end);
// the inner event type is *data and the payload follows at data+4.
// ⚠ This MUST differ from DispatchSmartBoxEventPattern — they were once an
// identical copy-paste, which deduped this hook away (it never installed, so
// combat events were never seen). Verified unique vs acclient.exe.
private static readonly byte?[] DispatchGameEventPattern =
[
0x83, 0xEC, 0x08, 0x53, 0x8B, 0x5C, 0x24, 0x10,
0x8B, 0x53, 0x30, 0x83, 0xFA, 0x04, 0x8B, 0x43,
0x2C, 0x56, 0x8B, 0xF1, 0x89, 0x44, 0x24, 0x14,
0x89, 0x54, 0x24, 0x08, 0x72, null, 0x8B, 0x08
0x81, 0xEC, 0xC0, 0x01, 0x00, 0x00, 0x53, 0x55,
0x8B, 0xAC, 0x24, 0xD0, 0x01, 0x00, 0x00, 0x56,
0x57, 0x8B, 0xF9, 0x8B, 0x8C, 0x24, 0xD4, 0x01,
0x00, 0x00, 0x8B, 0x11, 0x8B, 0xC1, 0x8D, 0x34,
0x29, 0x83, 0xC1, 0x04
];
private static IntPtr _originalDispatchSmartBoxEventPtr;
@ -86,7 +91,7 @@ internal static class SmartBoxHooks
IntPtr geAddr = new IntPtr(textSection.TextBaseVa + geOff);
if (hookedAddresses.Add(geAddr))
{
delegate* unmanaged[Thiscall]<IntPtr, IntPtr, uint> pGeDetour = &DispatchGameEventDetour;
delegate* unmanaged[Thiscall]<IntPtr, IntPtr, int, uint> pGeDetour = &DispatchGameEventDetour;
MinHook.Hook(geAddr, (IntPtr)pGeDetour, out _originalDispatchGameEventPtr);
RynthLog.Verbose($"Compat: game-event hook ready @ 0x{geAddr.ToInt32():X8}");
}
@ -109,58 +114,192 @@ internal static class SmartBoxHooks
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvThiscall) })]
private static unsafe uint DispatchSmartBoxEventDetour(IntPtr thisPtr, IntPtr blob)
{
MainThreadGuard.RecordIfFirst();
RecursionGuard.Tick("SmartBoxHooks.DispatchSmartBoxEvent");
var pOriginal = (delegate* unmanaged[Thiscall]<IntPtr, IntPtr, uint>)_originalDispatchSmartBoxEventPtr;
if (!LoginLifecycleHooks.HasObservedLoginComplete)
{
CharacterCaptureHooks.ProcessPotentialCharacterMessage(blob, isGameEvent: false);
try { CharacterCaptureHooks.ProcessPotentialCharacterMessage(blob, isGameEvent: false); } catch { }
return pOriginal(thisPtr, blob);
}
SmartBoxEventInfo info = ReadSmartBoxEventInfo(blob);
DiagEvent("SB", false, blob, info);
uint status = pOriginal(thisPtr, blob);
TryQueueHealthUpdate(blob, info);
// Game events arrive as 0xF7B0 wrapper: [F7B0][playerId][seq][innerEventType][...]
// Check for IdentifyObject response (inner event 0xC9) after the original processes it.
if (info.Opcode == GameEventOpcode)
TryHandleGameEvent(blob, info);
else if (info.Opcode == 0xC9 && info.RawObjectId != 0)
TryCacheVitalsFromIdentify(info.RawObjectId);
if (info.RawObjectId != 0 &&
(info.Opcode == PositionUpdateOpcode ||
info.Opcode == PlayerPositionUpdateOpcode ||
info.Opcode == VectorUpdateOpcode ||
info.Opcode == UpdateObjectOpcode))
try
{
PluginManager.QueueUpdateObject(info.RawObjectId);
TryQueueHealthUpdate(blob, info);
TryQueueDamageEvent(blob, info);
if (info.RawObjectId != 0 &&
(info.Opcode == PositionUpdateOpcode ||
info.Opcode == PlayerPositionUpdateOpcode ||
info.Opcode == VectorUpdateOpcode ||
info.Opcode == UpdateObjectOpcode))
{
PluginManager.QueueUpdateObject(info.RawObjectId);
}
}
catch { }
return status;
}
// UIQueueManager::ProcessNetBlobData(this, uint* data, int size). thiscall:
// `this` in ECX (thisPtr), then the two stack args (data, size). The inner
// GameEvent type is *data; the event payload follows at data+4. `size` is the
// payload byte LENGTH — verified against the live binary: the hooked fn's
// prologue computes its own bound as `lea esi,[data+size]`. NOTE: this is a
// DIFFERENT function/shape than DispatchSmartBoxEvent — must keep the 2nd
// stack arg or the thiscall callee-cleanup imbalances the stack and crashes AC.
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvThiscall) })]
private static unsafe uint DispatchGameEventDetour(IntPtr thisPtr, IntPtr blob)
private static unsafe uint DispatchGameEventDetour(IntPtr thisPtr, IntPtr data, int size)
{
var pOriginal = (delegate* unmanaged[Thiscall]<IntPtr, IntPtr, uint>)_originalDispatchGameEventPtr;
MainThreadGuard.RecordIfFirst();
// Engine-side BusyCount watchdog: fires on every inbound game event
// while in-world (AC's main thread). Self-heals busy-count desync.
try { BusyCountHooks.CheckWatchdog(); } catch { }
RecursionGuard.Tick("SmartBoxHooks.DispatchGameEvent");
var pOriginal = (delegate* unmanaged[Thiscall]<IntPtr, IntPtr, int, uint>)_originalDispatchGameEventPtr;
// Log game event opcodes for discovery
SmartBoxEventInfo info = ReadSmartBoxEventInfo(blob);
TryQueueHealthUpdate(blob, info);
try
{
// Reject undersized payloads instead of clamping up: an inflated
// bound would let parsers read past the real payload (uncatchable
// NativeAOT AV on a page boundary).
if (data != IntPtr.Zero && size >= 4)
{
uint eventType = unchecked((uint)Marshal.ReadInt32(data));
int len = size > 0x4000 ? 0x4000 : size;
ParseGameEvent(eventType, data, (uint)len);
}
}
catch { }
// Always attempt capture from game events (pre-login)
CharacterCaptureHooks.ProcessPotentialCharacterMessage(blob, isGameEvent: true);
return pOriginal(thisPtr, data, size);
}
uint result = pOriginal(thisPtr, blob);
private static int _geEventLogCount;
private static int _hpReadLogCount;
// After the original handler processes 0xC9 (IdentifyObject response),
// the weenie's qualities are populated — read maxHealth and cache it.
if (info.Opcode == 0xC9 && info.RawObjectId != 0)
TryCacheVitalsFromIdentify(info.RawObjectId);
// Parse an inbound GameEvent for the events combat cares about. `data` points
// at the event blob: inner type @ +0, payload @ +4. `size` bounds reads.
private static void ParseGameEvent(uint eventType, IntPtr data, uint size)
{
// Diagnostic: surface the first handful of combat-range events so the hook
// can be verified live and any offset corrected from real bytes. Capped.
if (eventType >= 0x0180 && eventType <= 0x01E0 && _geEventLogCount < 40)
{
_geEventLogCount++;
uint d1 = size >= 8 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, 4))) : 0;
uint d2 = size >= 12 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, 8))) : 0;
uint d3 = size >= 16 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, 12))) : 0;
RynthLog.Compat($"GE evt=0x{eventType:X4} len={size} p=[{d1:X8} {d2:X8} {d3:X8}]");
}
return result;
switch (eventType)
{
case 0x01C0: // UpdateHealth: [targetId u32][ratio f32]
if (size >= 12)
{
uint targetId = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, 4)));
float ratio = Marshal.PtrToStructure<float>(IntPtr.Add(data, 8));
uint maxHealth = 0, currentHealth = 0;
// We're on AC's main thread here, so read the creature's REAL
// MaxHealth straight from its qualities (SEH-guarded, appraisal-
// free) — fixes the bogus 50 stub for mobs the char can't assess.
// The plugin QueryHealth()s its combat target on lock, which is
// what makes this fire for the mobs it's actually fighting.
// Falls back to the wire-parsed appraisal cache if the read fails.
bool gotReal = ClientObjectHooks.TryReadCreatureMaxHealth(targetId, out uint realMax) && realMax > 0;
if (gotReal)
maxHealth = realMax;
else if (ObjectQualityCache.TryGetCreatureVitals(targetId, out CreatureVitals exact) && exact.MaxHealth > 0)
maxHealth = exact.MaxHealth;
if (maxHealth > 0)
currentHealth = (uint)Math.Round(maxHealth * Math.Clamp(ratio, 0f, 1f));
if (_hpReadLogCount < 25)
{
_hpReadLogCount++;
RynthLog.Compat($"Creature HP id=0x{targetId:X8}: sehRead={(gotReal ? realMax.ToString() : "none")} used={maxHealth} ratio={ratio:0.00}");
}
PluginManager.QueueUpdateHealth(targetId, ratio, currentHealth, maxHealth);
}
break;
case 0x01B1: // AttackerNotification (we hit)
case 0x01B2: // DefenderNotification (we're hit)
ParseGameEventDamage(eventType, data, size);
break;
case 0x01AD: // KillerNotification — death message string (we got a kill)
{
string? msg = ReadString16Latin1(data, 4, size);
if (!string.IsNullOrEmpty(msg))
{
if (_killNotifyLogCount < 12)
{
_killNotifyLogCount++;
RynthLog.Compat($"Combat: kill notify '{msg}'");
}
PluginManager.QueueKillNotification(msg);
}
break;
}
case 0x01C7: // UseDone: [errorType u32] — server finished an action
// (cast/use) with WeenieError.None(0) = completed, or an
// error (0x1D = YoureTooBusy). Read-only observation: bump
// a monotonic counter so the plugin can pace combat casts
// on real server completion instead of a blind interval.
// This is the authoritative ACE Player.IsBusy lifecycle
// signal — it never touches client m_cBusy.
{
uint err = size >= 8 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, 4))) : 0;
int seq = System.Threading.Interlocked.Increment(ref _useDoneSeq);
if (_useDoneLogCount < 25)
{
_useDoneLogCount++;
RynthLog.Compat($"UseDone seq={seq} err=0x{err:X}");
}
break;
}
}
}
// Monotonic count of inbound UseDone (0x1C7) events. The plugin records this
// at cast time and re-reads it to detect the server finishing the cast.
private static int _useDoneSeq;
private static int _useDoneLogCount;
public static int GetUseDoneSeq() => System.Threading.Volatile.Read(ref _useDoneSeq);
// AttackerNotification (0x01B1) / DefenderNotification (0x01B2). Payload at
// data+4: string16 name, u32 damageType, f64 percent, u32 damage,
// [u32 damageLocation (defender only),] u32 crit, …. Read-only byte math.
private static void ParseGameEventDamage(uint eventType, IntPtr data, uint size)
{
if (size < 24) return;
bool attacker = eventType == 0x01B1;
int nameLen = (ushort)Marshal.ReadInt16(IntPtr.Add(data, 4));
int strBlock = ((2 + nameLen + 3) / 4) * 4; // u16 len + chars, padded to a multiple of 4
int off = 4 + strBlock; // → damageType
int critOff = off + (attacker ? 16 : 20); // type(4)+percent(8)+damage(4)[+dmgLoc(4)]
if (critOff + 4 > size) return;
uint damageType = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, off)));
uint damage = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, off + 12)));
uint crit = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(data, critOff)));
if (damage == 0 || damage > 1_000_000) return;
if (_damageEventLogCount < 12)
{
_damageEventLogCount++;
RynthLog.Compat($"Combat: damage evt 0x{eventType:X3} dmg={damage} crit={crit} atk={attacker} len={size}");
}
PluginManager.QueueCombatDamage(damage, damageType, crit != 0, attacker);
}
private static SmartBoxEventInfo ReadSmartBoxEventInfo(IntPtr blob)
@ -206,13 +345,15 @@ internal static class SmartBoxHooks
uint maxHealth = 0;
uint currentHealth = 0;
if (ClientObjectHooks.TryGetWeenieObjectPtr(targetId, out IntPtr pWeenie))
// Appraisal-only: emit an absolute health pair ONLY from a real
// appraisal's wire-parsed CreatureProfile (id-keyed). With no
// appraisal, leave max=0 so the UI falls back to a % — the
// pointer-cache and creature Inq maxes are unreliable on ACE and
// fabricated wildly wrong values (e.g. 50/50 for a 190-hp mob).
if (ObjectQualityCache.TryGetCreatureVitals(targetId, out CreatureVitals exact) && exact.MaxHealth > 0)
{
if (ObjectQualityCache.TryGetMaxHealth(pWeenie, out uint cached))
{
maxHealth = cached;
currentHealth = (uint)Math.Round(maxHealth * Math.Clamp(ratio, 0f, 1f));
}
maxHealth = exact.MaxHealth;
currentHealth = (uint)Math.Round(maxHealth * Math.Clamp(ratio, 0f, 1f));
}
PluginManager.QueueUpdateHealth(targetId, ratio, currentHealth, maxHealth);
@ -222,13 +363,22 @@ internal static class SmartBoxHooks
}
}
private static int _identifyLogCount;
private static int _damageEventLogCount;
private static void TryHandleGameEvent(IntPtr blob, SmartBoxEventInfo info)
// AttackerNotification (0x01B1, you hit) / DefenderNotification (0x01B2, you're
// hit) carry the EXACT per-hit damage + crit — the only client-side source of
// real damage numbers (chat is flavor text; health deltas miss one-shots).
// These arrive as GameEvents whose blob envelope is
// [recipientId][sequence][eventType][payload] (eventType at +8), while
// SmartBox-dispatched events put eventType at +0. Detect the eventType at
// either offset, then parse the payload that follows:
// string16 name (u16 charCount + cp1252 1-byte chars, padded so (2+len)%4==0)
// u32 damageType, f64 percent, u32 damage, [u32 damageLocation (defender),]
// u32 crit, u64 attackConditions
// Pure read-only byte math (no allocation) to stay detour-safe.
private static void TryQueueDamageEvent(IntPtr blob, SmartBoxEventInfo info)
{
// 0xF7B0 game event layout: [0xF7B0(4)][playerId(4)][sequence(4)][innerEventType(4)][eventData...]
// Minimum size: 16 bytes for the header
if (blob == IntPtr.Zero || info.BlobSize < 16)
if (blob == IntPtr.Zero || info.BlobSize < 24)
return;
try
@ -237,43 +387,172 @@ internal static class SmartBoxHooks
if (payloadPtr == IntPtr.Zero)
return;
uint innerEvent = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, 12)));
uint et0 = unchecked((uint)Marshal.ReadInt32(payloadPtr));
uint et8 = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, 8)));
// 0xC9 = IdentifyObject response
// Layout after inner event type: [objectId(4)][flags(4)][success(4)][data...]
if (innerEvent == 0xC9 && info.BlobSize >= 20)
{
uint objectId = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, 16)));
if (objectId != 0)
TryCacheVitalsFromIdentify(objectId);
}
}
catch
{
}
}
int nameOff;
uint eventType;
if (et0 == 0x01B1 || et0 == 0x01B2) { eventType = et0; nameOff = 4; } // SmartBox-style
else if (et8 == 0x01B1 || et8 == 0x01B2) { eventType = et8; nameOff = 12; } // GameEvent envelope
else return;
private static void TryCacheVitalsFromIdentify(uint objectId)
{
try
{
if (!ClientObjectHooks.TryGetWeenieObjectPtr(objectId, out IntPtr pWeenie) || pWeenie == IntPtr.Zero)
bool attacker = eventType == 0x01B1;
int nameLen = (ushort)Marshal.ReadInt16(IntPtr.Add(payloadPtr, nameOff));
int strBlock = ((2 + nameLen + 3) / 4) * 4; // u16 len + chars, padded to a multiple of 4
int off = nameOff + strBlock; // → damageType
int critOff = off + (attacker ? 16 : 20); // type(4)+percent(8)+damage(4)[+dmgLoc(4)]
if (critOff + 4 > info.BlobSize)
return;
// We're on the game thread (DispatchGameEvent), so InqAttribute2ndStruct is safe.
if (PlayerVitalsHooks.TryReadObjectMaxHealth(pWeenie, out uint maxHealth) && maxHealth > 0)
{
ObjectQualityCache.SetMaxHealth(pWeenie, maxHealth);
uint damageType = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, off)));
uint damage = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, off + 12)));
uint crit = unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, critOff)));
if (damage == 0 || damage > 1_000_000)
return;
int count = Interlocked.Increment(ref _identifyLogCount);
if (count <= 12)
RynthLog.Verbose($"Compat: identify 0xC9 obj=0x{objectId:X8} maxHealth={maxHealth}");
if (_damageEventLogCount < 12)
{
_damageEventLogCount++;
RynthLog.Compat($"Combat: damage evt 0x{eventType:X3} nameOff={nameOff} dmg={damage} crit={crit} atk={attacker} blob={info.BlobSize}");
}
PluginManager.QueueCombatDamage(damage, damageType, crit != 0, attacker);
}
catch
{
}
}
private static int _killNotifyLogCount;
// KillerNotification (0x01AD) is sent to the player ONLY when they kill
// something, at the lethal hit — before the death animation plays out and
// the creature reclassifies to a corpse. That makes it the EARLIEST
// reliable "target dead" signal: the health=0 update and the Monster->Corpse
// flip both land at/after the corpse swap (ACE delays CreateCorpse by the
// full death-animation length), so combat that paces on those would burn a
// second full cast at an already-dead mob. Payload is a single string16 —
// the formatted death message with the victim name embedded; there is NO
// object id (GameEventKillerNotification just WriteString16L's the text).
// We forward the string so the plugin can match it against its one active
// target by name. Same envelope ambiguity as the damage events: eventType
// at +0 (SmartBox-style) or +8 (GameEvent envelope); the string16 follows
// immediately after the eventType u32.
private static void TryQueueKillNotification(IntPtr blob, SmartBoxEventInfo info)
{
if (blob == IntPtr.Zero || info.BlobSize < 6)
return;
try
{
IntPtr payloadPtr = Marshal.ReadIntPtr(IntPtr.Add(blob, NetBlobBufPtrOffset));
if (payloadPtr == IntPtr.Zero)
return;
uint et0 = unchecked((uint)Marshal.ReadInt32(payloadPtr));
uint et8 = info.BlobSize >= 12 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(payloadPtr, 8))) : 0;
int strOff;
if (et0 == 0x01AD) strOff = 4; // SmartBox-style: eventType at +0
else if (et8 == 0x01AD) strOff = 12; // GameEvent envelope: eventType at +8
else return;
string? deathMessage = ReadString16Latin1(payloadPtr, strOff, info.BlobSize);
if (string.IsNullOrEmpty(deathMessage))
return;
if (_killNotifyLogCount < 12)
{
_killNotifyLogCount++;
RynthLog.Compat($"Combat: kill notify strOff={strOff} blob={info.BlobSize} msg='{deathMessage}'");
}
PluginManager.QueueKillNotification(deathMessage);
}
catch
{
}
}
// Reads an AC string16 (u16 char count + that many 1-byte cp1252 chars) at
// the given payload offset, bounded by the blob size. Returns null on a
// missing/oversize length so a corrupt field can't allocate wildly inside
// this main-thread detour. High bytes are taken as Latin-1 (monster names
// are ASCII in practice). One small string alloc per kill — the same
// pattern ChatCallbackHooks already uses for inbound chat capture.
private static string? ReadString16Latin1(IntPtr payloadPtr, int off, uint blobSize)
{
if (off < 0 || off + 2 > blobSize) return null;
int len = (ushort)Marshal.ReadInt16(IntPtr.Add(payloadPtr, off));
if (len <= 0 || len > 256) return null;
if (off + 2 + len > blobSize) return null;
Span<char> chars = stackalloc char[len];
for (int i = 0; i < len; i++)
chars[i] = (char)Marshal.ReadByte(IntPtr.Add(payloadPtr, off + 2 + i));
return new string(chars);
}
// ── RE instrumentation (TEMPORARY) ───────────────────────────────────
// Diagnose why combat GameEvents (damage 0x1B1/2, kill 0x1AC/AD, health
// 0x1C0) don't reach the parsers on the user's Decal-coexistence client.
// Logs three things, all capped: (1) detour ALIVE + busyness — proves the
// hook fires and isn't on the wrong function; (2) any combat-range event's
// first dwords (COMBAT) so we see the opcode + envelope offset; (3) for the
// game-event detour, the first 30 events unfiltered (GE-ANY) so structure is
// visible even if the opcode sits at an unexpected offset. Remove once fixed.
private static int _geFire, _sbFire, _geCombat, _sbCombat, _geAny;
private static unsafe void DiagEvent(string tag, bool isGe, IntPtr blob, SmartBoxEventInfo info)
{
int fired = isGe ? ++_geFire : ++_sbFire;
if (fired == 1 || fired == 50 || fired % 500 == 0)
RynthLog.Compat($"{tag}-ALIVE fired={fired} lastOp=0x{info.Opcode:X4} blob={info.BlobSize}");
if (blob == IntPtr.Zero || info.BlobSize < 4)
return;
try
{
IntPtr p = Marshal.ReadIntPtr(IntPtr.Add(blob, NetBlobBufPtrOffset));
if (p == IntPtr.Zero)
return;
uint sz = info.BlobSize;
uint et0 = unchecked((uint)Marshal.ReadInt32(p));
uint w1 = sz >= 8 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(p, 4))) : 0;
uint et8 = sz >= 12 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(p, 8))) : 0;
uint w3 = sz >= 16 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(p, 12))) : 0;
uint w4 = sz >= 20 ? unchecked((uint)Marshal.ReadInt32(IntPtr.Add(p, 16))) : 0;
bool combat = (et0 >= 0x0180 && et0 <= 0x01E0) || (et8 >= 0x0180 && et8 <= 0x01E0);
if (combat)
{
ref int c = ref (isGe ? ref _geCombat : ref _sbCombat);
if (c < 50)
{
c++;
RynthLog.Compat($"{tag}-COMBAT sz={sz} w=[{et0:X8} {w1:X8} {et8:X8} {w3:X8} {w4:X8}]");
}
}
else if (isGe && _geAny < 30)
{
_geAny++;
RynthLog.Compat($"GE-ANY sz={sz} w=[{et0:X8} {w1:X8} {et8:X8} {w3:X8} {w4:X8}]");
}
}
catch { }
}
// WireParseIdentifyFromBlob / TryCacheVitalsFromIdentify removed 2026-05-18:
// calling CombatActionHooks.TryParseIdentifyResponse from an [UnmanagedCallersOnly]
// detour on AC's main thread triggers ObjectQualityCache dictionary growth
// (allocation) for each newly-identified mob → GC during the reverse-P/Invoke
// transition → RhpReversePInvokeAttachOrTrapThread2 STATUS_FAIL_FAST (silent
// process death, no dialog). Mob health display falls back to ratio (%) mode;
// absolute values can be restored via a pre-allocated pump-thread ring buffer.
private readonly record struct SmartBoxEventInfo(uint Opcode, uint RawObjectId, uint BlobSize);
}