mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
46597f6587213e1207c91c8c6baa82a204cb1e9d
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7531223b9a |
nameplate: assign stable slots instead of a compacting list
Switch nameplateN indexing from a compacting vector (append on ADDED, erase + shift-down on REMOVED) to retail-exact slot assignment: a plate keeps its slot for its whole lifetime, a removal frees the slot, and the next new plate reuses the lowest free one. Survivors are never renumbered when another plate is removed - matching modern WoW, where a middle plate vanishing leaves the others' tokens unchanged and its slot goes vacant until reused. g_orderedGUIDs -> g_slots (sparse; free slots hold GUID 0, trailing empties trimmed). GetGUIDByIndex returns 0 for a free or out-of-range slot; new GetSlotCount exposes the high-water mark. The reverse token walk in Unit::Identity now scans 1..GetSlotCount() and skips gaps instead of stopping at the first 0. The per-plate observer lifecycle is unchanged (keyed on GUID: register on ADD, unregister on REMOVE). Verified in-game: 3 plates in slots 1/2/3, removing the middle one leaves slots 1 and 3 occupied and 2 vacant - no renumber. |
||
|
|
d7078827fd |
unit: fire per-token unit events for focus and nameplateN
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. |
||
|
|
d9102bae3b |
Relicense source headers from LGPL to GPL v3
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. |
||
|
|
96b0cf6075 |
FocusUnit / ClearFocus + focus unit token (#2)
* FocusUnit
* UnitTokenFromGUID: place focus after target, not after mouseover
Retail's documented scan order is
player -> vehicle -> pet -> party -> partypet -> raid -> raidpet
-> nameplate -> arena -> arenapet -> boss -> target -> focus
-> npc -> mouseover -> softenemy -> softfriend -> softinteract
Earlier commit placed focus at the very end. Moves it into the
target-adjacent slot so a focused unit reverse-resolves to "focus"
the moment it isn't also "target", matching retail.
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
|
||
|
|
da8454c7c2 |
C_NamePlate API + nameplateN unit tokens (#1)
* 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> |