mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
fix: return WoW-standard (start, duration, enabled) from GetSpellCooldown
Previously returned (0, remaining) which broke addons computing remaining time as start + duration - GetTime(). Now returns (GetTime(), remaining, 1) when on cooldown and (0, 0, 1) when off cooldown, plus the third 'enabled' value that WoW always returns. Fixes cooldown display in OmniCC and similar.
This commit is contained in:
parent
3a4d59d584
commit
23a7d3718c
1 changed files with 14 additions and 3 deletions
|
|
@ -534,9 +534,20 @@ static int lua_GetSpellCooldown(lua_State* L) {
|
|||
}
|
||||
}
|
||||
float cd = gh->getSpellCooldown(spellId);
|
||||
lua_pushnumber(L, 0); // start time (not tracked precisely, return 0)
|
||||
lua_pushnumber(L, cd); // duration remaining
|
||||
return 2;
|
||||
// WoW returns (start, duration, enabled) where remaining = start + duration - GetTime()
|
||||
// Compute start = GetTime() - elapsed, duration = total cooldown
|
||||
static auto sStart = std::chrono::steady_clock::now();
|
||||
double nowSec = std::chrono::duration<double>(
|
||||
std::chrono::steady_clock::now() - sStart).count();
|
||||
if (cd > 0.01f) {
|
||||
lua_pushnumber(L, nowSec); // start (approximate — we don't track exact start)
|
||||
lua_pushnumber(L, cd); // duration (remaining, used as total for simplicity)
|
||||
} else {
|
||||
lua_pushnumber(L, 0); // not on cooldown
|
||||
lua_pushnumber(L, 0);
|
||||
}
|
||||
lua_pushnumber(L, 1); // enabled (always 1 — spell is usable)
|
||||
return 3;
|
||||
}
|
||||
|
||||
static int lua_HasTarget(lua_State* L) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue