Skip to content

Commit

Permalink
Fix spell id value not working for pet spells
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Dec 4, 2023
1 parent 42da602 commit bf351d8
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions playerbot/strategy/values/SpellIdValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ uint32 SpellIdValue::Calculate()
return 0;

wstrToLower(wnamepart);
char firstSymbol = tolower(namepart[0]);
int spellLength = wnamepart.length();
firstSymbol = tolower(namepart[0]);
spellLength = wnamepart.length();
}

int loc = bot->GetSession()->GetSessionDbcLocale();
Expand Down Expand Up @@ -95,20 +95,29 @@ uint32 SpellIdValue::Calculate()
{
for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr)
{
uint32 spellId = itr->first;
if (!ids.empty())
{
if (std::find(ids.begin(), ids.end(), spellId) == ids.end())
continue;
}

if(itr->second.state == PETSPELL_REMOVED)
continue;

uint32 spellId = itr->first;
const SpellEntry* pSpellInfo = sServerFacade.LookupSpellInfo(spellId);
if (!pSpellInfo)
continue;

if (pSpellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL)
continue;

char* spellName = pSpellInfo->SpellName[loc];
if (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || !Utf8FitTo(spellName, wnamepart))
continue;
if (ids.empty())
{
char* spellName = pSpellInfo->SpellName[loc];
if (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || !Utf8FitTo(spellName, wnamepart))
continue;
}

spellIds.insert(spellId);
}
Expand Down

0 comments on commit bf351d8

Please sign in to comment.