Core/Units: Refactor GetCastSpellInfo to return values via return value and hide internal lookup state tracker

This commit is contained in:
Shauren
2025-02-24 14:33:56 +01:00
parent 00223f3bee
commit e233079d2d
4 changed files with 27 additions and 14 deletions
+11 -8
View File
@@ -14085,16 +14085,19 @@ void Unit::ClearBossEmotes(Optional<uint32> zoneId, Player const* target) const
bool Unit::GetCastSpellInfoContext::AddSpell(uint32 spellId)
{
auto itr = std::ranges::find(VisitedSpells, spellId);
if (itr != VisitedSpells.end())
return false; // already exists
for (uint32& slot : VisitedSpells)
{
if (slot == spellId)
return false; // already exists
itr = std::ranges::find(VisitedSpells, 0u);
if (itr == VisitedSpells.end())
return false; // no free slots left
if (!slot)
{
slot = spellId;
return true;
}
}
*itr = spellId;
return true;
return false; // no free slots left
}
SpellInfo const* Unit::GetCastSpellInfo(SpellInfo const* spellInfo, TriggerCastFlags& triggerFlag, GetCastSpellInfoContext* context) const