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.
This commit is contained in:
Brues
2026-06-24 16:57:34 -05:00
parent c68ec17e0c
commit 492c70d156
4 changed files with 30 additions and 16 deletions
+11 -2
View File
@@ -242,7 +242,8 @@ bool IsPlayerCast(const uint8_t *unit, int slot) {
return false;
uint64_t casterGuid = 0;
uint32_t expMs = 0;
if (!Aura::Source::Get(UnitGuid(unit), spellID, &casterGuid, &expMs))
uint32_t durMs = 0;
if (!Aura::Source::Get(UnitGuid(unit), spellID, &casterGuid, &expMs, &durMs))
return false;
return casterGuid != 0 && casterGuid == Unit::Identity::PlayerGuid();
}
@@ -426,9 +427,17 @@ void Push(void *L, const uint8_t *unit, int slot) {
if (spellID != 0) {
uint64_t casterGuid = 0;
uint32_t expMs = 0;
if (Aura::Source::Get(UnitGuid(unit), spellID, &casterGuid, &expMs)) {
uint32_t durMs = 0;
if (Aura::Source::Get(UnitGuid(unit), spellID, &casterGuid, &expMs,
&durMs)) {
if (expirationTime == 0.0 && expMs != 0)
expirationTime = static_cast<double>(expMs) * 0.001;
// Prefer the applied (caster-modified) duration so `duration`
// stays consistent with `expirationTime` — otherwise a talented
// DoT (e.g. Improved Shadow Word: Pain) shows remaining time
// exceeding the base `duration`.
if (durMs != 0)
duration = static_cast<double>(durMs) * 0.001;
if (casterGuid != 0) {
// `sourceUnit` is a token (nil when the caster maps to no
// current token); `sourceGUID` is the raw "0x..." GUID and