FUN_TOKEN_TO_GUID gates "player" on the object-manager lookup, which
drops out transiently during zone transitions / brief CGPlayer rebuilds
even though [VAR_LOCAL_PLAYER_PTR + 0xC0] still holds a valid GUID.
Short-circuit the bare "player" token to read the canonical pointer
directly so we match modern WoW's semantics. Suffixed tokens still go
through the engine so the chained `.target` walk works.
Doesn't help at addon file-load on first login — the GUID isn't
populated anywhere in the engine until SMSG_UPDATE_OBJECT runs in the
main loop after FrameScript_Initialize returns. Addons that need it at
boot have to wait for PLAYER_LOGIN.
`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.
Adds the GameTooltip row entry in the README + a per-method section
in docs/API.md covering the tooltip shape, localization behavior
(Blizzard FrameXML globals with English fallbacks), and the
storage-format change that persists itemID alongside GUID per slot
to support naming missing items.
Registers `SetEquipmentSet` on the GameTooltip method registry,
mirroring the 4.3.4 implementation at 0x0046E690. Builds a tooltip
with header + counts (equipped / in inventory / ignored) + one line
per missing item.
Storage format now persists itemID alongside GUID per slot
(`slot N guid=0xHEX item=ID`), so missing items can be looked up by
name in the item cache even when the live CGItem is no longer in the
client's object map. Backward compat: pre-itemID files load fine and
fall back to a `%d missing` summary line for those slots.
Adds `Game::Lua::PushLocalizedString` and `PushLocalizedFormatInt`
helpers — generic lookup of `_G[name]` with a C-string fallback for
servers stripped of standard GlobalStrings. The tooltip uses these
for the four count lines via Blizzard's `ITEMS_VARIABLE_QUANTITY`,
`ITEMS_EQUIPPED`, `ITEMS_IN_INVENTORY`, `ITEM_SLOTS_IGNORED` keys,
and for the per-missing-item line via `ITEM_MISSING`.
AddOn side: a `GlobalStrings.lua` companion provides English defaults
for those five keys plus a `ShowEquipmentSet()` test helper in
Constants.lua.
First implementation passed `nargs=4` to `lua_call` where the stack
needed 5 (self + text + r + g + b for `tooltip:SetText`) — Lua then
treated `self` as the function, surfacing as
`<in C code>: in function 'SetEquipmentSet'` with no Lua frame above.
Fixed before this commit.
Reorders all 30 top-level sections (and the matching Contents TOC
groups) by case-insensitive name. Done via a one-shot Python script
that sliced the file by ## headers and reassembled in sorted order
— no content edits, every per-section sub-bullet and prose block
preserved verbatim.
Also adds the Hooks TOC group that was missing entirely. The Hooks
section existed in the body but had no TOC bullet pointing at it.
Sub-bullet count is unchanged before/after (188 ### subsections),
confirming nothing was dropped during the reshuffle.
Adds README + docs/API.md entries for the two new functions, plus a
correction to the UseHearthstone entry — it still described the old
Script_UseContainerItem dispatch after the 30b3d91 refactor that
routed it through FUN_ITEM_USE directly.
The GetActionInfo entry calls out the known gap: the 0x40000000
non-macro branch surfaces type "item" but nil for the id, since
extracting the itemID from the bag-action hash struct needs more
reversing than landed in 509fbfe.
`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.
A buggy hook was breaking the wrapped path because the callback ran
through lua_call; switching to lua_pcall mirrors 3.3.5's FUN_00817050
and matches the actual safety property of hooksecurefunc — the
original's results always reach the caller. Stack shuffle now sinks
results below the args once instead of duplicating args twice, so the
wrapper uses ~nargs+nresults slots and drops the O(nargs^2) Remove
loop.
Tried hooking the inner aura tooltip builder (FUN_0052F880) to mirror
its spellID into a side-table, then surfacing it from
GameTooltip:GetSpell/HasSpell. That consistently crashed in pfUI's
hooksecurefunc-wrapped path with the trampoline executing from
corrupted JIT memory. Reverted; left a note pointing at the next
candidate design (hooking the Script_* setter functions instead of
the inner builder).
Pulls GetSavedCharacterOrder / SetSavedCharacterOrder out of the
crowded CharacterList row and into a dedicated "GlueXML calls"
table after the in-game Calls table. Makes the in-world / glue
scope distinction visible at a glance and leaves room for future
glue-side additions.
README CharacterList row gains a GlueXML-only callout for the two new
globals plus their persistence path. docs/API.md gets a dedicated
subsection under CharacterList covering scope (glue Lua state, not
in-world), the API surface, the shared ClassicAPI.txt storage layout,
a usage example, and a brief how-it-works note pointing at
FUN_0046ABB0.
Replaces the planning writeup with a short summary of what landed:
final API, storage location, the three infrastructure pieces (glue hook,
GlueModuleAutoRegister, Settings::Account), and the misnamed-offset
note for future callers.
Migrates NameCache's `PersistentNameCacheEnabled` /
`NameCacheScanEnabled` settings and Order's `CharacterOrder.<realm>`
lines onto a single account-scoped settings file. Each module declares
a reset/serialize/parse section at static-init time and the registry
handles the load/save cycle plus account-change detection (re-loads on
autologin switch from the glue screen).
Prior to this, NameCache wholesale-rewrote `ClassicAPI.txt` on every
save and Order owned a separate `CharacterOrder.txt` for the same
account scope. Combining them avoids two files in `WTF\Account\<acct>\`
and lets future per-account modules layer in without coordinating.
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.
Mirrors the thread-message-hook pattern in Input::Modifier. The hook
catches WM_*BUTTON{DOWN,UP} on the engine's main thread before
dispatch, which:
- is event-driven (zero work when idle) vs ~5 GetAsyncKeyState +
GetWindowThreadProcessId calls per WorldTick
- scopes naturally to WoW's message queue, so the foreground-window
check is no longer needed
- catches sub-frame down+up pairs the poll would miss
XBUTTON side-key distinction now comes from GET_XBUTTON_WPARAM
instead of the separate VK_XBUTTON1/2 codes.
The six per-arity helpers (Fire_None / Fire_D / Fire_DD / Fire_DDD /
Fire_SD / Fire_S) all wrapped the same FUN_FIRE_EVENT engine call
with the same eventID<0 early-out — only the format string and arg
list differed. Collapsing into a single template Fire(eventID, fmt,
args...) keeps the printf-style format at the call site and frees us
from adding a new per-arity overload for each new event shape.
Three sites were doing the same 3-call (PushString + PushNumber + SetTable
on GLOBALS_INDEX) to declare integer globals. Promote to a shared helper
that uses RawSet (globals have no __newindex in vanilla 1.12, so the
metatable check SetTable does is dead).
Also lift CLASSIC_API_VERSION out of DllMain.cpp into api/Version.cpp
so it self-registers via ModuleAutoRegister like every other Lua surface,
instead of being a special case wired into FrameScript_Initialize_h.
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.
The Script_SelectGossip* Lua wrappers are thin stack-readers around
internal __fastcall(slot0Based, ...) engine helpers at 0x004E2320 /
0x004E24B0 / 0x004E2600. Call those directly instead of stomping the
Lua stack and tail-calling the wrappers. Also fixes SelectOption to
pass the password arg through (previously dropped — boxCoded options
needed it).
Drops the Lua-stack-stomp-and-dispatch pattern for Script_GetContainerItemLink /
Script_GetInventoryItemLink. Promotes the BuildLinkForCGItem helper that
GameTooltip:GetItem already uses into a shared Item::Link::FromCGItem, then
GetItemLink resolves the location to a CGItem and calls it directly.