Vanilla 1.12.1 requires a manual click on the AoE reticle to land a
ground-target spell. This pair of functions fires the cast (or
on-use item spell) and immediately commits placement at the
cursor's current world position, matching modern `[@cursor]`
semantics:
C_Spell.CastAtCursor(spellID)
C_Item.UseAtCursor(itemInfo)
Chains the engine's own primitives — name-resolver to spellbook
slot, cast dispatcher, then a screen→world raycast via the existing
mouseover machinery and the placement-commit function. Cancels
cleanly when the spell isn't ground-target or the cursor is over
UI / off-screen.
Also extracts the bag-search pattern (used by `UseAtCursor` and
existing by-name action APIs) into `Item::Location::FindByArgInBags`,
alongside the existing `FindByItemID` / `FindByGUID` family.
Vanilla 1.12.1 hashes FrameXML.toc + Bindings.xml + each addon's
contents and compares against signature blobs (Interface\FrameXML.sig
+ per-addon stored hash). ClassicAPI's file-read hook diverges those
in memory — Bindings.xml splice and the embedded !!!ClassicAPI addon
— so the engine fires FUN_00401560(10) and terminates with "Your
game interface files are corrupt".
Hook FUN_00401560 and drop calls with code 10. Other codes (login
failures, etc.) pass through unmodified. Stock vanilla binaries
(WoW.exe without a runtime patcher) now load ClassicAPI without
needing TLS-bootloader-style modifications.
Mail helms were showing up for cloth classes — the function only
checked invType→slot shape, not whether the player could actually
equip the item.
Adds a proficiency gate using the engine's per-itemClass mask table
at [0x00C4D4A0], populated by the SMSG_SET_PROFICIENCY handler at
0x005E7B70. `table[itemClass] & (1 << subclass)` is the same lookup
4.3.4's Script_GetInventoryItemsForSlot does (via FUN_00553AD0 ->
DAT_00DD4D38), and the same source the engine's own tooltip red-text
coloring and cursor-drop equip check read from. Covers both armor
and weapon proficiencies in one mask lookup.
Backports the modern WoW global that surfaces whatever's picked up
on the cursor. Reads the engine's cursor-state globals (type tag at
0x00B4D900 + per-type payload slots) and returns one of:
nil empty cursor
"item", itemID, itemLink bag item (full per-instance link)
"item", itemID, itemLink drag-source item (action bar /
equipment / mail) — itemLink
recovered by walking equipment+bags
for the live CGItem, same trick the
action-bar tooltip uses to display
enchant info on dragged gear
"money", copper gold-split / PickupPlayerMoney
"spell", slot, type, spellID spellbook spell
"macro", index macro
"merchant", merchantSlot merchant-frame item
Also splits the credstore/login offsets back into the same enum
(resolves the lingering merge in Offsets.h) and adds a shared
Item::QualityColor helper that reads the engine's `"|cffRRGGBB"`
color-prefix table at 0x00854124 directly instead of duplicating
the hex palette in cursor/Info.cpp and item/Tooltip.cpp.
New Item::Location::FindByItemID walks equipment then bags looking
for the first CGItem matching an itemID — used by the drag-source
link recovery.
* C_NamePlate.GetNamePlateGUIDs
* fixed NameCache header
* C_NamePlate.GetNamePlates
* GetNamePlates will show blizzard nameplates as well
* C_NamePlate.GetNamePlateForUnit
* nameplate events
* C_NamePlate.GetNamePlateForGUID
* NAME_PLATE_CREATED now sends frame as argument
* document verification provenance for nameplate-adjacent offsets
- Offsets.h: annotate LUA_REF_REF / LUA_REF_UNREF with their Ghidra
decompile shapes (FREELIST_REF chain + LUA_REFNIL/NOREF sentinels)
so the next maintainer doesn't have to re-derive whether these are
really luaL_ref/unref.
- Walk.h: warn that the 0x00B41414 player global overlays multiple
sub-objects; reading +0x1C/+0x24 here is safe, feeding it to the
inventory path crashes.
* harden nameplate frame push against stale registry refs
PushNamePlateFrame now type-checks the rawgeti'd value; on a stale
slot (post-/reload windows, freed slot, etc.) it pops and falls back
to a fresh wrapper instead of returning whatever the registry happens
to hold at that index in the new Lua state. Script_GetNamePlates now
routes through the same helper so it inherits the guard.
Also document the bound on g_seenPlates: pool reuse via DAT_00c4d920
caps it at the session's peak simultaneous-plate count.
* support nameplateN unit tokens
Hook FUN_TOKEN_TO_GUID so every Script_Unit* (UnitName, UnitGUID,
UnitHealth, UnitClass, UnitExists, ...) accepts `nameplateN` tokens
and their `target`-suffix chains (`nameplate1target`,
`nameplate1targettarget`) — modern WoW semantics on the vanilla
engine. Hook is gated by an SStrCmpI prefix check; non-nameplate
tokens fall straight through to the original resolver.
- Ordered GUID list is maintained alongside the existing
NAME_PLATE_UNIT_ADDED / _REMOVED diff. Append on ADDED, erase on
REMOVED — creation-order, stable for a plate's lifetime, modern
semantics.
- Suffix walker mirrors the engine's own LAB_005159d3 walker
instruction-for-instruction: SStrCmpI "target" + ObjectByGUID +
read UNIT_FIELD_TARGET (m_objectFields + 0x28).
- SStrCmpI typedef is __stdcall, not __cdecl. The function ends with
ret 0xc; declaring it cdecl makes MSVC emit a redundant add esp, 12
on top of the callee cleanup, drifting ESP +12 per call and
crashing somewhere deep in Lua once L gets read from a poisoned
stack slot.
- m_objectFields is a *pointer* at obj+0x110, not an inline byte
offset. Two dereferences (mov eax, [obj+0x110]; mov edi, [eax+0x28]),
not one — earlier version mistook the inline-vs-pointer shape and
read instruction bytes as GUIDs.
* document nameplateN unit-token support
- API.md NamePlate section: replace the "scope vs. modern (deferred)"
callout with a pointer to the new Unit tokens subsection; update
the events table and "modern divergence" callout to explain why
the GUID payload remains (engine dispatcher can't carry Lua values
through %s/%d/%u/%f format codes) even though the token form now
works.
- New "Unit tokens (`nameplateN`)" subsection covering the resolved
~30 UnitX functions, creation-order semantics, suffix chains
(`nameplate1target`, `targettarget`), and the SStrCmpI prefix-gate
implementation detail.
- UnitTokenFromGUID's "post-1.12 omitted" list: nameplateN is no
longer engine-unsupported (we hook the resolver) but it's still
not used as a reverse-lookup key — indices can be reassigned
during a session, so it'd be unstable.
- README: new Unit tokens table row pointing to the API.md anchor.
* return stable nameplate wrapper across calls
PushNamePlateFrame was building a fresh Lua table on every call for
unregistered (default vanilla) nameplates — so fields addons set on
the wrapper they received in NAME_PLATE_CREATED were lost on the
next GetNamePlateForUnit lookup. pfUI specifically writes
`plate.nameplate = styledButton` on the CREATED-delivered table to
hand its overlay back through our API, and that field was
disappearing.
Fix: pin the first wrapper for each nameplate pointer in the Lua
registry via luaL_ref, cache the refkey in g_wrapperRefkeys, and
rawgeti on every subsequent push. Same table identity for the life
of the engine plate. Bound by the CGNamePlateFrame pool size (~80).
Cleared on /reload via a new NamePlate::Info::PrepareForReload()
wired into FrameScript_Initialize_h next to the existing
Event::Custom and NameCache reload hooks — stale refkeys would
otherwise point into the freed registry.
* NAME_PLATE_UNIT events now fire token
* nameplate events: ship "nameplateN" tokens, delegate wrappers to engine
Two intertwined changes that together make nameplate-mod addons
(pfUI) survive pool recycle.
1. NAME_PLATE_UNIT_ADDED / _REMOVED arg1 is now the "nameplateN"
unit token, matching modern WoW exactly. For REMOVED we compute
the token before erasing from g_orderedGUIDs so the handler can
still resolve the leaving unit. Addons that want a stable hash
key call UnitGUID(arg1) to convert.
2. PushNamePlateFrame now delegates to the engine's own
FrameScript_Object::ScriptRegister (0x00701BD0) instead of
maintaining our own luaL_ref'd wrapper cache. Per-pointer the
engine builds a wrapper table once, refs it into the registry,
and stores the refkey at nameplate+0x08 - every code path
(ours, addons' CreateFrame(parent) extraction, the engine's own
internal pushers) then funnels through
rawgeti(REGISTRY, nameplate+0x08) and gets the same Lua table.
The prior approach kept our own wrapper alongside the engine's
once pfUI's CreateFrame inside NAME_PLATE_CREATED caused the
engine to register the underlying frame itself - fields set on
our wrapper (plate.nameplate = decoratedButton) disappeared from
the API surface even though they still existed on the orphaned
table. Single-source-of-truth fixes it. The refcount-pinning
caveat CLAUDE.md warned about is benign for pool-managed
nameplates (never destroyed during a session).
Also clear seenPlates / lastTickPlates / orderedGUIDs on
FrameScript_Initialize so currently-visible plates refire CREATED
+ UNIT_ADDED after /reload - re-presents them to the freshly
reloaded UI, matching modern WoW.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
Three new accessors for the equipment-set system that vanilla
exposes only partially:
GetItemSetIDByID(itemID) — modern's 16th GetItemInfo return.
GetItemSetID(itemLocation) — same, by ItemLocation table.
GetItemSetInfo(setID) — full ItemSet.dbc row as a table.
The "what set is this item in" path reads ItemStats_C::m_itemSet
at +0x1C0 (field position derived from VanillaHelpers's struct +
verified-offset arithmetic against the already-confirmed
m_bagFamily at +0x1D0). Cache-miss-warm pattern matches the other
*ByID readers (RequestLoadItemDataByID + listen for
GET_ITEM_INFO_RECEIVED).
GetItemSetInfo reads ItemSet.dbc directly — record layout decoded
from the per-record loader at FUN_0057BBA0:
+0x00 ID +0x6C SetSpellID[8]
+0x04 Name[8] (8 locales!) +0x8C SetThreshold[8]
+0x24 unknown +0xAC RequiredSkill
+0x28 ItemID[17] +0xB0 RequiredSkillRank
180-byte stride, 45 columns. ItemSet has only 8 locale slots (vs
Spell.dbc / ChrRaces.dbc's 9), so the name read clamps the global
VAR_LOCALE_INDEX to [0..7] to avoid reading past the locale array
into the unrelated +0x24 field.
Return table: { setID, name, items[], bonuses[{spellID, threshold}],
requiredSkill, requiredSkillRank }. Verified against Magister's
Regalia (setID 181): 8 items, 4 bonuses at thresholds 2/4/6/8.
Returns the spell's reagent list as an array of {itemID, count}
tables, one entry per non-empty reagent slot. Reads directly from
Spell.dbc; stops at the first empty slot, matching the engine's
own tooltip reagent loop.
Discovered while implementing that the reagent offsets we had in
Offsets.h were wrong:
Old: OFF_SPELL_REAGENT_ID = 0x110, OFF_SPELL_REAGENT_COUNT = 0x130
New: OFF_SPELL_REAGENT_ID = 0xA8, OFF_SPELL_REAGENT_COUNT = 0xC8
The old values came from a CMaNGOS-style SpellEntry schema that
doesn't match 1.12.1's actual record layout for reagent fields.
Verified empirically by decompiling BuildSpellTooltip (0x0052E610) —
its reagent loop iterates `localRec + 0x2A` (dword arithmetic =
byte +0xA8) as itemIDs and indexes [+8] (= byte +0xC8) for counts.
We already had a separate OFF_SPELL_RECORD_REAGENTS = 0xA8 entry
used by the tradeskill/craft scrapers (correct value), so it was
silently inconsistent — they were reading the same field by two
different names, one of which was wrong.
Fixed latent IsUsableSpell bug as a side effect: the reagent gate
was reading zeros from +0x110 / +0x130 and concluding "no reagents
required" for every spell. Now correctly returns (false, false) for
spells whose reagent the player doesn't have in their bags.
Verified: GetSpellReagents(23028) = {{itemID=17020, count=1}};
IsUsableSpell(23028)=1 with Arcane Powder in inventory.
Consolidated: removed the now-duplicate OFF_SPELL_RECORD_REAGENTS
alias; tradeskill scraper points at the canonical OFF_SPELL_REAGENT_ID.
Returns (inRange, checkedRange) — 40-yard healing-range check
matching modern's shape. Reuses the CGObject::GetPosition vtable
virtual at slot 5 (offset 0x14) that Script_CheckInteractDistance
uses, just with a fixed 1600.0 squared-distance threshold.
Two notable behaviors:
UnitInRange("player") → (false, false). Documented Blizzard quirk
carried over from modern — the function is meant for "is *another*
unit in range" checks, querying yourself is meaningless. Short-
circuited before the position read so checkedRange=false is
unambiguous.
checkedRange=false when the unit's position can't be obtained:
unresolvable tokens, empty party/raid slots, raid members in a
different zone, target with nothing targeted, etc. The position
virtual returns null in those cases.
Vtable shape verified via the bytes at 0x0048BACF / 0x0048BADC
(both unit and player calls pass an out-buffer to vtable[+0x14] —
Ghidra's decomp dropped the player-call buffer push from the
output).
Direct-by-ID item cooldown query. Returns (startTime, duration,
enable) — the same multi-return shape 1.12's
GetContainerItemCooldown(bag, slot) uses — without requiring a
physical slot reference.
Routes through FUN_ITEM_QUERY_COOLDOWN at 0x006E2ED0, which looks up
the item's ItemStats_C record, finds the slot with trigger=ON_USE
(OFF_ITEMSTATS_SPELL_TRIGGER[i] == 0), and queries that spell's
cooldown via the shared FUN_006E13E0 against the player-spell
cooldown manager. The "ON_USE spell's cooldown" interpretation is
how the engine itself surfaces item cooldowns to addons.
Calling-convention gotcha worth flagging: Ghidra labels the first
arg as uint*, but the ItemStats cache lookup uses the integer both
as a hash key and as the cached-entry field-0 match target (which
is a uint*-typed slot), so the decomp inherits the pointer typing.
The actual fastcall value is the itemID itself — passing &itemID
makes ItemStats interpret the stack address as the lookup key and
the call silently fails. Verified via the Hearthstone (6948) test:
&itemID returned (0, 0, 0); passing itemID directly returns
(732120.014, 3600, 1) after use.
GetItemCooldown(itemInfo) accepts itemID / link / numeric string /
name via the shared Item::Arg helper. C_Container.GetItemCooldown
also accepts links because the shared helper extracts them for
free, even though modern's spec says links aren't accepted.
True if the spell is currently being cast, queued mid-GCD, or
channeled by the player. Reads three engine slots and returns true
on any match:
VAR_CURRENT_CAST_SPELL (0x00CECA88) — cast bar; written by the
cast-start helper at FUN_006E4AD0, read by FUN_006E3D30's
is-currently-casting check (which Script_SpellStopCasting
consults before sending CMSG_CANCEL_CAST).
VAR_QUEUED_CAST_SPELL (0x00CECAA8) — the spell pushed aside when
a new cast superseded it mid-GCD; restored to current when the
new cast ends. Covers the "queued to cast next" half of
modern's documented semantics.
UNIT_FIELD_CHANNEL_SPELL (player descriptor +0x228) — channels
(Fishing, Drain Soul, Ritual of Summoning, etc.).
Accepts the full spellIdentifier shape via Spell::Arg::ResolveSpellID
(number / |Hspell:N|h link / known-spellbook name). Closes TODO #32.
Modern table-shape cooldown query. Accepts spellID (number),
spell name (with optional (Rank N) suffix), or |Hspell:N|h
hyperlink. Returns a SpellCooldownInfo table:
{ startTime, duration, isEnabled, modRate }
or nil for spellIDs without a Spell.dbc row. modRate is hard-coded
to 1.0 (vanilla has no haste-on-cooldown mechanic); the
post-vanilla fields (activeCategory, timeUntilEndOfStartRecovery,
isOnGCD) are left unset.
Reads the engine's per-spell cooldown manager via
FUN_SPELL_QUERY_COOLDOWN (0x006E2EA0). Fixed the
(*outDuration, *outStart) argument order while doing this — the
typedef in Spell::Usable had it as (*outStart, *outDuration), which
worked accidentally because both fields are 0 when no cooldown is
active, but produced swapped values when a cooldown was running.
Round-tripped against Blink (1953) to verify the corrected order.
Modern arg-order shape (unit first, questID second; questID-keyed).
Walks the unit's +0xE68 sub-struct quest list at +0x28 — same data
source as the engine's IsUnitOnQuest(logIndex, unit). Single Lua call
covers both "is the player on it" and "is a party/raid member on it"
without making the caller find a matching log index first.
Crash hazard fix: the +0xE68 sub-struct is uninitialized for NPCs
(CGCreature_C). First attempt gated on `[unit + 0xE4] & 1` (the
engine's own pre-check before +0xE68 derefs in SetUnitBuff etc.) but
that wasn't sufficient — passing an NPC token still AV'd in the
quest-list walk. The engine's Script_IsUnitOnQuest gets away with the
weaker gate because its GUID-type-filtered ObjMgr lookup
(FUN_00468460(0x10, ...)) rejects non-player GUIDs upstream;
FUN_RESOLVE_UNIT_TOKEN doesn't have that filter. Switched to
UNIT_FLAG_PLAYER_CONTROLLED, which is the gate Item::InventoryID and
Unit::Flags already use for the same hazard.
While doing that, extracted IsPlayerControlled to Unit::Flags::
(new Flags.h) as the canonical predicate. Removed the file-static
copy in Item::InventoryID and collapsed two inline copies in
Unit::Flags (TestPlayerFlag, ReadGuildKey) to call the shared helper.
Walks the player's buff range for an aura whose Spell.dbc effects
include SPELL_AURA_MOUNTED (78) and sends CMSG_CANCEL_AURA for that
spellID via the existing direct sender. Early-outs on
UNIT_FIELD_MOUNTDISPLAYID == 0 to skip the aura walk when the player
isn't mounted.
Vanilla 1.12 has no Dismount global; addons had to find the mount
buff via GetPlayerBuff and call CancelPlayerBuff with its 0-based
index. Matches Classic Era's no-arg shape.
No-arg drop-current-form, polyfilling the modern singular. Walks the
player's buff slots, scans each spell's Spell.dbc EffectApplyAuraName[3]
at +0x16C and EffectMiscValue[3] at +0x1A8 for the
SPELL_AURA_MOD_SHAPESHIFT (0x24) effect whose misc-value matches the
current form byte, and sends CMSG_CANCEL_AURA via FUN_006E7040 for the
owning spellID.
Offsets validated against both 1.12's Script_CastShapeshiftForm
(0x004B4810) — which does the same scan when re-toggling an active form
— and 3.3.5's Script_CancelShapeshiftForm inner FUN_00726CE0. Vanilla's
public Lua surface only exposes the index-based toggle via
CastShapeshiftForm, forcing addons to know which bar slot the current
form occupies before they can cancel it; the no-arg shape is a lot
easier.
Modern aura-cancel primitives — `CancelUnitBuff` decomposes to these
internally. Both go direct to the engine's CMSG_CANCEL_AURA sender
(`FUN_006E7040` at 0x006E7040, `__fastcall(spellID)`) and skip
Script_CancelPlayerBuff's client-side gates (the per-entry cancelable
flag at +0x0A bit 0x01 and the fallback AttributesEx & 0x04 check on
the spell record). Server is the authority on what's cancelable —
non-cancelable auras are rejected server-side as no-ops either way.
CancelSpellByName walks the player's unit-aura descriptor slots 0..31
(buff range) and matches Spell.dbc localized name case-insensitively.
Buff-only by design — matches modern semantics where dispels go
through separate UX.
Player-only (vanilla server only accepts CMSG_CANCEL_AURA for the
local player's own auras), so neither function takes a `unit` arg.
Pre-validates spellID via Spell::Lookup::RecordForID — the engine's
sender unconditionally derefs [record + 0x1C] after a NULL-on-OOR
record lookup, so skipping the check would AV on bad input.
Synthesize modern's per-form-change event by hooking the engine's
bonus-action-bar refresh helper at 0x004E4FC0 — fires every relevant
UNIT_BYTES_1 broadcast plus once at post-login. Cached-byte gate on
descriptor[+0x212] filters out the recomputes for non-form bytes
(standstate, etc.) the same helper handles. Sentinel -1 for "player
not resolvable yet" distinguishes early-login transients from real
"left a form" transitions.
Vanilla 1.12 only has UPDATE_SHAPESHIFT_FORMS (plural — list-changed).
`expirationTime` now reads from the engine's player-buff table at
`0x00BC6040` (same data path `GetPlayerBuffTimeLeft` uses) when the
unit is the local player. Other units still report 0 — the server
only broadcasts cast/duration for the local player's own auras.
Verified that the engine's ms tickcount matches Lua's GetTime() *
1000, so `expirationMs * 0.001` lands directly on the GetTime
timeline with no epoch reconciliation needed.
`duration` looks up `Spell.dbc.m_durationIndex` (+0x78) →
SpellDuration.dbc and applies the `(effLevel - spellBaseLevel) *
perLevel + base` scaling the engine uses internally, capped at max.
Populated for any unit (the base duration is identical regardless of
who's affected); talent / glyph extensions aren't included here since
those are caster-side and already baked into `expirationTime` on the
caster's side.
First attempt had the wrong field offset for spellID in the buff
table — read +0x0C (untalented rank, returned by Script_GetPlayerBuff
as its second result) instead of +0x04 (the actual spellID, used by
Script_GetPlayerBuffTexture to look up Spell.dbc). Fixed before this
commit.
This unblocks `buff.lua` bookkeeping (the bid-tracking ring-buffer
exists only to compensate for the missing time data) — addons can
now use modern UnitAuras semantics directly.
`C_Item.UseItemByName(itemInfo)` mirrors 3.3.5's function: locate the
item in bags, hand the CGItem pointer to the engine's by-pointer use
primitive `FUN_005D8D00`. That's the same fallback path
`Script_UseContainerItem` ends up in after every cursor-mode branch
(repair, spell-cast targeting, drop-on-bag) is skipped — branches
that don't fire for an addon-issued call from a clean cursor.
`C_Container.UseHearthstone` was doing the same Lua-stack roundtrip
(push bag/slot, call Script_UseContainerItem); now it locates the
hearthstone-equivalent item and calls `FUN_005D8D00` directly,
matching UseItemByName's shape.
First attempt of UseItemByName called `FUN_005E1840` thinking it was
the use primitive — turned out to be the equip/trade path that puts
the item on the cursor in mode 1 and triggers AutoEquip. The
"This item cannot be equipped" error from a hearthstone exposed the
mistake.
Mirrors modern WoW's `GetActionInfo(slot)` against the vanilla 1.12.1
action table at `0x00BC6980`. Top-4-bits encode the type tag; the
`0x40000000` tag is ambiguous between macros and bag-items and is
disambiguated by walking the 36-entry macro-slot map at `0x00BDCC60`
(same trick SuperWoWhook's modified `GetActionText` uses).
Returns:
- empty: nil
- spell: "spell", spellID, "spell"
- macro: "macro", macroSlot (1-based)
- item-by-ID: "item", itemID
- bag-item: "item", nil (itemID extraction from the bag-action
hash struct still needs reversing;
in practice these slots are stale —
the engine's HasAction returns false
for them)
Crash repro: moving items in bags faulted at EIP=0x00000777 after a
handful of descriptor updates. Root cause was a calling-convention
mismatch on the keyring hook added in b05ff06.
The Ghidra signature quoted in that commit said three stack args
(__thiscall unsigned(this, guidLo, guidHi, *current)), but the actual
function in the Octo binary at 0x004F8DB0 ends with `RET 0x10` —
four stack args, 16 bytes of callee cleanup. Our hook declared three,
emitted `RET 0xC`, and under-cleaned the caller's stack by 4 bytes per
call. After enough descriptor updates the cumulative drift caused a
later RET to pop a non-return-address value and jump there.
Verified by reading the actual binary at that VA: prologue references
[EBP+8/C/10] and the function epilogue is `RET 0x10` at 0x004F8E9B.
Vanilla 1.12 registers GetCVar/SetCVar/RegisterCVar/GetCVarDefault
and RunScript only on the in-game FrameScript engine; GlueXML had
no way to reach them. Mirroring is pointer-aliasing — same Script_*
C functions registered on glue via RegisterGlueFunction. CVar
storage is process-global so writes from either state are visible
on the other. C_CVar.GetCVarBool (our existing polyfill) gets a
GlueModuleAutoRegister alongside the existing in-game one.
The single addon driving the C_CharacterList.* bindings moved off
them; keeping the engine-hook surface live for a feature nobody
calls is dead weight. Snapshot record layout, hook target, and the
"why memory-only" rationale all land in TODO #95 so another DLL
can pick it up without re-deriving any of it.
Module-self-registration pattern for the glue Lua state, mirroring the
existing in-game ModuleAutoRegister. Modules opt in with a file-scope
GlueModuleAutoRegister; the hook on FUN_0046ABB0 (master glue init,
single caller, 35-byte linear function) fires their callbacks after
the engine finishes registering its own 109 glue functions onto the
freshly-created glue state.
Prior attempt hooked the inner FUN_0046DDF0 60-fn batch trampoline and
crashed on Octo, likely from sibling-DLL collision on a small target.
The linear caller is larger and less obvious; no crash, hook fires
cleanly on initial launch and every world->glue return.
Pattern-search of .text confirmed exactly three FUN_FIRE_EVENT(0x148,
"%d", ...) call sites in 1.12.1. Two were already covered; the third
lives inside FUN_004F8DB0 — the bag descriptor change callback. Its
keyring branch (slot range 0x51..0x70) fires BAG_UPDATE directly
without going through FUN_004F9370, which was the documented coverage
gap (CLAUDE.md / TODO #67).
Ghidra decompile gave us the calling convention:
__thiscall unsigned(void *bagDesc, uint, void *, uint *)
Wired as __fastcall with a dummy EDX param — same trampoline trick
used for Frame::RegisterEvent in DllMain. The non-keyring branch of
FUN_004F8DB0 still calls into FUN_004F9370 which is also hooked, but
double-fire is harmless: g_pending is idempotent until the per-frame
drain clears it.
Script_AutoEquipCursorItem is a thin Lua wrapper that just resolves
the local player and __thiscall's the engine helper at 0x005E1480.
Cut out the middleman.
Also drop FUN_SCRIPT_EQUIP_CURSOR_ITEM and FUN_SCRIPT_CURSOR_HAS_ITEM
offsets — no callers remain after recent refactors.