fix(aura): include the player's pet in the PLAYER filter

Blizzard defines the token as "Include only auras that were cast by the
player, or by the player's pet or vehicle"
(AuraUtil.AuraFilters.Player). There are no vehicles here, so the caster
set is player + pet -- but all three comparisons tested
`casterGuid == PlayerGuid()` and nothing else.

A pet's cast carries the PET's guid in the Aura::Source cache, since
that is who SMSG_SPELL_GO names, so "HARMFUL|PLAYER" silently dropped
every aura the pet applied. `!PLAYER` had the mirror bug: it returned
the pet's auras as though a third party cast them.

Centralize on one IsPlayerOrPetCaster predicate rather than fixing each
site -- IsPlayerCast, GroupIsPlayerCast and CachedMatches had already
grown three separate copies of the comparison, which is how they would
drift again. The pet guid comes from VAR_PET_GUID, a live engine global,
so the predicate stays two compares with no object resolve; it runs per
aura slot. A caster of 0 (cache miss) still matches nothing.

Unrelated and untouched: the `isFromPlayerOrPlayerPet` aura field, which
means "applied by ANY player or a player's pet" and is answered from the
caster's HIGHGUID prefix.

Verified in-game: a Hunter pet's Scorpid Poison now returns from
C_UnitAuras.GetAuraDataByIndex("target", 1, "HARMFUL|PLAYER").
This commit is contained in:
Brues
2026-09-16 23:32:16 -05:00
parent 56d2dbbc27
commit bbefdb847d
4 changed files with 50 additions and 29 deletions
+8 -10
View File
@@ -18563,12 +18563,10 @@ tokens (`"HELPFUL"`, `"HARMFUL"`,
- **`HELPFUL`** (default) / **`HARMFUL`** — pick buffs or debuffs by each
aura's polarity flag. In `GetUnitAuras`, supplying neither returns both.
- **`PLAYER`** — restrict to auras the local player cast, via the
`Aura::Source` caster cache (`sourceGUID == ` player GUID). Combines with
the range tokens (`"HARMFUL|PLAYER"` = your debuffs only). Because the
caster is best-effort, an aura whose cast we didn't observe is treated as
not-player-cast and excluded — so `PLAYER` can under-report auras that
predate login.
- **`PLAYER`** — restrict to auras that the player or the player's pet
cast. Combines with the range tokens (`"HARMFUL|PLAYER"` = your debuffs
only). The caster is known only for casts seen this session, so an aura
that predates login counts as not-player-cast and is excluded.
Other tokens (`RAID` / `CANCELABLE` / `INCLUDE_NAME_PLATE_ONLY`) are
accepted but no-op — they need engine systems (raid-dispel relevance,
@@ -18671,10 +18669,10 @@ leading `!`. This build honors:
- `HELPFUL` / `HARMFUL` — buffs / debuffs, by each aura's polarity flag
rather than its slot number. With neither token the query returns both
(the indexed getter defaults to helpful).
- `PLAYER` / `!PLAYER` — only auras the local player cast, or only
auras the player did not cast. Caster data comes from casts this
session, so an aura present before you saw it cast has no caster and
counts as not-player.
- `PLAYER` / `!PLAYER` — only auras the player or the player's pet cast,
or only the auras neither of them cast. Caster data comes from casts
this session, so an aura present before you saw it cast has no caster
and counts as not-player.
- `DISPELLABLE` / `!DISPELLABLE` — only auras that can be dispelled,
purged, or stolen (dispel type Magic, Curse, Disease, or Poison), or
only auras that cannot. This is "can it be removed at all", not "can
+2 -1
View File
@@ -23,7 +23,8 @@
// mistaken for `PLAYER` and `!PLAYER` is a negation rather than a match.
// Honored: `HELPFUL` / `HARMFUL` (the aura's real polarity, read however this
// server encodes it — see `Aura::Data::IsSlotHarmful`), `PLAYER` /
// `!PLAYER` (caster == / != the local player, from the Aura::Source cache),
// `!PLAYER` (caster is / isn't the local player or their pet, from the
// Aura::Source cache),
// `DISPELLABLE` / `!DISPELLABLE` (dispel type is / isn't one a
// dispel/purge/steal can remove — Spell.dbc Dispel ∈ Magic/Curse/Disease/
// Poison, matching the server's DISPEL_ALL_MASK), and `CROWD_CONTROL` /
+26 -8
View File
@@ -361,16 +361,36 @@ int SlotInFilterOrder(Filter filter, int i) {
return i;
}
// The caster set the `PLAYER` filter selects: the player AND the player's
// pet. Modern defines the token as "auras that were cast by the player, or
// by the player's pet or vehicle" (`AuraUtil.AuraFilters.Player`) — there
// are no vehicles here, so the pair is player + pet. A pet's cast carries
// the PET's guid in the Aura::Source cache (that is who SMSG_SPELL_GO
// names), so a plain player compare drops e.g. a Hunter's own Serpent
// Sting off a `HARMFUL|PLAYER` query. The pet guid is a live engine global,
// so this stays two compares with no object resolve — it runs per slot.
// A caster of 0 is a cache miss, never a match (see CasterMode).
bool IsPlayerOrPetCaster(uint64_t casterGuid) {
if (casterGuid == 0)
return false;
if (casterGuid == Unit::Identity::PlayerGuid())
return true;
const uint64_t pet =
Game::Read<uint64_t>(static_cast<uintptr_t>(Offsets::VAR_PET_GUID));
return pet != 0 && casterGuid == pet;
}
bool IsPlayerCast(const uint8_t *unit, int slot) {
const uint32_t spellID = ReadSpellID(unit, slot);
if (spellID == 0)
return false;
const uint64_t player = Unit::Identity::PlayerGuid();
return player != 0 && Attribute(UnitGuid(unit), spellID, slot).caster == player;
return IsPlayerOrPetCaster(
Attribute(UnitGuid(unit), spellID, slot).caster);
}
// Applies the PLAYER / !PLAYER caster restriction. `isPlayerCast` is the
// per-aura "was this cast by the local player" answer (false on a cache miss).
// per-aura "was this cast by the player or their pet" answer (false on a
// cache miss).
bool CasterMatches(CasterMode caster, bool isPlayerCast) {
switch (caster) {
case CasterMode::PlayerOnly: return isPlayerCast;
@@ -444,9 +464,8 @@ bool SlotMatchesFilter(const uint8_t *unit, int slot, Filter filter,
// no slot to attribute by and the cache is consulted by (guid, spellID) alone.
// A miss counts as "not the player" (same as IsPlayerCast).
bool GroupIsPlayerCast(uint64_t guid, uint32_t spellID) {
const uint64_t player = Unit::Identity::PlayerGuid();
return player != 0 &&
Attribute(guid, spellID, Aura::Source::SLOT_UNBOUND).caster == player;
return IsPlayerOrPetCaster(
Attribute(guid, spellID, Aura::Source::SLOT_UNBOUND).caster);
}
int FindNthSlot(const uint8_t *unit, int oneBasedIndex, Filter filter,
@@ -847,8 +866,7 @@ bool FallbackEligible(const uint8_t *unit, const Aura::Source::CachedAura &c,
// Applies `match` to a cache entry. The entry carries its caster, so the caster
// test is a plain GUID compare — no scan, nothing to defer.
bool CachedMatches(const Aura::Source::CachedAura &c, const Match &match) {
return MatchesAura(match, c.casterGuid == Unit::Identity::PlayerGuid(),
c.spellId);
return MatchesAura(match, IsPlayerOrPetCaster(c.casterGuid), c.spellId);
}
// The eligible cache-fallback entries for `unit` under `filter`, in `Enumerate`
+14 -10
View File
@@ -63,11 +63,13 @@ enum class Filter { Helpful, Harmful };
enum class Emit { Table, Positional };
// Caster restriction from the `PLAYER` / `!PLAYER` aura filter tokens.
// `Any` = no restriction; `PlayerOnly` = only auras the local player cast
// (`PLAYER`); `NotPlayer` = only auras NOT cast by the local player
// (`!PLAYER`). Caster attribution comes from the `Aura::Source` cache; a
// cache miss counts as "not the player" (so `PlayerOnly` excludes it and
// `NotPlayer` includes it — matching `IsPlayerCast`'s miss semantics).
// `Any` = no restriction; `PlayerOnly` = only auras the local player OR the
// player's pet cast (`PLAYER`); `NotPlayer` = the complement (`!PLAYER`).
// The pet is part of the set by definition — modern documents the token as
// "cast by the player, or by the player's pet or vehicle". Caster
// attribution comes from the `Aura::Source` cache; a cache miss counts as
// "not the player" (so `PlayerOnly` excludes it and `NotPlayer` includes
// it — matching `IsPlayerCast`'s miss semantics).
enum class CasterMode { Any, PlayerOnly, NotPlayer };
// Restriction from the `DISPELLABLE` / `!DISPELLABLE` aura filter tokens.
@@ -148,13 +150,15 @@ int FindSlotBySpellID(const uint8_t *unit, uint32_t spellID,
int FindSlotBySpellName(const uint8_t *unit, const char *spellName,
const Filter *filter, Match match = {});
// True iff the aura at `slot` was cast by the local player, per the
// `Aura::Source` cache. False on a cache miss (caster unknown) — so a
// PLAYER-filtered query excludes auras whose cast we didn't observe.
// True iff the aura at `slot` was cast by the local player or by the
// player's pet, per the `Aura::Source` cache. False on a cache miss (caster
// unknown) — so a PLAYER-filtered query excludes auras whose cast we didn't
// observe.
bool IsPlayerCast(const uint8_t *unit, int slot);
// Applies a `CasterMode` to a per-aura "was cast by the local player" answer.
// `Any` → always true; `PlayerOnly` → the answer; `NotPlayer` → its negation.
// Applies a `CasterMode` to a per-aura "was cast by the player or their pet"
// answer. `Any` → always true; `PlayerOnly` → the answer; `NotPlayer` → its
// negation.
bool CasterMatches(CasterMode caster, bool isPlayerCast);
// True iff the spell's dispel type is one a dispel/purge/steal can remove —