mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
Make the synthetic focus / nameplateN unit tokens first-class sources of the standard per-token unit events (UNIT_HEALTH, UNIT_MANA, UNIT_AURA, UNIT_LEVEL, ...): arg1 == "focus" / "nameplateN" now fires just like "party1", so focus and nameplate frames can update event-driven instead of polling. Vanilla fires these events only for units it "watches" (target/party/raid/pet/mouseover) - FUN_0060c520 recomputes a unit's token-category mask and, on 0->nonzero, FUN_0051bbb0 registers bank-UNIT descriptor-field observers whose callback broadcasts the field's event to the guid's tokens (field index == event id; health +0x40 = event 16 = UNIT_HEALTH). Focus and nameplates are not watch categories, so they never fired. New Unit::TokenObserver replicates that watch registration (FUN_0051bbb0's field set + per-index sizes) with a caller-supplied callback, via the engine's own observer registrar - the same API Player::Equipment uses. No hooks: zero MinHook trampolines, hence no collision risk (the reason this beats co-hooking the broadcast). The registrar appends a fresh node per (guid, field), so our observers coexist with the engine's - a unit that is target AND focus AND a nameplate fires all three tokens. Node lifetime is engine-managed (nodes die with the object; unregister no-ops post-despawn). - Focus: register/unregister in Unit::Focus::Set. - Nameplates: register on NAME_PLATE_UNIT_ADDED, unregister on _REMOVED and (all) in PrepareForReload, since objects survive /reload; the callback resolves the changed guid to its current plate index at fire time. Offsets cross-confirmed against nampower's offsets.hpp (SendUnitSignal 0x515e50, StringParamFormat "%s" 0x82e280, SignalEventParam 0x703f50, UNIT_HEALTH 16); the GUID->token reverse map nampower left as a TODO is FUN_00515c50.