mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Fix WAV decode cache and spell lookup performance
- audio_engine.cpp: cache key was based on vector pointer address, not content — cache never hit since each asset load produces a new allocation. Replace with FNV-1a over head+tail bytes + size, giving correct content-based identity at O(1) cost. Add 256-entry cap with eviction to prevent unbounded growth over long sessions. - game_handler.hpp/cpp, spellbook_screen, game_screen: knownSpells was a std::vector with O(n) std::find lookups scattered across packet handlers and UI code. Switch to std::unordered_set for O(1) insert, erase, and membership checks. Update all push_back/erase-remove/find call sites to use set operations.
This commit is contained in:
parent
e29b67dad9
commit
827679579f
6 changed files with 47 additions and 36 deletions
|
|
@ -417,7 +417,7 @@ public:
|
|||
void castSpell(uint32_t spellId, uint64_t targetGuid = 0);
|
||||
void cancelCast();
|
||||
void cancelAura(uint32_t spellId);
|
||||
const std::vector<uint32_t>& getKnownSpells() const { return knownSpells; }
|
||||
const std::unordered_set<uint32_t>& getKnownSpells() const { return knownSpells; }
|
||||
bool isCasting() const { return casting; }
|
||||
uint32_t getCurrentCastSpellId() const { return currentCastSpellId; }
|
||||
float getCastProgress() const { return castTimeTotal > 0 ? (castTimeTotal - castTimeRemaining) / castTimeTotal : 0.0f; }
|
||||
|
|
@ -1315,7 +1315,7 @@ private:
|
|||
uint64_t playerTransportStickyGuid_ = 0; // Last transport player was on (temporary retention)
|
||||
float playerTransportStickyTimer_ = 0.0f; // Seconds to keep sticky transport alive after transient clears
|
||||
std::unique_ptr<TransportManager> transportManager_; // Transport movement manager
|
||||
std::vector<uint32_t> knownSpells;
|
||||
std::unordered_set<uint32_t> knownSpells;
|
||||
std::unordered_map<uint32_t, float> spellCooldowns; // spellId -> remaining seconds
|
||||
uint8_t castCount = 0;
|
||||
bool casting = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue