mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
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:
+1
-1
@@ -9270,7 +9270,7 @@ selects.
|
||||
| `dispelName` | string | `"Magic"` / `"Curse"` / `"Disease"` / `"Poison"` (from `SpellDispelType.dbc`), or `""` if non-dispellable |
|
||||
| `isHelpful` | boolean | true for slot < 32 |
|
||||
| `isHarmful` | boolean | true for slot >= 32 |
|
||||
| `duration` | number | base applied duration in seconds, looked up via `Spell.dbc → SpellDuration.dbc` with level scaling. Talent / glyph duration extensions (Improved PW:F, etc.) aren't reflected here — those are baked into `expirationTime` on the caster's side. Returns 0 for spells flagged "no duration" (passives, paladin auras, infinite buffs) |
|
||||
| `duration` | number | applied duration in seconds. When the aura's cast was observed (in the `Aura::Source` cache), this is the caster-modified duration — talent/glyph extensions like Improved Shadow Word: Pain included — so it stays consistent with `expirationTime` (`remaining ≤ duration`). On a cache miss it falls back to the base `Spell.dbc → SpellDuration.dbc` value with level scaling. Returns 0 for spells flagged "no duration" (passives, paladin auras, infinite buffs) |
|
||||
| `expirationTime` | number | for `unit == "player"`, read from the engine's player-buff table at `0x00BC6040` (same data `GetPlayerBuffTimeLeft` returns). For any other unit, taken from the `Aura::Source` cache (cast time + duration captured from `SMSG_SPELL_GO`; see below). `0` when neither source has it. `expirationTime - GetTime()` gives the true remaining time |
|
||||
| `sourceUnit` | string | unit token of the caster (`"player"`, `"raid7"`, `"nameplate1"`, …), resolved from the `Aura::Source` cache. `nil` if the cast wasn't observed or the caster maps to no current token |
|
||||
| `sourceGUID` | string | caster's `"0x…"` GUID string from the same cache. **ClassicAPI extension — not a retail `AuraData` field.** Set whenever a caster is known, including when `sourceUnit` is `nil` (caster left token range). Stable for the session, unlike the volatile nameplate token; doubles as a unit token under SuperWoW. `nil` on a cache miss |
|
||||
|
||||
+11
-2
@@ -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
|
||||
|
||||
+9
-6
@@ -104,6 +104,7 @@ struct Entry {
|
||||
uint64_t casterGuid;
|
||||
uint32_t spellId;
|
||||
uint32_t expirationMs; // 0 = infinite / unknown duration
|
||||
uint32_t durationMs; // applied duration (incl. caster mods); 0 = none
|
||||
bool used;
|
||||
};
|
||||
|
||||
@@ -112,7 +113,7 @@ Entry g_cache[kCacheSize];
|
||||
int g_writeCursor = 0;
|
||||
|
||||
void Store(uint64_t targetGuid, uint32_t spellId, uint64_t casterGuid,
|
||||
uint32_t expirationMs) {
|
||||
uint32_t expirationMs, uint32_t durationMs) {
|
||||
if (targetGuid == 0 || spellId == 0 || casterGuid == 0)
|
||||
return;
|
||||
|
||||
@@ -121,6 +122,7 @@ void Store(uint64_t targetGuid, uint32_t spellId, uint64_t casterGuid,
|
||||
if (e.used && e.targetGuid == targetGuid && e.spellId == spellId) {
|
||||
e.casterGuid = casterGuid;
|
||||
e.expirationMs = expirationMs;
|
||||
e.durationMs = durationMs;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -128,13 +130,13 @@ void Store(uint64_t targetGuid, uint32_t spellId, uint64_t casterGuid,
|
||||
const uint32_t now = NowMs();
|
||||
for (auto &e : g_cache) {
|
||||
if (!e.used || (e.expirationMs != 0 && now >= e.expirationMs)) {
|
||||
e = {targetGuid, casterGuid, spellId, expirationMs, true};
|
||||
e = {targetGuid, casterGuid, spellId, expirationMs, durationMs, true};
|
||||
return;
|
||||
}
|
||||
}
|
||||
Entry &slot = g_cache[g_writeCursor];
|
||||
g_writeCursor = (g_writeCursor + 1) % kCacheSize;
|
||||
slot = {targetGuid, casterGuid, spellId, expirationMs, true};
|
||||
slot = {targetGuid, casterGuid, spellId, expirationMs, durationMs, true};
|
||||
}
|
||||
|
||||
// Drop entries whose timed aura has elapsed so the table doesn't fill with
|
||||
@@ -196,11 +198,11 @@ void __fastcall SpellGo_h(uint64_t *itemGUID, uint64_t *casterGUID,
|
||||
|
||||
if (numTargets == 0) {
|
||||
// No explicit hit list (self-cast with caster-implicit target).
|
||||
Store(caster, spellId, caster, expirationMs);
|
||||
Store(caster, spellId, caster, expirationMs, durationMs);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < numTargets; ++i)
|
||||
Store(targets[i], spellId, caster, expirationMs);
|
||||
Store(targets[i], spellId, caster, expirationMs, durationMs);
|
||||
}
|
||||
|
||||
const Game::HookAutoRegister _hook{Offsets::FUN_SPELL_GO,
|
||||
@@ -210,13 +212,14 @@ const Game::HookAutoRegister _hook{Offsets::FUN_SPELL_GO,
|
||||
} // namespace
|
||||
|
||||
bool Get(uint64_t unitGuid, uint32_t spellId, uint64_t *outCaster,
|
||||
uint32_t *outExpirationMs) {
|
||||
uint32_t *outExpirationMs, uint32_t *outDurationMs) {
|
||||
if (unitGuid == 0 || spellId == 0)
|
||||
return false;
|
||||
for (const auto &e : g_cache) {
|
||||
if (e.used && e.targetGuid == unitGuid && e.spellId == spellId) {
|
||||
*outCaster = e.casterGuid;
|
||||
*outExpirationMs = e.expirationMs;
|
||||
*outDurationMs = e.durationMs;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-7
@@ -31,13 +31,15 @@
|
||||
|
||||
namespace Aura::Source {
|
||||
|
||||
// Looks up the cached caster + expiration for the aura `spellId` currently
|
||||
// on the unit identified by `unitGuid`. Returns true and fills the out
|
||||
// params on a hit. `*outExpirationMs` is an absolute `GetTickCount`-epoch
|
||||
// timestamp (0 = unknown / infinite-duration aura); `*outCaster` is the
|
||||
// caster's 64-bit GUID (never 0 on a hit). Returns false on a miss or for
|
||||
// zero inputs.
|
||||
// Looks up the cached caster + timing for the aura `spellId` currently on
|
||||
// the unit identified by `unitGuid`. Returns true and fills the out params
|
||||
// on a hit. `*outExpirationMs` is an absolute `GetTickCount`-epoch timestamp
|
||||
// (0 = unknown / infinite-duration aura); `*outDurationMs` is the applied
|
||||
// duration including the caster's modifiers (talents etc.; 0 = none) — use
|
||||
// it for the `duration` field so it stays consistent with `expirationTime`;
|
||||
// `*outCaster` is the caster's 64-bit GUID (never 0 on a hit). Returns false
|
||||
// on a miss or for zero inputs.
|
||||
bool Get(uint64_t unitGuid, uint32_t spellId, uint64_t *outCaster,
|
||||
uint32_t *outExpirationMs);
|
||||
uint32_t *outExpirationMs, uint32_t *outDurationMs);
|
||||
|
||||
} // namespace Aura::Source
|
||||
|
||||
Reference in New Issue
Block a user