mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
fix: key macro cooldown cache by macro ID instead of slot index
The macro primary spell cache was keyed by action bar slot index, so switching characters or rearranging macros could return stale spell IDs from the previous character's macro in that slot. Now keyed by macro ID, which is stable per-macro regardless of which slot it occupies.
This commit is contained in:
parent
bfbf590ee2
commit
a103fb5168
2 changed files with 7 additions and 8 deletions
|
|
@ -435,9 +435,9 @@ private:
|
||||||
void loadExtendedCostDBC();
|
void loadExtendedCostDBC();
|
||||||
std::string formatExtendedCost(uint32_t extendedCostId, game::GameHandler& gameHandler);
|
std::string formatExtendedCost(uint32_t extendedCostId, game::GameHandler& gameHandler);
|
||||||
|
|
||||||
// Macro cooldown cache: maps macro slot index → resolved primary spell ID (0 = no spell found)
|
// Macro cooldown cache: maps macro ID → resolved primary spell ID (0 = no spell found)
|
||||||
std::unordered_map<int, uint32_t> macroPrimarySpellCache_;
|
std::unordered_map<uint32_t, uint32_t> macroPrimarySpellCache_;
|
||||||
uint32_t resolveMacroPrimarySpellId(int slotIndex, game::GameHandler& gameHandler);
|
uint32_t resolveMacroPrimarySpellId(uint32_t macroId, game::GameHandler& gameHandler);
|
||||||
|
|
||||||
// Death Knight rune bar: client-predicted fill (0.0=depleted, 1.0=ready) for smooth animation
|
// Death Knight rune bar: client-predicted fill (0.0=depleted, 1.0=ready) for smooth animation
|
||||||
float runeClientFill_[6] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
|
float runeClientFill_[6] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
|
||||||
|
|
|
||||||
|
|
@ -8642,11 +8642,10 @@ VkDescriptorSet GameScreen::getSpellIcon(uint32_t spellId, pipeline::AssetManage
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GameScreen::resolveMacroPrimarySpellId(int slotIndex, game::GameHandler& gameHandler) {
|
uint32_t GameScreen::resolveMacroPrimarySpellId(uint32_t macroId, game::GameHandler& gameHandler) {
|
||||||
auto cacheIt = macroPrimarySpellCache_.find(slotIndex);
|
auto cacheIt = macroPrimarySpellCache_.find(macroId);
|
||||||
if (cacheIt != macroPrimarySpellCache_.end()) return cacheIt->second;
|
if (cacheIt != macroPrimarySpellCache_.end()) return cacheIt->second;
|
||||||
|
|
||||||
uint32_t macroId = gameHandler.getActionBar()[slotIndex].id;
|
|
||||||
const std::string& macroText = gameHandler.getMacroText(macroId);
|
const std::string& macroText = gameHandler.getMacroText(macroId);
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
if (!macroText.empty()) {
|
if (!macroText.empty()) {
|
||||||
|
|
@ -8678,7 +8677,7 @@ uint32_t GameScreen::resolveMacroPrimarySpellId(int slotIndex, game::GameHandler
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
macroPrimarySpellCache_[slotIndex] = result;
|
macroPrimarySpellCache_[macroId] = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8733,7 +8732,7 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
||||||
float macroCooldownRemaining = 0.0f;
|
float macroCooldownRemaining = 0.0f;
|
||||||
float macroCooldownTotal = 0.0f;
|
float macroCooldownTotal = 0.0f;
|
||||||
if (slot.type == game::ActionBarSlot::MACRO && slot.id != 0 && !onCooldown) {
|
if (slot.type == game::ActionBarSlot::MACRO && slot.id != 0 && !onCooldown) {
|
||||||
uint32_t macroSpellId = resolveMacroPrimarySpellId(absSlot, gameHandler);
|
uint32_t macroSpellId = resolveMacroPrimarySpellId(slot.id, gameHandler);
|
||||||
if (macroSpellId != 0) {
|
if (macroSpellId != 0) {
|
||||||
float cd = gameHandler.getSpellCooldown(macroSpellId);
|
float cd = gameHandler.getSpellCooldown(macroSpellId);
|
||||||
if (cd > 0.0f) {
|
if (cd > 0.0f) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue