mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
Fires CURSOR_CHANGED(isDefault, newCursorType, oldCursorType, oldCursorVirtualID) and registers the Enum.UICursorType table its two type arguments index. Classic Era's Vanilla PaperDollFrame uses this event for the equip-slot highlight, so ported UI code looks for it. The trigger is a once-per-frame diff of the cursor globals on Tick::WorldTick, NOT the engine's CURSOR_UPDATE. That event only has three fire sites and none announces a non-item pickup: the cursor clear FUN_00495190 fires for every type but zeroes VAR_CURSOR_TYPE first, so the read there always says "empty", while FUN_00494b60 and FUN_004950f0 fire after a set only when a GUID or itemID is present. An interceptor on CURSOR_UPDATE therefore reported item cursors correctly and nothing else -- money, spells, macros and the two pet cursors were silent. There is no common choke point on the set side (each type writes VAR_CURSOR_TYPE in its own path), so a state diff is what covers them all. CURSOR_UPDATE is left completely untouched. Info::ReadRaw is the cheap half of the diff -- seven plain global reads, no object-manager lookup -- so the bag-item itemID resolve only happens on a frame where something actually changed. The cost of the diff is that the event lands one frame after the change. Also fixes a bug this uncovered in the shipped GetCursorInfo: Script_PickupMacro converts the Lua 1-based index into a macroID via VAR_MACRO_SLOT_MAP before storing it, so the cursor global holds e.g. 0x01000003, and PushMacroCursor pushed that straight through as the "macro index". docs/API.md already documented the return as macroIndex, so the contract was right and the code was wrong. Both paths now convert through the engine's own reverse scan FUN_MACRO_ID_TO_SLOT, the same conversion the legacy CreateMacro wrapper does. VAR_CURSOR_MACRO_INDEX is renamed VAR_CURSOR_MACRO_ID, since the old name invited the mistake. Verified in-game: item, spell (vanilla and Turtle-range IDs) and macro cursors all fire with correct old/new types, the repeated CURSOR_UPDATEs from moving a stack produce no CURSOR_CHANGED, and GetCursorInfo returns slot 4 for a General macro and 21 for a Character one. oldCursorVirtualID has no faithful equivalent here -- the modern client's "virtual ID" is not a concept this client has -- so it carries the previous content's identifying number and says so in the docs. No consumer is known to read it; Blizzard's own users treat the event as a bare notification.