mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
4bf2c17e0f413a0e56044c79841f63ef40907bcb
31
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9a8c314d69 |
fix(aura): scope flag-nibble polarity to Turtle
The aura flag nibble does not mean the same thing on every server, and
reading it as polarity everywhere was badly wrong off Turtle.
Stock (vmangos SpellAuraDefines.h + SetAuraFlag): the bits are
CANCELABLE 0x01, EFF_INDEX_2 0x02, EFF_INDEX_1 0x04, EFF_INDEX_0 0x08 —
one per spell effect index that carries an aura, plus cancelable for a
positive aura. No polarity is encoded at all. So testing 0x08 for
"harmful" was really testing "effect index 0 has an aura", which is true
of nearly every aura, and reported almost every BUFF as a debuff.
Turtle (tortoise-wow SetAuraFlag) replaces those effect-index bits with
polarity: 0x04 positive, 0x08 negative. It needs to, because it also
drops the else in the slot search so a debuff spills into 0..31 once the
16 harmful slots are full — the range stops being reliable there and the
nibble is what preserves the answer. Stock keeps a strict either/or, so
nothing ever crosses over and the range is exact.
IsSlotHarmful now picks per server and is the one place that decides.
Every other site defers to it rather than testing either signal.
Identity detection rather than behavioral: on Turtle every nibble is one
of {0x04,0x05,0x08}, while stock nibbles routinely fall outside that set,
so an out-of-set nibble proves stock — but the converse never arrives,
since single-effect stock auras land on 0x08 by coincidence. Stock is
provable, Turtle is not, and the unprovable direction is the catastrophic
one. A Turtle fork still detects (clones keep the TURTLE_* global names).
A non-Turtle server that copied the spill patch falls back to the range
and reports spilled debuffs as buffs, matching what native
UnitBuff/UnitDebuff already do there.
|
||
|
|
b81f672ad7 |
fix(aura): classify auras by polarity flag, not slot range
The server seats buffs in slots 0..31 and debuffs in 32..47 only while it can: once the 16 debuff slots are full, _AddSpellAuraHolder parks further debuffs in free BUFF slots and sets UNIT_FLAG_AURAS_VISIBLE so the client still renders them (tortoise-wow, verified). Classifying by slot range therefore reported those as buffs -- absent from HARMFUL, and wrong in isHelpful / isHarmful. Confirmed live on a 20-aura target: 18 harmful, two of them sitting in buff slots, where the old code returned 16. Every visible aura carries its real polarity in the per-slot flag nibble (SpellAuraHolder::SetAuraFlag writes 0x04 positive / 0x08 negative), so HELPFUL / HARMFUL now select on that instead. All the walkers -- by index, by spell ID, by name, GetUnitAuras, GetAuraSlots -- share one order helper, SlotInFilterOrder, which visits the polarity's home range first and the other range after, so every index is unchanged whenever nothing has spilled. Aura::Source's KindForSlot classifies the same way, keeping the descriptor-drop fallback consistent with the query paths. The out-of-range group array carries spell IDs with no flags, so that path stays range-based -- the seating range is the only polarity it has. GameTooltip:SetUnitAura now bridges the two index spaces. The engine's SetUnitBuff / SetUnitDebuff index their own slot RANGE, which diverges from the polarity index space as soon as a debuff spills, so the method resolves (index, filter) to an absolute slot and hands the engine the index that slot holds within its own range, picking the method by where the slot lives. It counts with the engine's TOOLTIP visibility predicate (FUN_GAMETOOLTIP_AURA_VISIBLE = 0x00534DF0), not the UnitBuff one (0x00519860): the latter adds a per-player immunity-bitmap check off record +0x2B0, so the two index spaces are not interchangeable. Both decompiled to confirm the walks being mirrored. The aura tooltip builder only ever receives spellId / level / stacks, so a debuff parked in a buff slot renders identically through SetUnitBuff. Note this is deliberately MORE than the engine does: stock UnitBuff / UnitDebuff split by slot range and show a spilled debuff as a buff. Retail's contract is the aura's actual polarity, and the descriptor already carries it, so we report that. |
||
|
|
fdbe66b057 |
fix(aura): let a duration rule edit an aura its own trigger creates
Turtle's Bestial Wrath gives the hunter's pet Scent of Blood for 18s, but C_UnitAuras reported 8s and then dropped the timer entirely while the buff was still up. Server-side (tortoise-wow spell_hunter_bestial_wrath) Bestial Wrath neither applies the aura nor carries its duration on the wire: effect 0 is TRIGGER_SPELL(Scent of Blood, 52995), and the script then stretches the holder that trigger just created via SetAuraMaxDuration/SetAuraDuration. Both are plain field writes, and 1.12's only duration packet is scoped to an aura-bearer that is a PLAYER, which a pet is not -- so the client never hears the 18s and keeps the 8s base it computed when the aura landed. Exactly the class of edit Aura::Source's duration rules exist to mirror; two things had to change before one could express it. The affected-aura selector demanded a SpellFamilyFlags overlap, and every Turtle custom spell carries flags of 0 (308 in the hunter family alone), so no mask could ever name this aura. It now takes a family-flag overlap and/or a SpellIconID, at least one of the two -- an icon is shared across a spell's whole rank ladder, so it stays as rank-proof as a flag, and icon 2245 picks out exactly the four Scent of Blood records and nothing else. Registrars reject the mask-0 + icon-0 rule that would match a whole class family, and RefreshDurationByFamily takes the same invariant so the two entry points cannot disagree about what they match. A trigger can also CREATE the aura it edits, which the immediate-apply model could not see. The trigger's SMSG_SPELL_GO arrives before the triggered cast's, so editing at trigger time either matches nothing or is overwritten moments later when the triggered cast stores its own base duration -- the edit is lost either way. Idempotent ops now ARM the target as well, and the next matching store re-applies the edit, from the cast path or the application path, whichever the aura arrives on. Only refresh and set arm: re-running those lands on the same value, while reduce would shave twice and remove would kill an aura that was legitimately re-applied, so Conflagrate behaves exactly as before. The rule reads Bestial Wrath's own duration from the client's spell data instead of hardcoding the server's 18s, so a rebalance that patches the DBC carries over on its own. Fixes brues-code/pfUI#50 |
||
|
|
6304a253dd |
feat(aura): Dark Harvest tick compression; channel-aura pushback restamp
Turtle's Dark Harvest (52550-52552) makes the caster's Affliction dots on the channel target tick 30% faster - and live preserves each dot's tick COUNT, so the dot's real remaining time drains at 130% rate during the overlap and it falls off early with no client-visible aura change (report: gone with ~3 s still showing; Cursive's community calibration models the same `remaining -= 0.30 x overlap`). tortoise-wow's recreation only re-times tick timers and leaves holder duration alone, which does NOT reproduce the early fall-off - so the compression math mirrors live, while the affected-set predicate mirrors the server script (IsDarkHarvestAfflictionPeriodicAura): same-caster warlock-family auras matching the Corruption/Drain Life/CoA/Drain Soul/Siphon Life/CoD mask with a periodic damage/leech effect (the aura-type gate is load-bearing: Turtle's Atrocity shares Corruption's 0x2 bit but is a proc aura - DBC sweep verified; the trigger mask 0x4000000000 selects exactly the three DH ranks). Aura::Source::AddTickCompression: while a caster's trigger-mask aura is live on a target (its cache entry's lifetime: SpellGo -> OnAuraRemoved eviction), that caster's matching entries drain an extra pct% of real time. Anchored math (expiration = anchor - elapsed x pct/100) so frame pacing can't drift it; an external re-stamp (dot recast, duration mod) re-anchors from the fresh value. Caster-paired like the server, so an observed party warlock's DH compresses their dots' timing too. ~1/s UNIT_AURA nudges for event-driven consumers, final nudge at release. Registered Turtle-gated in turtle/DarkHarvest.cpp with the percent read from the rank record's EffectBasePoints[1]+1 (-31 -> 30, fallback 30). Also: MSG_CHANNEL_UPDATE now re-anchors the cached target-side expiration of the player's channel-applied auras (Aura::Source::RestampPlayerChannel). The server shortens every hit target's holder on channel pushback (Spell::DelayedChannel -> DelaySpellAuraHolder) and only tells the caster via the new remaining time, so the SpellGo-stamped expiration read late by the accumulated pushback; self-target holders were already corrected natively via SMSG_UPDATE_AURA_DURATION. This also bounds the compression window under pushback for free. |
||
|
|
292e206dee |
fix(aura): seat descriptor slots on cast captures FIFO, not newest-first
When two casters' same-spellID DoTs land in one descriptor-update batch, the server assigns their slots ascending in cast order (_AddSpellAuraHolder's first-free-slot scan, verified in tortoise-wow) and the client diff dispatcher FUN_00604d00 fires OnAuraAdded in ascending slot order (both loops are plain slot = 0..0x2F walks). The first application therefore belongs to the earliest cast, and seating the NEWEST unbound capture paired the two casters' timers and attribution backwards. Seat the oldest unbound capture instead, bounded by a 3s window that covers instant applications and max-range projectile flight (Fireball's DoT applies at impact) while skipping hit-but-never-applied captures. The old "older = resisted" rationale for newest-first was moot: resisted and immune targets sit in SMSG_SPELL_GO's miss list, which ParseSpellGo never reads, so they never create captures at all. |
||
|
|
ded767bf19 |
feat(aura,turtle): support Turtle's Stinging Nettle serpent sting timers
The hunter talent (403; rank passives 51579/51580) makes Mongoose Bite and triggered fire traps apply the highest known Serpent Sting rank at 20/40% of its duration. Server-side it's a direct AddAura (tortoise-wow ApplyStingingNettle) — no SMSG_SPELL_GO for the sting — so the cache seated it caster-less at the full 15s base. Aura::Source gains a generalized triggered-application rule table (the judgement-attribution shape, rule-driven): a registered trigger's SPELL_GO — local player casts only — arms its hit targets for 2s, and a caster-less application matching the rule's family/mask consumes the arm in StampApplication (player attribution + the server's own max(1, base × pct / 100) with player duration mods). Rules can be gated on a talent passive, read live from the spell-knowledge bitmap at trigger time so respecs are honored. Because the server's re-apply over an existing shorter sting reuses the descriptor slot (no OnAuraAdded — verified in-game with chained Mongoose Bites), the trigger also refreshes the player's existing cached entry in place, honoring the server's keep-the-longer-remaining guard. The arm consume runs BEFORE the WasRecentPlayerCast attribution: the arm names the exact target, while the recent-cast window is spell-scoped only — a real sting cast at unit A must not stamp its full duration onto a nettle application on unit B; a real cast's own application stays protected by the cast-owned entry guard. Turtle::StingingNettle registers the rules behind the Turtle::Detected latch: fire traps by family mask (hunter 0x4 selects exactly the eight trap-effect spells the server's script binding lists — rank-proof), Mongoose Bite by exact IDs (its bit 0x2 is shared with Raptor Strike, which does not trigger nettle). The percents come from the rank spells' own EffectBasePoints[0] + 1 — the same DBC value the server's CalculateSimpleValue reads — with the server's 20/40 fallback. |
||
|
|
0f5b50ea14 |
feat(aura): refresh paladin judgement timers off swings and re-judges
The judgement debuff's duration is maintained server-side with no client-visible aura change: the paladin's white swings refresh it (tortoise-wow Unit::DealMeleeDamage - any nonzero melee damage RefreshHolder's every SPELLFAMILY_PALADIN + SPELL_ATTR_EX3_ALWAYS_HIT aura the attacker cast on the victim), and a re-judge is an in-place holder refresh that dirties no descriptor field. Aura::Source's countdown therefore ran to zero while the debuff stayed up (brues-code/pfUI#45). Two client-side triggers mirror the server exactly: - Swings: Aura::JudgementRefresh subscribes to SMSG_ATTACKERSTATEUPDATE (wire format verified against the server's own SendAttackStateUpdate writer) and on totalDamage > 0 calls the caster-STRICT Aura::Source::RefreshJudgements(victim, attacker) - strict because a swing gives no proof of ownership, and adopting there would let any tank's white swings pin another paladin's judgement timer. - The Judgement cast (20271, the one spell every seal judges through): the debuff itself is cast server-side with no SPELL_GO the client hears (verified live - entries were seated caster-less by OnAuraAdded), so the Judgement cast's own SPELL_GO is what names the owner. HandleSpellGo refresh-with-adoption's the victim's existing judgement entries (the re-judge case) and arms a 2s attribution window that StampApplication consumes to give the freshly applied debuff its caster - which is what makes the strict swing matching work at all. Refreshes re-fire UNIT_AURA via the existing deferred signal; StoreFromCast now signals on its in-place recast path too, since an identity-preserving refresh changes no descriptor field and event-driven aura bars would never re-read the new timing. Ability damage (Crusader/Holy Strike) is deliberately NOT a trigger: melee-class spell damage never routes through the server's refresh block (DealMeleeDamage's only caller is the white-swing path). Verified in-game: every landing swing snaps the cached expiration to now + 10s and pfUI's timer follows; misses/dodges (totalDamage 0) do not refresh; re-judging resets the timer. Fixes brues-code/pfUI#45 |
||
|
|
72c4185026 |
fix(aura): identify a cached aura by its caster and descriptor slot (#21)
* fix(aura): identify a cached aura by its caster and descriptor slot Two casters of one spell on one target are two auras in two descriptor slots, but `Aura::Source` held a single entry per `(target, spellId)`. The second cast overwrote the first caster's `casterGuid` and timing, and `OnAuraRemoved` for either copy evicted the entry backing the survivor. Observable from Lua, with a same-class groupmate debuffing your target: `sourceUnit` names the wrong caster, so a `PLAYER`-filtered query drops your own debuff; and the base-duration estimate stored for the other caster elapses while your talent-extended aura is still up, which `PushEnriched` reports as `expirationTime = 0` — an aura on the unit with no timer at all. Entries are now keyed `(target, spellId, caster)`, the identity the server uses. Recovering which instance a descriptor slot holds needs the two halves joined: SpellGo knows the caster but no slot, `OnAuraAdded` knows the slot but no caster, and they arrive in that order, so the application hook seats its slot on the newest cast capture still awaiting one. `Get` takes that slot and resolves by it first, falling back to the unit's sole entry for the spell — every single-caster case, and the paths with no descriptor to read a slot from. Several entries and no binding resolves to a miss: the caller's unknown-caster defaults beat a coin flip between two casters. `OnAuraRemoved` and `EvictAbsent` retire the instance in the vacated slot rather than every entry sharing its spell ID. * fix(aura): compare unbound-entry freshness wrap-safely FindFreshestUnbound picked the newest unbound capture with a raw `stampMs >` on two absolute engine ticks. That compare inverts across the 2^32 ms tick wrap (~49.7 days uptime, or the rdtsc backend already past 2^31 after a warm reboot), so the OLDER capture would win and OnAuraAdded would seat the descriptor slot onto the wrong cast — mis-attributing that aura's caster and duration. Pick by smallest Time::Clock::Elapsed(stamp, now) instead, the wrap-safe signed difference the rest of the codebase uses for tick math. * fix(aura): keep the observed caster on the aura fallback paths The cache-fallback push paths (the descriptor-drop fallback and the out-of-range group-member fallback) already hold each aura instance's caster and timing — Enumerate copies them straight out of the cache entry. But PushEnriched then re-resolved them through Get(guid, spell, slot), which returns a miss for an unbound entry that shares its spell with another caster's entry. So an aura Enumerate had fully attributed came back out with no sourceUnit/sourceGUID and no expirationTime. Hand the entry's own attribution to PushEnriched as `known` so the fallback reports what the cache already knew instead of re-deriving it. * refactor(aura): route Get and Evict through one FindInstance resolver Get and Evict each hand-rolled the same FindBySlot-then-FindSole ladder — the read-side rule for which instance a slot-bearing query names. Naming it once keeps the two from drifting into resolving the same query to different instances (reporting one caster while evicting another). No behavior change. * perf(aura): bound cache scans to the active high-water prefix Every Aura::Source lookup linear-scanned all 2048 cache slots. Get runs per-aura per-query — hundreds of times a frame when addons poll UnitAura in a raid — so the full scan dominated the read path. Track a high-water mark that Claim (the sole allocator) extends and FlushAll resets, and scan only [0, g_usedHigh). Every used entry lives below the mark, so no lookup can miss one. Outside a raid the working set is a handful of auras, cutting a ~2048-entry scan to ~30; in a raid it drops to the real working set. Claim still scans the full array — as the allocator it must hand out slots beyond the current prefix. --------- Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com> |
||
|
|
39d22ac124 |
fix(time): centralize engine ms-tick reads in Time::Clock
The engine's OS millisecond counter (FUN_OS_TICKCOUNT_MS, same epoch GetTime() scales by 0.001) is unsigned and wraps at 2^32 ms. Nine files each re-derived the reader; several stored the tick into a signed int, so past 2^31 ms (~24.9 days uptime) every timestamp went negative and `startTime + duration` landed in the past -- callers saw every cooldown, aura, and lockout as already elapsed. The same bug shipped three times (the cooldown by-ID getters and C_LossOfControl). Add one source of truth -- Time::Clock (src/time/Clock.h) -- with a uint32 NowMs() and wrap-safe Reached/Remaining/Elapsed helpers, and route every tick reader through it. No module re-derives the reader or hand- rolls a `now < deadline` compare (which inverts across the wrap) anymore. Also fixes the reported cooldown/LoC getters (unsigned out-params, wrap-safe compares) and three latent instances of the same `now < end` inversion found while sweeping: totem/Tracker's two timer getters and aura/Source's cache-eviction pass. Named Time::Clock, not Time::Tick, because a Time::Tick inner name shadows the global Tick namespace (the WorldTick hook) from inside any Time::* file. Discovered by fuffc in #17. |
||
|
|
2d5ecdc493 |
refactor(spell): identify Ferocious Bite structurally, share IsFitToFamily
Carnage's Ferocious Bite gate was a hardcoded list of five rank IDs. Replace
it with the server's own structural test (IsDruidFerociousBite): druid family
+ the Rip/Bite family flag + a direct-damage effect (the damage effect is what
separates Bite from Rip, its DoT sibling that shares the flag). Rank-proof and
covers any Turtle-added rank with no ID list. Verified against the client
Spell.dbc: all five FB ranks are {family 7, flag 0x800000, Effect[0]
SCHOOL_DAMAGE}; Rip shares the flag but is APPLY_AURA, and Rake carries a
different flag.
The family + flag-bit test is the client-side form of the server's
SpellEntry::IsFitToFamily, and Aura::Source::AffectedMatchesRaw read the same
two fields inline, so extract Spell::Lookup::IsFitToFamily and route both
through it. Adds SPELL_EFFECT_SCHOOL_DAMAGE (= 2, verified vs the server's
SpellDefines.h).
|
||
|
|
783ffd05bf |
feat(aura): Carnage Rip/Rake refresh + signal duration-mod changes
Turtle's Carnage refreshes the caster's Rip and Rake off Ferocious Bite, behind a per-combo-point roll whose outcome the client only sees as the combo point the proc returns. A src/turtle/Carnage watcher arms on a Ferocious Bite send and confirms on the first combo-point rise, then refreshes the cached auras. Verified against tortoise-wow spell_druid_carnage: icons 108 (Rip) / 494 (Rake), family bits 0x800000 / 0x1000, caster scoping, and RefreshHolder (restore the aura's own applied duration). A cache duration edit has no engine packet behind it, so nothing re-fired UNIT_AURA and event-driven aura bars never saw the change. The trigger mods (ApplyMod) and the Carnage refresh now enqueue the affected unit, and the WorldTick flush re-broadcasts UNIT_AURA via the engine's own per-token signal (FUN_UNIT_EVENT_BROADCAST), deferred off the SMSG_SPELL_GO subscriber. Also move the two static Turtle duration mods (Conflagrate -> Immolate, Molten Blast -> Flame Shock) from Lua into src/turtle/DurationMods via a new C++ entry Aura::Source::AddDurationMod, and drop the now-unused exact-spellID RegisterAuraDurationModifier Lua export (RegisterAuraDurationModifierByTrigger stays for Shadow Weaving). Based on the approach from @fuffc in #15. Closes #15 |
||
|
|
2612118ff6 |
refactor(object): centralize GUID->object resolution in Object::ByGuid
Every caller of the engine object resolver (0x00468460) re-declared the
same __fastcall typedef and split the GUID into lo/hi by hand -- 30 call
sites across 28 files. Add object/Resolve.{h,cpp} with
void *Object::ByGuid(int typeMask, uint64_t guid, const char *debugName, int priority)
and route every site through it (behavior-identical: same typeMask,
debugName, priority per site; single-uint64 callers pass guid, split-lo/hi
callers reconstruct it).
Also collapse the duplicate offset constant: FUN_CLNT_OBJ_MGR_OBJECT_PTR
was a second name for the same 0x00468460 address as
FUN_OBJECT_RESOLVE_BY_GUID (a single-source-of-truth violation). Remove
it; the ABI-equivalent (u32,void*,u64,int) view it documented is folded
into the surviving constant's comment.
|
||
|
|
722c257acb |
fix(aura): size source cache to the raid working set; never evict a present aura
The Aura::Source cache holds one entry per (target, spellId) for every aura-applying SMSG_SPELL_GO observed — every buff on every unit in view, not just the player's. At 256 entries the table was permanently full in a group or raid, so nearly every new cast fell through Store's overflow branch, which overwrote a blind round-robin slot with no presence or expiry check. That slot was almost always a live buff, dropping its cached caster — the "buff kept its sourceGUID for a few minutes then lost it" report (e.g. Blessing of Wisdom). Size kCacheSize to the realistic worst case (2048 — a fully raid-buffed 40-man plus debuffs, ~80 KB static) so the table stops living at capacity, and replace the round-robin overflow with a presence-aware victim: prefer the least-recently-updated ORPHAN (no live descriptor backing — out of range / despawned), and only touch a still-present entry under true saturation (every one of 2048 slots a live aura, practically unreachable). This extends the descriptor-presence invariant the tick sweep and slot-reuse already honor to the last unguarded eviction path, so an aura still on a resolvable unit keeps its source for its whole life. Verified in-game: 30+ minutes in a full Stormwind with no source loss. |
||
|
|
7caee620e8 |
fix(aura): make C_UnitAuras sourceGUID persist and infer self-buff casters
Two changes so an aura's source stops vanishing: Pin observed casters. The WorldTick expiry sweep (and Store's slot reuse) dropped a cache entry once its computed expirationMs elapsed — but that time is only a base-duration estimate for non-player casters (we lack their mod tables), so a talent-extended debuff expired in the cache while still live on the target. The entry took the caster with it, and the descriptor path then rendered the aura with no sourceGUID. Now an entry whose aura the owning unit's live descriptor still lists is never timer-reclaimed (DescriptorListsAura resolves the GUID through the object manager); only genuinely orphaned entries — unit out of range / stealthed / despawned — expire. The fallback path already skips expired entries, so no phantom can resurface. PushEnriched also reports an already-elapsed cached expiration as unknown rather than a negative remaining time. Infer self-buff casters. On a caster miss (no cache entry, or one with no caster), a self-only-target aura can only have been self-cast, so the unit carrying it is its own source. Factor the record scan out of the C_Spell.IsSelfBuff Lua wrapper into Spell::IsSelfBuff::IsSelfBuff and call it from PushEnriched to recover sourceUnit/sourceGUID for pre-existing self-buffs we never saw applied. Caster is exact; timing stays unknown. |
||
|
|
8a434fea0e |
fix(aura): keep SMSG_SPELL_GO caster through the descriptor-sync race
C_UnitAuras dropped sourceGUID/sourceUnit for buffs cast by other units (e.g. a druid's Mark of the Wild / Gift of the Wild on the player). SMSG_SPELL_GO arrives before the SMSG_UPDATE_OBJECT that adds the aura to the target's descriptor. In that window an addon aura poll runs ReconcileCache, which calls EvictAbsent. The just-captured cache entry named an aura the descriptor did not list yet, so EvictAbsent dropped it and lost the caster. OnAuraAdded then recreated the entry with no caster, so sourceGUID stayed nil. Verified by trace: every "Store NEW caster=0x8" was followed at once by "EvictAbsent (had caster=0x8)". Give each cache entry a write timestamp (stampMs) and exempt entries younger than kEvictGraceMs (2s) from EvictAbsent. A real removal is far older and still gets dropped, and OnAuraRemoved evicts genuine removals directly, so stale-aura cleanup is unaffected. Verified in-game: a remote druid buff now reports sourceGUID; a self-cast buff still reports sourceGUID + sourceUnit="player". |
||
|
|
1da06d4a73 |
frame: attribute backport, modern script args, and SMSG hook consolidation (#13)
* frame: backport Frame:SetAttribute/GetAttribute + unit-frame mouseover/click Adds native SetAttribute / SetAttributeNoHandler / GetAttribute on the base Frame registry: a per-frame, case-insensitive value store with the 3.3.5 prefix/name/suffix getter precedence, stored on the frame's own Lua table. A `unit` attribute makes the frame a mouseover source. A WorldTick poll of the engine's mouse-focus frame (GetMouseFocus's global) calls the real mouseover setter (FUN_00492890) for its unit -- 1:1 with hovering the 3D model: model highlight, mouseover tooltip, UPDATE_MOUSEOVER_UNIT, and the native GUID slot. Stomp-proof (the engine's 3D-hover setter is event-driven) and independent of the frame's scripts, so an addon setting its own OnEnter can't break it. A `type1`/`type2`/`type` attribute installs a chained OnClick on that frame only (PCall-guarded, Button-only) that dispatches target / assist / focus on the unit at click time, then runs any prior handler. No global hooks: mouseover reads the mouse-focus global; clicks use the frame's own OnClick. Deliberately does NOT MinHook the button-click dispatcher (FUN_00779540) -- SuperWoW's click-casting owns that prologue and a second inline hook corrupts the trampoline (ERROR #132). * frame: extend attribute backport (one-verb click dispatcher + OnAttributeChanged) The `type*` click path now mirrors retail's SecureActionButton_OnClick: resolve ONE verb per click from the modifier/button-qualified `type` attribute and perform it, instead of a fixed `type1=target`. - Modifier/button resolution: `[alt-/ctrl-/shift-]type[1..5]` with prefix..name..suffix -> name..suffix -> name precedence, read from the live key state and the click's button. - Verbs: target (with the engine's default-interaction precedence - cast a pending spell / drop a cursor item on the unit instead of switching target), assist, focus, spell, stopcasting, macro, and menu. - Own-the-click: when a verb resolves we perform it and do NOT chain the frame's previous OnClick, so a configured `type1` no longer double- dispatches alongside an addon's own conditional click handler. - Self-healing wire: addons that re-SetScript OnClick (pfUI on every raid relayout) clobber our closure; WireOnClick re-wraps a clobbered Lua handler but skips its own C closure, so re-setting `type*` recovers without double-chaining. Dispatch goes straight to C++ where we own the code - no Lua round-trip through the global table: spell -> Spell::AtUnit::CastByName (a native unit-targeted cast; the unit's GUID is fed to the engine's dispatcher so there's no target juggling, and ground-target spells land at the unit's feet), focus -> Unit::Focus::Set, and the target verb's predicates -> Spell::AtCursor::IsPlacementActive / Cursor::Info::HasItem. Only genuine engine entries (TargetUnit/AssistUnit/SpellTargetUnit/DropItemOnUnit/ SpellStopCasting) and addon-provided functions still go through Lua globals. Spell::AtUnit gains a C++ header sharing its CastCore with the C_Spell.CastAtUnit Lua entry. macro verb: takes the content from the `macrotext`/`macro` attribute and prefers an addon-provided RunMacro (SuperCleveRoidMacros etc. - handles named macros and extended macro text), falling back to running the text natively when no RunMacro global is present. The native path runs each line through the stock FrameXML ChatEdit_ParseText via a throwaway edit-box (GetText closure + no-op __index), so it needs no addon. menu/togglemenu verb: pops the standard unit dropdown at the cursor via the new ClassicAPI_ToggleUnitMenu (Util/SecureUnitMenu.lua), resolving the unit -> menu type with Blizzard's own generic resolver (self->SELF, pet->PET, grouped player->PARTY, other player->PLAYER, NPC->RAID_TARGET_ICON). Keeps the FrameXML dropdown logic in Lua with the C side as a thin call. OnAttributeChanged is now a real SetScript/GetScript/HookScript-able frame script on every frame: SetAttribute fires it, SetAttributeNoHandler suppresses it. Made settable by co-hooking the base-frame script-name resolver FUN_0076a0d0 (the one every frame type delegates through) and handing back an external per-frame {handler, context} cell for that name - frames are immortal in 1.12, so the cell never goes stale. One hook does it (vs the tooltip OnTooltipSet* work's five) because we already own the firing side. 1.12 convention: the handler reads this = frame, arg1 = name, arg2 = value. Recursion-guarded so a handler may itself SetAttribute. * frame: add Frame:ClearAttribute (retail 11.2.0) `cleared = frame:ClearAttribute(name)` removes an attribute and returns whether it was set. Registered on the base Frame method registry next to SetAttribute/GetAttribute, so every frame has it. Routes through DoSet's nil-value path (removes the stored key, drops a `unit` mouseover binding) but does NOT fire OnAttributeChanged — verified against a live retail 11.2 client: SetAttribute fires the handler, ClearAttribute fires nothing, and the return is true for a set attribute / false when there was nothing to clear. * frame: store attributes in the Lua registry, hidden from Lua Attributes were kept as a subtable on the frame's own Lua table under a control-char key ("\1ClassicAPIAttributes"). That key, while collision- safe, is still enumerable via pairs(frame) and readable/writable from Lua. Move the store to registry[frame] in the Lua registry (LUA_REGISTRYINDEX), which has no _G path — so the attribute map is invisible to pairs(frame) and can't be read or tampered with from script, matching how retail keeps attributes C-side. Only PushSub changed (create/fetch now key the registry by the frame table); GetAttribute/DoSet/CopyAttr sit on top unchanged. 1.12 frames are immortal, so the strong registry key never leaks. The dead kAttrKey constant is removed. Verified in-game: SetAttribute/GetAttribute still round-trip, and a pairs(frame) scan no longer finds any ClassicAPI key. * frame: add the `item` click verb (SecureActionButton item action) type*="item" uses the modifier-qualified `item` attribute: - a "bag slot" string (e.g. "0 1") -> UseContainerItem(bag, slot); - otherwise an item name / itemID / link -> C_Item.UseItemByName(item, unit), passing the unit as the use target (self-use items ignore it, targeted ones like scrolls/bandages apply to it); - the deprecated `bag` + `slot` attributes are honored when `item` is unset. Both bag paths go through lua_call (new CallTableFunc2Str / CallGlobalNum2) rather than a direct C++ call: the item-use bag walk does SetTop(L, 0), so it needs its own Lua stack frame — a direct call would wipe the dispatcher's stack. (spell stays direct because Spell::AtUnit is stack-free; the helper comment records the distinction.) Retail's "bag slot" string is the preferred form; the deprecated per-attribute form is supported too. * docs: format the attribute click verbs as a table The verbs were one long paragraph of nested parentheticals - hard to scan. Replace it with a Verb | Extra attributes | Action table so each verb's inputs and behavior are legible at a glance. Content-equivalent; no API change. * frame: clear target on the `target` verb when unit is "none" Retail's SecureActionButton target action treats a "none" unit as "clear target". Match it: the `target` verb calls ClearTarget() when the resolved `unit` is "none" (case-insensitive), before the normal cursor/spell precedence. Mouseover already handles "none" implicitly (it resolves to GUID 0 = no unit). Docs' target-verb row updated. * frame: pass modern positional args to script handlers Vanilla always invokes frame-script handlers with zero Lua args; the handler reads this/arg1/event as globals. Modern addon ports write SetScript("OnMouseWheel", function(self, delta) ...) and get nothing. Co-hook both script runners -- FUN_FRAME_INVOKE_SCRIPT (no-arg scripts) and FUN_FRAME_RUN_SCRIPT_ARGS (scripts with values) -- and reimplement their pcall tail: keep the engine's exact this/argN global save-set- restore and message-handler errfunc, but additionally push self + arg1..argN as real positional arguments and pcall with nargs = 1+N. Purely additive: a zero-param vanilla handler ignores the extras and reads globals; a modern (self, delta) handler binds them. OnEvent gets (self, event, arg1..argN), detected structurally by matching the invoked handler ref against the frame OnEvent slot (frame+0x0C) -- exact, since each SetScript makes a distinct ref. Runtime switch SetModernScriptArgs()/GetModernScriptArgs(), default on; when off both detours are a straight passthrough to the original runner, which matters because FUN_FRAME_RUN_SCRIPT_ARGS is the hottest Lua path in the engine (every OnUpdate frame). Verified in-game across OnMouseWheel/OnClick/OnValueChanged/OnUpdate/OnEnter/OnLeave/OnEvent. * net: consolidate spell SMSG hooks onto one dispatch funnel The spell subsystem's per-opcode SMSG handlers (SpellGo, SpellStart, SpellDelayed, ChannelStart/Update, SpellFailure, SpellFailedOther, SpellCooldown) were each co-hooked directly -- and nampower (hadesmem) plus SuperWoW detour the same prologues. Two inline hookers on one prologue is the documented MinHook collision risk, and a whole-protocol bisect fingered exactly this cluster as the crash-suspect surface. Add Net::PacketDispatch: a receive-side mirror of Net::SendObserver that co-hooks the single incoming-SMSG dispatch funnel FUN_NET_MESSAGE_DISPATCH (0x00537AA0) -- a chokepoint nampower does NOT hook (it detours the leaf handlers) -- and fans each packet out to opcode subscribers with the cursor at the body and centralized save/restore. Migrate all eight handlers to subscribers: aura/Source (SpellGo, which re-decodes the packed guids + spellId the leaf handler used to hand it pre-decoded), spell/Cast (Start/Delayed/Channel*/Failure*), and lossofcontrol (Cooldown). The parse bodies are unchanged; only the hook site moved. Subscribers run before the engine's leaf handler instead of after a co-hook's original -- verified order-independent for all eight (self-contained cache/state updates; SpellGo's aura-application handoff rides a separate SMSG_UPDATE_OBJECT). Cuts the ClassicAPI-nampower shared spell prologues from 10 to 3 (the OnAura* method hooks, which have no packet chokepoint to relocate to). One hook on an uncontended function replaces eight on contended ones. Verified in-game: cast bars, channels (incl. Mind Control cast-then- channel), pushback, remote-cast interrupt eviction, and C_LossOfControl school lockouts all intact. * ScriptArgs is back to opt-in * frame: fix ScriptArgs comments to match opt-in default * frame/net: dedupe packet observers, reuse Lua/token helpers, fix attr edge cases Post-review cleanup of the attribute + SMSG-consolidation work. - net: extract the shared packet-observer plumbing (PacketObserver.h) — the intrusive subscriber list, Subscribe(), and the read-opcode / reset-cursor / fan-out / restore loop — so Net::PacketDispatch (SMSG, u16) and Net::SendObserver (CMSG, u32) each reduce to a one-line hook thunk over FanOutByOpcode<OpcodeT>. Drops the dead per-namespace Callback aliases rather than keeping them as compat shims. - Game::Lua: promote PushGlobalFunction / CallGlobal / CallGlobalString into the shared Lua helpers (a pattern several modules open-code); Frame attributes use them instead of private copies. - frame/Attributes: resolve unit tokens through Unit::Identity::GuidForToken (engine resolver + player fast-path) instead of a duplicate raw-cast wrapper. - frame/Attributes: wire the chained OnClick for every "type" action attribute the click resolver reads (IsTypeAttr: modifier prefixes + type1..type5), not just type/type1/type2 — a middle-click or modifier-only binding now installs. - frame/Attributes: FireAttributeChanged snapshots and restores the caller's arg1/arg2 around the fire, so calling SetAttribute from inside a running script handler no longer clobbers its globals. |
||
|
|
29e3dab24a |
UNIT_SPELLCAST_* event family + GUID unit tokens (#11)
* spell: backport UNIT_SPELLCAST_* events for the local player
Adds the TBC+ cast/channel events (START, STOP, DELAYED, SUCCEEDED,
INTERRUPTED, FAILED, SENT, CHANNEL_START, CHANNEL_UPDATE, CHANNEL_STOP)
for the player, so cast-bar / rotation addons written against the modern
signature work on 1.12. Each carries (unit, castGUID, spellID, spellName,
rank) -- SENT inserts `target` at arg2 -- with a synthesized modern-shape
castGUID (Cast-3-0-0-0-<spellID>-<castUID>) shared across all of a cast's
events so START pairs with STOP. arg1 is always "player" (player-only phase).
The events are derived, not independently tracked: Spell::Cast already
hooks every cast/channel path for UnitCastingInfo/UnitChannelInfo, so
Spell::CastEvents reuses that state.
- START/STOP/DELAYED/CHANNEL_START/STOP: polled from Cast's OnWorldTick
against the previous snapshot.
- SUCCEEDED: fired from the SMSG_SPELL_GO hook (covers instants too).
Deferred for channels so it lands after CHANNEL_START (modern order).
- INTERRUPTED/FAILED: split by result code in a Spell_C_SpellFailed
co-hook -- a started cast that aborts (kick/move/LoS) fires INTERRUPTED
(repeated per retry, reusing the cast guid); a pre-cast rejection fires
FAILED.
- SENT: minted from the CMSG_CAST_SPELL send, threading its castGUID
forward so all of a cast's events share one guid.
- CHANNEL_UPDATE: from a new MSG_CHANNEL_UPDATE co-hook, which also
re-anchors g_channel.endMs to the server's remaining time so channel
pushback (which shortens vanilla channels) shows in UnitChannelInfo.
Every fire is gated on Event::Custom::HasListeners (new), so the system
costs one pointer-compare per transition when no addon registers.
Supporting changes:
- Net::SendObserver: shared co-hook on the NetClient send funnel with an
AutoSubscribe list, so CastEvents (SENT) and ComboDuration (combo-point
capture) both watch outgoing packets without owning the hook. Extracted
from ComboDuration's private hook.
- Cast.cpp: player channel now self-expires at its computed endMs in the
poll (was cleared only by the ~1s-lagged +0x228 field, so CHANNEL_STOP
trailed the real end by ~1s); wrap-safe delta compare so a long-uptime
ms tick past 2^31 can't misfire it.
Player-only; remote-unit fan-out, FAILED_QUIET, and empowered casts are
not implemented.
* spell: extend UNIT_SPELLCAST_* to non-player units (phase 2)
Fires the six observable cast/channel events -- START, STOP,
CHANNEL_START, CHANNEL_STOP, SUCCEEDED, INTERRUPTED -- for other units,
not just the player. Each is fanned out once per unit token currently
mapping to the caster (target / focus / nameplateN / party / raid / pet /
mouseover), so a target frame, a party frame, and a nameplate cast bar
all get their own event with a shared castGUID -- matching retail.
Token fan-out reuses the engine's own GUID->token reverse map
(FUN_00515c50, nampower's unfilled GetNamesFromGUID) for native tokens,
plus focus/nameplate which the engine can't see, via
Unit::Identity::TokensForGUID. SuperWoW's raw-GUID token ("0x...") is
filtered out so only standard tokens fan out.
Remote events are derived from Spell::Cast's existing packet hooks:
- START / CHANNEL_START from HandleSpellStart (SMSG_SPELL_START)
- SUCCEEDED from the SPELL_GO hook (Aura::Source)
- STOP / CHANNEL_STOP at the computed end, or on abort
- INTERRUPTED (casts only) from HandleCastAborted (ClearCastingSpell /
failure packets)
A per-caster state machine (PollRemote, from OnWorldTick) fires them in
modern order; a channel's SPELL_GO cast->channel ClearCastingSpell is
filtered so it doesn't self-interrupt at its own start.
Not fired for remotes (data is caster-only / client-local): SENT,
DELAYED, FAILED, CHANNEL_UPDATE.
Also in this change:
- castGUID follows type rule from https://warcraft.wiki.gg/wiki/GUID#Cast : real casts are Type 3 with a
time-based castUID (low 23 bits = UNIX second, high bits = per-second
counter, matching retail's structure), threaded across a cast's events
(player and remote converge on the same value); FAILED is Type 2 with
a flat incrementing integer.
- Channels never fire INTERRUPTED (player or remote) -- retail emits
only CHANNEL_STOP whether a channel completes or is cut short.
arg1 is the caster's unit token ("player" or another token); the
spellName / rank tail extensions are unchanged.
* spell: return the castGUID as UnitCastingInfo's castID
UnitCastingInfo / CastingInfo now return the cast's castGUID as castID
(return 7) instead of nil -- the same string the UNIT_SPELLCAST_* events
carry, so an addon can correlate the polled info with the events. It's
pulled from Spell::CastEvents (the single source of the castUID) via a new
CurrentCastGuid accessor, and works for the player and remote units. The
timing stays sourced from Spell::Cast -- only the castGUID crosses over,
so there's no duplication of cast state.
UnitChannelInfo is left retail-exact (no castID; channels don't carry
one), even though our channel events do include the shared castGUID.
Also corrects the spell-cast-GUID spec attribution in comments/docs to
warcraft.wiki.gg/wiki/GUID#Cast (it was wrongly credited to Wowhead).
* spell: add UNIT_SPELLCAST_RETICLE_TARGET / _CLEAR events
Backports the ground-target reticle events for the player:
RETICLE_TARGET when an AoE placement reticle comes up (Blizzard, Flare,
Rain of Fire, ...), RETICLE_CLEAR when it's cancelled. Args are
(unit, "", spellID, spellName, rank); arg1 is always "player".
Driven by polling the engine's targeting-flag global (0x00CECAC0 -- the
predicate behind SpellIsTargeting) from OnWorldTick: 0->nonzero fires
RETICLE_TARGET with the pending spellID (0x00CEAC58, written by
Spell_C_CastSpell); nonzero->0 fires RETICLE_CLEAR. CLEAR is suppressed
on placement (a CMSG_CAST_SPELL for the reticle spell went out, seen via
the shared send observer), so it fires only on a genuine cancel --
matching retail, which emits no CLEAR when the spell is placed/cast.
The castGUID slot (arg2) is "" rather than retail's nil: there's no cast
to identify yet, and the engine's event dispatcher can't emit a nil
mid-argument-list (a NULL %s corrupts the args after it -- the nil trick
only survives as the last arg). unit (arg1) and spellID (arg3) are exact.
* spell: fire UNIT_SPELLCAST_FAILED_QUIET for the quiet result whitelist
Vanilla's Spell_C_SpellFailed dropped SPELL_FAILED_DONT_REPORT silently.
Modern surfaces suppressed (no-error-text) failures as
UNIT_SPELLCAST_FAILED_QUIET rather than FAILED.
Verified against the 3.3.5 client's unit-spellcast dispatch (FUN_007fecc0),
which selects the QUIET event for a fixed 3-code whitelist, mapped to 1.12's
SpellCastResult enum (FUN_006e23e0):
CHARMED (0x14) . DONT_REPORT (0x17) . SPELL_IN_PROGRESS (0x61)
SPELL_IN_PROGRESS (casting while already casting / a nampower spell-queue
rejection) is the common case that previously mis-fired as a loud FAILED.
* unit: accept raw GUID literals as unit tokens
Fold a "0x<hex>" branch into the existing FUN_TOKEN_TO_GUID hook so every
Unit* function (UnitName, UnitHealth, UnitClass, UnitExists, ...) accepts a
64-bit GUID literal in place of a token. The parsed GUID goes straight to
the engine's own object-manager lookup (the path "player" takes), so an
unloaded/out-of-range GUID resolves to nil like any absent unit, no error.
Reuses the existing suffix walker, so "0x...target" composes.
Gated on SuperWoW's absence (GetModuleHandleA("SuperWoWhook.dll"), cached):
SuperWoW already provides GUID input via its own resolver hook, so when it
is loaded we defer to avoid two layers parsing the same string. Behaves
identically either way. Input direction only.
|
||
|
|
1f3f3cb9f6 |
aura: infer server-side DoT-duration changes from the triggering cast
C_UnitAuras expirationTime for a debuff on another unit is derived from
SMSG_SPELL_GO at cast time; the vanilla server never retransmits a LATER
server-side duration change on a non-self unit (verified in the server
source: SetAuraDuration/RefreshHolder, and UpdateAuraDuration is self-
scoped -- on a mob no packet is built at all). So a refresh/consume goes
stale in our cache. We can't hear the change, but we DO see the triggering
cast, so mirror the server's edit off that.
Aura::Source gains a rule engine applied in SpellGo_h (before the aura
gate -- triggers apply no aura themselves): a trigger matched by exact
spellID OR by SpellFamilyName + school index, an affected aura matched by
family + family-flag overlap (+ optional icon, rank-proof like the server
scripts), and an op (refresh/reduce/set/remove). Proc-applied affected
auras enter the cache unattributed (casterGuid 0); the rule accepts those
and attributes them to the trigger caster (also gives them a sourceUnit).
Lua: C_UnitAuras.RegisterAuraDurationModifier (exact-ID trigger) and
RegisterAuraDurationModifierByTrigger (family+school trigger), so the
server-specific ruleset lives in the addon, not the DLL.
Default Turtle ruleset (AuraDurationModifiers.lua, gated on
TURTLE_WOW_VERSION; IDs/flags DBC-verified):
Conflagrate -> reduce Immolate 3s
Molten Blast -> refresh Flame Shock
Shadow Weaving (5/5 talent 15334) -> priest shadow-school casts refresh
Shadow Vulnerability 15258 (covers the max-stack refresh blind spot;
Turtle reworked it, so stock DBC proc masks don't apply -- match by
school). Best-effort: DoT-tick procs emit no cast packet.
Carnage's roll-gated Rip/Rake refresh is deliberately excluded (the client
can't know the server roll).
Verified in-game (debug trace): Conflagrate/Molten Blast, and Mind Blast /
SW:P / Mind Flay all refresh 15258 with advancing expiration + sourceUnit.
|
||
|
|
60479677c1 |
aura: best-effort duration guess for out-of-range group/raid auras
An out-of-range party/raid member has no CGUnit and never yields SMSG_SPELL_GO, so the caster/duration cache never learned their auras' timing and expirationTime stayed 0. But SMSG_PARTY_MEMBER_STATS carries their aura spell IDs and the server sends it on change (SendUpdateToOutOfRangeGroupMembers flushes the moment an aura add/remove dirties the group mask), so a spell ID that newly appears in the group array did so ~one tick + latency after the real application. Aura::Source::ObserveGroupAuras (called from the group enumerate paths in Aura::Data) keeps a per-member snapshot of the last-seen spell-ID set and, on a genuine absent->present transition, stamps now + base duration into the same cache PushEnriched already reads. Covers party and raid alike (AuraArray reads the raid slot too; snapshot table sized for a 40-man). Base duration only (no remote caster mods) and no caster recorded (sourceUnit/GUID stay nil). Auras already present at first sight have unknown age and are not stamped; snapshots reset on map change and after 30s unpolled. The Store guard keeps any real SpellGo timing, so this never downgrades better data. |
||
|
|
e447c70ca3 |
aura: recover player-talented DoT duration in the application hooks
A player DoT with a duration talent (e.g. Improved Shadow Word: Pain, 2/2 -> 24s vs 18s base) intermittently showed the base duration. The displayed value is the Aura::Source cache entry's durationMs, which is computed two ways: SpellGo knows caster == player so it applies the player's duration mods (skipMod 0 -> 24s), while the OnAuraAdded / OnAuraStacksChanged application hooks have no caster and take the unmodified base (skipMod 1 -> 18s). Normally SpellGo owns the entry and the application hooks can't clobber it, but the base value wins whenever SpellGo can't land its talented value on THIS target's entry: an empty SMSG_SPELL_GO hit list files it under the caster instead (numTargets == 0), or a slot reshuffle evicts + refills the entry after SpellGo ran. Both are packet-order dependent, hence the flicker. Fix: SpellGo (which knows caster == player) records recent player aura casts by spellId; the application hooks recompute with skipMod 0 and attribute the caster when the spellId matches a recent player cast. Robust against both the attribution miss and the refill race, and leaves other units' auras on the base path (we lack their mod tables). |
||
|
|
a20e1206fb |
totem: add GetTotemInfo(slot) with a self-tracking totem subsystem
Vanilla 1.12 tracks nothing about totems client-side (the totem bar, PLAYER_TOTEM_UPDATE, and GetTotemInfo are all TBC additions), so Totem::Tracker tracks the four element slots itself — data-driven: - Slot from the summon spell's Spell.dbc effect (87-90 = SUMMON_TOTEM_SLOT1..4 = Fire/Earth/Water/Air; slot = effect - 86). - Creature entry from the effect's EffectMiscValue (for death detection). - Duration from SpellDuration.dbc via the engine duration helper. - haveTotem tool item from the spell's Totem[0] field (0xA0) — the totem the spell requires (a tool, not a consumed reagent) — resolved from the player's spellbook on SPELLS_CHANGED, not hardcoded. Casts are observed through Aura::Source's existing SMSG_SPELL_GO hook (a one-line notify before its aura gate, since a summon applies no aura) — no new hook, respects one-hook-per-target. Tool items resolve on SPELLS_CHANGED (a no-arg event via the shared Event::SignalHook), when the spellbook is populated. A slot clears when its duration elapses OR when the totem creature disappears early (killed / Totemic Recall / destroyed), detected by a throttled WorldTick object-manager scan for the player-owned creature of that entry (seen-then-gone latch; CreatedBy == player so another shaman's same-entry totem can't mask yours). GetTotemInfo returns haveTotem, totemName, startTime, duration, icon, modRate=1, spellID. Turtle-custom totems are tracked automatically. Also exposes Item::Count::InInventory (equipped + bags) as a shared helper for the tool-presence check. Verified in-game: Earthbind lands in slot 2, haveTotem reflects the Earth Totem tool, and Totemic Recall clears the slot early. |
||
|
|
e8a03d584b |
spell: add GetSpellBonusDamage / GetSpellBonusHealing
GetSpellBonusDamage(school) reads the player's per-school spell damage
directly from the CGPlayer sub-struct at [player+0xE68]+0xFD4 (POS) / +0xFF0
(NEG), net = POS-NEG. That field isn't in the broadcast descriptor (+0x110
reads zero — the vanilla server never sends it there), but the client keeps a
fully-computed copy at +0xE68 with gear/enchants/buffs/talents/sets baked in.
Same source nampower's GetSpellPower reads; verified 613 generic / 647 Fire on
a geared mage. 1-based school, matching 3.3.5's Script_GetSpellBonusDamage.
GetSpellBonusHealing() has no such field (vanilla lacks a healing-done field
entirely), so it's derived to mirror the server's SpellBaseHealingBonusDone:
- flat healing: SPELL_AURA_MOD_HEALING_DONE (135) off gear equip-effects,
item enchants, random suffixes, and active buffs
- Spirit conversion: SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT (175) x
total Spirit / 100 (Priest Spiritual Guidance)
- Armor conversion: SPELL_AURA_MOD_SPELL_HEALING_OF_ARMOR_PERCENT (199) x
armor / 100 (Turtle Ironclad)
Percents are read straight from Spell.dbc, so it's generic across any
aura-175/199 talent/buff including Turtle customs, and gated on SPELL_ATTR_
PASSIVE for the known-spell-bitmap walk. Spirit/Armor come from UNIT_FIELD_
STAT4 (+0x250) / UNIT_FIELD_RESISTANCES[0] (+0x254).
Item flat healing routes through the shared Item::StatAccum engine rather than
re-implementing the item spell/suffix/enchant walk: extract a reusable
ApplyEnchant() (from ApplyRandomSuffix) plus a Value() reader, and read
ITEM_MOD_SPELL_HEALING_DONE_SHORT.
The healing sum is expensive (StatAccum over 19 items + buff table + the 27k
known-spell bitmap), so it's cached and recomputed only when a player stat
input changes. New Player::StatSignal (a pull-based epoch) is bumped from the
aura hooks (player-guarded), the equipment observer, and the spell learn/
unlearn writers (0x4B25B0 / 0x4B2C50) -- so buffs, gear, and talent respecs
all invalidate instantly. A coarse world-tick recompute remains only as a
backstop against a missed signal.
|
||
|
|
81434f7014 |
aura: evict phantom cache entries on removal and descriptor reconcile
C_UnitAuras' descriptor-drop fallback could surface a "phantom" aura that was actually gone — enumerated with a spellId but SetUnitAura rendering an empty tooltip. Two cases, both fixed: - Owner cancels a buff (e.g. a flask) while dead: the server keeps death-persistent auras through death without changing any field, so death itself fires no OnAuraRemoved. Any OnAuraRemoved we do receive for one is genuine (cancel/dispel/expiry), so always evict the cache entry — including death-persistent auras on dead units. Fixes the phantom for the caster and nearby observers (both receive the removal packet). - A buff cancelled while its owner is out of an observer's range sends no packet, so the stale entry lingers. Reconcile on return: when a unit's descriptor holds >=1 raw aura it's in view and fully synced, so it's authoritative — evict any cached entry whose spell isn't in the array (Aura::Data::ReconcileCache -> Aura::Source::EvictAbsent, run at the top of the fallback path). Reads raw slots so a flag-hidden aura still counts as present; skips an empty array (can't tell out-of-range from buffless). The only residual is a buff cancelled while the owner is still out of range, which vanilla can't report until they return. |
||
|
|
bb9579c398 |
aura: flush source cache on map transition (stuck buffs after leaving BG)
Leaving a battleground (incl. the /afk teleport out while dead) bulk- clears the player's aura descriptor WITHOUT firing per-aura OnAuraRemoved, so Aura::Source entries for auras that are now gone lingered and Aura::Data's descriptor-empty fallback kept surfacing them. The tell from the report: a real buff (filling a descriptor slot) temporarily masks the phantoms, removing it brings them back. Can't evict on descriptor-empty — that's the exact state the fallback must survive (rogue stealth, party-range drops). The clean distinguisher is a map transition: a BG/instance/continent change moves the Map.dbc ID, while stealth/range don't. OnWorldTick now polls VAR_CURRENT_MAP_ID and flushes the whole cache on any change (no new hook). Every other unit from the old map has despawned, and the player's real auras re-sync from the descriptor / PLAYER_BUFF tables on entering the new world, so a full flush loses nothing legitimate. Reported via pfUI issue #20. |
||
|
|
d6bf05c12c |
Combo-point finisher durations for C_UnitAuras
Rupture at 4 combo points reported duration=6 (the SpellDuration.dbc base) instead of the real 14s: finisher durations are computed server-side at cast time and 1.12 never transmits them for debuffs the player puts on other units. Verified with a whole-protocol sniff -- SMSG_UPDATE_AURA_DURATION (0x137) is self-scoped (slot+duration for the player's own aura array), 0x2DD has no client handler and never arrives, and nothing else carries the value. (pfUI issue #17.) Mirror the server's computation instead (new Aura::ComboDuration): - Snapshot combo points ([player+0xE68]+0x1029, the field behind Script_GetComboPoints) the instant CMSG_CAST_SPELL leaves, via a co-hook on the NetClient send funnel (FUN_NET_SEND 0x005379A0). The server consumes CP before SMSG_SPELL_GO returns, so reading at SpellGo time is too late; the send funnel also covers nampower-queued casts, which bypass any Spell_C_CastSpell co-hook via trampoline re-entry. - Compute base + (max - base) * CP / 5 from the spell's own SpellDuration.dbc row ((v)mangos CalculateSpellDuration), then apply the player's duration SpellMods, matching server order. DBC-driven and spell-agnostic: finishers are exactly the rows with base != max (Rupture 6/16s, Kidney Shot 1/6s, r1 0/5s, Slice and Dice 6/21s; Expose Armor 30/30 self-disables). Consumed by Aura::Source's SpellGo hook; 0 falls through to the existing base path. - Turtle's reworked Rip (8s + 2s per CP) has NO client data: all six ranks' DurationIndex points at SpellDuration row 87, which Turtle added server-side only -- the client table jumps 86 -> 105. Built-in values cover it, gated on the dangling-row condition itself (the only dangling cross-reference in the entire client Spell.dbc, per a full DurationIndex/CastingTimeIndex/RangeIndex sweep) rather than on realm detection: stock clients resolve Rip's index normally, and if Turtle ships the missing row the DBC takes over automatically. - C_UnitAuras.RegisterComboDuration(spellID, baseSec, maxSec) as an escape hatch for other servers with the same class of client-data gap; a registered override beats DBC and built-ins. Verified in-game: Rupture at 4 CP now reads duration=14. |
||
|
|
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. |
||
|
|
939b52ae69 |
Recover dropped auras in C_UnitAuras; evict on removal
The 1.12 engine drops a unit's UNIT_FIELD_AURA slots when it loses sync with the unit (rogue stealth, party range fluctuation) even though the auras are still active server-side, so C_UnitAuras.GetAuraDataByIndex / GetBuffDataByIndex returned nil for auras that are still up. Fall back to the Aura::Source cache (caster/timing captured from SMSG_SPELL_GO at cast time, which survives descriptor clears) when the descriptor has no slot: - Aura::Source: entries gain a helpful/harmful kind, recorded from the descriptor slot at application time (OnAuraAdded/OnAuraStacksChanged); SpellGo-only entries stay unknown and are excluded. New Enumerate() returns non-expired entries of a given kind for a unit. - Aura::Data: a shared BuildTable feeds both the descriptor Push and a new cache-fed path; PushNthCacheFallback / AppendCacheFallbacks append cache entries after the descriptor ones, deduped against populated slots. - Aura::Api: the index path and GetUnitAuras consult the fallback. To keep the fallback from resurrecting auras that are genuinely gone (replaced by a higher rank, dispelled, fell off early), co-hook OnAuraRemoved (FUN_00612320) and evict the cache entry. A rogue stealthing does NOT route through OnAuraRemoved (object-visibility drop, not per-aura removal), so eviction and stealth-recovery coexist: real removals evict, visibility drops don't. Add FUN_ON_AURA_REMOVED offset. Fixes #5 |
||
|
|
b8d55e8dea |
Back UnitCastingInfo / UnitChannelInfo for remote units
Vanilla stores no cast record for other units, so UnitCastingInfo(other) returned nil and remote channels had no timing. Co-hook the SMSG_SPELL_START handler (0x006E7640, gated on opcode 0x131) -- the only packet carrying another unit's cast with a server-authoritative cast time -- and cache it per caster GUID (cast vs. channel split by AttributesEx channel bits). - UnitCastingInfo(unit): full timing for any unit within its cast window; enemy/target/focus/nameplate cast bars now work, not just the player. - UnitChannelInfo(unit): remote channels get real start/end times when the channel's begin was observed, validated against the live +0x228 field so a stale entry never sticks; falls back to the old no-times path otherwise. - Player path unchanged (self-tracked); the cache skips caster==PlayerGuid. Factor the CDataStore packet reader out of Aura::Source into a shared Net::PacketReader header (vtable-correct) used by both packet hooks. Best-effort: only casts begun while the unit was in range are seen, and an interrupted remote cast lingers until its computed end (1.12 sends no per-unit interrupt packet to hook). |
||
|
|
5550cb02b7 |
Fill AuraData.expirationTime for proc / triggered auras
SpellGo only sees directly-cast auras, so proc-applied debuffs (Shadow Weaving etc.) had no expiration. Co-hook two more engine functions that fire for every aura application: - CGUnit_C::OnAuraAdded (0x006123F0) - any aura newly occupying a slot, procs included; stamps now + base duration (no caster). - CGUnit_C::OnAuraStacksChanged (0x00612450) - re-stamps on a stack-count change so a climbing stacking debuff (Shadow Weaving 1->5) refreshes. Both pass fromCast=false to Store, which skips entries SpellGo already owns, so directly-cast auras keep their talented timing + caster regardless of hook order. Consolidate the object-GUID read into Unit::Identity:: GuidForObject so the lookup and the new hooks key the cache identically. Known limitation (documented): a refresh at MAX stacks (5->5) changes no client-visible aura field, so the server sends no UpdateField and no callback fires - there's no packet to hook. The countdown runs out and expirationTime falls back to 0 (unknown) while the aura still shows. |
||
|
|
492c70d156 |
Use applied (caster-modified) duration for AuraData.duration
duration came from a base Spell.dbc/SpellDuration.dbc lookup while expirationTime came from the Aura::Source cache computed with the caster's duration modifiers. For a talented DoT (e.g. 2/2 Improved Shadow Word: Pain, 18s -> 24s) the two disagreed, so remaining (expirationTime - GetTime()) exceeded duration -- impossible for a single aura. Cache the applied durationMs alongside expirationMs in Aura::Source and have Push prefer it for the duration field, keeping the two consistent (remaining <= duration). Falls back to the base DBC value on a cache miss. |
||
|
|
b17aeda203 |
Add aura caster + non-player expiration to C_UnitAuras
Populate AuraData sourceUnit/sourceGUID and non-player expirationTime by co-hooking SMSG_SPELL_GO (FUN_SPELL_GO) and caching (targetGuid, spellId) -> caster + expiration. The vanilla unit aura array stores only spell IDs; the SpellGo packet is the only place the client sees an aura's caster and a server-authoritative duration. We parse the engine packet ourselves, so this is self-sufficient (no nampower dependency) -- when nampower is loaded we simply co-hook the same site. sourceGUID is a ClassicAPI extension (raw "0x..." string), set whenever a caster is known including when sourceUnit is nil; stable across the session, unlike the volatile nameplate token, and usable as a unit token under SuperWoW. Also consolidate the local-player-GUID read into Unit::Identity::PlayerGuid() (was duplicated inline in four files) and expose Unit::Identity GuidForToken / TokenFromGUID for reuse. |