Backport the modern C_NewItems system - IsNewItem / RemoveNewItem /
ClearAll - flagging items freshly added to bags as "new", cleared once
acknowledged. Vanilla has none of the machinery (no DBC, no server data),
so it is pure client-side bookkeeping, done entirely in C++ like retail.
Newness is keyed on each item's instance GUID (read off the CGItem), so a
flag survives the item being moved between slots - impossible for a Lua
addon, which can only track by (bag, slot). Bags 0..4 only; equipment and
bank are out of scope, matching retail.
The feed is event-driven, not polled: it subscribes to Bag::UpdateDelayed
(which co-hooks the engine's three BAG_UPDATE fire sites), so a bag rescan
runs only on frames where a bag actually changed. A one-time baseline taken
~1.5s after login (re-armed on character switch) keeps items owned at login
from being flagged. BAG_NEW_ITEMS_UPDATED fires when the set changes.
Consolidations along the way:
- New Bag::UpdateDelayed::AutoSubscribe exposes the authoritative
"a bag changed this frame" signal as a C++ subscription.
- New Item::Location::ContainerInventory factors the CGContainer -> its
inventory (vtable +0x10) dispatch hand-rolled in item/Count,
item/AverageLevel, and equipmentset/Locations; all now share it.
- New Item::Location::EquippedBagInventory (equipped bag -> inventory) plus
the FUN_GET_EQUIPPED_BAG_GUID / OFF_CONTAINER_GET_INVENTORY offsets.
- NewItems resolves the player via the shared Unit::Identity::PlayerObject.
The repo was internally inconsistent: the LICENSE file is GPL v3 but every
src/ header carried the LGPL v3 notice and the README said "LGPL v3 or
later". LGPL was also the wrong fit — this is an injected mod plus a
bundled addon, not a library other code links against, so LGPL's linking
exception buys nothing.
It's also required: src/voicechat/Tts.cpp is ported from awesome_wotlk's
VoiceChat.cpp, which is GPL v3, and a derivative of GPL code cannot be
relicensed under more permissive terms. Dependencies stay compatible —
MinHook (BSD-2) and the nampower-mirrored packet shapes (BSD) are
GPL-compatible, and SAPI is covered by the system-library exception.
Swept "GNU Lesser General Public License" -> "GNU General Public License"
across all 257 src/ headers and changed the README license line to match
the GPL v3 LICENSE file. Comment-only; no build impact.
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.
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.
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.