[Bots] Move BotGetSpellsByType to cache (#4655)

This commit is contained in:
nytmyr
2025-02-07 13:05:36 -06:00
committed by GitHub
parent e0d95b4302
commit ed7023f336
4 changed files with 29 additions and 28 deletions
+12 -4
View File
@@ -12631,12 +12631,20 @@ void Bot::CleanBotBlockedBuffs()
}
}
std::vector<BotSpells_wIndex> Bot::BotGetSpellsByType(uint16 spell_type) {
if (AIBot_spells_by_type[spell_type].empty()) {
spell_type = GetParentSpellType(spell_type);
const std::vector<BotSpells_wIndex>& Bot::BotGetSpellsByType(uint16 spell_type) const {
auto it = AIBot_spells_by_type.find(spell_type);
if (it == AIBot_spells_by_type.end() || it->second.empty()) {
it = AIBot_spells_by_type.find(GetParentSpellType(spell_type));
if (it == AIBot_spells_by_type.end()) {
static const std::vector<BotSpells_wIndex> empty;
return empty;
}
}
return AIBot_spells_by_type[spell_type];
return it->second;
}
void Bot::AssignBotSpellsToTypes(std::vector<BotSpells>& AIBot_spells, std::unordered_map<uint16, std::vector<BotSpells_wIndex>>& AIBot_spells_by_type) {